From 426b44f1fad190137b80d216fa137fb2b7fd8f2a Mon Sep 17 00:00:00 2001 From: Michael Kuperstein Date: Mon, 17 Aug 2015 10:06:08 +0000 Subject: [PATCH] [GMR] isNonEscapingGlobalNoAlias() should look through Bitcasts/GEPs when looking at loads. This fixes yet another case from PR24288. Differential Revision: http://reviews.llvm.org/D12064 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245207 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/IPA/GlobalsModRef.cpp | 2 +- test/Analysis/GlobalsModRef/nonescaping-noalias.ll | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 2798888ce7d..5482a13d1e7 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -651,7 +651,7 @@ bool GlobalsModRef::isNonEscapingGlobalNoAlias(const GlobalValue *GV, if (auto *LI = dyn_cast(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(LI->getPointerOperand())) + if (isa(GetUnderlyingObject(LI->getPointerOperand(), *DL))) continue; // Otherwise, a load could come from anywhere, so bail. diff --git a/test/Analysis/GlobalsModRef/nonescaping-noalias.ll b/test/Analysis/GlobalsModRef/nonescaping-noalias.ll index a3f50837208..b955031506a 100644 --- a/test/Analysis/GlobalsModRef/nonescaping-noalias.ll +++ b/test/Analysis/GlobalsModRef/nonescaping-noalias.ll @@ -62,6 +62,7 @@ entry: } @g3 = internal global i32 1 +@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 @@ loop: %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 -- 2.34.1