[PATCH] D20458: [esan] Use ModulePass for EfficiencySanitizerPass.
Qin Zhao via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 21:09:50 PDT 2016
zhaoqin created this revision.
zhaoqin added a reviewer: aizatsky.
zhaoqin added subscribers: kcc, bruening, vitalybuka, eugenis, llvm-commits.
Uses ModulePass instead of FunctionPass for EfficiencySanitizerPass.
http://reviews.llvm.org/D20458
Files:
include/llvm/Transforms/Instrumentation.h
lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
Index: lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ 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;
Index: include/llvm/Transforms/Instrumentation.h
===================================================================
--- include/llvm/Transforms/Instrumentation.h
+++ 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20458.57887.patch
Type: text/x-patch
Size: 2965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160520/7f24f229/attachment.bin>
More information about the llvm-commits
mailing list