summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.m.kuperstein@intel.com>2015-08-11 08:06:44 +0000
committerMichael Kuperstein <michael.m.kuperstein@intel.com>2015-08-11 08:06:44 +0000
commit07f31d92ca053c3e6c981b897c2f9f22ac0666b5 (patch)
treeecf12d0a31845e4b17f6980d57792f56ecd88d68 /llvm/lib/Analysis
parent0fd3610e6dde8e04e51da4a747e120bcbc9ca097 (diff)
downloadbcm5719-llvm-07f31d92ca053c3e6c981b897c2f9f22ac0666b5.tar.gz
bcm5719-llvm-07f31d92ca053c3e6c981b897c2f9f22ac0666b5.zip
[GMR] Be a bit smarter about which globals don't alias when doing recursive lookups
Should hopefully fix the remainder of PR24288. Differential Revision: http://reviews.llvm.org/D11900 llvm-svn: 244575
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/IPA/GlobalsModRef.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp
index f7b55c2cf8f..f429603da0b 100644
--- a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp
@@ -717,12 +717,23 @@ bool GlobalsModRef::isNonEscapingGlobalNoAlias(const GlobalValue *GV,
if (InputGV == GV)
return false;
- // FIXME: It would be good to handle other obvious no-alias cases here, but
- // it isn't clear how to do so reasonbly without building a small version
- // of BasicAA into this code. We could recurse into AliasAnalysis::alias
- // here but that seems likely to go poorly as we're inside the
- // implementation of such a query. Until then, just conservatievly retun
- // false.
+ // Distinct GlobalVariables never alias, unless overriden or zero-sized.
+ // FIXME: The condition can be refined, but be conservative for now.
+ auto *GVar = dyn_cast<GlobalVariable>(GV);
+ auto *InputGVar = dyn_cast<GlobalVariable>(InputGV);
+ if (GVar && InputGVar &&
+ !GVar->isDeclaration() && !InputGVar->isDeclaration() &&
+ !GVar->mayBeOverridden() && !InputGVar->mayBeOverridden()) {
+ Type *GVType = GVar->getInitializer()->getType();
+ Type *InputGVType = InputGVar->getInitializer()->getType();
+ if (GVType->isSized() && InputGVType->isSized() &&
+ (DL->getTypeAllocSize(GVType) > 0) &&
+ (DL->getTypeAllocSize(InputGVType) > 0))
+ continue;
+ }
+
+ // Conservatively return false, even though we could be smarter
+ // (e.g. look through GlobalAliases).
return false;
}
@@ -767,7 +778,12 @@ bool GlobalsModRef::isNonEscapingGlobalNoAlias(const GlobalValue *GV,
continue;
}
- // Unknown instruction, bail.
+ // FIXME: It would be good to handle other obvious no-alias cases here, but
+ // it isn't clear how to do so reasonbly without building a small version
+ // of BasicAA into this code. We could recurse into AliasAnalysis::alias
+ // here but that seems likely to go poorly as we're inside the
+ // implementation of such a query. Until then, just conservatievly retun
+ // false.
return false;
} while (!Inputs.empty());
OpenPOWER on IntegriCloud