diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -992,6 +992,8 @@ GV.replaceAllUsesWith(NewGV); return false; } + if (!GV.isImplicitDSOLocal()) + GV.setDSOLocal(false); return true; } diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-dsolocal.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-dsolocal.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-dsolocal.ll @@ -0,0 +1,15 @@ +; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s +; RUN: llvm-modextract -b -n 0 -o %t0.bc %t +; RUN: llvm-modextract -b -n 1 -o %t1.bc %t +; RUN: llvm-dis -o - %t0.bc | FileCheck --check-prefix=M0 %s +; RUN: llvm-dis -o - %t1.bc | FileCheck --check-prefix=M1 %s + +; M0: @g = external constant [1 x i8] +; M1: @g = dso_local constant [1 x i8] c"0", !type !0 +@g = dso_local constant [1 x i8] c"0", !type !0 + +define [1 x i8]* @f() { + ret [1 x i8]* @g +} + +!0 = !{i32 0, !"typeid"}