Skip to content

Commit 54957e6

Browse files
committed
IRGen: Backport workaround for rdar://problem/53836960
The Swift 5.1 version of LLVM miscompiles relative references to lazy_ptr symbols for symbols defined in the same translation unit. Work around that by making GOT equivalents not appear as GOT equivalents to the backend by withholding `unnamed_addr`. Speculative fix for rdar://problem/55082864
1 parent e50d21e commit 54957e6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,13 +2562,22 @@ static llvm::GlobalVariable *createGOTEquivalent(IRGenModule &IGM,
25622562
// rdar://problem/50968433: Unnamed_addr constants appear to get emitted
25632563
// with incorrect alignment by the LLVM JIT in some cases. Don't use
25642564
// unnamed_addr as a workaround.
2565-
if (!IGM.getOptions().UseJIT) {
2565+
// rdar://problem/53836960: LLVM miscompiles relative references to local
2566+
// symbols.
2567+
if (!IGM.getOptions().UseJIT
2568+
&& (!IGM.Triple.isOSDarwin()
2569+
|| (IGM.Triple.getArch() != llvm::Triple::x86 &&
2570+
IGM.Triple.getArchName() != "armv7" &&
2571+
IGM.Triple.getArchName() != "armv7s" &&
2572+
IGM.Triple.getArchName() != "thumbv7" &&
2573+
IGM.Triple.getArchName() != "thumbv7s" &&
2574+
!IGM.Triple.isWatchABI()))) {
25662575
gotEquivalent->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
25672576
} else {
25682577
ApplyIRLinkage(IRLinkage::InternalLinkOnceODR)
25692578
.to(gotEquivalent);
25702579
}
2571-
2580+
25722581
return gotEquivalent;
25732582
}
25742583

0 commit comments

Comments
 (0)