summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJohannes Doerfert <jdoerfert@anl.gov>2019-08-14 21:25:08 +0000
committerJohannes Doerfert <jdoerfert@anl.gov>2019-08-14 21:25:08 +0000
commit9a1a1f96d9cda223252ac7c868426a326b90d647 (patch)
treecec80bf0f90e6f5fb802e246619be7d47688d7d8 /llvm/lib/Transforms
parent66214b581c4357748fdcad9e824a70bd9b7187aa (diff)
downloadbcm5719-llvm-9a1a1f96d9cda223252ac7c868426a326b90d647.tar.gz
bcm5719-llvm-9a1a1f96d9cda223252ac7c868426a326b90d647.zip
[Attributor] Do not update or manifest dead attributes
Summary: If the associated context instruction is assumed dead we do not need to update or manifest the state. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66116 llvm-svn: 368921
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 33a49a5f954..2f062bfac5e 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1076,7 +1076,6 @@ AANonNullImpl::generatePredicate(Attributor &A) {
std::function<bool(Value &, const SmallPtrSetImpl<ReturnInst *> &)> Pred =
[&](Value &RV, const SmallPtrSetImpl<ReturnInst *> &RetInsts) -> bool {
-
if (isKnownNonZero(&RV, A.getDataLayout()))
return true;
@@ -2143,6 +2142,23 @@ struct AANoReturnFunction final : AANoReturnImpl {
/// Attributor
/// ----------------------------------------------------------------------------
+bool Attributor::isAssumedDead(const AbstractAttribute &AA,
+ const AAIsDead *LivenessAA) {
+ const Instruction *CtxI = AA.getIRPosition().getCtxI();
+ if (!CtxI)
+ return false;
+
+ if (!LivenessAA)
+ LivenessAA =
+ getAAFor<AAIsDead>(AA, IRPosition::function(*CtxI->getFunction()));
+ if (!LivenessAA || !LivenessAA->isAssumedDead(CtxI))
+ return false;
+
+ // TODO: Do not track dependences automatically but add it here as only a
+ // "is-assumed-dead" result causes a dependence.
+ return true;
+}
+
bool Attributor::checkForAllCallSites(const function_ref<bool(CallSite)> &Pred,
const AbstractAttribute &QueryingAA,
bool RequireAllCallSites) {
@@ -2354,8 +2370,9 @@ ChangeStatus Attributor::run() {
// Update all abstract attribute in the work list and record the ones that
// changed.
for (AbstractAttribute *AA : Worklist)
- if (AA->update(*this) == ChangeStatus::CHANGED)
- ChangedAAs.push_back(AA);
+ if (!isAssumedDead(*AA, nullptr))
+ if (AA->update(*this) == ChangeStatus::CHANGED)
+ ChangedAAs.push_back(AA);
// Reset the work list and repopulate with the changed abstract attributes.
// Note that dependent ones are added above.
@@ -2415,6 +2432,9 @@ ChangeStatus Attributor::run() {
if (!State.isValidState())
continue;
+ // Skip dead code.
+ if (isAssumedDead(*AA, nullptr))
+ continue;
// Manifest the state and record if we changed the IR.
ChangeStatus LocalChange = AA->manifest(*this);
if (LocalChange == ChangeStatus::CHANGED && AreStatisticsEnabled())
OpenPOWER on IntegriCloud