diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-18 19:55:11 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-18 19:55:11 -0800 |
commit | a8a348a02b2c2e79a634889467f769e8dff9396e (patch) | |
tree | 92a1f7f7e80cfe04b218cb89ab3a9ed1ed9965d9 /lib/Transforms/NaCl/ExpandI64.cpp | |
parent | 24eee40db0cbc4602359e9f25a9787e1d1ced8fb (diff) |
remove bitcasts that were introduced while legalizing functions in i64 legalization of functions
Diffstat (limited to 'lib/Transforms/NaCl/ExpandI64.cpp')
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp index 9febcd0ce4..8a0c1426a2 100644 --- a/lib/Transforms/NaCl/ExpandI64.cpp +++ b/lib/Transforms/NaCl/ExpandI64.cpp @@ -850,6 +850,27 @@ bool ExpandI64::runOnModule(Module &M) { removeIllegalFunc(Func); } + // remove bitcasts that were introduced while legalizing functions + for (Module::iterator Iter = M.begin(), E = M.end(); Iter != E; ) { + Function *Func = Iter++; + for (Function::iterator BB = Func->begin(), E = Func->end(); + BB != E; + ++BB) { + for (BasicBlock::iterator Iter = BB->begin(), E = BB->end(); + Iter != E; ) { + Instruction *I = Iter++; + unsigned Opcode = I->getOpcode(); + if (Opcode == Instruction::BitCast || Opcode == Instruction::PtrToInt) { + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(I->getOperand(0))) { + assert(CE->getOpcode() == Instruction::BitCast); + assert(isa<FunctionType>(cast<PointerType>(CE->getType())->getElementType())); + I->setOperand(0, CE->getOperand(0)); + } + } + } + } + } + return Changed; } |