[PATCH] D12408: CFL AA Bugfix -- Mark no-args function return values as unknown values
George Burgess IV via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 10:22:05 PDT 2015
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: hfinkel.
george.burgess.iv added a subscriber: llvm-commits.
Fix an issue where we wouldn't properly note that the return value of a no-args function could alias something an escaped variable.
(So, for the given test case, we wouldn't properly detect that `%Escapes` and `%Retrieved` may alias)
Thanks to Chandler, Richard, and Nick for pinging me about this! :)
http://reviews.llvm.org/D12408
Files:
lib/Analysis/CFLAliasAnalysis.cpp
test/Analysis/CFLAliasAnalysis/opaque-call-alias.ll
Index: test/Analysis/CFLAliasAnalysis/opaque-call-alias.ll
===================================================================
--- test/Analysis/CFLAliasAnalysis/opaque-call-alias.ll
+++ test/Analysis/CFLAliasAnalysis/opaque-call-alias.ll
@@ -0,0 +1,20 @@
+; We previously had a case where we would put results from a no-args call in
+; its own stratified set. This would make cases like the one in @test say that
+; nothing (except %Escapes and %Arg) can alias
+
+; RUN: opt < %s -cfl-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
+
+; CHECK: Function: test
+; CHECK: MayAlias: i8* %Arg, i8* %Escapes
+; CHECK: MayAlias: i8* %Arg, i8* %Retrieved
+; CHECK: MayAlias: i8* %Escapes, i8* %Retrieved
+define void @test(i8* %Arg) {
+ %Noalias = alloca i8
+ %Escapes = alloca i8
+ call void @set_thepointer(i8* %Escapes)
+ %Retrieved = call i8* @get_thepointer()
+ ret void
+}
+
+declare void @set_thepointer(i8* %P)
+declare i8* @get_thepointer()
Index: lib/Analysis/CFLAliasAnalysis.cpp
===================================================================
--- lib/Analysis/CFLAliasAnalysis.cpp
+++ lib/Analysis/CFLAliasAnalysis.cpp
@@ -398,16 +398,22 @@
}
template <typename InstT> void visitCallLikeInst(InstT &Inst) {
+ // TODO: Add support for noalias args/all the other fun function attributes
+ // that we can tack on.
SmallVector<Function *, 4> Targets;
if (getPossibleTargets(&Inst, Targets)) {
if (tryInterproceduralAnalysis(Targets, &Inst, Inst.arg_operands()))
return;
// Cleanup from interprocedural analysis
Output.clear();
}
+ // Because the function is opaque, we need to note that anything
+ // could have happened to the arguments, and that the result could alias
+ // just about anything, too.
for (Value *V : Inst.arg_operands())
Output.push_back(Edge(&Inst, V, EdgeType::Assign, AttrAll));
+ Output.push_back(Edge(&Inst, &Inst, EdgeType::Assign, AttrAll));
}
void visitCallInst(CallInst &Inst) { visitCallLikeInst(Inst); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12408.33336.patch
Type: text/x-patch
Size: 2072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150827/fceb1b35/attachment.bin>
More information about the llvm-commits
mailing list