[llvm] r271322 - [CFLAA] Don't link GEP pointers to GEP indices.
George Burgess IV via llvm-commits
llvm-commits at lists.llvm.org
Tue May 31 12:55:07 PDT 2016
Author: gbiv
Date: Tue May 31 14:55:05 2016
New Revision: 271322
URL: http://llvm.org/viewvc/llvm-project?rev=271322&view=rev
Log:
[CFLAA] Don't link GEP pointers to GEP indices.
Code like the following is considered broken, and doesn't need to be
supported by our AA magicks:
void getFoo(int *P) {
int *PAlias = (int *)((char *)NULL + (uintptr_t)P);
}
This patch makes CFLAA drop support for code like this.
Patch by Jia Chen.
Differential Revision: http://reviews.llvm.org/D20775
Added:
llvm/trunk/test/Analysis/CFLAliasAnalysis/gep-index-no-alias.ll
Modified:
llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp
Modified: llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp?rev=271322&r1=271321&r2=271322&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp Tue May 31 14:55:05 2016
@@ -209,8 +209,6 @@ public:
void visitGetElementPtrInst(GetElementPtrInst &Inst) {
auto *Op = Inst.getPointerOperand();
Output.push_back(Edge(&Inst, Op, EdgeType::Assign, AttrNone));
- for (auto I = Inst.idx_begin(), E = Inst.idx_end(); I != E; ++I)
- Output.push_back(Edge(&Inst, *I, EdgeType::Assign, AttrNone));
}
void visitSelectInst(SelectInst &Inst) {
Added: llvm/trunk/test/Analysis/CFLAliasAnalysis/gep-index-no-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CFLAliasAnalysis/gep-index-no-alias.ll?rev=271322&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CFLAliasAnalysis/gep-index-no-alias.ll (added)
+++ llvm/trunk/test/Analysis/CFLAliasAnalysis/gep-index-no-alias.ll Tue May 31 14:55:05 2016
@@ -0,0 +1,14 @@
+; This testcase ensures that gep result does not alias gep indices
+
+; RUN: opt < %s -disable-basicaa -cfl-aa -aa-eval -print-no-aliases -disable-output 2>&1 | FileCheck %s
+; RUN: opt < %s -aa-pipeline=cfl-aa -passes=aa-eval -print-no-aliases -disable-output 2>&1 | FileCheck %s
+
+; CHECK: Function: foo
+; CHECK: [2 x i32]* %a, [2 x i32]* %b
+define void @foo(i32 %n) {
+ %a = alloca [2 x i32], align 4
+ %b = alloca [2 x i32], align 4
+ %c = getelementptr inbounds [2 x i32], [2 x i32]* %a, i32 0, i32 %n
+ %d = getelementptr inbounds [2 x i32], [2 x i32]* %b, i32 0, i32 %n
+ ret void
+}
More information about the llvm-commits
mailing list