I have a structure type:
typedef struct boundptr {
uint8_t *ptr;
size_t size;
} boundptr;
and I want to catch all the arguments of a function of that type. E.g. in this function:
boundptr sample_function_stub(boundptr lp, boundptr lp2);
On my 64bit machine, Clang translates that signature to:
define { i8*, i64 } @sample_function_stub(i8* %lp.coerce0, i64 %lp.coerce1, i8* %lp2.coerce0, i64 %lp2.coerce1) #0 {
Question:
Is there a better way to reconstruct such arguments?
Is it possible to forbid such argument lowering, while keeping the same ABI for external calls?
Some more context:
So in the LLVM IR, I guess, according to the platform ABI, the compiler broke down the structure into separate fields (which is not the worst case, see 1). BTW, it reconstructs the original two parameters lp
and lp2
later in the function body.
Now for my analysis, I want to get those two parameters lp
and lp2
in full, out of these 4(lp.coerce0
, lp.coerce1
, lp2.coerce0
and lp2.coerce1
). In this case, I probably can rely on the names (.coerce0
means first field, .coerce1
- second).
I do not like this approach:
- I am not sure, that Clang with keep this convention in later versions
- It certainly depends on the ABI, so there may be a different breakdown on another platform.
On the other side, I can not use the reconstruction code in the beginning of the function, because I may confuse it with some user code for a local variable.
I use Clang 3.4.2
based on LLVM 3.4.2
for target x86_64-pc-linux-gnu
.
P.S. Here is another example, showing how wildly Clang can mess up with function arguments.