C++ code: (What I mean to generate)
incrementFaultSiteCount(“BBName”, 2);
My question is:
What is this phenomenon called, is it called “inlined/expanded function argument”?
It seems the “inlined” GetElementPtr instruction is just more concise and saves the need for a name for a register holding the value of the pointer. Is this correct?
I’m now generating the aforementioned instructions (non-inlined) with the following code snippet with LLVM 3.2. Is there a way to generate “inlined” GetElementPtr instructions when calling a function just like the first example programmatically?
C++ code: (What I mean to generate)
incrementFaultSiteCount(“BBName”, 2);
My question is:
What is this phenomenon called, is it called “inlined/expanded function argument”?
This is a constant expression cast. It will only happen for a constant arguments, in this case the address of global @bbname. You should get these if you run instcombine on it.
- What is this phenomenon called, is it called "inlined/expanded function
argument"?
This is the syntax used when the getelementptr is a
GetElementPtrConstantExpr rather than an Instruction, and that's
generally true for the inlined forms: if you can make an expression
out of Constants in some way then it'll be "inlined".
- I'm now generating the aforementioned instructions (non-inlined) with the
following code snippet with LLVM 3.2. Is there a way to generate "inlined"
GetElementPtr instructions when calling a function just like the first
example programmatically?
Yep, the function you want is GetElementPtrConstantExpr::Create.
Incidentally, in these cases the "cpp" backend can be very useful. If
you can write LLVM IR to do what you want it will give you back some
C++ code that emits the IR.