Fix for the bug with gcc4.7: incorrect usage of ArrayRef

This commit is contained in:
Dmitry Babokin
2013-04-15 13:16:28 +04:00
parent 29c482789f
commit 269a00f9ec

View File

@@ -4831,7 +4831,11 @@ MaskOpsCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
if (bop->getOpcode() == llvm::Instruction::Xor) {
// Check for XOR with all-true values
if (lIsAllTrue(bop->getOperand(1))) {
llvm::ArrayRef<llvm::Value *> arg(bop->getOperand(0));
llvm::Value *val = bop->getOperand(0);
// Note that ArrayRef takes reference to an object, which must live
// long enough, so passing return value of getOperand directly is
// incorrect and it actually causes crashes with gcc 4.7 and later.
llvm::ArrayRef<llvm::Value *> arg(val);
llvm::CallInst *notCall = llvm::CallInst::Create(notFunc, arg,
bop->getName());
ReplaceInstWithInst(iter, notCall);