1、在中定义了循环关键字#pragma clang loop的类型
loop-hint-keyword:enable, disable, assume_safety
loop-hint-value:constant-expression
2、 使用#pragma clang loop unroll_count(x)指示循环展开,或者命令行-mllvm -unroll-count,参考discuss 76347
3、类似gcc, 可以使用 #pragma clang attribute push/pop, Compiler Explorer
详见 Clang Language Extensions — Clang 8 documentation
#pragma clang attribute push(__attribute__((optnone)), apply_to = function)
4、#pragma pop_macro 在commit c0a585d63c支持合入
5、使用__attribute__((optimize(0))) int main ()关闭优化
6、gcc pragma的介绍 https://gcc.gnu.org/onlinedocs/gcc/Loop-Specific-Pragmas.html
7、添加一个新的pragma force_vectorize 的实例 ,⚙ D156910 [clang] Add pragma force_vectorize (llvm.org)
step1: 词法、语法处理,在Parser::HandlePragmaLoopHint/CheckLoopHintExpr中检查tok
step2: 将关键新建记录 LoopInfoStack::push-->setLookUpInfo, 比如以map记录变量信息
step3:在LoopInfoStack::InsertHelper读取(变量索引),转换为metadata (包括场景识别)
step4: 在合适的patch对metadata解析处理
8、向量化可以通过 #pragma clang loop vectorize(disable) 关闭 Compiler Explorer