[LLVMdev] Eliminating redundant loads

David Jones djones at xtreme-eda.com
Mon Feb 23 03:22:34 PST 2015


You have not installed the DataLayout in the Module, as I had pointed out
earlier.

Compile a small program using clang, to get IR. You will notice a "target
datalayout" declaration at the top of the IR. There is no such declaration
in your IR.

This is precisely the problem I had. You need to add the DataLayout to the
Module, at which point a "target datalayout" declaration will appear in
your IR, and the optimization passes will have enough alias information to
be able to eliminate your redundant loads.

On Mon, Feb 23, 2015 at 2:02 AM, Dibyendu Majumdar <mobile at majumdar.org.uk>
wrote:

> On 23 February 2015 at 01:29, Kamal Sharma <kgs1.rice at gmail.com> wrote:
> > Hi  Dibyendu,
> >
> > It would be very helpful if you could post the original source code or
> > snippet.
> > That way, one can investigate deeper to understand the problem.
> >
> > Regards,
> > Kamal Sharma
> >
>
> Hi Kamal,
>
> Sure. I guess I ought to create a test that one can look in isolation.
>
> I am working on building a JIT compiler for Lua (actually a derivative
> of Lua). It is currently work in progress.
> The approach is to compile Lua bytecodes into LLVM IR.
>
> The IR generated from my code is here (after optimization I should add):
>
> https://github.com/dibyendumajumdar/ravi/blob/master/clang-output/lua_op_loadk_return_ravi.ll
>
> I am using the output from Clang as a guide to generating IR. So I
> write small snippets of code in C which are equivalent to Lua
> bytecodes - then use Clang to emit the IR. I use this to work out the
> IR I need to build.
>
> The C equivalent of the program I am compiling is here:
>
> https://github.com/dibyendumajumdar/ravi/blob/master/clang-output/lua_op_loadk_return.c
>
> The difference between the C version and what I generate is that I put
> a load of the "base" pointer at the beginning of every Lua opcode.
> This is because some Lua opcodes can reallocate the memory pointed to
> by base. I was hoping that the optimizer will get rid of the redundant
> stuff.
>
> The code generation is all done here:
>
> https://github.com/dibyendumajumdar/ravi/blob/master/src/ravijit.cpp
>
> I don't expect you to wade through all this - but I will be grateful
> for any help / guidance you can provide.
>
> Thanks and Regards
> Dibyendu
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150223/d3d26c32/attachment.html>


More information about the llvm-dev mailing list