Adding pragma related metadata to only one loop

Hi everyone,

I wanted to assign a new pragma for loops in clang. Let’s call it “#pragma XXX” which can be applied to any loop in the entire loop hierarchy. I added the support for my pragma by following the same steps as were being used in the default implementation of “unroll” pragma.

But now, when I compile any program using clang to llvm IR it attaches the pragma related metadata to the loop as well as to all the loops nested inside it. I just want to add the metadata to that particular loop and not all the loops nested inside it. Can someone suggest what would be the right way of doing this? or rather what files should I look into.

So far I have made changes in the following files:

  1. include/clang/Basic/Attr.td
  2. include/clang/Parse/Parser.h
  3. lib/CodeGen/CGLoopInfo.cpp
  4. lib/CodeGen/CGLoopInfo.h
  5. lib/Parse/ParsePragma.cpp
  6. lib/Sema/SemaStmtAttr.cpp

Any help would be appreciated.

Thanks,

Best Regards,
Nitish

I have attached all the files that I have changed. Along with that, there is matrix-mul.c in which I am using a pragma, but that metadata for that pragma is getting applied to all the loops in the loop nest (as can be seen from .ll file).

Any help would be great!

Thanks a lot in advance,

Best Regards,
Nitish

Attr.td (98.1 KB)

CGLoopInfo.cpp (11.4 KB)

CGLoopInfo.h (5.9 KB)

matrix-mul.c (1.13 KB)

matrix-mul.ll (23.3 KB)

ParsePragma.cpp (102 KB)

Parser.h (114 KB)

SemaStmtAttr.cpp (13.3 KB)