[llvm] [llvm] Fix the MCSubtargetInfo used for module-level assembly. (PR #97685)
Chris Copeland via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 4 00:22:24 PDT 2024
https://github.com/chrisnc created https://github.com/llvm/llvm-project/pull/97685
Provide both the default target CPU and default target features from the
module's context, rather than empty strings.
Fixes #61991.
>From e4346340b94512978fdd4b9aa6c45c23ac65acab Mon Sep 17 00:00:00 2001
From: Chris Copeland <chris at chrisnc.net>
Date: Thu, 4 Jul 2024 00:03:28 -0700
Subject: [PATCH] [llvm] Fix the MCSubtargetInfo used for module-level
assembly.
Provide both the default target CPU and default target features from the
module's context, rather than empty strings.
Fixes #61991.
---
llvm/lib/Object/ModuleSymbolTable.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp
index d8f520ad02c2f..079c33c801f6e 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -22,6 +22,7 @@
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/InlineAsm.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
@@ -92,8 +93,11 @@ initializeRecordStreamer(const Module &M,
if (!MAI)
return;
+ LLVMContext &Context = M.getContext();
+
std::unique_ptr<MCSubtargetInfo> STI(
- T->createMCSubtargetInfo(TT.str(), "", ""));
+ T->createMCSubtargetInfo(TT.str(), Context.getDefaultTargetCPU(),
+ Context.getDefaultTargetFeatures()));
if (!STI)
return;
More information about the llvm-commits
mailing list