[LLVMdev] Lowering x64bit LLVM IR to x86bit LLVM IR

Tim Northover t.p.northover at gmail.com
Thu Dec 18 07:33:27 PST 2014


> This is generated with my are written. Now, I want to test this generated,
> lowered x64bit IR for x86bit machine.

It looks very different from the 64-bit input, but that's a problem
for debugging to resolve I suppose.

> Please let me know how I can test this. How I can test generated LLVM IR,
> how I can debug this generated LLVM IR.

If it was me, I'd start with functions with well-defined inputs and
outputs (e.g. "int foo(int a, int b) { return a + b; }"). Create a
test-harness that calls out to this function and then replace the
default implementation with one that comes from your specially
converted IR. Use that to make sure the values match up.

You'd likely have difficulties with mismatched calling conventions, so
it might be better to use global variables for all input/output (so
"int a, b, res; void foo() { res = a + b; }" instead). They tend to be
easier to get working.

Cheers.

Tim.



More information about the llvm-dev mailing list