summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2015-03-10 02:40:06 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2015-03-10 02:40:06 +0000
commitb54a8d62a4859bf69e9b6e877a6e73fdc67ced40 (patch)
treeb54be91837fddfe98563463e880948295a964d6e /llvm/lib/Analysis
parenta28d91d81b5daa4d8b92452ea8203a57023b576f (diff)
downloadbcm5719-llvm-b54a8d62a4859bf69e9b6e877a6e73fdc67ced40.tar.gz
bcm5719-llvm-b54a8d62a4859bf69e9b6e877a6e73fdc67ced40.zip
Added special handling for inttoptr in CFLAA.
We now treat pointers given to ptrtoint and pointers retrieved from inttoptr as similar to arguments or globals (can alias anything, etc.) This solves some of the problems we were having with giving incorrect results. llvm-svn: 231741
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/CFLAliasAnalysis.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/CFLAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAliasAnalysis.cpp
index c2c054f3f2e..da5e95ff48d 100644
--- a/llvm/lib/Analysis/CFLAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/CFLAliasAnalysis.cpp
@@ -85,11 +85,13 @@ typedef unsigned StratifiedAttr;
LLVM_CONSTEXPR unsigned MaxStratifiedAttrIndex = NumStratifiedAttrs;
LLVM_CONSTEXPR unsigned AttrAllIndex = 0;
LLVM_CONSTEXPR unsigned AttrGlobalIndex = 1;
-LLVM_CONSTEXPR unsigned AttrFirstArgIndex = 2;
+LLVM_CONSTEXPR unsigned AttrUnknownIndex = 2;
+LLVM_CONSTEXPR unsigned AttrFirstArgIndex = 3;
LLVM_CONSTEXPR unsigned AttrLastArgIndex = MaxStratifiedAttrIndex;
LLVM_CONSTEXPR unsigned AttrMaxNumArgs = AttrLastArgIndex - AttrFirstArgIndex;
LLVM_CONSTEXPR StratifiedAttr AttrNone = 0;
+LLVM_CONSTEXPR StratifiedAttr AttrUnknown = 1 << AttrUnknownIndex;
LLVM_CONSTEXPR StratifiedAttr AttrAll = ~AttrNone;
// \brief StratifiedSets call for knowledge of "direction", so this is how we
@@ -263,6 +265,16 @@ public:
llvm_unreachable("Unsupported instruction encountered");
}
+ void visitPtrToIntInst(PtrToIntInst &Inst) {
+ auto *Ptr = Inst.getOperand(0);
+ Output.push_back(Edge(Ptr, Ptr, EdgeType::Assign, AttrUnknown));
+ }
+
+ void visitIntToPtrInst(IntToPtrInst &Inst) {
+ auto *Ptr = &Inst;
+ Output.push_back(Edge(Ptr, Ptr, EdgeType::Assign, AttrUnknown));
+ }
+
void visitCastInst(CastInst &Inst) {
Output.push_back(Edge(&Inst, Inst.getOperand(0), EdgeType::Assign,
AttrNone));
@@ -931,16 +943,16 @@ static FunctionInfo buildSetsFrom(CFLAliasAnalysis &Analysis, Function *Fn) {
break;
}
- if (Added) {
- auto Aliasing = Weight.second;
- if (auto MaybeCurIndex = valueToAttrIndex(CurValue))
- Aliasing.set(*MaybeCurIndex);
- if (auto MaybeOtherIndex = valueToAttrIndex(OtherValue))
- Aliasing.set(*MaybeOtherIndex);
- Builder.noteAttributes(CurValue, Aliasing);
- Builder.noteAttributes(OtherValue, Aliasing);
+ auto Aliasing = Weight.second;
+ if (auto MaybeCurIndex = valueToAttrIndex(CurValue))
+ Aliasing.set(*MaybeCurIndex);
+ if (auto MaybeOtherIndex = valueToAttrIndex(OtherValue))
+ Aliasing.set(*MaybeOtherIndex);
+ Builder.noteAttributes(CurValue, Aliasing);
+ Builder.noteAttributes(OtherValue, Aliasing);
+
+ if (Added)
Worklist.push_back(OtherNode);
- }
}
}
}
OpenPOWER on IntegriCloud