Skip to content

Commit 636564e

Browse files
committed
IRGen: collocate WASM/ELF handling
WASM currently is treated identically to the ELF paths. Collocate the types to make it easier to ensure that all the paths are correctly handling the emission. This adds the missed case for the module hash.
1 parent 01f46b3 commit 636564e

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,12 +905,11 @@ std::string IRGenModule::GetObjCSectionName(StringRef Section,
905905
? ("__DATA," + Section).str()
906906
: ("__DATA," + Section + "," + MachOAttributes).str();
907907
case llvm::Triple::ELF:
908+
case llvm::Triple::Wasm:
908909
return Section.substr(2).str();
909910
case llvm::Triple::XCOFF:
910911
case llvm::Triple::COFF:
911912
return ("." + Section.substr(2) + "$B").str();
912-
case llvm::Triple::Wasm:
913-
return Section.substr(2).str();
914913
}
915914

916915
llvm_unreachable("unexpected object file format");
@@ -937,12 +936,11 @@ void IRGenModule::SetCStringLiteralSection(llvm::GlobalVariable *GV,
937936
return;
938937
}
939938
case llvm::Triple::ELF:
939+
case llvm::Triple::Wasm:
940940
return;
941941
case llvm::Triple::XCOFF:
942942
case llvm::Triple::COFF:
943943
return;
944-
case llvm::Triple::Wasm:
945-
return;
946944
}
947945

948946
llvm_unreachable("unexpected object file format");

lib/IRGen/GenMeta.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,13 @@ void IRGenModule::setTrueConstGlobal(llvm::GlobalVariable *var) {
113113
var->setSection("__TEXT,__const");
114114
break;
115115
case llvm::Triple::ELF:
116+
case llvm::Triple::Wasm:
116117
var->setSection(".rodata");
117118
break;
118119
case llvm::Triple::XCOFF:
119120
case llvm::Triple::COFF:
120121
var->setSection(".rdata");
121122
break;
122-
case llvm::Triple::Wasm:
123-
var->setSection(".rodata");
124-
break;
125123
}
126124
}
127125

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@ bool IRGenModule::finalize() {
12691269
ModuleHash->setSection("__LLVM,__swift_modhash");
12701270
break;
12711271
case llvm::Triple::ELF:
1272+
case llvm::Triple::Wasm:
12721273
ModuleHash->setSection(".swift_modhash");
12731274
break;
12741275
case llvm::Triple::COFF:

0 commit comments

Comments
 (0)