Skip to content

Commit 73bb080

Browse files
authored
Merge pull request swiftlang#28659 from compnerd/tools-for-wasi
IRGen,Driver: extract tool usage into a variable (NFC)
2 parents 0585eb0 + e2d208d commit 73bb080

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

lib/Driver/Driver.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,9 +2043,12 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
20432043
for (const Action *A : AllLinkerInputs)
20442044
if (A->getType() == file_types::TY_Object)
20452045
AutolinkExtractInputs.push_back(A);
2046-
if (!AutolinkExtractInputs.empty() &&
2047-
(TC.getTriple().getObjectFormat() == llvm::Triple::ELF ||
2048-
TC.getTriple().isOSCygMing())) {
2046+
const auto &Triple = TC.getTriple();
2047+
const bool AutolinkExtractRequired =
2048+
(Triple.getObjectFormat() == llvm::Triple::ELF && !Triple.isPS4()) ||
2049+
Triple.getObjectFormat() == llvm::Triple::Wasm ||
2050+
Triple.isOSCygMing();
2051+
if (!AutolinkExtractInputs.empty() && AutolinkExtractRequired) {
20492052
auto *AutolinkExtractAction =
20502053
C.createAction<AutolinkExtractJobAction>(AutolinkExtractInputs);
20512054
// Takes the same inputs as the linker...
@@ -2055,8 +2058,9 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
20552058

20562059
if (MergeModuleAction) {
20572060
if (OI.DebugInfoLevel == IRGenDebugInfoLevel::Normal) {
2058-
if (TC.getTriple().getObjectFormat() == llvm::Triple::ELF ||
2059-
TC.getTriple().getObjectFormat() == llvm::Triple::COFF) {
2061+
const bool ModuleWrapRequired =
2062+
Triple.getObjectFormat() != llvm::Triple::MachO;
2063+
if (ModuleWrapRequired) {
20602064
auto *ModuleWrapAction =
20612065
C.createAction<ModuleWrapJobAction>(MergeModuleAction);
20622066
LinkAction->addInput(ModuleWrapAction);

lib/IRGen/IRGenModule.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,21 +1153,17 @@ void IRGenModule::emitAutolinkInfo() {
11531153
}),
11541154
AutolinkEntries.end());
11551155

1156-
if ((TargetInfo.OutputObjectFormat == llvm::Triple::COFF &&
1157-
!Triple.isOSCygMing()) ||
1158-
TargetInfo.OutputObjectFormat == llvm::Triple::MachO || Triple.isPS4()) {
1156+
const bool AutolinkExtractRequired =
1157+
(TargetInfo.OutputObjectFormat == llvm::Triple::ELF && !Triple.isPS4()) ||
1158+
TargetInfo.OutputObjectFormat == llvm::Triple::Wasm ||
1159+
Triple.isOSCygMing();
11591160

1161+
if (!AutolinkExtractRequired) {
11601162
// On platforms that support autolinking, continue to use the metadata.
11611163
Metadata->clearOperands();
11621164
for (auto *Entry : AutolinkEntries)
11631165
Metadata->addOperand(Entry);
1164-
11651166
} else {
1166-
assert((TargetInfo.OutputObjectFormat == llvm::Triple::ELF ||
1167-
TargetInfo.OutputObjectFormat == llvm::Triple::Wasm ||
1168-
Triple.isOSCygMing()) &&
1169-
"expected ELF output format or COFF format for Cygwin/MinGW");
1170-
11711167
// Merge the entries into null-separated string.
11721168
llvm::SmallString<64> EntriesString;
11731169
for (auto &EntryNode : AutolinkEntries) {

0 commit comments

Comments
 (0)