Use CGLoopInfo to emit metadata for loop hint pragmas.
authorTyler Nowicki <tyler.nowicki@gmail.com>
Mon, 27 Jul 2015 20:10:20 +0000 (20:10 +0000)
committerTyler Nowicki <tyler.nowicki@gmail.com>
Mon, 27 Jul 2015 20:10:20 +0000 (20:10 +0000)
commit54c020d372defdef97235f4849e07292eb2f03ad
treebe6872130c8b6e2c8a03ec871727b58bebef59a6
parent917c4d41eafcd9da0cdc1ac0379d654560578e04
Use CGLoopInfo to emit metadata for loop hint pragmas.

When ‘#pragma clang loop vectorize(assume_safety)’ was specified on a loop other loop hints were lost. The problem is that CGLoopInfo attaches metadata differently than EmitCondBrHints in CGStmt. For do-loops CGLoopInfo attaches metadata to the br in the body block and for while and for loops, the inc block. EmitCondBrHints on the other hand always attaches data to the br in the cond block. When specifying assume_safety CGLoopInfo emits an empty llvm.loop metadata shadowing the metadata in the cond block. Loop transformations like rotate and unswitch would then eliminate the cond block and its non-empty metadata.

This patch unifies both approaches for adding metadata and modifies the existing safety tests to include non-assume_safety loop hints.

llvm-svn: 243315
clang/lib/CodeGen/CGLoopInfo.cpp
clang/lib/CodeGen/CGLoopInfo.h
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGenCXX/pragma-loop-safety.cpp
clang/test/CodeGenCXX/pragma-loop.cpp
clang/test/CodeGenCXX/pragma-unroll.cpp