59
59
using namespace llvm ;
60
60
61
61
#define DEBUG_TYPE " attributor"
62
+ #define VERBOSE_DEBUG_TYPE DEBUG_TYPE " -verbose"
62
63
63
64
DEBUG_COUNTER (ManifestDBGCounter, " attributor-manifest" ,
64
65
" Determine what attributes are manifested in the IR" );
@@ -1384,7 +1385,7 @@ bool Attributor::checkForAllUses(
1384
1385
const Use *U = Worklist.pop_back_val ();
1385
1386
if (isa<PHINode>(U->getUser ()) && !Visited.insert (U).second )
1386
1387
continue ;
1387
- LLVM_DEBUG ( {
1388
+ DEBUG_WITH_TYPE (VERBOSE_DEBUG_TYPE, {
1388
1389
if (auto *Fn = dyn_cast<Function>(U->getUser ()))
1389
1390
dbgs () << " [Attributor] Check use: " << **U << " in " << Fn->getName ()
1390
1391
<< " \n " ;
@@ -1395,11 +1396,13 @@ bool Attributor::checkForAllUses(
1395
1396
bool UsedAssumedInformation = false ;
1396
1397
if (isAssumedDead (*U, &QueryingAA, LivenessAA, UsedAssumedInformation,
1397
1398
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 " );
1399
1401
continue ;
1400
1402
}
1401
1403
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 " );
1403
1406
continue ;
1404
1407
}
1405
1408
@@ -1411,9 +1414,11 @@ bool Attributor::checkForAllUses(
1411
1414
if (AA::getPotentialCopiesOfStoredValue (
1412
1415
*this , *SI, PotentialCopies, QueryingAA, UsedAssumedInformation,
1413
1416
/* 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 " );
1417
1422
for (Value *PotentialCopy : PotentialCopies)
1418
1423
if (!AddUsers (*PotentialCopy, U))
1419
1424
return false ;
@@ -1486,7 +1491,7 @@ bool Attributor::checkForAllCallSites(function_ref<bool(AbstractCallSite)> Pred,
1486
1491
SmallVector<const Use *, 8 > Uses (make_pointer_range (Fn.uses ()));
1487
1492
for (unsigned u = 0 ; u < Uses.size (); ++u) {
1488
1493
const Use &U = *Uses[u];
1489
- LLVM_DEBUG ( {
1494
+ DEBUG_WITH_TYPE (VERBOSE_DEBUG_TYPE, {
1490
1495
if (auto *Fn = dyn_cast<Function>(U))
1491
1496
dbgs () << " [Attributor] Check use: " << Fn->getName () << " in "
1492
1497
<< *U.getUser () << " \n " ;
@@ -1496,15 +1501,16 @@ bool Attributor::checkForAllCallSites(function_ref<bool(AbstractCallSite)> Pred,
1496
1501
});
1497
1502
if (isAssumedDead (U, QueryingAA, nullptr , UsedAssumedInformation,
1498
1503
/* 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 " );
1500
1506
continue ;
1501
1507
}
1502
1508
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(U.getUser ())) {
1503
1509
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
+ } );
1508
1514
for (const Use &CEU : CE->uses ())
1509
1515
Uses.push_back (&CEU);
1510
1516
continue ;
@@ -1634,8 +1640,9 @@ static bool checkForAllInstructionsImpl(
1634
1640
if (A && !CheckPotentiallyDead &&
1635
1641
A->isAssumedDead (IRPosition::inst (*I), QueryingAA, LivenessAA,
1636
1642
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 " ;);
1639
1646
continue ;
1640
1647
}
1641
1648
@@ -1744,19 +1751,22 @@ void Attributor::runTillFixpoint() {
1744
1751
AbstractAttribute *InvalidAA = InvalidAAs[u];
1745
1752
1746
1753
// 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 " );
1750
1758
while (!InvalidAA->Deps .empty ()) {
1751
1759
const auto &Dep = InvalidAA->Deps .back ();
1752
1760
InvalidAA->Deps .pop_back ();
1753
1761
AbstractAttribute *DepAA = cast<AbstractAttribute>(Dep.getPointer ());
1754
1762
if (Dep.getInt () == unsigned (DepClassTy::OPTIONAL)) {
1755
- LLVM_DEBUG (dbgs () << " - recompute: " << *DepAA);
1763
+ DEBUG_WITH_TYPE (VERBOSE_DEBUG_TYPE,
1764
+ dbgs () << " - recompute: " << *DepAA);
1756
1765
Worklist.insert (DepAA);
1757
1766
continue ;
1758
1767
}
1759
- LLVM_DEBUG (dbgs () << " - invalidate: " << *DepAA);
1768
+ DEBUG_WITH_TYPE (VERBOSE_DEBUG_TYPE, dbgs ()
1769
+ << " - invalidate: " << *DepAA);
1760
1770
DepAA->getState ().indicatePessimisticFixpoint ();
1761
1771
assert (DepAA->getState ().isAtFixpoint () && " Expected fixpoint state!" );
1762
1772
if (!DepAA->getState ().isValidState ())
0 commit comments