Index: include/llvm/IR/GlobalValue.h =================================================================== --- include/llvm/IR/GlobalValue.h +++ include/llvm/IR/GlobalValue.h @@ -113,6 +113,7 @@ friend class Constant; void maybeSetDsoLocal() { + // hasLocalLinkage => false if (hasLocalLinkage() || (!hasDefaultVisibility() && !hasExternalWeakLinkage())) setDSOLocal(true); Index: lib/Transforms/Instrumentation/DataFlowSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -653,6 +653,13 @@ AttributeList::ReturnIndex, AttributeFuncs::typeIncompatible(NewFT->getReturnType())); + // If the function being created has non-local linkage, it should not have the + // dso_local attribute. Explicitly remove dso_local, in case it was set when + // attributes were copied from F. + if (!NewF->hasLocalLinkage()) { + NewF->setDSOLocal(false); + } + BasicBlock *BB = BasicBlock::Create(*Ctx, "entry", NewF); if (F->isVarArg()) { NewF->removeAttributes(AttributeList::FunctionIndex, Index: test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt =================================================================== --- test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt +++ test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt @@ -6,3 +6,5 @@ fun:custom*=uninstrumented fun:custom*=custom + +fun:uninstrumented*=uninstrumented Index: test/Instrumentation/DataFlowSanitizer/uninstrumented_internal_function.ll =================================================================== --- /dev/null +++ test/Instrumentation/DataFlowSanitizer/uninstrumented_internal_function.ll @@ -0,0 +1,16 @@ +; RUN: opt < %s -dfsan -dfsan-args-abi -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s +; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s + +target triple = "x86_64-unknown-linux-gnu" + +define internal i8 @uninstrumented_internal_fun(i8 %in) { + ret i8 %in +} + +define i8 @call_uninstrumented_fun(i8 %in) { + %call = call i8 @uninstrumented_internal_fun(i8 %in) + ret i8 %call +} + +; CHECK: define linkonce_odr {{(i8|{ i8, i16 })}} @"dfsw$uninstrumented_internal_fun" +; CHECK-NOT: dso_local