[llvm-commits] [LLVM, PR11652 PATCH]: Fixed Bug 11652 - assertion failures when Type.cpp is compiled with -Os
Stepan Dyatkovskiy
stpworld at narod.ru
Fri Dec 30 11:41:32 PST 2011
The problem is in Type.h. The fields in Type class are declared in next
order:
TypeID ID : 8;
unsigned SubclassData : 24;
unsigned NumContainedTys;
Attempt to set new SubclassData value rewrites lowest byte in
NumContainedTys when -Os is set. GCC bug? Anyway setting SubclassData
with two workaround strings fixes the problem:
void setSubclassData(unsigned val) {
unsigned tmp = NumContainedTys; // Workaround for GCC -Os
SubclassData = val;
NumContainedTys = tmp; // Workaround for GCC -Os
// Ensure we don't have any accidental truncation.
assert(SubclassData == val && "Subclass data too large for field");
}
Probably there is another ways to protect NumContainedTys from overwritting?
Please find the patch in attachment for review.
-Stepan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 11652.patch
Type: text/x-patch
Size: 738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111230/e5ea0279/attachment.bin>
More information about the llvm-commits
mailing list