r174049 - [msan] Run more optimizations after MemorySanitizer pass.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Jan 31 01:53:29 PST 2013


Author: eugenis
Date: Thu Jan 31 03:53:29 2013
New Revision: 174049

URL: http://llvm.org/viewvc/llvm-project?rev=174049&view=rev
Log:
[msan] Run more optimizations after MemorySanitizer pass.

MSan instrumentation is driven by the original code. We take every
incoming instruction and emit another instruction (or ten) next to
it, operating on the shadow values (but sometimes on the real values,
too). Two programs in one, essentially. There can be any kinds of
redundancies in the second one, so we just run whatever is normally
run at -O2, and then exclude some passes that do not help much with
benchmarks.


Modified:
    cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=174049&r1=174048&r2=174049&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan 31 03:53:29 2013
@@ -184,6 +184,18 @@ static void addMemorySanitizerPass(const
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
   PM.add(createMemorySanitizerPass(CGOpts.SanitizeMemoryTrackOrigins,
                                    CGOpts.SanitizerBlacklistFile));
+
+  // MemorySanitizer inserts complex instrumentation that mostly follows
+  // the logic of the original code, but operates on "shadow" values.
+  // It can benefit from re-running some general purpose optimization passes.
+  if (Builder.OptLevel > 0) {
+    PM.add(createEarlyCSEPass());
+    PM.add(createReassociatePass());
+    PM.add(createLICMPass());
+    PM.add(createGVNPass());
+    PM.add(createInstructionCombiningPass());
+    PM.add(createDeadStoreEliminationPass());
+  }
 }
 
 static void addThreadSanitizerPass(const PassManagerBuilder &Builder,





More information about the cfe-commits mailing list