[llvm] 74ace2c - [Attributor] Ensure no recursive reasoning is used for isAssumedDead
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 12 00:21:06 PST 2023
Author: Johannes Doerfert
Date: 2023-01-12T00:14:06-08:00
New Revision: 74ace2c7aedef89d341e997e87c82475b0181201
URL: https://github.com/llvm/llvm-project/commit/74ace2c7aedef89d341e997e87c82475b0181201
DIFF: https://github.com/llvm/llvm-project/commit/74ace2c7aedef89d341e997e87c82475b0181201.diff
LOG: [Attributor] Ensure no recursive reasoning is used for isAssumedDead
This is a precaution for the future.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 416f554edce2..c3cb22dabfc8 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1361,6 +1361,10 @@ bool Attributor::isAssumedDead(const Instruction &I,
FnLivenessAA = &getOrCreateAAFor<AAIsDead>(IRPosition::function(F, CBCtx),
QueryingAA, DepClassTy::NONE);
+ // Don't use recursive reasoning.
+ if (QueryingAA == FnLivenessAA)
+ return false;
+
// If we have a context instruction and a liveness AA we use it.
if (CheckBBLivenessOnly ? FnLivenessAA->isAssumedDead(I.getParent())
: FnLivenessAA->isAssumedDead(&I)) {
@@ -1377,7 +1381,8 @@ bool Attributor::isAssumedDead(const Instruction &I,
const IRPosition IRP = IRPosition::inst(I, CBCtx);
const AAIsDead &IsDeadAA =
getOrCreateAAFor<AAIsDead>(IRP, QueryingAA, DepClassTy::NONE);
- // Don't check liveness for AAIsDead.
+
+ // Don't use recursive reasoning.
if (QueryingAA == &IsDeadAA)
return false;
@@ -1422,7 +1427,8 @@ bool Attributor::isAssumedDead(const IRPosition &IRP,
QueryingAA, DepClassTy::NONE);
else
IsDeadAA = &getOrCreateAAFor<AAIsDead>(IRP, QueryingAA, DepClassTy::NONE);
- // Don't check liveness for AAIsDead.
+
+ // Don't use recursive reasoning.
if (QueryingAA == IsDeadAA)
return false;
@@ -1446,6 +1452,10 @@ bool Attributor::isAssumedDead(const BasicBlock &BB,
FnLivenessAA = &getOrCreateAAFor<AAIsDead>(IRPosition::function(F),
QueryingAA, DepClassTy::NONE);
+ // Don't use recursive reasoning.
+ if (QueryingAA == FnLivenessAA)
+ return false;
+
if (FnLivenessAA->isAssumedDead(&BB)) {
if (QueryingAA)
recordDependence(*FnLivenessAA, *QueryingAA, DepClass);
More information about the llvm-commits
mailing list