[PATCH] GlobalOpt: Don't optimize dllimport for initializers

David Majnemer david.majnemer at gmail.com
Mon Jun 23 13:31:15 PDT 2014


================
Comment at: lib/Transforms/IPO/GlobalOpt.cpp:1987-1988
@@ -1987,1 +1986,4 @@
+
+  // Simple integer, undef, constant aggregate zero, etc are all supported.
+  if (C->getNumOperands() == 0 || isa<BlockAddress>(C))
     return true;
----------------
Reid Kleckner wrote:
> IMO getNumOperands() == 0 is the common case (ints), so I'd put that check first.
Can't. GlobalVariable with no initializer will get caught by that check.

================
Comment at: test/Transforms/GlobalOpt/constantfold-initializers.ll:55-62
@@ +54,10 @@
+
+ at dllexportptr = global i32* null, align 4
+; CHECK-NOT: @dllexportptr = global i32* @dllexportvar, align 4
+ at dllexportvar = external dllimport global i32
+define internal void @test3() {
+entry:
+  store i32* @dllexportvar, i32** @dllexportptr, align 4
+  ret void
+}
+
----------------
Reid Kleckner wrote:
> Why are these all called dllexport-stuff?  It seems like dllimport would be the better naming.
> 
> Can you add a test to verify that globalopt fires on dllexport data?  Based on the comment you fixed, it seems like it didn't used to.
Done.

================
Comment at: test/Transforms/GlobalOpt/constantfold-initializers.ll:56
@@ +55,3 @@
+ at dllexportptr = global i32* null, align 4
+; CHECK-NOT: @dllexportptr = global i32* @dllexportvar, align 4
+ at dllexportvar = external dllimport global i32
----------------
Reid Kleckner wrote:
> IMO a positive CHECK line for "@dllexport = global i32* null" would make a better test.
Done.

http://reviews.llvm.org/D4249






More information about the llvm-commits mailing list