189{
190 bool modified = false;
191 for (Module::iterator F = module.begin(), E = module.end(); F != E; ++F)
192 {
193
194 std::vector<Instruction* > Worklist;
195
196
197
198
199
200 for (Function::iterator BB = (*F).begin(); BB != (*F).end(); ++BB)
201 {
202 for (BasicBlock::iterator i = BB->begin(); i != BB->end(); ++i)
203 {
204
205
206
207
210 {
212 {
213 Worklist.push_back (I);
214 }
215 }
216 }
217 }
218
219
220
221
222 if (Worklist.size()) modified = true;
223
224
225
226
227
228
229 while (Worklist.size())
230 {
232 Worklist.pop_back();
233
234
235
236
237
238
239
241 {
243 {
244
245
246
247
248
249
250
251
254 {
256 for (
u32_t i2 =
index; i2 < PHI->getNumIncomingValues(); ++i2)
257 {
258 if ((PHI->getIncomingBlock (i2)) == PHI->getIncomingBlock (
index))
259 PHI->setIncomingValue (i2, NewInst);
260 }
261 Worklist.push_back (NewInst);
262 }
263 }
264 }
265 else
266 {
268 {
269
270
271
272
273
275 {
277 I->replaceUsesOfWith (CE, NewInst);
278 Worklist.push_back (NewInst);
279 }
280 }
281 }
282 }
283
284 }
285 return modified;
286}
static Instruction * convertExpression(ConstantExpr *CE, Instruction *InsertPt)
static ConstantExpr * hasConstantExpr(Value *V)
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
llvm::Instruction Instruction
llvm::ConstantExpr ConstantExpr