Implementing front-end of a user-directed optimization

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
Hi cfe-dev,

I am implementing a user-guided optimization (xTool).
Programmers will provide pragma directives to guide the backend. Since
I am new to LLVM and clang, I am having a hard time figuring out how
to implement it. Here are the steps I am considering for the frontend:

User will provide directives as:

#pragma xTool someClause
{
     Compound statements
}

I want to implement directives handling as a "clang plug-in". I am
thinking to create AST node classes for xTool directive inheriting
Stmt class from the plug-in. Is it possible with current clang? If it
is possible I can access the compound statements enclosed in {} with
"CapturedStmt". Or should I consider to "annotate" the stmt node
instead of creating a new class?

Any feedback on how to implement this on the clang frontend would be
really helpful. So far I have looked into few codes of the OpenMP
directive implementation.

--
Probir
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
Hi,

I am working on user-directed optimizations/transformations as well. A
lot depends on where you want to apply the optimization: On the (1)
AST-level in the frontend, during (2) IR-gen in the front-end or on
the (3) IR-level in the mid/back-end, (4) as a source-to-source
transformation.

For (1), there a TreeTransform to transform an AST subtree into
another one. This an approach I took for
https://reviews.llvm.org/D76342

The approach (2) is used by clang's OpenMP implementation.

For (3), one emits metadata into the LLVM-IR.
https://reviews.llvm.org/D70572 uses this approach. Instead of
introducing a new AST node kind, one can also use the AttributedStmt
kind and introduce an attribute on statements. This is the approach by
https://github.com/SOLLVE/llvm-project/tree/pragma-clang-loop and
generally used to implement the current `#pragma clang loop`
annotations.

With (4), one would use clang to only parse the source into an AST and
use a Rewriter class to emit a new source code.


Since there is no interface for clang library users to insert custom
AST nodes or attributes, this leaves two choices:

A source-to-source transformation (4):
 * Ask clang to parse some source code and return the AST
 * Register a pragma handler to callback when your custom pragma is seen.
 * In the pragma handler insert the annotate attribute (which just
takes a string)
 * When encountering the annotation during the AST walk, your tool can react.

Or process the annotation attribute which is emitted as a
`llvm.*.annotation` builtin in the IR (1):
 * Register the pragma handler as before
 * Register a pass plugin in LLVM which looks for the annotation builtins.


Michael






Am Mi., 10. Juni 2020 um 14:45 Uhr schrieb Probir Roy via cfe-dev
<[hidden email]>:

>
> Hi cfe-dev,
>
> I am implementing a user-guided optimization (xTool).
> Programmers will provide pragma directives to guide the backend. Since
> I am new to LLVM and clang, I am having a hard time figuring out how
> to implement it. Here are the steps I am considering for the frontend:
>
> User will provide directives as:
>
> #pragma xTool someClause
> {
>      Compound statements
> }
>
> I want to implement directives handling as a "clang plug-in". I am
> thinking to create AST node classes for xTool directive inheriting
> Stmt class from the plug-in. Is it possible with current clang? If it
> is possible I can access the compound statements enclosed in {} with
> "CapturedStmt". Or should I consider to "annotate" the stmt node
> instead of creating a new class?
>
> Any feedback on how to implement this on the clang frontend would be
> really helpful. So far I have looked into few codes of the OpenMP
> directive implementation.
>
> --
> Probir
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
I will perform link-time optimization. At the front-end, I want to
generate a module summary in the IR guided by the user pragmas. At
link-time, I will perform a summary based whole program analysis.

For this should I consider approach (2): IR-gen in the front-end? If
that's the case, I will need to modify Clang to insert a new AST node
class, right? Where should I write the pass to generate the module
summary? Also, how to get the associated CapturedStmt? Code examples
would be very helpful.

-Probir


On Wed, Jun 10, 2020 at 4:31 PM Michael Kruse <[hidden email]> wrote:

>
> Hi,
>
> I am working on user-directed optimizations/transformations as well. A
> lot depends on where you want to apply the optimization: On the (1)
> AST-level in the frontend, during (2) IR-gen in the front-end or on
> the (3) IR-level in the mid/back-end, (4) as a source-to-source
> transformation.
>
> For (1), there a TreeTransform to transform an AST subtree into
> another one. This an approach I took for
> https://reviews.llvm.org/D76342
>
> The approach (2) is used by clang's OpenMP implementation.
>
> For (3), one emits metadata into the LLVM-IR.
> https://reviews.llvm.org/D70572 uses this approach. Instead of
> introducing a new AST node kind, one can also use the AttributedStmt
> kind and introduce an attribute on statements. This is the approach by
> https://github.com/SOLLVE/llvm-project/tree/pragma-clang-loop and
> generally used to implement the current `#pragma clang loop`
> annotations.
>
> With (4), one would use clang to only parse the source into an AST and
> use a Rewriter class to emit a new source code.
>
>
> Since there is no interface for clang library users to insert custom
> AST nodes or attributes, this leaves two choices:
>
> A source-to-source transformation (4):
>  * Ask clang to parse some source code and return the AST
>  * Register a pragma handler to callback when your custom pragma is seen.
>  * In the pragma handler insert the annotate attribute (which just
> takes a string)
>  * When encountering the annotation during the AST walk, your tool can react.
>
> Or process the annotation attribute which is emitted as a
> `llvm.*.annotation` builtin in the IR (1):
>  * Register the pragma handler as before
>  * Register a pass plugin in LLVM which looks for the annotation builtins.
>
>
> Michael
>
>
>
>
>
>
> Am Mi., 10. Juni 2020 um 14:45 Uhr schrieb Probir Roy via cfe-dev
> <[hidden email]>:
> >
> > Hi cfe-dev,
> >
> > I am implementing a user-guided optimization (xTool).
> > Programmers will provide pragma directives to guide the backend. Since
> > I am new to LLVM and clang, I am having a hard time figuring out how
> > to implement it. Here are the steps I am considering for the frontend:
> >
> > User will provide directives as:
> >
> > #pragma xTool someClause
> > {
> >      Compound statements
> > }
> >
> > I want to implement directives handling as a "clang plug-in". I am
> > thinking to create AST node classes for xTool directive inheriting
> > Stmt class from the plug-in. Is it possible with current clang? If it
> > is possible I can access the compound statements enclosed in {} with
> > "CapturedStmt". Or should I consider to "annotate" the stmt node
> > instead of creating a new class?
> >
> > Any feedback on how to implement this on the clang frontend would be
> > really helpful. So far I have looked into few codes of the OpenMP
> > directive implementation.
> >
> > --
> > Probir
> > _______________________________________________
> > cfe-dev mailing list
> > [hidden email]
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
You should look into the existing ThinLTO infrastructure, it does what you describe here, but at the IR level directly. This should be enough to get you going https://clang.llvm.org/docs/ThinLTO.html http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html for a high level description of how this works.

Best,
—Daniel

On 11 Jun 2020, at 13:23, Probir Roy via cfe-dev <[hidden email]> wrote:

I will perform link-time optimization. At the front-end, I want to
generate a module summary in the IR guided by the user pragmas. At
link-time, I will perform a summary based whole program analysis.

For this should I consider approach (2): IR-gen in the front-end? If
that's the case, I will need to modify Clang to insert a new AST node
class, right? Where should I write the pass to generate the module
summary? Also, how to get the associated CapturedStmt? Code examples
would be very helpful.

-Probir


On Wed, Jun 10, 2020 at 4:31 PM Michael Kruse <[hidden email]> wrote:

Hi,

I am working on user-directed optimizations/transformations as well. A
lot depends on where you want to apply the optimization: On the (1)
AST-level in the frontend, during (2) IR-gen in the front-end or on
the (3) IR-level in the mid/back-end, (4) as a source-to-source
transformation.

For (1), there a TreeTransform to transform an AST subtree into
another one. This an approach I took for
https://reviews.llvm.org/D76342

The approach (2) is used by clang's OpenMP implementation.

For (3), one emits metadata into the LLVM-IR.
https://reviews.llvm.org/D70572 uses this approach. Instead of
introducing a new AST node kind, one can also use the AttributedStmt
kind and introduce an attribute on statements. This is the approach by
https://github.com/SOLLVE/llvm-project/tree/pragma-clang-loop and
generally used to implement the current `#pragma clang loop`
annotations.

With (4), one would use clang to only parse the source into an AST and
use a Rewriter class to emit a new source code.


Since there is no interface for clang library users to insert custom
AST nodes or attributes, this leaves two choices:

A source-to-source transformation (4):
* Ask clang to parse some source code and return the AST
* Register a pragma handler to callback when your custom pragma is seen.
* In the pragma handler insert the annotate attribute (which just
takes a string)
* When encountering the annotation during the AST walk, your tool can react.

Or process the annotation attribute which is emitted as a
`llvm.*.annotation` builtin in the IR (1):
* Register the pragma handler as before
* Register a pass plugin in LLVM which looks for the annotation builtins.


Michael






Am Mi., 10. Juni 2020 um 14:45 Uhr schrieb Probir Roy via cfe-dev
<[hidden email]>:

Hi cfe-dev,

I am implementing a user-guided optimization (xTool).
Programmers will provide pragma directives to guide the backend. Since
I am new to LLVM and clang, I am having a hard time figuring out how
to implement it. Here are the steps I am considering for the frontend:

User will provide directives as:

#pragma xTool someClause
{
    Compound statements
}

I want to implement directives handling as a "clang plug-in". I am
thinking to create AST node classes for xTool directive inheriting
Stmt class from the plug-in. Is it possible with current clang? If it
is possible I can access the compound statements enclosed in {} with
"CapturedStmt". Or should I consider to "annotate" the stmt node
instead of creating a new class?

Any feedback on how to implement this on the clang frontend would be
really helpful. So far I have looked into few codes of the OpenMP
directive implementation.

--
Probir
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
In reply to this post by Vassil Vassilev via cfe-dev
Am Do., 11. Juni 2020 um 07:23 Uhr schrieb Probir Roy <[hidden email]>:
> For this should I consider approach (2): IR-gen in the front-end? If
> that's the case, I will need to modify Clang to insert a new AST node
> class, right? Where should I write the pass to generate the module
> summary? Also, how to get the associated CapturedStmt? Code examples
> would be very helpful.

What kind of directives are you adding to statements that are useful
for LTO? Naivly, I'd assume annotations on functions would be more
interesting.

Consider using attributes and AttributedStmt instead of CapturedStmt.
CapturedStmt are intended for e.g. lambda which need the info which
variables are accessed inside of it. It's implementation is also
somewhat tied to its use cases.

Michael
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
The user will annotate callee as well as a few callers and their error
handling code.

#pragma xTool caller
{
      try{
          ret = callee();
      }catch(e)
      { ... }
}

I am not sure how to handle the compound statements enclosed in {}. I
will check the usages of AttributedStmt.

On Thu, Jun 11, 2020 at 1:40 PM Michael Kruse <[hidden email]> wrote:

>
> Am Do., 11. Juni 2020 um 07:23 Uhr schrieb Probir Roy <[hidden email]>:
> > For this should I consider approach (2): IR-gen in the front-end? If
> > that's the case, I will need to modify Clang to insert a new AST node
> > class, right? Where should I write the pass to generate the module
> > summary? Also, how to get the associated CapturedStmt? Code examples
> > would be very helpful.
>
> What kind of directives are you adding to statements that are useful
> for LTO? Naivly, I'd assume annotations on functions would be more
> interesting.
>
> Consider using attributes and AttributedStmt instead of CapturedStmt.
> CapturedStmt are intended for e.g. lambda which need the info which
> variables are accessed inside of it. It's implementation is also
> somewhat tied to its use cases.
>
> Michael



--
Probir Roy
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
In reply to this post by Vassil Vassilev via cfe-dev
On Wed, 10 Jun 2020, 13:31 Michael Kruse via cfe-dev, <[hidden email]> wrote:
Hi,

I am working on user-directed optimizations/transformations as well. A
lot depends on where you want to apply the optimization: On the (1)
AST-level in the frontend, during (2) IR-gen in the front-end or on
the (3) IR-level in the mid/back-end, (4) as a source-to-source
transformation.

For (1), there a TreeTransform to transform an AST subtree into
another one. This an approach I took for
https://reviews.llvm.org/D76342

This approach is generally not in line with clang's design philosophy and should be avoided where feasible. (If you need to do semantic analysis on the result of the transformation, then it's typically not feasible to avoid it; in such cases the best we can do is to retain both the original source form and the (minimally) desugared form. But that should typically not be necessary for an optimization.)

The approach (2) is used by clang's OpenMP implementation.

For (3), one emits metadata into the LLVM-IR.
https://reviews.llvm.org/D70572 uses this approach. Instead of
introducing a new AST node kind, one can also use the AttributedStmt
kind and introduce an attribute on statements. This is the approach by
https://github.com/SOLLVE/llvm-project/tree/pragma-clang-loop and
generally used to implement the current `#pragma clang loop`
annotations.

With (4), one would use clang to only parse the source into an AST and
use a Rewriter class to emit a new source code.


Since there is no interface for clang library users to insert custom
AST nodes or attributes, this leaves two choices:

A source-to-source transformation (4):
 * Ask clang to parse some source code and return the AST
 * Register a pragma handler to callback when your custom pragma is seen.
 * In the pragma handler insert the annotate attribute (which just
takes a string)
 * When encountering the annotation during the AST walk, your tool can react.

Or process the annotation attribute which is emitted as a
`llvm.*.annotation` builtin in the IR (1):
 * Register the pragma handler as before
 * Register a pass plugin in LLVM which looks for the annotation builtins.

It would also be possible to implement the transform in a fork of clang rather than using clang as a library, or to propose patches to expand the library interface to support the desired extensibility in general. Each option has a different set of tradeoffs.

Michael






Am Mi., 10. Juni 2020 um 14:45 Uhr schrieb Probir Roy via cfe-dev
<[hidden email]>:
>
> Hi cfe-dev,
>
> I am implementing a user-guided optimization (xTool).
> Programmers will provide pragma directives to guide the backend. Since
> I am new to LLVM and clang, I am having a hard time figuring out how
> to implement it. Here are the steps I am considering for the frontend:
>
> User will provide directives as:
>
> #pragma xTool someClause
> {
>      Compound statements
> }
>
> I want to implement directives handling as a "clang plug-in". I am
> thinking to create AST node classes for xTool directive inheriting
> Stmt class from the plug-in. Is it possible with current clang? If it
> is possible I can access the compound statements enclosed in {} with
> "CapturedStmt". Or should I consider to "annotate" the stmt node
> instead of creating a new class?
>
> Any feedback on how to implement this on the clang frontend would be
> really helpful. So far I have looked into few codes of the OpenMP
> directive implementation.
>
> --
> Probir
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
Am Do., 11. Juni 2020 um 13:06 Uhr schrieb Richard Smith
<[hidden email]>:
>> For (1), there a TreeTransform to transform an AST subtree into
>> another one. This an approach I took for
>> https://reviews.llvm.org/D76342
>
>
> This approach is generally not in line with clang's design philosophy and should be avoided where feasible. (If you need to do semantic analysis on the result of the transformation, then it's typically not feasible to avoid it; in such cases the best we can do is to retain both the original source form and the (minimally) desugared form. But that should typically not be necessary for an optimization.)

It is also my less preferable option. However, in D76342 (which keeps
the original source and the desugared form) I have done so because the
desugared AST can be used as input for OpenMP loop directives; it's
semantic analyzer takes a substatement as input. Unfortunately most of
the logic for OpenMP loop directives is implemented in the semantic
analyzer (generating AST expressions) instead of in CodeGen. To some
extend this is unavoidable because iterator overloaded operators need
to be resolved in the desugared form. However, once D76342 is
greenlit, I'd work an moving more of the loop directive logic into
CodeGen.

I added you as a reviewer of D76342. Would you be interested in reviewing it?

Michael
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
In reply to this post by Vassil Vassilev via cfe-dev
Am Do., 11. Juni 2020 um 12:54 Uhr schrieb Probir Roy <[hidden email]>:

> The user will annotate callee as well as a few callers and their error
> handling code.
>
> #pragma xTool caller
> {
>       try{
>           ret = callee();
>       }catch(e)
>       { ... }
> }

Isn't it obvious that this is a caller of callee()?

Michael
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
Good question. I will construct the module summary based on caller and
callee information provided by the user. The relation between caller
and callee will be decided during link-time analysis.

On Thu, Jun 11, 2020 at 3:21 PM Michael Kruse <[hidden email]> wrote:

>
> Am Do., 11. Juni 2020 um 12:54 Uhr schrieb Probir Roy <[hidden email]>:
> > The user will annotate callee as well as a few callers and their error
> > handling code.
> >
> > #pragma xTool caller
> > {
> >       try{
> >           ret = callee();
> >       }catch(e)
> >       { ... }
> > }
>
> Isn't it obvious that this is a caller of callee()?
>
> Michael



--
Probir Roy
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
I was able to add attributes to AST. However, I am currently stuck in
code generation. I am trying to add meta-data to the AttributedStmt
but I am not sure how to do it.

For now, I have generated the following AttributedStmt in AST:

|   |-AttributedStmt 0x5630129efcc8 <<invalid sloc>, line:12:16>
|   | |-MyCustomAttr 0x5630129efc90 <line:11:9, col:38> Implicit Call foo foo2
|   | `-BinaryOperator 0x5630129efc70 <line:12:2, col:16> 'int' '='
|   |   |-DeclRefExpr 0x5630129efb78 <col:2> 'int' lvalue Var
0x5630129ef9d8 'c2' 'int'
|   |   `-CallExpr 0x5630129efc10 <col:7, col:16> 'int'
|   |     |-ImplicitCastExpr 0x5630129efbf8 <col:7> 'int (*)(int,
int)' <FunctionToPointerDecay>
|   |     | `-DeclRefExpr 0x5630129efb98 <col:7> 'int (int, int)'
Function 0x5630129ef5a0 'foo2' 'int (int, int)'
|   |     |-ImplicitCastExpr 0x5630129efc40 <col:12> 'int' <LValueToRValue>
|   |     | `-DeclRefExpr 0x5630129efbb8 <col:12> 'int' lvalue Var
0x5630129ef8d8 'a' 'int'
|   |     `-ImplicitCastExpr 0x5630129efc58 <col:15> 'int' <LValueToRValue>
|   |       `-DeclRefExpr 0x5630129efbd8 <col:15> 'int' lvalue Var
0x5630129ef958 'b' 'int'

Now, I want to add some metadata to these enclosed attributed
statements and generate IR. I understand that I can use setMetadata
for adding metadata to an instruction.
For the above case, should I create a new block with the attributed
statements and then add meta-data to the block? How can I create a new
block with the attributed statement?
Can you please provide some directions/example code on how to add
metadata to the "attributed" statements?

Here is the example code and generated AST:
https://gist.github.com/proywm/a8c47bc8b863a782d4201499f2aae2a1

--
Probir Roy
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Implementing front-end of a user-directed optimization

Vassil Vassilev via cfe-dev
As by your example, #pragma xTool caller seems to apply on a scope,
not a block. Blocks themselves cannot be annotated, it wouldn't make
sense since blocks are merged/fused/moved and metadata on them would
be lost. Metadata only applies to instructions, functions have
attributes. You can also insert intrinsic instruction (e.g. "begin of
scope" and "end of scope") into the instruction stream.

Michael

Am Di., 23. Juni 2020 um 14:13 Uhr schrieb Probir Roy <[hidden email]>:

>
> I was able to add attributes to AST. However, I am currently stuck in
> code generation. I am trying to add meta-data to the AttributedStmt
> but I am not sure how to do it.
>
> For now, I have generated the following AttributedStmt in AST:
>
> |   |-AttributedStmt 0x5630129efcc8 <<invalid sloc>, line:12:16>
> |   | |-MyCustomAttr 0x5630129efc90 <line:11:9, col:38> Implicit Call foo foo2
> |   | `-BinaryOperator 0x5630129efc70 <line:12:2, col:16> 'int' '='
> |   |   |-DeclRefExpr 0x5630129efb78 <col:2> 'int' lvalue Var
> 0x5630129ef9d8 'c2' 'int'
> |   |   `-CallExpr 0x5630129efc10 <col:7, col:16> 'int'
> |   |     |-ImplicitCastExpr 0x5630129efbf8 <col:7> 'int (*)(int,
> int)' <FunctionToPointerDecay>
> |   |     | `-DeclRefExpr 0x5630129efb98 <col:7> 'int (int, int)'
> Function 0x5630129ef5a0 'foo2' 'int (int, int)'
> |   |     |-ImplicitCastExpr 0x5630129efc40 <col:12> 'int' <LValueToRValue>
> |   |     | `-DeclRefExpr 0x5630129efbb8 <col:12> 'int' lvalue Var
> 0x5630129ef8d8 'a' 'int'
> |   |     `-ImplicitCastExpr 0x5630129efc58 <col:15> 'int' <LValueToRValue>
> |   |       `-DeclRefExpr 0x5630129efbd8 <col:15> 'int' lvalue Var
> 0x5630129ef958 'b' 'int'
>
> Now, I want to add some metadata to these enclosed attributed
> statements and generate IR. I understand that I can use setMetadata
> for adding metadata to an instruction.
> For the above case, should I create a new block with the attributed
> statements and then add meta-data to the block? How can I create a new
> block with the attributed statement?
> Can you please provide some directions/example code on how to add
> metadata to the "attributed" statements?
>
> Here is the example code and generated AST:
> https://gist.github.com/proywm/a8c47bc8b863a782d4201499f2aae2a1
>
> --
> Probir Roy
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev