diff options
| author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-07-27 23:07:07 +0000 |
|---|---|---|
| committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-07-27 23:07:07 +0000 |
| commit | dbd35c44d4fe5e4f092ecdd2d2ca1c2205f7d2c1 (patch) | |
| tree | fdc402c7eb75d5c1f48485776e1ce312f04f8e64 /llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp | |
| parent | 37f4e0e096df8497c5b55d91585c1b7d98954fe2 (diff) | |
| download | bcm5719-llvm-dbd35c44d4fe5e4f092ecdd2d2ca1c2205f7d2c1.tar.gz bcm5719-llvm-dbd35c44d4fe5e4f092ecdd2d2ca1c2205f7d2c1.zip | |
[CFLAA] Add getModRefBehavior to CFLAnders.
This patch lets CFLAnders respond to mod-ref queries. It also includes
a small bugfix to CFLSteens.
Patch by Jia Chen.
Differential Revision: https://reviews.llvm.org/D22823
llvm-svn: 276939
Diffstat (limited to 'llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp')
| -rw-r--r-- | llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp index 9b211540f4e..f1fac43a5dc 100644 --- a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp +++ b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -344,6 +344,9 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA, ModRefInfo CFLSteensAAResult::getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) { if (auto CalledFunc = CS.getCalledFunction()) { + if (!CalledFunc->hasExactDefinition()) + return MRI_ModRef; + auto &MaybeInfo = ensureCached(const_cast<Function *>(CalledFunc)); if (!MaybeInfo.hasValue()) return MRI_ModRef; @@ -382,6 +385,10 @@ CFLSteensAAResult::getModRefBehavior(ImmutableCallSite CS) { FunctionModRefBehavior CFLSteensAAResult::getModRefBehavior(const Function *F) { assert(F != nullptr); + // We cannot process external functions + if (!F->hasExactDefinition()) + return FMRB_UnknownModRefBehavior; + // TODO: Remove the const_cast auto &MaybeInfo = ensureCached(const_cast<Function *>(F)); if (!MaybeInfo.hasValue()) @@ -397,18 +404,21 @@ FunctionModRefBehavior CFLSteensAAResult::getModRefBehavior(const Function *F) { // Currently we don't (and can't) distinguish reads from writes in // RetParamRelations. All we can say is whether there may be memory access or // not. - if (RetParamRelations.empty()) + bool AccessNoMemory = + all_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { + return ExtRelation.From.DerefLevel == 0 && + ExtRelation.To.DerefLevel == 0; + }); + if (AccessNoMemory) return FMRB_DoesNotAccessMemory; // Check if something beyond argmem gets touched. bool AccessArgMemoryOnly = - std::all_of(RetParamRelations.begin(), RetParamRelations.end(), - [](const ExternalRelation &ExtRelation) { - // Both DerefLevels has to be 0, since we don't know which - // one is a read and which is a write. - return ExtRelation.From.DerefLevel == 0 && - ExtRelation.To.DerefLevel == 0; - }); + all_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { + return ExtRelation.From.Index > 0 && ExtRelation.To.Index > 0 && + ExtRelation.From.DerefLevel <= 1 && + ExtRelation.To.DerefLevel <= 1; + }); return AccessArgMemoryOnly ? FMRB_OnlyAccessesArgumentPointees : FMRB_UnknownModRefBehavior; } |

