[llvm-dev] How to debug LLVM

via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 29 16:37:31 PDT 2018


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


More information about the llvm-dev mailing list