Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp =================================================================== --- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1480,11 +1480,10 @@ if (!AsmInfo.isSectionAtomizableBySymbols(Section)) return true; - // If it is not dead stripped, it is safe to use private labels. - const MCSectionMachO &SMO = cast(Section); - if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP)) - return true; - + // FIXME: we should be able to use private labels for sections that can't be + // dead-stripped (there's no issue with blocking atomization there), but `ld + // -r` sometimes drops the no_dead_strip attribute from sections so for safety + // we don't allow it. return false; } Index: llvm/test/CodeGen/X86/osx-private-labels.ll =================================================================== --- llvm/test/CodeGen/X86/osx-private-labels.ll +++ llvm/test/CodeGen/X86/osx-private-labels.ll @@ -73,7 +73,7 @@ @private13 = private global i32 42, section "__DATA, __objc_classlist, regular, no_dead_strip" ; CHECK: .section __DATA,__objc_classlist,regular,no_dead_strip ; CHECK-NEXT: .p2align 2 -; CHECK-NEXT: L_private13: +; CHECK-NEXT: _private13: @private14 = private global [4 x i8] c"zed\00", section "__TEXT,__objc_classname,cstring_literals" ; CHECK: .section __TEXT,__objc_classname,cstring_literals