[PATCH] D20458: [esan] Use ModulePass for EfficiencySanitizerPass.
Derek Bruening via llvm-commits
llvm-commits at lists.llvm.org
Fri May 20 13:06:24 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270263: [esan] Use ModulePass for EfficiencySanitizerPass. (authored by bruening).
Changed prior to commit:
http://reviews.llvm.org/D20458?vs=57887&id=57975#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20458
Files:
llvm/trunk/include/llvm/Transforms/Instrumentation.h
llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
Index: llvm/trunk/include/llvm/Transforms/Instrumentation.h
===================================================================
--- llvm/trunk/include/llvm/Transforms/Instrumentation.h
+++ llvm/trunk/include/llvm/Transforms/Instrumentation.h
@@ -127,7 +127,7 @@
};
// Insert EfficiencySanitizer instrumentation.
-FunctionPass *createEfficiencySanitizerPass(
+ModulePass *createEfficiencySanitizerPass(
const EfficiencySanitizerOptions &Options = EfficiencySanitizerOptions());
// Options for sanitizer coverage instrumentation.
Index: llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
@@ -78,18 +78,19 @@
}
/// EfficiencySanitizer: instrument each module to find performance issues.
-class EfficiencySanitizer : public FunctionPass {
+class EfficiencySanitizer : public ModulePass {
public:
EfficiencySanitizer(
const EfficiencySanitizerOptions &Opts = EfficiencySanitizerOptions())
- : FunctionPass(ID), Options(OverrideOptionsFromCL(Opts)) {}
+ : ModulePass(ID), Options(OverrideOptionsFromCL(Opts)) {}
const char *getPassName() const override;
- bool runOnFunction(Function &F) override;
- bool doInitialization(Module &M) override;
+ bool runOnModule(Module &M) override;
static char ID;
private:
+ bool initOnModule(Module &M);
void initializeCallbacks(Module &M);
+ bool runOnFunction(Function &F, Module &M);
bool instrumentLoadOrStore(Instruction *I, const DataLayout &DL);
bool instrumentMemIntrinsic(MemIntrinsic *MI);
bool shouldIgnoreMemoryAccess(Instruction *I);
@@ -125,7 +126,7 @@
return "EfficiencySanitizer";
}
-FunctionPass *
+ModulePass *
llvm::createEfficiencySanitizerPass(const EfficiencySanitizerOptions &Options) {
return new EfficiencySanitizer(Options);
}
@@ -172,7 +173,7 @@
IRB.getInt32Ty(), IntptrTy, nullptr));
}
-bool EfficiencySanitizer::doInitialization(Module &M) {
+bool EfficiencySanitizer::initOnModule(Module &M) {
Ctx = &M.getContext();
const DataLayout &DL = M.getDataLayout();
IRBuilder<> IRB(M.getContext());
@@ -198,13 +199,20 @@
return false;
}
-bool EfficiencySanitizer::runOnFunction(Function &F) {
+bool EfficiencySanitizer::runOnModule(Module &M) {
+ bool Res = initOnModule(M);
+ initializeCallbacks(M);
+ for (auto &F : M) {
+ Res |= runOnFunction(F, M);
+ }
+ return Res;
+}
+
+bool EfficiencySanitizer::runOnFunction(Function &F, Module &M) {
// This is required to prevent instrumenting the call to __esan_init from
// within the module constructor.
if (&F == EsanCtorFunction)
return false;
- // As a function pass, we must re-initialize every time.
- initializeCallbacks(*F.getParent());
SmallVector<Instruction *, 8> LoadsAndStores;
SmallVector<Instruction *, 8> MemIntrinCalls;
bool Res = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20458.57975.patch
Type: text/x-patch
Size: 3031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160520/5239cbca/attachment.bin>
More information about the llvm-commits
mailing list