[llvm] bff0987 - Fix return status of DataFlowSanitizer pass
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 07:06:24 PDT 2020
Author: serge-sans-paille
Date: 2020-06-11T16:05:17+02:00
New Revision: bff09876d7cdac82d9f00ab290839198cc311a6f
URL: https://github.com/llvm/llvm-project/commit/bff09876d7cdac82d9f00ab290839198cc311a6f
DIFF: https://github.com/llvm/llvm-project/commit/bff09876d7cdac82d9f00ab290839198cc311a6f.diff
LOG: Fix return status of DataFlowSanitizer pass
Take into account added functions, global values and attribute change.
Differential Revision: https://reviews.llvm.org/D81239
Added:
Modified:
llvm/include/llvm/IR/Module.h
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 36d58661ae4c..3f97d048f862 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -593,6 +593,7 @@ class Module {
const_global_iterator global_begin() const { return GlobalList.begin(); }
global_iterator global_end () { return GlobalList.end(); }
const_global_iterator global_end () const { return GlobalList.end(); }
+ size_t global_size () const { return GlobalList.size(); }
bool global_empty() const { return GlobalList.empty(); }
iterator_range<global_iterator> globals() {
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 795ef13919c1..c9409a8874e6 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -811,16 +811,25 @@ bool DataFlowSanitizer::runOnModule(Module &M) {
if (ABIList.isIn(M, "skip"))
return false;
+ const unsigned InitialGlobalSize = M.global_size();
+ const unsigned InitialModuleSize = M.size();
+
+ bool Changed = false;
+
if (!GetArgTLSPtr) {
Type *ArgTLSTy = ArrayType::get(ShadowTy, 64);
ArgTLS = Mod->getOrInsertGlobal("__dfsan_arg_tls", ArgTLSTy);
- if (GlobalVariable *G = dyn_cast<GlobalVariable>(ArgTLS))
+ if (GlobalVariable *G = dyn_cast<GlobalVariable>(ArgTLS)) {
+ Changed |= G->getThreadLocalMode() != GlobalVariable::InitialExecTLSModel;
G->setThreadLocalMode(GlobalVariable::InitialExecTLSModel);
+ }
}
if (!GetRetvalTLSPtr) {
RetvalTLS = Mod->getOrInsertGlobal("__dfsan_retval_tls", ShadowTy);
- if (GlobalVariable *G = dyn_cast<GlobalVariable>(RetvalTLS))
+ if (GlobalVariable *G = dyn_cast<GlobalVariable>(RetvalTLS)) {
+ Changed |= G->getThreadLocalMode() != GlobalVariable::InitialExecTLSModel;
G->setThreadLocalMode(GlobalVariable::InitialExecTLSModel);
+ }
}
ExternalShadowMask =
@@ -1044,7 +1053,8 @@ bool DataFlowSanitizer::runOnModule(Module &M) {
}
}
- return false;
+ return Changed || !FnsToInstrument.empty() ||
+ M.global_size() != InitialGlobalSize || M.size() != InitialModuleSize;
}
Value *DFSanFunction::getArgTLSPtr() {
More information about the llvm-commits
mailing list