summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-08-02 22:17:25 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-08-02 22:17:25 +0000
commit777efb162000e9fc8ef3df3ba901c5d6f8bab829 (patch)
tree087ac75d890670d40ce447666de17a0ef087f707 /llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
parenteb685cd7984176eeb5140b7661714402a0339cf2 (diff)
downloadbcm5719-llvm-777efb162000e9fc8ef3df3ba901c5d6f8bab829.tar.gz
bcm5719-llvm-777efb162000e9fc8ef3df3ba901c5d6f8bab829.zip
[CFLAA] Be more conservative with values we haven't seen.
There were issues with simply reporting AttrUnknown on previously-unknown values in CFLAnders. So, we now act *entirely* conservatively for values we haven't seen before. As in the prior patch (r277362), writing a lit test for this isn't exactly trivial. If someone wants a test badly, I'm willing to try to write one. Patch by Jia Chen. Differential Revision: https://reviews.llvm.org/D23077 llvm-svn: 277533
Diffstat (limited to 'llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
index 19cc515c537..354035e63d3 100644
--- a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
@@ -305,7 +305,7 @@ class CFLAndersAAResult::FunctionInfo {
/// Summary of externally visible effects.
AliasSummary Summary;
- AliasAttrs getAttrs(const Value *) const;
+ Optional<AliasAttrs> getAttrs(const Value *) const;
public:
FunctionInfo(const Function &, const SmallVectorImpl<Value *> &,
@@ -479,17 +479,14 @@ CFLAndersAAResult::FunctionInfo::FunctionInfo(
populateExternalRelations(Summary.RetParamRelations, Fn, RetVals, ReachSet);
}
-AliasAttrs CFLAndersAAResult::FunctionInfo::getAttrs(const Value *V) const {
+Optional<AliasAttrs>
+CFLAndersAAResult::FunctionInfo::getAttrs(const Value *V) const {
assert(V != nullptr);
- // Return AttrUnknown if V is not found in AttrMap. Sometimes V can be created
- // after the analysis gets executed, and we want to be conservative in
- // those cases.
- AliasAttrs Attr = getAttrUnknown();
auto Itr = AttrMap.find(V);
if (Itr != AttrMap.end())
- Attr = Itr->second;
- return Attr;
+ return Itr->second;
+ return None;
}
bool CFLAndersAAResult::FunctionInfo::mayAlias(const Value *LHS,
@@ -498,9 +495,17 @@ bool CFLAndersAAResult::FunctionInfo::mayAlias(const Value *LHS,
uint64_t RHSSize) const {
assert(LHS && RHS);
- // Check AliasAttrs first since it's cheaper
- auto AttrsA = getAttrs(LHS);
- auto AttrsB = getAttrs(RHS);
+ // Check if we've seen LHS and RHS before. Sometimes LHS or RHS can be created
+ // after the analysis gets executed, and we want to be conservative in those
+ // cases.
+ auto MaybeAttrsA = getAttrs(LHS);
+ auto MaybeAttrsB = getAttrs(RHS);
+ if (!MaybeAttrsA || !MaybeAttrsB)
+ return true;
+
+ // Check AliasAttrs before AliasMap lookup since it's cheaper
+ auto AttrsA = *MaybeAttrsA;
+ auto AttrsB = *MaybeAttrsB;
if (hasUnknownOrCallerAttr(AttrsA))
return AttrsB.any();
if (hasUnknownOrCallerAttr(AttrsB))
OpenPOWER on IntegriCloud