-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Regression: huge .rodata section generated because of constant vector of bool. #55522
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
Comments
AFAICT this is still an issue on LLVM 14.04 |
With the following assertion added, we can see what the issue is: diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 4a31bf85446b..7326d161deb6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2981,6 +2981,7 @@ static void emitGlobalConstantVector(const DataLayout &DL,
unsigned Size = DL.getTypeAllocSize(CV->getType());
unsigned EmittedSize = DL.getTypeAllocSize(CV->getType()->getElementType()) *
CV->getType()->getNumElements();
+ assert(EmittedSize <= Size && "Size cannot be less than EmittedSize!");
if (unsigned Padding = Size - EmittedSize)
AP.OutStreamer->emitZeros(Padding);
}
The debugger shows that I've bisected it to bdd55b2 ("Fix the default alignment of i1 vectors.", @efriedma-quic) It's still broken on trunk. |
The generated code isn't really correct even on older versions of LLVM. I'll take a look. |
Can this be backported for 14.0.7? |
@joebonrichie: 14.0.6 was last release of 14. |
Vectors are defined to be tightly packed, regardless of the element type. The AsmPrinter didn't realize this, and was allocating extra padding. Fixes llvm/llvm-project#49286 Fixes llvm/llvm-project#53246 Fixes llvm/llvm-project#55522 Differential Revision: https://reviews.llvm.org/D129164
Given the simple .ll file
@0 = internal constant <4 x i1> <i1 true, i1 false, i1 true, i1 false>
,LLVM 14 will generate an object file with 4Gb of rodata
If I try with vector of i8, I correctly obtain 4 bytes of rodata.
Vectors of i2, and i4 also generate the same issue.
This seems to be a regression from LLVM 13 where this was working fine (I believe the warning is just because my .ll is too dry).
I've tried searching for similar issue but without success.
The text was updated successfully, but these errors were encountered: