Skip to content

Commit be509bc

Browse files
ro-iarsenm
andcommitted
Apply suggestions from code review
Co-authored-by: Matt Arsenault <[email protected]>
1 parent bb2089c commit be509bc

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

llvm/lib/Transforms/Utils/ControlFlowUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ BasicBlock *ControlFlowHub::createCallBrTarget(
360360
// Jump from the new target block to the original successor.
361361
BranchInst::Create(Succ, CallBrTarget);
362362
if (LI) {
363-
if (Loop *L = LI->getLoopFor(AttachToCallBr ? CallBrBlock : Succ); L) {
363+
if (Loop *L = LI->getLoopFor(AttachToCallBr ? CallBrBlock : Succ)) {
364364
bool AddToLoop = true;
365365
if (AttachToCallBr) {
366366
// Check if the loops are disjoint. In that case, we do not add the

llvm/lib/Transforms/Utils/FixIrreducible.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static bool fixIrreducible(Cycle &C, CycleInfo &CI, DominatorTree &DT,
290290
}
291291

292292
for (BasicBlock *P : Predecessors) {
293-
if (BranchInst *Branch = dyn_cast<BranchInst>(P->getTerminator()); Branch) {
293+
if (BranchInst *Branch = dyn_cast<BranchInst>(P->getTerminator())) {
294294
// Exactly one of the two successors is the header.
295295
BasicBlock *Succ0 = Branch->getSuccessor(0) == Header ? Header : nullptr;
296296
BasicBlock *Succ1 = Succ0 ? nullptr : Header;
@@ -302,20 +302,19 @@ static bool fixIrreducible(Cycle &C, CycleInfo &CI, DominatorTree &DT,
302302
LLVM_DEBUG(dbgs() << "Added internal branch: " << P->getName() << " -> "
303303
<< (Succ0 ? Succ0->getName() : "") << " "
304304
<< (Succ1 ? Succ1->getName() : "") << "\n");
305-
} else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(P->getTerminator());
306-
CallBr) {
305+
} else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(P->getTerminator())) {
307306
for (unsigned I = 0; I < CallBr->getNumSuccessors(); ++I) {
308307
BasicBlock *Succ = CallBr->getSuccessor(I);
309308
if (Succ != Header)
310309
continue;
311-
BasicBlock *NewSucc = llvm::ControlFlowHub::createCallBrTarget(
310+
BasicBlock *NewSucc = ControlFlowHub::createCallBrTarget(
312311
CallBr, Succ, I, false, &CI, &DTU, LI);
313312
CHub.addBranch(NewSucc, Succ);
314313
LLVM_DEBUG(dbgs() << "Added internal branch: " << NewSucc->getName()
315314
<< " -> " << Succ->getName() << "\n");
316315
}
317316
} else {
318-
llvm_unreachable("Unsupported block terminator.");
317+
llvm_unreachable("unsupported block terminator");
319318
}
320319
}
321320

@@ -340,20 +339,19 @@ static bool fixIrreducible(Cycle &C, CycleInfo &CI, DominatorTree &DT,
340339
LLVM_DEBUG(dbgs() << "Added external branch: " << P->getName() << " -> "
341340
<< (Succ0 ? Succ0->getName() : "") << " "
342341
<< (Succ1 ? Succ1->getName() : "") << "\n");
343-
} else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(P->getTerminator());
344-
CallBr) {
342+
} else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(P->getTerminator())) {
345343
for (unsigned I = 0; I < CallBr->getNumSuccessors(); ++I) {
346344
BasicBlock *Succ = CallBr->getSuccessor(I);
347345
if (!C.contains(Succ))
348346
continue;
349-
BasicBlock *NewSucc = llvm::ControlFlowHub::createCallBrTarget(
347+
BasicBlock *NewSucc = ControlFlowHub::createCallBrTarget(
350348
CallBr, Succ, I, true, &CI, &DTU, LI);
351349
CHub.addBranch(NewSucc, Succ);
352350
LLVM_DEBUG(dbgs() << "Added external branch: " << NewSucc->getName()
353351
<< " -> " << Succ->getName() << "\n");
354352
}
355353
} else {
356-
llvm_unreachable("Unsupported block terminator.");
354+
llvm_unreachable("unsupported block terminator");
357355
}
358356
}
359357

llvm/lib/Transforms/Utils/UnifyLoopExits.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ static bool unifyLoopExits(DominatorTree &DT, LoopInfo &LI, Loop *L) {
161161

162162
for (unsigned I = 0; I < ExitingBlocks.size(); ++I) {
163163
BasicBlock *BB = ExitingBlocks[I];
164-
if (BranchInst *Branch = dyn_cast<BranchInst>(BB->getTerminator());
165-
Branch) {
164+
if (BranchInst *Branch = dyn_cast<BranchInst>(BB->getTerminator())) {
166165
BasicBlock *Succ0 = Branch->getSuccessor(0);
167166
Succ0 = L->contains(Succ0) ? nullptr : Succ0;
168167

@@ -174,8 +173,7 @@ static bool unifyLoopExits(DominatorTree &DT, LoopInfo &LI, Loop *L) {
174173
LLVM_DEBUG(dbgs() << "Added exiting branch: " << BB->getName() << " -> {"
175174
<< (Succ0 ? Succ0->getName() : "<none>") << ", "
176175
<< (Succ1 ? Succ1->getName() : "<none>") << "}\n");
177-
} else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(BB->getTerminator());
178-
CallBr) {
176+
} else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(BB->getTerminator())) {
179177
for (unsigned J = 0; J < CallBr->getNumSuccessors(); ++J) {
180178
BasicBlock *Succ = CallBr->getSuccessor(J);
181179
if (L->contains(Succ))
@@ -196,7 +194,7 @@ static bool unifyLoopExits(DominatorTree &DT, LoopInfo &LI, Loop *L) {
196194
CallBrTargetBlocks.push_back(NewSucc);
197195
}
198196
} else {
199-
llvm_unreachable("Unsupported block terminator.");
197+
llvm_unreachable("unsupported block terminator");
200198
}
201199
}
202200

llvm/test/Transforms/FixIrreducible/bug45623.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if.else629: ; preds = %backtrack
9191
br label %retry
9292
}
9393

94-
define dso_local void @tre_tnfa_run_backtrack_callbr(i1 %arg) {
94+
define void @tre_tnfa_run_backtrack_callbr(i1 %arg) {
9595
; CHECK-LABEL: @tre_tnfa_run_backtrack_callbr(
9696
; CHECK-NEXT: entry:
9797
; CHECK-NEXT: callbr void asm "", ""()

0 commit comments

Comments
 (0)