From: serge-sans-paille Date: Thu, 4 Jun 2020 07:13:39 +0000 (+0200) Subject: Fix return status of DataFlowSanitizer pass X-Git-Tag: llvmorg-12-init~3363 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bff09876d7cdac82d9f00ab290839198cc311a6f;p=platform%2Fupstream%2Fllvm.git Fix return status of DataFlowSanitizer pass Take into account added functions, global values and attribute change. Differential Revision: https://reviews.llvm.org/D81239 --- diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index 36d5866..3f97d04 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -593,6 +593,7 @@ public: 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 globals() { diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index 795ef13..c9409a8 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(ArgTLS)) + if (GlobalVariable *G = dyn_cast(ArgTLS)) { + Changed |= G->getThreadLocalMode() != GlobalVariable::InitialExecTLSModel; G->setThreadLocalMode(GlobalVariable::InitialExecTLSModel); + } } if (!GetRetvalTLSPtr) { RetvalTLS = Mod->getOrInsertGlobal("__dfsan_retval_tls", ShadowTy); - if (GlobalVariable *G = dyn_cast(RetvalTLS)) + if (GlobalVariable *G = dyn_cast(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() {