[LLVMdev] runtime pass
mats petersson
mats at planetcatfish.com
Tue Jul 21 06:11:07 PDT 2015
By specific point, do you mean:
- a specific instruction as identified by some means, e.g if (operaton ==
add && operand1 == 42 && operand2 == 17) { ... insert special code ... }
- a specific location in the code e.g. if (ProgramCounter == 123456) { ...
insert special code here ... }
- some instruction in a specific function e.g. if (function == MyFunc &&
instructionNumber == 4) { ... insert special code ... }
- some combination of the above?
I'm not sure I can help much, but calling the "runtime" of the application
is really just a case of adding a function (declaration, not definition)
with the right prototype and calling it, and then call the function.
This is how my compiler does "create a function":
https://github.com/Leporacanthicus/lacsap/blob/master/expr.cpp#L112
And here is an example of a function that creates the function prototype
and calls the a function:
https://github.com/Leporacanthicus/lacsap/blob/master/expr.cpp#L741
It will then be up to the linker to do the right thing to call the actual
function (and if you try to call a function that doesn't exist, it will
fail to link...)
--
Mats
On 21 July 2015 at 13:29, marwayusuf at feng.bu.edu.eg <
marwayusuf at feng.bu.edu.eg> wrote:
> First, thanks for your help.
>
> Actually, I mean the second one, runtime of application. I've already made
> some instrumentation in the given IR, but only to add some extra code and
> change some variables. Now, if I want to instrument it to call some
> function that is able to parse stackmap section in the object file and
> change the given IR itself, is that possible?
>
>
> Regards,
> Marwa Yusuf
> Teaching Assistant - Computer Engineering Department
> Faculty of Engineering - Benha University
> E-JUST PhD Student
> Computer Science & Engineering Dept.
>
>
> ------------------------------
> *From:* Stephen Thomas <stephen.warner.thomas at gmail.com>
> *Sent:* Wednesday, July 15, 2015 9:20 PM
> *To:* marwayusuf at feng.bu.edu.eg
> *Cc:* llvmdev at cs.uiuc.edu
> *Subject:* Re: [LLVMdev] runtime pass
>
> Marwa,
>
> By "runtime", are you referring to the runtime of opt? If so, I assume
> your question is about how to make sure certain passes run before your pass
> runs, so that their results are available to your pass. The "Writing an
> LLVM Pass" doc has a nice section on the interaction between passes:
>
>
> http://llvm.org/docs/WritingAnLLVMPass.html#specifying-interactions-between-passes
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_docs_WritingAnLLVMPass.html-23specifying-2Dinteractions-2Dbetween-2Dpasses&d=AwMFAw&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=6rTmZhjspQwuyjO5timFdiEiRcwJIu16-WzX_4pa_Fg&s=vDlBPSzU3vGvlc-tM8Gs-EOhaz1hsRvpv7xQBdyuaqw&e=>
>
> Alternatively, if by "runtime", you are referring to the runtime of the
> application under analysis, then that's trickier. LLVM is designed to run
> analysis and transformation passes at compilation time, not runtime. So it
> depends on what you're trying to do. If you're trying to profile the
> application to, e.g., gather values of certain variables, that's certainly
> possible by first writing a transformation pass that instruments the IR
> with calls at certain points in the target application.
>
> Cheers,
> Steve
>
>
>
> On Wed, Jul 15, 2015 at 10:05 AM, marwayusuf at feng.bu.edu.eg <
> marwayusuf at feng.bu.edu.eg> wrote:
>
>> Dear All
>>
>> I need to create a pass that is triggered to run at a specific point
>> during runtime. Also, this pass needs to have access to object file and to
>> be able to modify the original IR. Any idea how to make such pass?
>>
>>
>> Regards,
>> Marwa Yusuf
>> Teaching Assistant - Computer Engineering Department
>> Faculty of Engineering - Benha University
>> E-JUST PhD Student
>> Computer Science & Engineering Dept.
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150721/d930afcd/attachment.html>
More information about the llvm-dev
mailing list