From 054cec05b84e878a68e7ecc71342312e76850649 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Aug 2013 20:08:15 +0000 Subject: DataFlowSanitizer: Replace non-instrumented aliases of instrumented functions, and vice versa, with wrappers. Differential Revision: http://llvm-reviews.chandlerc.com/D1442 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189054 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/DataFlowSanitizer.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/Transforms/Instrumentation') diff --git a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index e92d88de1d..1bf6b99ea9 100644 --- a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -470,7 +470,8 @@ bool DataFlowSanitizer::runOnModule(Module &M) { FnsToInstrument.push_back(&*i); } - // Give function aliases prefixes when necessary. + // Give function aliases prefixes when necessary, and build wrappers where the + // instrumentedness is inconsistent. for (Module::alias_iterator i = M.alias_begin(), e = M.alias_end(); i != e;) { GlobalAlias *GA = &*i; ++i; @@ -481,6 +482,16 @@ bool DataFlowSanitizer::runOnModule(Module &M) { bool GAInst = isInstrumented(GA), FInst = isInstrumented(F); if (GAInst && FInst) { addGlobalNamePrefix(GA); + } else if (GAInst != FInst) { + // Non-instrumented alias of an instrumented function, or vice versa. + // Replace the alias with a native-ABI wrapper of the aliasee. The pass + // below will take care of instrumenting it. + Function *NewF = + buildWrapperFunction(F, "", GA->getLinkage(), F->getFunctionType()); + GA->replaceAllUsesWith(NewF); + NewF->takeName(GA); + GA->eraseFromParent(); + FnsToInstrument.push_back(NewF); } } } -- cgit v1.2.3