We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The logic that folds loads of static initializers doesn't take into account whether the variable being initialized may be modified at runtime.
Here's a patch that fixes it:
RCS file: /var/cvs/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp,v retrieving revision 1.319 diff -u -r1.319 SelectionDAGISel.cpp --- SelectionDAGISel.cpp +++ SelectionDAGISel.cpp @@ -3298,7 +3298,7 @@ } if (G) { GlobalVariable *GV = dyn_cast(G->getGlobal());
if (GV) {
if (GV && GV->isConstant()) { Str = GV->getStringValue(false); if (!Str.empty()) { CopyFromStr = true;
And here's a testcase that reproduces it:
target datalayout = "e-p:32:32" target endian = little target pointersize = 32 target triple = "i686-pc-linux-gnu" %fmt = global [4 x sbyte] c"%x\0A\00" %bytes = global [4 x sbyte] c"\AA\BB\CC\DD"
implementation
void %foo() { %y = alloca uint %c = cast uint* %y to sbyte* %z = getelementptr [4 x sbyte]* %bytes, int 0, int 0 call void %llvm.memcpy.i32( sbyte* %c, sbyte* %z, uint 4, uint 1 ) %r = load uint* %y %t = cast [4 x sbyte]* %fmt to sbyte* %tmp = call int (sbyte*, ...)* %printf( sbyte* %t, uint %r ) ret void }
declare void %llvm.memcpy.i32(sbyte*, sbyte*, uint, uint)
declare int %printf(sbyte*, ...)
The text was updated successfully, but these errors were encountered:
Patch applied. Thanks!
Sorry, something went wrong.
[flang] Sync AffinePromotion and AffineDemotion from main (llvm#1395)
28024b3
No branches or pull requests
Extended Description
The logic that folds loads of static initializers doesn't take into account
whether the variable being initialized may be modified at runtime.
Here's a patch that fixes it:
Index: SelectionDAGISel.cpp
RCS file: /var/cvs/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp,v
retrieving revision 1.319
diff -u -r1.319 SelectionDAGISel.cpp
--- SelectionDAGISel.cpp
+++ SelectionDAGISel.cpp
@@ -3298,7 +3298,7 @@
}
if (G) {
GlobalVariable *GV = dyn_cast(G->getGlobal());
And here's a testcase that reproduces it:
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
%fmt = global [4 x sbyte] c"%x\0A\00"
%bytes = global [4 x sbyte] c"\AA\BB\CC\DD"
implementation
void %foo() {
%y = alloca uint
%c = cast uint* %y to sbyte*
%z = getelementptr [4 x sbyte]* %bytes, int 0, int 0
call void %llvm.memcpy.i32( sbyte* %c, sbyte* %z, uint 4, uint 1 )
%r = load uint* %y
%t = cast [4 x sbyte]* %fmt to sbyte*
%tmp = call int (sbyte*, ...)* %printf( sbyte* %t, uint %r )
ret void
}
declare void %llvm.memcpy.i32(sbyte*, sbyte*, uint, uint)
declare int %printf(sbyte*, ...)
The text was updated successfully, but these errors were encountered: