[llvm] [RISCV] Use 'riscv-isa' module flag to set ELF flags and attributes. (PR #85155)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 22:11:05 PDT 2024
================
@@ -385,8 +385,32 @@ void RISCVAsmPrinter::emitStartOfAsmFile(Module &M) {
if (const MDString *ModuleTargetABI =
dyn_cast_or_null<MDString>(M.getModuleFlag("target-abi")))
RTS.setTargetABI(RISCVABI::getTargetABI(ModuleTargetABI->getString()));
+
+ MCSubtargetInfo SubtargetInfo = *TM.getMCSubtargetInfo();
+
+ // Use module flag to update feature bits.
+ if (auto *MD = dyn_cast_or_null<MDNode>(M.getModuleFlag("riscv-isa"))) {
+ for (auto &ISA : MD->operands()) {
+ if (auto *ISAString = dyn_cast_or_null<MDString>(ISA)) {
+ auto ParseResult = llvm::RISCVISAInfo::parseArchString(
+ ISAString->getString(), /*EnableExperimentalExtension=*/true,
+ /*ExperimentalExtensionVersionCheck=*/true);
+ if (!errorToBool(ParseResult.takeError())) {
+ auto &ISAInfo = *ParseResult;
+ for (const auto &Feature : RISCVFeatureKV) {
+ if (ISAInfo->hasExtension(Feature.Key) &&
----------------
topperc wrote:
Is this blocking for this patch? We haven't had any way of detecting such an error in LTO for a long time now.
https://github.com/llvm/llvm-project/pull/85155
More information about the llvm-commits
mailing list