Skip to content

Commit e2cc82b

Browse files
authored
[NFC] [LowerAllowCheck] use InstIterator (llvm#145817)
1 parent 13e0640 commit e2cc82b

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

llvm/lib/Transforms/Instrumentation/LowerAllowCheckPass.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "llvm/Analysis/ProfileSummaryInfo.h"
1616
#include "llvm/IR/Constants.h"
1717
#include "llvm/IR/DiagnosticInfo.h"
18+
#include "llvm/IR/InstIterator.h"
1819
#include "llvm/IR/Instructions.h"
1920
#include "llvm/IR/IntrinsicInst.h"
2021
#include "llvm/IR/Intrinsics.h"
@@ -111,31 +112,29 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI,
111112
return ShouldRemoveRandom() || ShouldRemoveHot(*(II->getParent()), cutoff);
112113
};
113114

114-
for (BasicBlock &BB : F) {
115-
for (Instruction &I : BB) {
116-
IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I);
117-
if (!II)
118-
continue;
119-
auto ID = II->getIntrinsicID();
120-
switch (ID) {
121-
case Intrinsic::allow_ubsan_check:
122-
case Intrinsic::allow_runtime_check: {
123-
++NumChecksTotal;
124-
125-
bool ToRemove = ShouldRemove(II);
126-
127-
ReplaceWithValue.push_back({
128-
II,
129-
ToRemove,
130-
});
131-
if (ToRemove)
132-
++NumChecksRemoved;
133-
emitRemark(II, ORE, ToRemove);
134-
break;
135-
}
136-
default:
137-
break;
138-
}
115+
for (Instruction &I : instructions(F)) {
116+
IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I);
117+
if (!II)
118+
continue;
119+
auto ID = II->getIntrinsicID();
120+
switch (ID) {
121+
case Intrinsic::allow_ubsan_check:
122+
case Intrinsic::allow_runtime_check: {
123+
++NumChecksTotal;
124+
125+
bool ToRemove = ShouldRemove(II);
126+
127+
ReplaceWithValue.push_back({
128+
II,
129+
ToRemove,
130+
});
131+
if (ToRemove)
132+
++NumChecksRemoved;
133+
emitRemark(II, ORE, ToRemove);
134+
break;
135+
}
136+
default:
137+
break;
139138
}
140139
}
141140

0 commit comments

Comments
 (0)