[Bug tree-optimization/65773] [5 Regression] GCC 5.1 miscompiles LLVM function AArch64InstrInfo::loadRegFromStackSlot()
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Apr 16 10:30:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65773
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, the source in question is:
const MachineInstrBuilder &MI = BuildMI(MBB, MBBI, DL, get(Opc))
.addReg(DestReg, getDefRegState(true))
.addFrameIndex(FI);
if (Offset)
MI.addImm(0);
MI.addMemOperand(MMO);
which in *.gimple dump looks like:
try
{
D.382398 = &this->D.207751.D.207513.D.205713;
D.382399 = llvm::MCInstrInfo::get (D.382398, Opc);
D.325474 = llvm::BuildMI (MBB, MBBI, &D.325473, D.382399);
[return slot optimization]
try
{
D.382400 = llvm::getDefRegState (1);
D.382401 = llvm::MachineInstrBuilder::addReg (&D.325474,
DestReg, D.382400, 0);
MI = llvm::MachineInstrBuilder::addFrameIndex (D.382401, FI);
}
finally
{
D.325474 = {CLOBBER};
}
}
finally
{
llvm::DebugLoc::~DebugLoc (&D.325473);
D.325473 = {CLOBBER};
}
if (Offset != 0) goto <D.382402>; else goto <D.382403>;
<D.382402>:
llvm::MachineInstrBuilder::addImm (MI, 0);
goto <D.382404>;
<D.382403>:
<D.382404>:
llvm::MachineInstrBuilder::addMemOperand (MI, MMO);
which suggests that the temporary that BuildMI returns goes out of scope at the
end of the
const MachineInstrBuilder &MI = BuildMI(MBB, MBBI, DL, get(Opc))
.addReg(DestReg, getDefRegState(true))
.addFrameIndex(FI);
and sets the reference to the out of scope temporary.
const
MachineInstrBuilder &addReg(unsigned RegNo, unsigned flags = 0,
unsigned SubReg = 0) const {
ends with
return *this;
and
const MachineInstrBuilder &addFrameIndex(int Idx) const {
MI->addOperand(*MF, MachineOperand::CreateFI(Idx));
return *this;
}
too.
More information about the Gcc-bugs
mailing list