Weak store / Memory hints

Hello LLVM list,

I am writing a JIT compiler for a SQL in-memory database and I have an issue:

I want to compile specialized functions per-object which replace a virtual function call.

What I want to achieve is to feed memory from runtime into the code. I know the runtime value behind some values (especially the ‘this’ pointer) and want llvm to profit from that additional knowledge for instance by replacing loads of memory where I know it’s constant (i.e. the virtual function table; some fields that are only changed in the constructor, etc.)

In the moment I see 3 ways to achieve this

  1. find all loads, check the range and replace them by their loaded value

  2. add store instructions in the beginning of the code that override the “unknown” values with their known parts (ugly - consumes memory bandwith and requires an additional GVN pass)

  3. a weak store instruction which is ignored by the code generator but gives hints to the load-store-optimization

  4. do have an other idea?