[cfe-dev] Emitting loop metadata in codegen

Redmond, Paul paul.redmond at intel.com
Fri Feb 22 12:50:57 PST 2013


Hi,

As discussed earlier I'm implementing #pragma ivdep in clang. I use AttributedStmt with an IVDepAttr to wrap loop Stmts in the AST. So far I have only hacked in codegen to attach loop metadata.

To do this correctly I need to attach metadata to all predecessors of the loop header. Also, I need to attach metadata to all loads and stores in the loop. (see llvm.loop.parallel and llvm.mem.parallel_loop_access)

I'm wondering what the best way to implement this in clang codegen? I think this could get really messy and become very fragile if I just start modifying EmitForStmt, etc to check for some flag.

One idea I've been thinking about is creating the metadata after code emission using a llvm loop pass (living in clang/lib/CodeGen) Basically during codegen I would attach a simple metadata (clang.pragma.ivdep or something) to a block in the loop and use the pass to translate to the metadata understood by llvm. I don't see a precedent for running clang-specific passes in codegen though..

Comments and suggestions are appreciated.

paul



More information about the cfe-dev mailing list