Skip to content

Commit 3f198ad

Browse files
committed
Merge pull request #2888 from compnerd/metadata
IRGen: address a TODO in the type metadata emission
2 parents 24988f8 + dcbeb01 commit 3f198ad

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,11 +1989,16 @@ llvm::Value *IRGenFunction::emitTypeLayoutRef(SILType type) {
19891989

19901990
void IRGenModule::setTrueConstGlobal(llvm::GlobalVariable *var) {
19911991
switch (TargetInfo.OutputObjectFormat) {
1992+
case llvm::Triple::UnknownObjectFormat:
1993+
llvm_unreachable("unknown object format");
19921994
case llvm::Triple::MachO:
1993-
var->setSection("__TEXT, __const");
1995+
var->setSection("__TEXT,__const");
19941996
break;
1995-
// TODO: ELF?
1996-
default:
1997+
case llvm::Triple::ELF:
1998+
var->setSection(".rodata");
1999+
break;
2000+
case llvm::Triple::COFF:
2001+
var->setSection(".rdata");
19972002
break;
19982003
}
19992004
}

test/IRGen/nominal-type-section.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %swift -target x86_64-apple-macosx10.10 -emit-ir -parse-stdlib -primary-file %s -module-name main -o - | FileCheck %s -check-prefix CHECK-MACHO
2+
// RUN: %swift -target x86_64-unknown-linux-gnu -emit-ir -parse-stdlib -primary-file %s -module-name main -o - | FileCheck %s -check-prefix CHECK-ELF
3+
// RUN: %swift -target x86_64-unknown-windows-itanium -emit-ir -parse-stdlib -primary-file %s -module-name main -o - | FileCheck %s -check-prefix CHECK-COFF
4+
5+
// CHECK-MACHO: @_TMnV4main1s = constant {{.*}}, section "__TEXT,__const"
6+
// CHECK-ELF: @_TMnV4main1s = {{.*}}constant {{.*}}, section ".rodata"
7+
// CHECK-COFF: @_TMnV4main1s = {{.*}}constant {{.*}}, section ".rdata"
8+
9+
public struct s {
10+
}
11+

0 commit comments

Comments
 (0)