Skip to content

Commit f155758

Browse files
committed
Exit early instead of nest in removeLifetimeIntrinsics loop
1 parent a782b33 commit f155758

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

llvm/lib/Target/DirectX/DXILWriter/DXILWriterPass.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,24 @@ static void legalizeLifetimeIntrinsics(Module &M) {
8181
}
8282

8383
static void removeLifetimeIntrinsics(Module &M) {
84-
for (Function &F : make_early_inc_range(M))
84+
for (Function &F : make_early_inc_range(M)) {
85+
8586
if (Intrinsic::ID IID = F.getIntrinsicID();
86-
IID == Intrinsic::lifetime_start || IID == Intrinsic::lifetime_end) {
87-
for (User *U : make_early_inc_range(F.users())) {
88-
LifetimeIntrinsic *LI = dyn_cast<LifetimeIntrinsic>(U);
89-
assert(LI && "Expected user of lifetime intrinsic function to be "
90-
"a LifetimeIntrinsic instruction");
91-
BitCastInst *BCI = dyn_cast<BitCastInst>(LI->getArgOperand(1));
92-
assert(BCI && "Expected pointer operand of LifetimeIntrinsic to be a "
93-
"BitCastInst");
94-
LI->eraseFromParent();
95-
BCI->eraseFromParent();
96-
}
97-
F.eraseFromParent();
87+
IID != Intrinsic::lifetime_start && IID != Intrinsic::lifetime_end)
88+
continue;
89+
90+
for (User *U : make_early_inc_range(F.users())) {
91+
LifetimeIntrinsic *LI = dyn_cast<LifetimeIntrinsic>(U);
92+
assert(LI && "Expected user of lifetime intrinsic function to be "
93+
"a LifetimeIntrinsic instruction");
94+
BitCastInst *BCI = dyn_cast<BitCastInst>(LI->getArgOperand(1));
95+
assert(BCI && "Expected pointer operand of LifetimeIntrinsic to be a "
96+
"BitCastInst");
97+
LI->eraseFromParent();
98+
BCI->eraseFromParent();
9899
}
100+
F.eraseFromParent();
101+
}
99102
}
100103

101104
class EmbedDXILPass : public llvm::ModulePass {

0 commit comments

Comments
 (0)