X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTransforms%2FInstrumentation%2FDataFlowSanitizer.cpp;h=1bf6b99ea978efef9b40ea2f0bae84664ed48b76;hb=054cec05b84e878a68e7ecc71342312e76850649;hp=e92d88de1d39dbb9ade779c83bb56c1dcb288a8a;hpb=4f68e9ea8e6a9d98b60bbdde719dcb9d68991980;p=oota-llvm.git diff --git a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index e92d88de1d3..1bf6b99ea97 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); } } }