[llvm-dev] How to debug LLVM

沈天豪 via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 2 05:03:18 PDT 2018


Hi,Matt
Thank you for your suggestion.
I'm sorry that I reply to you so late.

About  building a debug version, I don't know whether adding "-DCMAKE_BUILD_TYPE=DEBUG" when I cmake LLVM is right way.

The result .s file after using 'llc test.ll -stop-after machine-cp' has my intrinsic and the binary file also have.But it can't run.

Thank you again,
Tianhao Shen.






At 2018-10-30 07:37:31, Matthew.Davis at sony.com wrote:
>Hi Tianhao,
>
>> From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of ??? via llvm-dev
>> Subject: [llvm-dev] How to debug LLVM
>> 
>> Hi,every one.
>> I want to add an intrinsics which mapping a new instruction.
>> What I added in LLVM  can compile and link.  But when I lli test.bc, it breaks down. 
>> I want to know where is wrong, but bugpoint tool and XRay don't find the wrong.
>> (Maybe I use these tools incorrectly. ) I want to know how to debug intrinsics and  instruction.
>> Thank you,
>> Tianhao Shen.
>
>When you say "it breaks down," I assume you mean there is some internal compiler crash? 
>I'd suggest building a debug version of the compiler, if you do not already have one. 
>Assertions are very helpful in debugging, and if you are trying to resolve a crash, analyzing 
>crashes from a debugger is much simpler than using a release build.
>
>Before you run lli, have you examined the machine instruction representation?  One trick
>you might find handy is the following:  emit your test code as llvm IR and ensure your
>intrinsic is represented correctly in IR.  You can feed that IR file into 'llc' and dump the
>machine code representation.  To take a peek at the machine form of your code, run llc: 
>'llc test.ll -stop-after machine-cp'  where test.ll is your IR file that uses your newly added
>intrinsic. The resulting .s file should have the lowered MachineInstr representation
>which should present your newly added instruction.
>
>Hope that helps,
>
>-Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181102/9d9657cf/attachment.html>


More information about the llvm-dev mailing list