[llvm-dev] Mark code from source to IR

Johan Wehrli via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 23 05:03:00 PDT 2016


Hi Jonas,

> Does it have to be comments, or could you do something like this?

Not at all, it was just an example, it can pragma or builtin function or anything else.

> You could look at how __builtin_expect is handled inside the compiler. In lib/Transforms/Scalar/LowerExpectIntrinsic.cpp, branch weight metadata is generated based on that function. You could probably adapt this to generate the metadata that you need.

I will take a look at it thanks.

Greetings.

Johan

> On 23 Sep 2016, at 11:52, Jonas Wagner <jonas.wagner at epfl.ch> wrote:
> 
> Hi,
> 
> I am looking at a way to mark part of a source code for an optimisation pass (or how to transfert information from source code to IR).
> 
> Does it have to be comments, or could you do something like this?
> 
> if (optimize_me(i%2)) {
>   ...
> }
> 
> You could look at how __builtin_expect is handled inside the compiler. In lib/Transforms/Scalar/LowerExpectIntrinsic.cpp, branch weight metadata is generated based on that function. You could probably adapt this to generate the metadata that you need.
> 
> Best,
> Jonas
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160923/06c848f7/attachment.html>


More information about the llvm-dev mailing list