Alexander Potapenko
2011-Nov-22 11:18 UTC
[LLVMdev] Instrumentation passes and -O0 optimization level
Hi LLVMdev, llvm::PassManagerBuilder allows to customize the default pass sequenceby registering passes at specific extension points.However all of theextensions if the -O0 flag is added to the command line; as thecomment says, "If all optimizations are disabled, just run thealways-inline pass."This doesn't play well with _instrumentation_passes which should not be disabled regardless of the optimizationlevel. My proposal is to add a specific extension point to preserve a passeven if O0 is used (below is the usage example with theAddressSanitizer pass)Another solution would be to introduce a passattribute which tells whether the pass should be preserved if theoptimizations are disabled, but this will require some refactoring ofthe PassManagerBuilder class. What do you think of the following patch? -------------------------8<--------------------------------------------------Index: include/llvm/Transforms/IPO/PassManagerBuilder.h===================================================================--- include/llvm/Transforms/IPO/PassManagerBuilder.h (revision 144800)+++ include/llvm/Transforms/IPO/PassManagerBuilder.h (working copy)@@ -67,7 +67,12 @@ /// EP_ScalarOptimizerLate - This extension point allows addingoptimization /// passes after most of the main optimizations, but before the last /// cleanup-ish optimizations.- EP_ScalarOptimizerLate+ EP_ScalarOptimizerLate,++ /// EP_EnabledOnOptLevel0 - This extension point allows adding passes that+ /// should not be disabled by O0 optimization level. The passes will be+ /// inserted after the inlining pass.+ EP_EnabledOnOptLevel0 }; /// The Optimization Level - Specify the basic optimization level.Index: lib/Transforms/IPO/PassManagerBuilder.cpp===================================================================--- lib/Transforms/IPO/PassManagerBuilder.cpp (revision 144800)+++ lib/Transforms/IPO/PassManagerBuilder.cpp (working copy)@@ -101,6 +101,7 @@ MPM.add(Inliner); Inliner = 0; }+ addExtensionsToPM(EP_EnabledOnOptLevel0, MPM); return; } Index: tools/clang/lib/CodeGen/BackendUtil.cpp===================================================================--- tools/clang/lib/CodeGen/BackendUtil.cpp (revision 144800)+++ tools/clang/lib/CodeGen/BackendUtil.cpp (working copy)@@ -150,6 +150,8 @@ if (CodeGenOpts.AddressSanitizer) { PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate, addAddressSanitizerPass);+ PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,+ addAddressSanitizerPass); } // Figure out TargetLibraryInfo.-------------------------8<-------------------------------------------------- TIA,Alexander Potapenko Software Engineer Google Moscow
Chandler Carruth
2011-Nov-22 11:23 UTC
[LLVMdev] Instrumentation passes and -O0 optimization level
On Tue, Nov 22, 2011 at 3:18 AM, Alexander Potapenko <glider at google.com>wrote:> What do you think of the following patch? >Unfortunately, it looks like your email got garbled... Please attach patches as actual files rather than as text at the end of the message, otherwise lots of email software does the wrong thing with them... -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111122/ff059cd8/attachment.html>
Alexander Potapenko
2011-Nov-22 11:25 UTC
[LLVMdev] Instrumentation passes and -O0 optimization level
> Unfortunately, it looks like your email got garbled... Please attach patches > as actual files rather than as text at the end of the message, otherwise > lots of email software does the wrong thing with them...See attached. Sorry for that. -------------- next part -------------- A non-text attachment was scrubbed... Name: clang.patch Type: text/x-patch Size: 1819 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111122/d8baa0e3/attachment.bin>
Apparently Analagous Threads
- [LLVMdev] Instrumentation passes and -O0 optimization level
- [LLVMdev] Instrumentation passes and -O0 optimization level
- [LLVMdev] Instrumentation passes and -O0 optimization level
- [LLVMdev] Instrumentation passes and -O0 optimization level
- [LLVMdev] Instrumentation passes and -O0 optimization level