[LLVMdev] operator overloading fails while debugging with gdb for i386
Mayur Pandey
mayurthebond at gmail.com
Thu Dec 6 19:56:49 PST 2012
Hi,
The issue seems in the file x86ISelLowering.cpp where we dont have an
implementation for returning the hidden pointer in the specified register
for 32 bit. We do have it for 64bit. On adding the following:
in function
X86TargetLowering::LowerReturn
if (!(Subtarget->is64Bit()) &&
DAG.getMachineFunction().getFunction()->hasStructRetAttr()) {
MachineFunction &MF = DAG.getMachineFunction();
X86MachineFunctionInfo *FuncInfo = MF.getInfo<X86MachineFunctionInfo>();
unsigned Reg = FuncInfo->getSRetReturnReg();
assert(Reg &&
"SRetReturnReg should have been set in LowerFormalArguments().");
SDValue Val = DAG.getCopyFromReg(Chain, dl, Reg, getPointerTy());
Chain = DAG.getCopyToReg(Chain, dl, X86::EAX, Val, Flag);
Flag = Chain.getValue(1);
MRI.addLiveOut(X86::EAX);
}
in function
X86TargetLowering::LowerFormalArguments
if (!(Is64Bit) && MF.getFunction()->hasStructRetAttr()) {
X86MachineFunctionInfo *FuncInfo = MF.getInfo<X86MachineFunctionInfo>();
unsigned Reg = FuncInfo->getSRetReturnReg();
if (!Reg) {
Reg = MF.getRegInfo().createVirtualRegister(getRegClassFor(MVT::i32));
FuncInfo->setSRetReturnReg(Reg);
}
SDValue Copy = DAG.getCopyToReg(DAG.getEntryNode(), dl, Reg, InVals[0]);
Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Copy, Chain);
}
we get the correct output in gdb and the there are no side-effects also.
Please verify whether this is a genuine fix.
The
On Mon, Dec 3, 2012 at 4:46 PM, Renato Golin <rengolin at systemcall.org>wrote:
> On 3 December 2012 10:42, Mayur Pandey <mayurthebond at gmail.com> wrote:
> > So this seems to be the cause of the problem.
>
> I guess you're mixing two different problems. First, is the possible
> lack of conformance with the ABI you state, which I can't comment
> since I don't know that ABI very well. Second, is the fact that clang
> is not printing correct debug information (or is not interoperating
> well enough with gdb).
>
> Fixing the first issue will not necessarily fix the second.
>
>
> > @Renato Golin:- Does the code execute correctly? Does a printf on the sum
> > outputs the
> > correct value? : yes the code executes correctly and some gives the
> correct
> > value. Its only in gdb that we face this problem as gdb expects the
> hidden
> > pointer in eax.
>
> As I expected. Following the ABI is not a requirement to have working
> code, or a debuggable code. GDB is probably expecting programs to
> follow the ABI if they do not have decent Dwarf, which seems clang is
> failing on both.
>
> Debuggers have to deal with all sorts of user (and compiler) code, and
> to give users the "debug illusion", they make too many guesses.
> However, if the Dwarf information is correct to begin with, I
> seriously hope that GDB would rely on that, rather than "expect"
> values to be on specific registers.
>
> Have a look in the Dwarf symbols clang generates with your code and
> make sure that clang is not printing the correct location information
> for that variable on the ranges where it lives on registers and which
> registers.
>
> If clang's info is right, there's only the ABI bug and GDB is being
> silly. If the info is wrong, then we may need to fix *both* bugs (ABI
> + Dwarf), not just the ABI one.
>
>
> --
> cheers,
> --renato
>
> http://systemcall.org/
>
--
Thanx & Regards
*Mayur Pandey *
Senior Software Engineer
Samsung India Software Operations
Bangalore
+91-9742959541
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121207/25101014/attachment.html>
More information about the llvm-dev
mailing list