From 269a00f9ec7f6eabed0ea80c069e956ab725b36a Mon Sep 17 00:00:00 2001 From: Dmitry Babokin Date: Mon, 15 Apr 2013 13:16:28 +0400 Subject: [PATCH] Fix for the bug with gcc4.7: incorrect usage of ArrayRef --- cbackend.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cbackend.cpp b/cbackend.cpp index 40d0ab8f..aa4115cb 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -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 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 arg(val); llvm::CallInst *notCall = llvm::CallInst::Create(notFunc, arg, bop->getName()); ReplaceInstWithInst(iter, notCall);