Skip to content

Commit 1716924

Browse files
committed
[Attributor][NFC] Introduce a flag to skip liveness checks
While we can disallow AAs, liveness checks are everywhere and if the user doesn't want them it is costly to go through just to find out everything is assumed live.
1 parent 21c0d6b commit 1716924

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,9 @@ struct AttributorConfig {
14531453
/// function marked live. See also: InitializationCallback>
14541454
bool DefaultInitializeLiveInternals = true;
14551455

1456+
/// Flag to determine if we should skip all liveness checks early on.
1457+
bool UseLiveness = true;
1458+
14561459
/// Callback function to be invoked on internal functions marked live.
14571460
std::function<void(Attributor &A, const Function &F)> InitializationCallback =
14581461
nullptr;

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,8 @@ bool Attributor::isAssumedDead(const AbstractAttribute &AA,
14071407
const AAIsDead *FnLivenessAA,
14081408
bool &UsedAssumedInformation,
14091409
bool CheckBBLivenessOnly, DepClassTy DepClass) {
1410+
if (!Configuration.UseLiveness)
1411+
return false;
14101412
const IRPosition &IRP = AA.getIRPosition();
14111413
if (!Functions.count(IRP.getAnchorScope()))
14121414
return false;
@@ -1419,6 +1421,8 @@ bool Attributor::isAssumedDead(const Use &U,
14191421
const AAIsDead *FnLivenessAA,
14201422
bool &UsedAssumedInformation,
14211423
bool CheckBBLivenessOnly, DepClassTy DepClass) {
1424+
if (!Configuration.UseLiveness)
1425+
return false;
14221426
Instruction *UserI = dyn_cast<Instruction>(U.getUser());
14231427
if (!UserI)
14241428
return isAssumedDead(IRPosition::value(*U.get()), QueryingAA, FnLivenessAA,
@@ -1467,6 +1471,8 @@ bool Attributor::isAssumedDead(const Instruction &I,
14671471
bool &UsedAssumedInformation,
14681472
bool CheckBBLivenessOnly, DepClassTy DepClass,
14691473
bool CheckForDeadStore) {
1474+
if (!Configuration.UseLiveness)
1475+
return false;
14701476
const IRPosition::CallBaseContext *CBCtx =
14711477
QueryingAA ? QueryingAA->getCallBaseContext() : nullptr;
14721478

@@ -1527,6 +1533,8 @@ bool Attributor::isAssumedDead(const IRPosition &IRP,
15271533
const AAIsDead *FnLivenessAA,
15281534
bool &UsedAssumedInformation,
15291535
bool CheckBBLivenessOnly, DepClassTy DepClass) {
1536+
if (!Configuration.UseLiveness)
1537+
return false;
15301538
// Don't check liveness for constants, e.g. functions, used as (floating)
15311539
// values since the context instruction and such is here meaningless.
15321540
if (IRP.getPositionKind() == IRPosition::IRP_FLOAT &&
@@ -1572,6 +1580,8 @@ bool Attributor::isAssumedDead(const BasicBlock &BB,
15721580
const AbstractAttribute *QueryingAA,
15731581
const AAIsDead *FnLivenessAA,
15741582
DepClassTy DepClass) {
1583+
if (!Configuration.UseLiveness)
1584+
return false;
15751585
const Function &F = *BB.getParent();
15761586
if (!FnLivenessAA || FnLivenessAA->getAnchorScope() != &F)
15771587
FnLivenessAA = getOrCreateAAFor<AAIsDead>(IRPosition::function(F),

0 commit comments

Comments
 (0)