Index: lib/Transforms/Utils/FunctionImportUtils.cpp =================================================================== --- lib/Transforms/Utils/FunctionImportUtils.cpp +++ lib/Transforms/Utils/FunctionImportUtils.cpp @@ -64,6 +64,11 @@ if (GVar && GVar->isConstant() && GVar->hasUnnamedAddr()) return false; + if (GVar && GVar->hasSection()) + // Some sections like "__DATA,__cfstring" are "magic" and promotion is not + // allowed. Just disable promotion on any GVar with sections right now. + return false; + // Eventually we only need to promote functions in the exporting module that // are referenced by a potentially exported function (i.e. one that is in the // summary index). Index: test/ThinLTO/X86/section.ll =================================================================== --- /dev/null +++ test/ThinLTO/X86/section.ll @@ -0,0 +1,12 @@ +; Do setup work for all below tests: generate bitcode and combined index +; RUN: llvm-as -module-summary %s -o %t.bc +; RUN: llvm-lto -thinlto-action=thinlink -o %t2.bc %t.bc +; RUN: llvm-lto -thinlto-action=promote -thinlto-index %t2.bc %t.bc -o - | llvm-dis | FileCheck %s + +; CHECK: @private = private constant %struct.NSConstantString + +%struct.NSConstantString = type { i32*, i32, i8*, i32 } +@private = private constant %struct.NSConstantString { i32* null, i32 1992, i8* null, i32 0 }, section "__DATA,__cfstring" +define void @foo() { + ret void +} \ No newline at end of file