|
15 | 15 | #include "llvm/Analysis/ProfileSummaryInfo.h"
|
16 | 16 | #include "llvm/IR/Constants.h"
|
17 | 17 | #include "llvm/IR/DiagnosticInfo.h"
|
| 18 | +#include "llvm/IR/InstIterator.h" |
18 | 19 | #include "llvm/IR/Instructions.h"
|
19 | 20 | #include "llvm/IR/IntrinsicInst.h"
|
20 | 21 | #include "llvm/IR/Intrinsics.h"
|
@@ -111,31 +112,29 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI,
|
111 | 112 | return ShouldRemoveRandom() || ShouldRemoveHot(*(II->getParent()), cutoff);
|
112 | 113 | };
|
113 | 114 |
|
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; |
139 | 138 | }
|
140 | 139 | }
|
141 | 140 |
|
|
0 commit comments