summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-08-22 20:08:15 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-08-22 20:08:15 +0000
commit34f0c313e21646b6725bcc6e0d07945114e1f5c1 (patch)
treeb0477e7a084bcfa7e2c1b5567ce4c295255ba611 /llvm/lib
parent761a4fc4755e67219ad1f2152def89356405bcac (diff)
downloadbcm5719-llvm-34f0c313e21646b6725bcc6e0d07945114e1f5c1.tar.gz
bcm5719-llvm-34f0c313e21646b6725bcc6e0d07945114e1f5c1.zip
DataFlowSanitizer: Replace non-instrumented aliases of instrumented functions, and vice versa, with wrappers.
Differential Revision: http://llvm-reviews.chandlerc.com/D1442 llvm-svn: 189054
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index e92d88de1d3..1bf6b99ea97 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/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);
}
}
}
OpenPOWER on IntegriCloud