[PATCH] GSoC project: "Add support for directive to uniquely identify the loops in high-level languages"

Dmitry N. Mikushin maemarcus at gmail.com
Sat Apr 13 12:52:19 PDT 2013


Hi,

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:

1) add a useful LLVM functionality, that will help to improve compiler
testing in applications
2) attract attention of undergrad students to LLVM and guide them into
compiler internals with simple engineering task

Below is full description and a patch, which adds it to OpenProjects page
of LLVM site.
Please review.

Thanks,
- D.

==========

Add support for directive to uniquely identify the loops in high-level
languages

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.

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.

One natural solution might be to markup loops in high-level language:

    #pragma llvm loopname Loop1
    for (int i = 0; i < n; i++)
    {
      ...
    }

and pass this name through the frontend to LLVM IR metadata node or
annotation intrinsic attached to the loop header.

Then, different optimization passes will be able to output targeted
diagnostics:

    Loop "Loop1" was vectorized
    Loop "Loop1" was taken on GPU

Adding directive support would mostly be the work on Clang frontend side:
= Choose directive representation for LLVM IR: metadata, intrinsic, etc.
= Add parsing of directive into parser and codegen it into selected
representation
= Write a dummy LLVM pass showing how the loop naming directive could be
used for diagnostics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130413/ae85dbe9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenProjects.html.patch
Type: application/octet-stream
Size: 2551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130413/ae85dbe9/attachment.obj>


More information about the llvm-commits mailing list