diff options
-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; } |