[llvm-dev] Function start address
via llvm-dev
llvm-dev at lists.llvm.org
Sun Jun 3 11:57:28 PDT 2018
Hi Muhui,
If the function does exist in the binary, it is entirely possible (I think) to have no instruction specifically associated with the function definition's source line, even though other instructions are associated with other lines in the function. I (or someone) would need to look at a specific example before being able to say one way or the other if that is what you are running into.
==============
I don't understand what "no instruction specifically associated with the function definition's source line," this sentence mean. Could you please explain more? If you are interested, I am glad to give you a specific example. Please tell me whether you need it.
I tried a simple example like this:
int f(int a, int b)
{
return a + b;
}
In the IR, it looks like the function definition is given as being on line 1 (the "int f" part), however in the DWARF line table the first instruction is associated with line 2 (the opening brace). That's what I meant by "no instruction specifically associated with the function definition's source line"; even though the function is defined (according to C/C++) on line 1, there are no instructions for that line; the first instruction of the function is instead associated with the line where the scope starts.
I see that there is a different attribute in the IR metadata, called scopeLine, which is 2. That might be what you want.
Have you considered building a static array of function addresses? If you used weak references it would not interfere with optimizing away entire functions, which I mentioned above. Or would that be too intrusive into your use case? Apologies if this suggestion has come up before.
==============
To be honest, No. Since I am using llvm IR to do the code analysis. Function start address is just a part of the whole evaluation. I would prefer to combine all the tools into one tool with llvm IR and dwarf debug information. Thus, I may not evaluate the function addresses with a static table. Thank you very much
Hmm. I am curious what sort of analysis would be done within the IR, while still depending on the address of the functions in the final object file. The IR is long gone by the time the compiler is emitting the final instruction stream.
Hope this helps,
--paulr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180603/e7f67259/attachment.html>
More information about the llvm-dev
mailing list