[LLVMdev] [PATCH] Support asm comment output

Chris Lattner clattner at apple.com
Mon Jul 13 13:46:27 PDT 2009


On Jul 13, 2009, at 11:29 AM, David Greene wrote:

> On Monday 13 July 2009 13:13, Chris Lattner wrote:
>
>>> We're not going to submit our line number stuff anyway (it's too
>>> much of a
>>> hack) but we would like the comment infrastructure to be there.
>>
>> DebugLoc is there.  The transition isn't complete at the LLVM IR
>> level, but it is at the MachineInstr level AFAIK.
>
> Well, the IR level is pretty important to us since we convert our
> code into LLVM IR and add source line comments at the same time.

Well sure, but how is that relevant?  Just generate llvm.stoppoint and  
isel turns them into debug locs.  Just because debugloc isn't on  
llvm::Instruction doesn't mean you don't get line numbers :).

>> I don't know what you mean by "pattern information".  We can  
>> obviously
>> enhance tblgen to include any information that we need, but I don't
>> see how the asmprinter wouldn't know something that an earlier pass
>> would.  Again, it would be helpful if you included example output to
>> show what you're going for.
>
> Ok, here's an example:
>
>        movl    (%rsi), %ecx                                # LLVM
> Instruction:         volatile store i32* %ksize, i32** %ksize3       ;
> [oox.4 : sln.5]
>
>                                                            #  
> [result] Pattern
> 1367

Instead of printing 1367, why not print "MOV32rm" like -print- 
machineinstr does?  If you really want 1367, just print MI- 
 >getOpcode().  The asmprinter definitely has this information.

> I forgot about the LLVM instruction information.  That's something  
> that can't
> be synthesized by the asmprinter.  Again, we only emit some of this  
> with
> special debug flags so we don't carry the original IR around in  
> comments all
> the time.  :)

Sure, I understand that comments in general only get turned on with  
something like -fverbose-asm.  But where/how do you expect this  
information to be propagated onto the machineinstrs?

For now, lets go forward with the plan of having the asmprinter  
generate the comments.  It sounds like it can cover at least 75% of  
what you're interested in, and the other cases probably have better  
solutions that sticking a vector of std::string on MachineInstr.

-Chris



More information about the llvm-dev mailing list