[LLVMdev] Loop Metadata?

Devang Patel dpatel at apple.com
Fri Feb 10 13:53:42 PST 2012


On Feb 10, 2012, at 1:42 PM, Sebastian Pop <spop at codeaurora.org> wrote:

> On Fri, Feb 10, 2012 at 1:14 PM, Devang Patel <dpatel at apple.com> wrote:
>> 
>> On Feb 10, 2012, at 10:19 AM, Hal Finkel <hfinkel at anl.gov> wrote:
>> 
>>> Is there currently a good way of attaching metadata to loops?
>>> 
>>> The use case that I have in mind is implementing a feature whereby the
>>> user can put
>>> #pragma unroll(N)
>>> above a loop and that serves has an instruction to the optimizer to
>>> unroll the loop N times.
> 
> I had something similar in mind for #pragma vectorize
> 
>>> I understand that LLVM does not have a first-class loop construct, but
>>> would attaching the metadata to the instructions that branch to the loop
>>> header be a good idea?
>> 
>> That's the starting point. The key is how to chose loop identifying instruction (or instructions ?) for the annotation and preserve the annotation through transformations. At some point during optimization, it may be a good idea to hand it over to LoopPassManager.
>> 
> 
> I don't think annotations are good to implement pragmas.
> Annotations are going to disappear if you dump the code to file.
> Pragma are a hard contract in between the programmer and the
> compiler: the compiler cannot afford loosing a pragma information.
> 
> I was considering something like using a builtin call to transmit
> the pragma info from the front-end throughout the compiler.
> That would expose the pragma "call" in the IR and LLVM would
> have to deal with it as a first class construct.
> This would avoid loosing the pragma annotation on the way.

How would you tie a built-in call with a loop ?

> 
> Speaking about OpenMP, I think that a big part of it should be
> taken care of in the clang front-end.  I do not think that we should
> expose syntactic kind of info to the middle-end optimizers.
> 
> Sebastian
> --
> Qualcomm Innovation Center, Inc is a member of Code Aurora Forum




More information about the llvm-dev mailing list