[PATCH] D12064: [GMR] isNonEscapingGlobalNoAlias() should look through Bitcasts/GEPs when looking at loads.

Michael Kuperstein via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 04:55:57 PDT 2015


mkuper created this revision.
mkuper added a reviewer: chandlerc.
mkuper added a subscriber: llvm-commits.

Yet another case that shows up in eembc, see PR24288.

http://reviews.llvm.org/D12064

Files:
  lib/Analysis/IPA/GlobalsModRef.cpp
  test/Analysis/GlobalsModRef/nonescaping-noalias.ll

Index: test/Analysis/GlobalsModRef/nonescaping-noalias.ll
===================================================================
--- test/Analysis/GlobalsModRef/nonescaping-noalias.ll
+++ test/Analysis/GlobalsModRef/nonescaping-noalias.ll
@@ -62,6 +62,7 @@
 }
 
 @g3 = internal global i32 1
+ at g4 = internal global [10 x i32*] zeroinitializer
 
 define i32 @test4(i32* %param, i32 %n, i1 %c1, i1 %c2, i1 %c3) {
 ; Ensure that we can fold a store to a load of a global across a store to
@@ -86,7 +87,7 @@
   %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]
   %ptr = phi i32* [ %ptr3, %entry ], [ %ptr5, %loop ]
   store i32 7, i32* %ptr
-  %ptr4 = load i32*, i32** @g2
+  %ptr4 = load i32*, i32** getelementptr ([10 x i32*], [10 x i32*]* @g4, i32 0, i32 1)
   %ptr5 = select i1 %c2, i32* %ptr4, i32* %call
   %inc = add i32 %iv, 1
   %test = icmp slt i32 %inc, %n
Index: lib/Analysis/IPA/GlobalsModRef.cpp
===================================================================
--- lib/Analysis/IPA/GlobalsModRef.cpp
+++ lib/Analysis/IPA/GlobalsModRef.cpp
@@ -651,7 +651,7 @@
     if (auto *LI = dyn_cast<LoadInst>(Input)) {
       // A pointer loaded from a global would have been captured, and we know
       // that the global is non-escaping, so no alias.
-      if (isa<GlobalValue>(LI->getPointerOperand()))
+      if (isa<GlobalValue>(GetUnderlyingObject(LI->getPointerOperand(), *DL)))
         continue;
 
       // Otherwise, a load could come from anywhere, so bail.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12064.32240.patch
Type: text/x-patch
Size: 1489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150816/7e7564c6/attachment.bin>


More information about the llvm-commits mailing list