Hi,<br><br>This patch adds a proposal of a student project on adding simple loop directive support in frontend and utilizing it for diagnostics in LLVM passes. The project serves two main purposes:<br><br>1) add a useful LLVM functionality, that will help to improve compiler testing in applications<br>
2) attract attention of undergrad students to LLVM and guide them into compiler internals with simple engineering task<br><br>Below is full description and a patch, which adds it to OpenProjects page of LLVM site.<br>Please review.<br>
<br>Thanks,<br>- D.<br><br>==========<br><br>Add support for directive to uniquely identify the loops in high-level languages<br><br>Consider there are dozens of regression tests in high-level languages, reporting whether or not the recent changes in compiler are breaking some kind of loop handling (vectorization, parallelization, etc.). Consider there is a post-processing utility, which parses diagnostic output from each test and tries to determine whether particular loop was handled properly.<br>
<br>In lower level, LLVM already has an infrastructure to test if a pass or a backend transforms the given LLVM IR into expected form. Rather than that, this proposal aims to address more high-level scope of use, where developers need to verify the consistency of many parts of compiler pipeline - from frontend to code generation.<br>
<br>One natural solution might be to markup loops in high-level language:<br><br>    #pragma llvm loopname Loop1<br>    for (int i = 0; i < n; i++)<br>    {<br>      ...<br>    }<br><br>and pass this name through the frontend to LLVM IR metadata node or annotation intrinsic attached to the loop header.<br>
<br>Then, different optimization passes will be able to output targeted diagnostics:<br><br>    Loop "Loop1" was vectorized<br>    Loop "Loop1" was taken on GPU<br><br>Adding directive support would mostly be the work on Clang frontend side:<br>
= Choose directive representation for LLVM IR: metadata, intrinsic, etc.<br>= Add parsing of directive into parser and codegen it into selected representation<br>= Write a dummy LLVM pass showing how the loop naming directive could be used for diagnostics<br>
<br>