[llvm] fa5d31f - [GlobalsAA] Teach to handle `addrspacecast`.
Michael Liao via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 8 21:05:06 PST 2020
Author: Michael Liao
Date: 2020-11-09T00:04:52-05:00
New Revision: fa5d31f825699b0fe858d4f432bd3fbbbec523c8
URL: https://github.com/llvm/llvm-project/commit/fa5d31f825699b0fe858d4f432bd3fbbbec523c8
DIFF: https://github.com/llvm/llvm-project/commit/fa5d31f825699b0fe858d4f432bd3fbbbec523c8.diff
LOG: [GlobalsAA] Teach to handle `addrspacecast`.
Added:
llvm/test/Analysis/GlobalsModRef/addrspacecast.ll
Modified:
llvm/lib/Analysis/GlobalsModRef.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp
index a9df8238a403..34669d0c662b 100644
--- a/llvm/lib/Analysis/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/GlobalsModRef.cpp
@@ -367,7 +367,8 @@ bool GlobalsAAResult::AnalyzeUsesOfPointer(Value *V,
} else if (Operator::getOpcode(I) == Instruction::GetElementPtr) {
if (AnalyzeUsesOfPointer(I, Readers, Writers))
return true;
- } else if (Operator::getOpcode(I) == Instruction::BitCast) {
+ } else if (Operator::getOpcode(I) == Instruction::BitCast ||
+ Operator::getOpcode(I) == Instruction::AddrSpaceCast) {
if (AnalyzeUsesOfPointer(I, Readers, Writers, OkayStoreDest))
return true;
} else if (auto *Call = dyn_cast<CallBase>(I)) {
diff --git a/llvm/test/Analysis/GlobalsModRef/addrspacecast.ll b/llvm/test/Analysis/GlobalsModRef/addrspacecast.ll
new file mode 100644
index 000000000000..f626fd17ae25
--- /dev/null
+++ b/llvm/test/Analysis/GlobalsModRef/addrspacecast.ll
@@ -0,0 +1,15 @@
+; RUN: opt -globals-aa -aa-eval -print-all-alias-modref-info -disable-output %s 2>&1 | FileCheck %s
+
+ at g0 = internal addrspace(3) global i32 undef
+
+; CHECK-LABEL: test1
+; CHECK-DAG: NoAlias: i32* %gp, i32* %p
+; CHECK-DAG: NoAlias: i32 addrspace(3)* @g0, i32* %p
+; CHECK-DAG: MustAlias: i32 addrspace(3)* @g0, i32* %gp
+define i32 @test1(i32* %p) {
+ %gp = addrspacecast i32 addrspace(3)* @g0 to i32*
+ store i32 0, i32* %gp
+ store i32 1, i32* %p
+ %v = load i32, i32* %gp
+ ret i32 %v
+}
More information about the llvm-commits
mailing list