Skip to content

Commit ecec190

Browse files
committed
fixup! [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain
1 parent 320061a commit ecec190

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,13 +1717,13 @@ static void findCSKYMultilibs(const Driver &D, const llvm::Triple &TargetTriple,
17171717
}
17181718

17191719
/// Extend the multi-lib re-use selection mechanism for RISC-V.
1720-
/// This funciton will try to re-use multi-lib if they are compatible.
1720+
/// This function will try to re-use multi-lib if they are compatible.
17211721
/// Definition of compatible:
17221722
/// - ABI must be the same.
17231723
/// - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
17241724
/// is a subset of march=rv32imc.
17251725
/// - march that contains atomic extension can't reuse multi-lib that
1726-
/// doesn't has atomic, vice versa. e.g. multi-lib=march=rv32im and
1726+
/// doesn't have atomic, vice versa. e.g. multi-lib=march=rv32im and
17271727
/// march=rv32ima are not compatible, because software and hardware
17281728
/// atomic operation can't work together correctly.
17291729
static bool
@@ -1734,21 +1734,20 @@ RISCVMultilibSelect(const MultilibSet &RISCVMultilibSet, StringRef Arch,
17341734
if (RISCVMultilibSet.select(Flags, SelectedMultilibs))
17351735
return true;
17361736

1737-
llvm::StringMap<bool> FlagSet;
17381737
Multilib::flags_list NewFlags;
17391738
std::vector<MultilibBuilder> NewMultilibs;
17401739

1741-
auto ParseResult = llvm::RISCVISAInfo::parseArchString(
1742-
Arch, /*EnableExperimentalExtension=*/true,
1743-
/*ExperimentalExtensionVersionCheck=*/false);
1740+
llvm::Expected<std::unique_ptr<llvm::RISCVISAInfo>> ParseResult =
1741+
llvm::RISCVISAInfo::parseArchString(
1742+
Arch, /*EnableExperimentalExtension=*/true,
1743+
/*ExperimentalExtensionVersionCheck=*/false);
17441744
if (!ParseResult) {
1745-
// Ignore any error here, we assume it will handled in another place.
1745+
// Ignore any error here, we assume it will be handled in another place.
17461746
consumeError(ParseResult.takeError());
17471747
return false;
17481748
}
1749-
auto &ISAInfo = *ParseResult;
17501749

1751-
auto CurrentExts = ISAInfo->getExtensions();
1750+
auto &ISAInfo = *ParseResult;
17521751

17531752
addMultilibFlag(ISAInfo->getXLen() == 32, "-m32", NewFlags);
17541753
addMultilibFlag(ISAInfo->getXLen() == 64, "-m64", NewFlags);
@@ -1762,7 +1761,7 @@ RISCVMultilibSelect(const MultilibSet &RISCVMultilibSet, StringRef Arch,
17621761
}
17631762

17641763
llvm::StringSet<> AllArchExts;
1765-
// Reconstruct multi-lib list, and break march option into seperated
1764+
// Reconstruct multi-lib list, and break march option into separated
17661765
// extension. e.g. march=rv32im -> +i +m
17671766
for (auto M : RISCVMultilibSet) {
17681767
bool Skip = false;
@@ -1777,21 +1776,23 @@ RISCVMultilibSelect(const MultilibSet &RISCVMultilibSet, StringRef Arch,
17771776
}
17781777

17791778
// Break down -march into individual extension.
1780-
auto MLConfigParseResult = llvm::RISCVISAInfo::parseArchString(
1781-
Flag.drop_front(7), /*EnableExperimentalExtension=*/true,
1782-
/*ExperimentalExtensionVersionCheck=*/false);
1779+
llvm::Expected<std::unique_ptr<llvm::RISCVISAInfo>> MLConfigParseResult =
1780+
llvm::RISCVISAInfo::parseArchString(
1781+
Flag.drop_front(7), /*EnableExperimentalExtension=*/true,
1782+
/*ExperimentalExtensionVersionCheck=*/false);
17831783
if (!MLConfigParseResult) {
17841784
// Ignore any error here, we assume it will handled in another place.
17851785
llvm::consumeError(MLConfigParseResult.takeError());
17861786

1787-
// We might got parsing error if rv32e in the list, we could just skip
1787+
// We might get parsing error if rv32e in the list, we could just skip
17881788
// that and process the rest of multi-lib configs.
17891789
Skip = true;
17901790
continue;
17911791
}
17921792
auto &MLConfigISAInfo = *MLConfigParseResult;
17931793

1794-
auto MLConfigArchExts = MLConfigISAInfo->getExtensions();
1794+
const llvm::RISCVISAInfo::OrderedExtensionMap &MLConfigArchExts =
1795+
MLConfigISAInfo->getExtensions();
17951796
for (auto MLConfigArchExt : MLConfigArchExts) {
17961797
auto ExtName = MLConfigArchExt.first;
17971798
NewMultilib.flag(Twine("-", ExtName).str());

clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
// Test case for scanning input of GCC output as multilib config
2-
// Skip this test on Windows, we can't create a dummy GCC to output
3-
// multilib config, ExecuteAndWait only execute *.exe file.
4-
// UNSUPPORTED: system-windows
5-
61
// RUN: %clang %s \
72
// RUN: -target riscv64-unknown-elf \
83
// RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \

0 commit comments

Comments
 (0)