<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div>The LLVM Polly wiki page earlier mentioned a design[2] where Clang and LLVM<br>Polly would emit annotations to the code and there would be a seperate pass that<br>would transform the code using these annotations. The issue I see with this<br>approach is that this pass will have to be run immediately after the Clang and<br>LLVM Polly emit these intrinsics. Otherwise a different pass might make the<br>annotations invalid. A dead code elimination pass might remove the code for<br>which these annotations were meant for example.<br><br></div></blockquote><div><br></div><div>It depends on how they're implemented of course, but if they were (for example)</div><div>metadata then yes something could delete it. If they were intrinsics then it could</div><div>also be deleted, but the optimizers would have to prove that they could be - which</div><div>means that the optimizers would need to be taught about whatever you're adding.</div><br><blockquote type="cite"><div>I believe the simpler way is to have a library of classes to represent OpenMP<br>directives and functions to transform these objects to LLVM objects and then<br>have LLVM and Clang use this library directly.<br><br>I would like to know if I am missing something about the design using<br>annotations as well as any alternative designs.<br></div></blockquote></div><br><div>Well, "annotations" is pretty vague, though I can see Polly making the annotations</div><div>and then calling a Polly transform pass to transform before handing back to the</div><div>llvm optimizers. I think this is what was being talked about. This is more on the</div><div>line of autoparallelization rather than paying attention to OpenMP pragmas and</div><div>directives. For simple OpenMP pragma support it would probably be better to lower</div><div>to intrinsics and calls to an OpenMP library. This is what is currently done in</div><div>llvm-gcc (the calls and separation) - a similar mechanism could probably work for</div><div>clang. Ultimately I think the greater body of work is having clang parse and emit</div><div>the correct code rather than how to represent it in IR.</div><div><br></div><div>-eric</div></body></html>