Skip to content

Commit c564708

Browse files
lukaszgotszaldinteligcbot
authored andcommitted
refactor asserts in GenXCoalescing.cpp
1 parent e24c466 commit c564708

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXCoalescing.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ void GenXCoalescing::recordCandidates(FunctionGroup *FG)
617617
}
618618
}
619619
} else if (isa<BitCastInst>(Inst) || isa<AddrSpaceCastInst>(Inst)) {
620-
IGC_ASSERT(!isa<StructType>(Inst->getType()) && "not expecting bitcast to struct");
621-
IGC_ASSERT(!isa<StructType>(Inst->getOperand(0)->getType()) && "not expecting bitcast from struct");
620+
IGC_ASSERT_MESSAGE(!isa<StructType>(Inst->getType()), "not expecting bitcast to struct");
621+
IGC_ASSERT_MESSAGE(!isa<StructType>(Inst->getOperand(0)->getType()), "not expecting bitcast from struct");
622622
// The source and destination of a bitcast can copy coalesce,
623623
// but only if it is not the case that the source is a phi and
624624
// the destination has a use in a phi node in the same block and
@@ -1138,10 +1138,10 @@ void GenXCoalescing::processPhiCopy(PHINode *Phi, unsigned Inc,
11381138
Value *Incoming = Phi->getIncomingValue(Inc);
11391139
auto *IncomingBlock = Phi->getIncomingBlock(Inc);
11401140
// Should be checked in analysePhiCopies
1141-
IGC_ASSERT(DestLR->getCategory() < RegCategory::NUMREALCATEGORIES &&
1142-
"Should be checked earlier!");
1143-
IGC_ASSERT(!isa<UndefValue>(Incoming) && "Should be checked earlier!");
1144-
IGC_ASSERT(!isa<Constant>(Incoming) && "Should be checked earlier!");
1141+
IGC_ASSERT_MESSAGE(DestLR->getCategory() < RegCategory::NUMREALCATEGORIES,
1142+
"Should be checked earlier!");
1143+
IGC_ASSERT_MESSAGE(!isa<UndefValue>(Incoming), "Should be checked earlier!");
1144+
IGC_ASSERT_MESSAGE(!isa<Constant>(Incoming), "Should be checked earlier!");
11451145
// Check it again: something could change
11461146
if (Liveness->getLiveRange(Incoming) == DestLR) {
11471147
LLVM_DEBUG(dbgs() << "Already coalesced " << Incoming->getName() << " -> "
@@ -1167,8 +1167,8 @@ void GenXCoalescing::processPhiCopy(PHINode *Phi, unsigned Inc,
11671167
if (auto *I = dyn_cast<Instruction>(Incoming)) {
11681168
// This should not happen for good BBs (not join blocks)
11691169
// if DFG is correct.
1170-
IGC_ASSERT(DomTree->dominates(I->getParent(), InsertPoint->getParent()) &&
1171-
"Dominance corrupted!");
1170+
IGC_ASSERT_MESSAGE(DomTree->dominates(I->getParent(), InsertPoint->getParent()),
1171+
"Dominance corrupted!");
11721172
}
11731173

11741174
// Store info for copy
@@ -1187,15 +1187,15 @@ void GenXCoalescing::processPhiBranchingJoinLabelCopy(
11871187
Value *Incoming = Phi->getIncomingValue(Inc);
11881188
auto *IncomingBlock = Phi->getIncomingBlock(Inc);
11891189
// Should be checked in analysePhiCopies
1190-
IGC_ASSERT(DestLR->getCategory() < RegCategory::NUMREALCATEGORIES &&
1191-
"Should be checked earlier!");
1192-
IGC_ASSERT(!isa<UndefValue>(Incoming) && "Should be checked earlier!");
1193-
IGC_ASSERT(!isa<Constant>(Incoming) && "Should be checked earlier!");
1190+
IGC_ASSERT_MESSAGE(DestLR->getCategory() < RegCategory::NUMREALCATEGORIES,
1191+
"Should be checked earlier!");
1192+
IGC_ASSERT_MESSAGE(!isa<UndefValue>(Incoming), "Should be checked earlier!");
1193+
IGC_ASSERT_MESSAGE(!isa<Constant>(Incoming), "Should be checked earlier!");
11941194
// Should be checked in processPhiCopy
1195-
IGC_ASSERT(Liveness->getLiveRange(Incoming) != DestLR &&
1196-
"Should be checked earlier!");
1197-
IGC_ASSERT(GotoJoin::isBranchingJoinLabelBlock(IncomingBlock) &&
1198-
"Should be checked earlier!");
1195+
IGC_ASSERT_MESSAGE(Liveness->getLiveRange(Incoming) != DestLR,
1196+
"Should be checked earlier!");
1197+
IGC_ASSERT_MESSAGE(GotoJoin::isBranchingJoinLabelBlock(IncomingBlock),
1198+
"Should be checked earlier!");
11991199

12001200
LLVM_DEBUG(dbgs() << "Handling branching join label block case\n");
12011201

@@ -1214,7 +1214,7 @@ void GenXCoalescing::processPhiBranchingJoinLabelCopy(
12141214
// This situation is detected via corrupted dominance.
12151215
if (!DomTree->dominates(PhiPred->getParent(), InsertPoint->getParent())) {
12161216
auto *PhiCopy = copyNonCoalescedPhi(PhiPred, Phi);
1217-
IGC_ASSERT(PhiCopy && "Invalid phi copy!");
1217+
IGC_ASSERT_MESSAGE(PhiCopy, "Invalid phi copy!");
12181218
Phis.push_back(PhiCopy);
12191219
return;
12201220
}
@@ -1227,8 +1227,8 @@ void GenXCoalescing::processPhiBranchingJoinLabelCopy(
12271227
// For join block, def must be somewhere before it
12281228
// because of SIMD CF Conformance. Case for Phi is
12291229
// described and handled above.
1230-
IGC_ASSERT(DomTree->dominates(I->getParent(), InsertPoint->getParent()) &&
1231-
"Dominance corrupted!");
1230+
IGC_ASSERT_MESSAGE(DomTree->dominates(I->getParent(), InsertPoint->getParent()),
1231+
"Dominance corrupted!");
12321232
}
12331233

12341234
// Store info for copy
@@ -1306,8 +1306,8 @@ void GenXCoalescing::processCalls(FunctionGroup *FG)
13061306
for (unsigned StructIdx = 0,
13071307
se = IndexFlattener::getNumElements(Arg->getType());
13081308
StructIdx != se; ++StructIdx) {
1309-
IGC_ASSERT(!StructIdx &&
1310-
"coalesce failure on struct call arg not tested");
1309+
IGC_ASSERT_MESSAGE(!StructIdx,
1310+
"coalesce failure on struct call arg not tested");
13111311
auto FuncArgSV = SimpleValue(Arg, StructIdx);
13121312
auto CallArgSV = SimpleValue(CallArg, StructIdx);
13131313
// See if they are coalesced.
@@ -1960,8 +1960,8 @@ Iter GenXCoalescing::mergeCopiesTillFailed(SimpleValue CopySV, Iter BeginIt,
19601960
if (It->Source.getValue()->getType() == CurrCopy->getType()) {
19611961
*It->UseInDest = CurrCopy;
19621962
} else {
1963-
IGC_ASSERT(It->Source.getIndex() == 0 &&
1964-
"Must be non-aggregated type: should come from bitcast");
1963+
IGC_ASSERT_MESSAGE(It->Source.getIndex() == 0,
1964+
"Must be non-aggregated type: should come from bitcast");
19651965
IRBuilder<> Builder(CurrCopy->getNextNode());
19661966
BCI = cast<BitCastInst>(Builder.CreateBitCast(
19671967
CurrCopy, It->Source.getValue()->getType(), "red_copy_type_conv"));
@@ -2033,7 +2033,7 @@ Instruction *GenXCoalescing::createCopy(const CopyData &CD) {
20332033
case PHICOPY:
20342034
case PHICOPY_BRANCHING_JP: {
20352035
PHINode *Phi = dyn_cast<PHINode>(CD.Dest.getValue());
2036-
IGC_ASSERT(Phi && "Expected PHI");
2036+
IGC_ASSERT_MESSAGE(Phi, "Expected PHI");
20372037
unsigned Num =
20382038
(CD.CopyT == PHICOPY)
20392039
? Numbering->getPhiNumber(
@@ -2072,7 +2072,7 @@ Instruction *GenXCoalescing::createCopy(const CopyData &CD) {
20722072
Liveness->rebuildLiveRange(DestLR);
20732073
}
20742074

2075-
IGC_ASSERT(NewCopy && "Bad copy");
2075+
IGC_ASSERT_MESSAGE(NewCopy, "Bad copy");
20762076

20772077
return NewCopy;
20782078
}

0 commit comments

Comments
 (0)