Reputation: 5545
I would like to understand how arguments are passed to function in .ll textual format.
My c function prototype looks like :
int power(int n, int r)
clang (followed by opt) compiles to :
define i32 @power(i32, i32) #0 {
"n" and "r" have vanished ! I need them here, in the textual IR!
Otherwise, it is not trivial to understand how the arguments are actually used.
Or maybe there is an obscure convention like "%1" is the first argument of the function, etc, but that does not seem so evident.
Any idea ?
Is there a naming convention or whatever to understand how my "c" arguments mapped to .ll names, in the function header ?
Upvotes: 0
Views: 112
Reputation: 9675
There's no such convention, no, and the names don't really map in that direction since IR has values rather than variables.
int a = 42;
while(b())
a += c();
d(a);
There is one variable called a, but the IR will probably contain four values that correspond to a's values at the end of the line 1, start of line 3, end of line 3 and start of line 4.
This answer shows how to add names. Whether to do that is up to you, and if you want to do it, you have to find a naming scheme too. "a.line4.column0" or anything else.
Upvotes: 1