Skip to content

Commit f89deef

Browse files
committed
[Attributor][NFC] Hide verbose output behind attributor-verbose
1 parent d0f9ddd commit f89deef

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
using namespace llvm;
6060

6161
#define DEBUG_TYPE "attributor"
62+
#define VERBOSE_DEBUG_TYPE DEBUG_TYPE "-verbose"
6263

6364
DEBUG_COUNTER(ManifestDBGCounter, "attributor-manifest",
6465
"Determine what attributes are manifested in the IR");
@@ -1384,7 +1385,7 @@ bool Attributor::checkForAllUses(
13841385
const Use *U = Worklist.pop_back_val();
13851386
if (isa<PHINode>(U->getUser()) && !Visited.insert(U).second)
13861387
continue;
1387-
LLVM_DEBUG({
1388+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE, {
13881389
if (auto *Fn = dyn_cast<Function>(U->getUser()))
13891390
dbgs() << "[Attributor] Check use: " << **U << " in " << Fn->getName()
13901391
<< "\n";
@@ -1395,11 +1396,13 @@ bool Attributor::checkForAllUses(
13951396
bool UsedAssumedInformation = false;
13961397
if (isAssumedDead(*U, &QueryingAA, LivenessAA, UsedAssumedInformation,
13971398
CheckBBLivenessOnly, LivenessDepClass)) {
1398-
LLVM_DEBUG(dbgs() << "[Attributor] Dead use, skip!\n");
1399+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE,
1400+
dbgs() << "[Attributor] Dead use, skip!\n");
13991401
continue;
14001402
}
14011403
if (IgnoreDroppableUses && U->getUser()->isDroppable()) {
1402-
LLVM_DEBUG(dbgs() << "[Attributor] Droppable user, skip!\n");
1404+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE,
1405+
dbgs() << "[Attributor] Droppable user, skip!\n");
14031406
continue;
14041407
}
14051408

@@ -1411,9 +1414,11 @@ bool Attributor::checkForAllUses(
14111414
if (AA::getPotentialCopiesOfStoredValue(
14121415
*this, *SI, PotentialCopies, QueryingAA, UsedAssumedInformation,
14131416
/* OnlyExact */ true)) {
1414-
LLVM_DEBUG(dbgs() << "[Attributor] Value is stored, continue with "
1415-
<< PotentialCopies.size()
1416-
<< " potential copies instead!\n");
1417+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE,
1418+
dbgs()
1419+
<< "[Attributor] Value is stored, continue with "
1420+
<< PotentialCopies.size()
1421+
<< " potential copies instead!\n");
14171422
for (Value *PotentialCopy : PotentialCopies)
14181423
if (!AddUsers(*PotentialCopy, U))
14191424
return false;
@@ -1486,7 +1491,7 @@ bool Attributor::checkForAllCallSites(function_ref<bool(AbstractCallSite)> Pred,
14861491
SmallVector<const Use *, 8> Uses(make_pointer_range(Fn.uses()));
14871492
for (unsigned u = 0; u < Uses.size(); ++u) {
14881493
const Use &U = *Uses[u];
1489-
LLVM_DEBUG({
1494+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE, {
14901495
if (auto *Fn = dyn_cast<Function>(U))
14911496
dbgs() << "[Attributor] Check use: " << Fn->getName() << " in "
14921497
<< *U.getUser() << "\n";
@@ -1496,15 +1501,16 @@ bool Attributor::checkForAllCallSites(function_ref<bool(AbstractCallSite)> Pred,
14961501
});
14971502
if (isAssumedDead(U, QueryingAA, nullptr, UsedAssumedInformation,
14981503
/* CheckBBLivenessOnly */ true)) {
1499-
LLVM_DEBUG(dbgs() << "[Attributor] Dead use, skip!\n");
1504+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE,
1505+
dbgs() << "[Attributor] Dead use, skip!\n");
15001506
continue;
15011507
}
15021508
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(U.getUser())) {
15031509
if (CE->isCast() && CE->getType()->isPointerTy()) {
1504-
LLVM_DEBUG(
1505-
dbgs() << "[Attributor] Use, is constant cast expression, add "
1506-
<< CE->getNumUses()
1507-
<< " uses of that expression instead!\n");
1510+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE, {
1511+
dbgs() << "[Attributor] Use, is constant cast expression, add "
1512+
<< CE->getNumUses() << " uses of that expression instead!\n";
1513+
});
15081514
for (const Use &CEU : CE->uses())
15091515
Uses.push_back(&CEU);
15101516
continue;
@@ -1634,8 +1640,9 @@ static bool checkForAllInstructionsImpl(
16341640
if (A && !CheckPotentiallyDead &&
16351641
A->isAssumedDead(IRPosition::inst(*I), QueryingAA, LivenessAA,
16361642
UsedAssumedInformation, CheckBBLivenessOnly)) {
1637-
LLVM_DEBUG(dbgs() << "[Attributor] Instruction " << *I
1638-
<< " is potentially dead, skip!\n";);
1643+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE,
1644+
dbgs() << "[Attributor] Instruction " << *I
1645+
<< " is potentially dead, skip!\n";);
16391646
continue;
16401647
}
16411648

@@ -1744,19 +1751,22 @@ void Attributor::runTillFixpoint() {
17441751
AbstractAttribute *InvalidAA = InvalidAAs[u];
17451752

17461753
// Check the dependences to fast track invalidation.
1747-
LLVM_DEBUG(dbgs() << "[Attributor] InvalidAA: " << *InvalidAA << " has "
1748-
<< InvalidAA->Deps.size()
1749-
<< " required & optional dependences\n");
1754+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE,
1755+
dbgs() << "[Attributor] InvalidAA: " << *InvalidAA
1756+
<< " has " << InvalidAA->Deps.size()
1757+
<< " required & optional dependences\n");
17501758
while (!InvalidAA->Deps.empty()) {
17511759
const auto &Dep = InvalidAA->Deps.back();
17521760
InvalidAA->Deps.pop_back();
17531761
AbstractAttribute *DepAA = cast<AbstractAttribute>(Dep.getPointer());
17541762
if (Dep.getInt() == unsigned(DepClassTy::OPTIONAL)) {
1755-
LLVM_DEBUG(dbgs() << " - recompute: " << *DepAA);
1763+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE,
1764+
dbgs() << " - recompute: " << *DepAA);
17561765
Worklist.insert(DepAA);
17571766
continue;
17581767
}
1759-
LLVM_DEBUG(dbgs() << " - invalidate: " << *DepAA);
1768+
DEBUG_WITH_TYPE(VERBOSE_DEBUG_TYPE, dbgs()
1769+
<< " - invalidate: " << *DepAA);
17601770
DepAA->getState().indicatePessimisticFixpoint();
17611771
assert(DepAA->getState().isAtFixpoint() && "Expected fixpoint state!");
17621772
if (!DepAA->getState().isValidState())

0 commit comments

Comments
 (0)