启用Pass的方法
- out-of-tree
- Opt启用Pass(常用,Legacy&New PM均可用)
- Xclang编译选项启动Pass
- in-tree
- 资料较少,需要在Sanitizer.def里加入希望在编译选项中看到的(-fsanitizer=)whatever_name,然后通过PassManager初始化对应的Pass类。
LLVM New Pass Manager
较新的LLVM开始同时支持Legacy Pass Manager(Legacy PM)和New Pass Manager(New PM)来管理LLVM Pass。Legacy PM在CGSCC Pass(Call Graph Strongly Connected Component)中无法支持对先前的函数分析结果进行缓存及检索,因此促使了New PM的诞生(参考这里)。New PM将Pass和Analysis分离,使用专门的Analysis Manager来管理Analysis的结果。
Legacy PM可能在Clang14中被弃用?(根据GDB调试clang的结果来看,clang14使用New PM而非Legacy PM初始化ASAN,而clang12中使用Legacy PM而非New PM初始化ASAN)
引文来自这里
There will be efforts to deprecate and remove the legacy PM for the optimization pipeline in the future.