https://github.com/chrisnc updated https://github.com/llvm/llvm-project/pull/97685
>From 6019e4723fe8c3bf17f4c0c54c22e9f854f2459e Mon Sep 17 00:00:00 2001 From: Chris Copeland <[email protected]> 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. --- clang/test/CodeGen/module-asm-fp.ll | 14 ++++++++++++++ llvm/lib/Object/ModuleSymbolTable.cpp | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/module-asm-fp.ll diff --git a/clang/test/CodeGen/module-asm-fp.ll b/clang/test/CodeGen/module-asm-fp.ll new file mode 100644 index 0000000000000..16637b37e4846 --- /dev/null +++ b/clang/test/CodeGen/module-asm-fp.ll @@ -0,0 +1,14 @@ +; REQUIRES: arm-registered-target + +; Check that module-level asm with FP instructions works when the target +; features are not implied by the architecture. + +; RUN: %clang_cc1 -triple armv7r-unknown-none-eabi -target-feature +vfp4 -emit-llvm-bc %s -o %t.o + +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv7r-unknown-none-eabi" + +module asm ".globl fp_add" +module asm "fp_add:" +module asm "vadd.f32 s0, s0, s1" +module asm "bx lr" diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp index 9442becdb7d33..e030f8777847f 100644 --- a/llvm/lib/Object/ModuleSymbolTable.cpp +++ b/llvm/lib/Object/ModuleSymbolTable.cpp @@ -21,6 +21,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" @@ -90,7 +91,10 @@ initializeRecordStreamer(const Module &M, if (!MAI) return; - std::unique_ptr<MCSubtargetInfo> STI(T->createMCSubtargetInfo(TT, "", "")); + LLVMContext &Context = M.getContext(); + + std::unique_ptr<MCSubtargetInfo> STI(T->createMCSubtargetInfo( + TT, Context.getDefaultTargetCPU(), Context.getDefaultTargetFeatures())); if (!STI) return; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
