Skip to content

Commit fef958d

Browse files
committed
SILGen: Use public_external linkage for __dso_handle instead of hidden_external
This allows it to be referenced from inlinable functions. Fixes <rdar://problem/32597278>.
1 parent 54423c7 commit fef958d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2927,7 +2927,7 @@ visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, SGFContext C) {
29272927
auto DSOGlobal = SGF.SGM.M.lookUpGlobalVariable("__dso_handle");
29282928
if (!DSOGlobal)
29292929
DSOGlobal = SILGlobalVariable::create(SGF.SGM.M,
2930-
SILLinkage::HiddenExternal,
2930+
SILLinkage::PublicExternal,
29312931
IsNotSerialized, "__dso_handle",
29322932
BuiltinRawPtrTy);
29332933
auto DSOAddr = SGF.B.createGlobalAddr(SILLoc, DSOGlobal);

test/SILGen/dso_handle.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s | %FileCheck %s
22

3-
// CHECK: sil_global hidden_external [[DSO:@__dso_handle]] : $Builtin.RawPointer
3+
// CHECK: sil_global [[DSO:@__dso_handle]] : $Builtin.RawPointer
44

55
// CHECK-LABEL: sil @main : $@convention(c)
66
// CHECK: bb0
@@ -13,4 +13,12 @@ func printDSOHandle(dso: UnsafeRawPointer = #dsohandle) -> UnsafeRawPointer {
1313
return dso
1414
}
1515

16+
@_inlineable public func printDSOHandleInlineable(dso: UnsafeRawPointer = #dsohandle) -> UnsafeRawPointer {
17+
return dso
18+
}
19+
20+
@_inlineable public func callsPrintDSOHandleInlineable() {
21+
printDSOHandleInlineable()
22+
}
23+
1624
_ = printDSOHandle()

0 commit comments

Comments
 (0)