mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 04:46:27 +08:00
[msan] Insert simplification passes after instrumentation
This resolves TODO from D96406. InstCombine issue is fixed with D133394. Save 4.5% of .text on CTMark.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/GlobalsModRef.h"
|
||||
#include "llvm/Analysis/StackSafetyAnalysis.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
@@ -72,14 +73,16 @@
|
||||
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
|
||||
#include "llvm/Transforms/Instrumentation/MemProfiler.h"
|
||||
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
|
||||
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
|
||||
#include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h"
|
||||
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
|
||||
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
|
||||
#include "llvm/Transforms/ObjCARC.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/EarlyCSE.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "llvm/Transforms/Scalar/JumpThreading.h"
|
||||
#include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
|
||||
#include "llvm/Transforms/Scalar/NewGVN.h"
|
||||
#include "llvm/Transforms/Utils.h"
|
||||
#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
|
||||
#include "llvm/Transforms/Utils/Debugify.h"
|
||||
@@ -97,6 +100,7 @@ using namespace llvm;
|
||||
|
||||
namespace llvm {
|
||||
extern cl::opt<bool> DebugInfoCorrelate;
|
||||
extern cl::opt<bool> RunNewGVN;
|
||||
|
||||
// Experiment to move sanitizers earlier.
|
||||
static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
|
||||
@@ -661,16 +665,21 @@ static void addSanitizers(const Triple &TargetTriple,
|
||||
CodeGenOpts.SanitizeMemoryParamRetval);
|
||||
MPM.addPass(MemorySanitizerPass(options));
|
||||
if (Level != OptimizationLevel::O0) {
|
||||
// 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.
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(EarlyCSEPass()));
|
||||
// TODO: Consider add more passes like in
|
||||
// addGeneralOptsForMemorySanitizer. EarlyCSEPass makes visible
|
||||
// difference on size. It's not clear if the rest is still
|
||||
// usefull. InstCombinePass breakes
|
||||
// compiler-rt/test/msan/select_origin.cpp.
|
||||
// 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.
|
||||
MPM.addPass(RecomputeGlobalsAAPass());
|
||||
FunctionPassManager FPM;
|
||||
FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
|
||||
FPM.addPass(InstCombinePass());
|
||||
FPM.addPass(JumpThreadingPass());
|
||||
if (RunNewGVN)
|
||||
FPM.addPass(NewGVNPass());
|
||||
else
|
||||
FPM.addPass(GVNPass());
|
||||
FPM.addPass(InstCombinePass());
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user