-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertion failures when Type.cpp is compiled with -Os #12024
Comments
You can try splitting Type.cpp into two files, put half the definitions into one file, see which file contains the miscomputed function, etc. |
An 'interesting' result on that front: Depending on how I split the functions between the two new files, sometimes the assertions disappear entirely. Still figuring out which combination of functions being in the same translation unit causes it... |
I split Type.cpp into two files. PointerType's constructor seems to be the culprit function, because moving it between the two files changes which object file needs to be replaced to fix the assertions. However, if it's in a file by itself, the assertions don't occur. Right now, the minimal combination I found that causes failure is this, with just one other function definition in the file: #include "LLVMContextImpl.h" void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) { setSubclassData(getSubclassData() | SCDB_HasBody); Type *Elts = getContext().pImpl-> ContainedTys = Elts; PointerType::PointerType(Type *E, unsigned AddrSpace) |
Okay... at that point, all you can really do is try to separate out an executable testcase that crashes from the rest of LLVM, and file a bug in the gcc or Ubuntu bug tracker... |
Huh, I guess it's bitfield shenanigans going by this patch? http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20111226/134181.html |
Yes, likely the same issue... did anyone actually file it against gcc, though? |
PATCH The problem is in Type.h. The fields in Type class are declared in next Attempt to set new SubclassData value rewrites lowest byte in void setSubclassData(unsigned val) { Probably there is another ways to protect NumContainedTys from overwritting? Please find the patch in attachment for review. -Stepan. |
|
Fixed in r147470 |
For the record, I just filed a bug with GCC: |
Extended Description
This is probably a GCC bug, but does anyone have advice on how to reduce it further?
GCC version:
g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
With r147274 and configuring with these options:
cmake ../llvm -DCMAKE_BUILD_TYPE=Debug -DLLVM_BUILD_CLANG=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=-Os
It causes assertion failures in a ton of unit tests:
.../include/llvm/Type.h:296: llvm::Type* llvm::Type::getContainedType(unsigned int) const: Assertion `i < NumContainedTys && "Index out of range!"' failed.
Stack dump:
0. Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo1'
.../lib/Bitcode/Writer/ValueEnumerator.h:94: unsigned int llvm::ValueEnumerator::getTypeID(llvm::Type*) const: Assertion `I != TypeMap.end() && "Type not in ValueEnumerator!"' failed.
Stack dump:
0. Program arguments: bin/./opt -strip-debug
.../lib/Bitcode/Reader/BitcodeReader.cpp:740: bool llvm::BitcodeReader::ParseTypeTableBody(): Assertion `TypeList[NumRecords] == 0 && "Already read type?"' failed.
Expected Passes : 4167
Expected Failures : 50
Unsupported Tests : 13
Unexpected Failures: 1437
Taking off that -DCMAKE_CXX_FLAGS=-Os makes the assertions go away. And copying Type.cpp.o from a build without -Os into a build that was configured with it also fixes them (where -b2 was a good build, and the current directory is a bad one):
cp -ai ../llvm-b2/lib/VMCore/CMakeFiles/LLVMCore.dir/Type.cpp.o lib/VMCore/CMakeFiles/LLVMCore.dir/
The text was updated successfully, but these errors were encountered: