llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Hans Wennborg (zmodem)

<details>
<summary>Changes</summary>

Reverts llvm/llvm-project#<!-- -->204548

This is causing the runtimes build to fail with e.g.:

```
&lt;inline asm&gt;:11:5: error: 32 bit reloc applied to a field with a 
different size
   11 | jmp __interceptor_strlen@<!-- -->plt
      |     ^
```

See comments on the PR.

---

Patch is 56.65 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/207399.diff


59 Files Affected:

- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+5-1) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-7) 
- (modified) clang/test/CodeGen/2006-01-23-FileScopeAsm.c (+6-11) 
- (modified) clang/test/CodeGen/asm.c (+3-4) 
- (modified) clang/test/CodeGen/asm_incbin.c (+1-2) 
- (modified) clang/test/CodeGen/cfi-salt.c (+5-6) 
- (modified) clang/test/CodeGen/kcfi.c (+3-4) 
- (modified) clang/test/CodeGenCUDA/filter-decl.cu (+2-3) 
- (modified) clang/test/CodeGenCXX/gnu-asm-constexpr.cpp (+1-2) 
- (modified) clang/test/CodeGenObjC/category-class.m (+3-4) 
- (modified) clang/test/CodeGenObjC/objc-runtime-name.m (+3-4) 
- (modified) clang/test/Frontend/ast-codegen.c (+1-2) 
- (modified) clang/test/Modules/codegen.test (+1-2) 
- (modified) llvm/docs/LangRef.rst (+6-21) 
- (modified) llvm/docs/ReleaseNotes.md (-4) 
- (modified) llvm/include/llvm/Bitcode/LLVMBitCodes.h (-2) 
- (modified) llvm/include/llvm/CodeGen/AsmPrinter.h (-13) 
- (modified) llvm/include/llvm/IR/Module.h (+11-85) 
- (modified) llvm/lib/AsmParser/LLParser.cpp (+3-36) 
- (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+1-16) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+3-13) 
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+6-22) 
- (modified) llvm/lib/IR/AsmWriter.cpp (+13-30) 
- (modified) llvm/lib/IR/Core.cpp (+1-12) 
- (modified) llvm/lib/IR/Module.cpp (-20) 
- (modified) llvm/lib/LTO/LTO.cpp (+2-2) 
- (modified) llvm/lib/Linker/IRMover.cpp (+3-6) 
- (modified) llvm/lib/Object/ModuleSymbolTable.cpp (+44-46) 
- (modified) llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp (+9-14) 
- (modified) llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/ExtractGV.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+12-14) 
- (modified) llvm/lib/Transforms/Utils/SplitModule.cpp (+1-1) 
- (removed) llvm/test/Assembler/module-asm-invalid.ll (-25) 
- (modified) llvm/test/Bitcode/compatibility-3.6.ll (+1-2) 
- (modified) llvm/test/Bitcode/compatibility-3.7.ll (+1-2) 
- (modified) llvm/test/Bitcode/compatibility-3.8.ll (+1-2) 
- (modified) llvm/test/Bitcode/compatibility-3.9.ll (+1-2) 
- (modified) llvm/test/Bitcode/compatibility-4.0.ll (+1-2) 
- (modified) llvm/test/Bitcode/compatibility-5.0.ll (+1-2) 
- (modified) llvm/test/Bitcode/compatibility-6.0.ll (+1-2) 
- (modified) llvm/test/Bitcode/compatibility.ll (+1-2) 
- (modified) llvm/test/Bitcode/highLevelStructure.3.2.ll (+1-2) 
- (removed) llvm/test/Bitcode/module-asm.ll (-29) 
- (removed) llvm/test/CodeGen/RISCV/module-asm-features.ll (-17) 
- (modified) llvm/test/Instrumentation/DataFlowSanitizer/prefix-rename.ll 
(+1-2) 
- (removed) llvm/test/LTO/RISCV/module-asm.ll (-18) 
- (modified) llvm/test/LTO/X86/inline-asm-lto-discard.ll (+11-13) 
- (removed) llvm/test/Linker/Inputs/module-asm.ll (-2) 
- (modified) llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll (+8-9) 
- (removed) llvm/test/Linker/module-asm.ll (-9) 
- (modified) llvm/test/ThinLTO/X86/import-symver.ll (+1-2) 
- (modified) llvm/test/Transforms/LowerTypeTests/export-symver.ll (+1-2) 
- (modified) 
llvm/test/Transforms/ThinLTOBitcodeWriter/cfi-icall-static-inline-asm.ll (+1-2) 
- (modified) llvm/test/Transforms/ThinLTOBitcodeWriter/x86/module-asm.ll (+1-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp (+1-1) 
- (modified) mlir/lib/Target/LLVMIR/ModuleImport.cpp (+4-7) 
- (modified) mlir/test/Target/LLVMIR/module-asm.mlir (+2-3) 


``````````diff
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index e518b875f44bb..69c5e88f3c768 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -6610,6 +6610,10 @@ void CGObjCMac::FinishModule() {
   if ((!LazySymbols.empty() || !DefinedSymbols.empty()) &&
       CGM.getTriple().isOSBinFormatMachO()) {
     SmallString<256> Asm;
+    Asm += CGM.getModule().getModuleInlineAsm();
+    if (!Asm.empty() && Asm.back() != '\n')
+      Asm += '\n';
+
     llvm::raw_svector_ostream OS(Asm);
     for (const auto *Sym : DefinedSymbols)
       OS << "\t.objc_class_name_" << Sym->getName() << "=0\n"
@@ -6620,7 +6624,7 @@ void CGObjCMac::FinishModule() {
       OS << "\t.objc_category_name_" << Category << "=0\n"
          << "\t.globl .objc_category_name_" << Category << "\n";
 
-    CGM.getModule().appendModuleInlineAsm(OS.str());
+    CGM.getModule().setModuleInlineAsm(OS.str());
   }
 }
 
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index e155fdd752d7f..813cd67e4dd51 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -8057,13 +8057,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     if (LangOpts.SYCLIsDevice)
       break;
     auto *AD = cast<FileScopeAsmDecl>(D);
-
-    const TargetOptions &TargetOpts = getTarget().getTargetOpts();
-    llvm::Module::GlobalAsmProperties Props;
-    Props.TargetFeatures = llvm::join(TargetOpts.Features, ",");
-    Props.TargetCPU = TargetOpts.CPU;
-    getModule().appendModuleInlineAsm(
-        llvm::Module::GlobalAsmFragment(AD->getAsmString(), Props));
+    getModule().appendModuleInlineAsm(AD->getAsmString());
     break;
   }
 
diff --git a/clang/test/CodeGen/2006-01-23-FileScopeAsm.c 
b/clang/test/CodeGen/2006-01-23-FileScopeAsm.c
index 8a212a0b61905..877da4fc669e3 100644
--- a/clang/test/CodeGen/2006-01-23-FileScopeAsm.c
+++ b/clang/test/CodeGen/2006-01-23-FileScopeAsm.c
@@ -1,18 +1,13 @@
 // UNSUPPORTED: target={{.*}}-zos{{.*}}
-// RUN: %clang_cc1 %s -triple=riscv64 -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,RISCV64
-// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +d -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,RISCV64-D
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,DEFAULT
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
 
-// RISCV64: module asm(target_features: "+64bit,+i")
-// RISCV64-D: module asm(target_features: "+64bit,+d,+f,+i,+zicsr")
-// DEFAULT: module asm
-// CHECK-NEXT: "foo1"
+// CHECK: module asm "foo1"
 __asm__ ("foo1");
-// CHECK-NEXT: "foo2"
+// CHECK: module asm "foo2"
 __asm__ ("foo2");
-// CHECK-NEXT: "foo3"
+// CHECK: module asm "foo3"
 __asm__ ("foo3");
-// CHECK-NEXT: "foo4"
+// CHECK: module asm "foo4"
 __asm__ ("foo4");
-// CHECK-NEXT: "foo5"
+// CHECK: module asm "foo5"
 __asm__ ("foo5");
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
index ea69c7a17d1cb..d7465b22fbbf6 100644
--- a/clang/test/CodeGen/asm.c
+++ b/clang/test/CodeGen/asm.c
@@ -2,10 +2,9 @@
 
 // PR10415:
 //
-// CHECK: module asm(target_features: "{{.*}}")
-// CHECK-NEXT: "foo1"
-// CHECK-NEXT: "foo2"
-// CHECK-NEXT: "foo3"
+// CHECK:      module asm "foo1"
+// CHECK-NEXT: module asm "foo2"
+// CHECK-NEXT: module asm "foo3"
 __asm__ ("foo1");
 __asm__ ("foo2");
 __asm__ ("foo3");
diff --git a/clang/test/CodeGen/asm_incbin.c b/clang/test/CodeGen/asm_incbin.c
index bbc5d3af55ea2..6234eea1d6738 100644
--- a/clang/test/CodeGen/asm_incbin.c
+++ b/clang/test/CodeGen/asm_incbin.c
@@ -6,5 +6,4 @@ asm(".incbin \"foo.h\"");
 // RUN: cd %t
 // RUN: %clang -c -emit-llvm %t/tu.c -o %t/tu.ll
 // RUN: llvm-dis %t/tu.ll -o - | FileCheck %s
-// CHECK: module asm
-// CHECK-NEXT: ".incbin \22foo.h\22"
+// CHECK: module asm ".incbin \22foo.h\22"
diff --git a/clang/test/CodeGen/cfi-salt.c b/clang/test/CodeGen/cfi-salt.c
index 18156dc014280..2a90dc31d939b 100644
--- a/clang/test/CodeGen/cfi-salt.c
+++ b/clang/test/CodeGen/cfi-salt.c
@@ -26,14 +26,13 @@ typedef unsigned int (*ufn_t)(void);
 typedef unsigned int (* __cfi_salt ufn_salt_t)(void);
 
 /// Must emit __kcfi_typeid symbols for address-taken function declarations
-// CHECK: module asm
-// CHECK-NEXT: ".weak __kcfi_typeid_[[F4:[a-zA-Z0-9_]+]]"
-// CHECK-NEXT: ".set __kcfi_typeid_[[F4]], {{[0-9]+}} /* 
[[#%d,LOW_SODIUM_HASH:]] */"
-// CHECK-NEXT: ".weak __kcfi_typeid_[[F4_SALT:[a-zA-Z0-9_]+]]"
-// CHECK-NEXT: ".set __kcfi_typeid_[[F4_SALT]], {{[0-9]+}} /* 
[[#%d,ASM_SALTY_HASH:]] */"
+// CHECK: module asm ".weak __kcfi_typeid_[[F4:[a-zA-Z0-9_]+]]"
+// CHECK: module asm ".set __kcfi_typeid_[[F4]], {{[0-9]+}} /* 
[[#%d,LOW_SODIUM_HASH:]] */"
+// CHECK: module asm ".weak __kcfi_typeid_[[F4_SALT:[a-zA-Z0-9_]+]]"
+// CHECK: module asm ".set __kcfi_typeid_[[F4_SALT]], {{[0-9]+}} /* 
[[#%d,ASM_SALTY_HASH:]] */"
 
 /// Must not __kcfi_typeid symbols for non-address-taken declarations
-// CHECK-NOT: ".weak __kcfi_typeid_f6"
+// CHECK-NOT: module asm ".weak __kcfi_typeid_f6"
 
 int f1(void);
 int f1_salt(void) __cfi_salt;
diff --git a/clang/test/CodeGen/kcfi.c b/clang/test/CodeGen/kcfi.c
index f08cf7635fb5a..da32859dd3d88 100644
--- a/clang/test/CodeGen/kcfi.c
+++ b/clang/test/CodeGen/kcfi.c
@@ -6,11 +6,10 @@
 #endif
 
 /// Must emit __kcfi_typeid symbols for address-taken function declarations
-// CHECK: module asm
-// CHECK-NEXT: ".weak __kcfi_typeid_[[F4:[a-zA-Z0-9_]+]]"
-// CHECK-NEXT: ".set __kcfi_typeid_[[F4]], {{[0-9]+}} /* [[#%d,HASH:]] */"
+// CHECK: module asm ".weak __kcfi_typeid_[[F4:[a-zA-Z0-9_]+]]"
+// CHECK: module asm ".set __kcfi_typeid_[[F4]], {{[0-9]+}} /* [[#%d,HASH:]] 
*/"
 /// Must not __kcfi_typeid symbols for non-address-taken declarations
-// CHECK-NOT: ".weak __kcfi_typeid_{{f6|_Z2f6v}}"
+// CHECK-NOT: module asm ".weak __kcfi_typeid_{{f6|_Z2f6v}}"
 
 // C: @ifunc1 = ifunc i32 (i32), ptr @resolver1
 // C: @ifunc2 = ifunc i64 (i64), ptr @resolver2
diff --git a/clang/test/CodeGenCUDA/filter-decl.cu 
b/clang/test/CodeGenCUDA/filter-decl.cu
index f87d62a56631e..02dacd0ad8ef4 100644
--- a/clang/test/CodeGenCUDA/filter-decl.cu
+++ b/clang/test/CodeGenCUDA/filter-decl.cu
@@ -5,9 +5,8 @@
 
 // This has to be at the top of the file as that's where file-scope
 // asm ends up.
-// CHECK-HOST: module asm
-// CHECK-HOST-NEXT: "file scope asm is host only"
-// CHECK-DEVICE-NOT: "file scope asm is host only"
+// CHECK-HOST: module asm "file scope asm is host only"
+// CHECK-DEVICE-NOT: module asm "file scope asm is host only"
 __asm__("file scope asm is host only");
 
 // CHECK-HOST: constantdata = internal global
diff --git a/clang/test/CodeGenCXX/gnu-asm-constexpr.cpp 
b/clang/test/CodeGenCXX/gnu-asm-constexpr.cpp
index 2b4abee5dc05f..175a3b7bc588c 100644
--- a/clang/test/CodeGenCXX/gnu-asm-constexpr.cpp
+++ b/clang/test/CodeGenCXX/gnu-asm-constexpr.cpp
@@ -19,8 +19,7 @@ struct string_view {
 namespace GH143242 {
     constexpr string_view code2 = R"(nop; nop; nop; nop)";
     asm((code2));
-    // CHECK: module asm(target_features: "{{.*}}")
-    // CHECK-NEXT: "nop; nop; nop; nop"
+    // CHECK: module asm "nop; nop; nop; nop"
 }
 
 int func() {return 0;};
diff --git a/clang/test/CodeGenObjC/category-class.m 
b/clang/test/CodeGenObjC/category-class.m
index febe94ce5b9f5..92fd36cbe4066 100644
--- a/clang/test/CodeGenObjC/category-class.m
+++ b/clang/test/CodeGenObjC/category-class.m
@@ -1,10 +1,9 @@
 // RUN: %clang_cc1 -triple i386-apple-darwin9 
-fobjc-runtime=macosx-fragile-10.5  -emit-llvm -o - %s | FileCheck %s
 // PR7431
 
-// CHECK: module asm
-// CHECK-NEXT: "\09.lazy_reference .objc_class_name_A"
-// CHECK-NEXT: "\09.objc_category_name_A_foo=0"
-// CHECK-NEXT: "\09.globl .objc_category_name_A_foo"
+// CHECK: module asm "\09.lazy_reference .objc_class_name_A"
+// CHECK: module asm "\09.objc_category_name_A_foo=0"
+// CHECK: module asm "\09.globl .objc_category_name_A_foo"
 
 @interface A
 @end
diff --git a/clang/test/CodeGenObjC/objc-runtime-name.m 
b/clang/test/CodeGenObjC/objc-runtime-name.m
index a7f59caced390..c838b8c2c6f1a 100644
--- a/clang/test/CodeGenObjC/objc-runtime-name.m
+++ b/clang/test/CodeGenObjC/objc-runtime-name.m
@@ -3,10 +3,9 @@
 // Check that the runtime name is emitted and used instead of the class
 // identifier.
 
-// CHECK: module asm
-// CHECK-NEXT: {{.*}}objc_class_name_XYZ=0
-// CHECK-NEXT: {{.*}}globl .objc_class_name_XYZ
-// CHECK-NEXT: {{.*}}lazy_reference .objc_class_name_XYZ
+// CHECK: module asm {{.*}}objc_class_name_XYZ=0
+// CHECK: module asm {{.*}}globl .objc_class_name_XYZ
+// CHECK: module asm {{.*}}lazy_reference .objc_class_name_XYZ
 
 // CHECK: @[[OBJC_CLASS_NAME:.*]] = private unnamed_addr constant [4 x i8] 
c"XYZ{{.*}}, section "__TEXT,__cstring,cstring_literals",
 // CHECK: = private global {{.*}} @[[OBJC_CLASS_NAME]], section 
"__OBJC,__cls_refs,literal_pointers,no_dead_strip"
diff --git a/clang/test/Frontend/ast-codegen.c 
b/clang/test/Frontend/ast-codegen.c
index c26b0a1908379..2e2e3d360dd17 100644
--- a/clang/test/Frontend/ast-codegen.c
+++ b/clang/test/Frontend/ast-codegen.c
@@ -2,8 +2,7 @@
 // RUN: %clang -target i386-unknown-unknown -emit-ast -o %t.ast %s
 // RUN: %clang -target i386-unknown-unknown -emit-llvm -S -o - %t.ast | 
FileCheck %s
 
-// CHECK: module asm(target_features: "{{.*}}")
-// CHECK-NEXT: "foo"
+// CHECK: module asm "foo"
 __asm__("foo");
 
 // CHECK: @g0 = dso_local global i32 0, align 4
diff --git a/clang/test/Modules/codegen.test b/clang/test/Modules/codegen.test
index 5cc5b3c1cda2a..0af630a754805 100644
--- a/clang/test/Modules/codegen.test
+++ b/clang/test/Modules/codegen.test
@@ -18,8 +18,7 @@ was implemented to workaround/support the initialization of 
iostreams
 (implemented as a namespace scope static in the header - only to be provided
 when that specific header is included in the program).
 
-BOTH: module asm
-BOTH-NEXT: "narf"
+BOTH: module asm "narf"
 
 FOO: $_Z2f1PKcz = comdat any
 FOO: $_ZN13implicit_dtorD1Ev = comdat any
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2c8276d04b668..5ce6019660e0b 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -3357,34 +3357,19 @@ Module-Level Inline Assembly
 ----------------------------
 
 Modules may contain "module-level inline asm" blocks, which corresponds
-to the GCC "file scope inline asm" blocks:
+to the GCC "file scope inline asm" blocks. These blocks are internally
+concatenated by LLVM and treated as a single unit, but may be separated
+in the ``.ll`` file if desired. The syntax is very simple:
 
 .. code-block:: llvm
 
-    module asm
-        "inline asm code goes here"
-        "more can go here"
+    module asm "inline asm code goes here"
+    module asm "more can go here"
 
-The sequence of string literals is internally concatenated using newlines as
-separators. The strings can contain any character by escaping non-printable
+The strings can contain any character by escaping non-printable
 characters. The escape sequence used is simply "\\xx" where "xx" is the
 two digit hex code for the number.
 
-Additionally, module-level inline assembly can specify an optional list of
-properties:
-
-.. code-block:: llvm
-
-    module asm(target_features: "+foo", target_cpu: "bar")
-        "inline asm code goes here"
-        "more can go here"
-
-Currently, the only supported properties are ``target_features`` and
-``target_cpu``, with the same meaning as the ``"target-features"`` and
-``"target-cpu"`` function attributes.
-
-Consecutive blocks with identical properties will be concatenated into one.
-
 Note that the assembly string *must* be parseable by LLVM's integrated 
assembler
 (unless it is disabled), even when emitting a ``.s`` file.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index cbec4d5b912d0..e42a959ab3101 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -111,10 +111,6 @@ Makes programs 10x faster by doing Special New Thing.
   corresponding metadata) now apply only at the point of definition, instead of
   for the execution of the function (for arguments) or forever (for returns).
 
-* Module-level inline assembly now accepts optional `target_features` and
-  `target_cpu` properties. This resolves errors during LTO on some
-  architectures.
-
 ### Changes to LLVM infrastructure
 
 * Removed ``Constant::isZeroValue``. It was functionally identical to
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h 
b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 1761e7a542a73..af4cac996a78c 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -120,8 +120,6 @@ enum ModuleCodes {
 
   // IFUNC: [ifunc value type, addrspace, resolver val#, linkage, visibility]
   MODULE_CODE_IFUNC = 18,
-
-  MODULE_CODE_ASM_PROPERTY = 19, // [strchr x N]
 };
 
 /// PARAMATTR blocks have code for defining a parameter attribute set.
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h 
b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 335bf9de9a071..78e64440657cc 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -930,19 +930,6 @@ class LLVM_ABI AsmPrinter : public MachineFunctionPass {
                                 const MCSubtargetInfo *EndInfo,
                                 const MachineInstr *MI);
 
-  /// Emit necessary directives to allow use of instructions that are permitted
-  /// by target features enabled by STI, but are not permitted by target
-  /// features enabled by the global subtarget (TM.getSubTargetInfo()).
-  /// Returns whether anything was emitted.
-  virtual bool emitTargetFeaturePush(const MCSubtargetInfo &STI) {
-    return false;
-  }
-
-  /// Emit necessary directives to restore target feature state.
-  /// The \p DidPush argument is the result of the prior 
emitTargetFeaturePush()
-  /// call.
-  virtual void emitTargetFeaturePop(const MCSubtargetInfo &STI, bool DidPush) 
{}
-
   /// This emits visibility information about symbol, if this is supported by
   /// the target.
   void emitVisibility(MCSymbol *Sym, unsigned Visibility,
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 63d1013896b47..4f7e33969f16f 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -169,45 +169,6 @@ class LLVM_ABI Module {
         : Behavior(B), Key(K), Val(V) {}
   };
 
-  struct GlobalAsmProperties {
-    std::string TargetFeatures;
-    std::string TargetCPU;
-
-    /// Set a property using a string name.
-    /// Returns whether the property name was valid.
-    LLVM_ABI bool set(StringRef Name, std::string Value);
-
-    /// Get a list of set properties as pairs of key and value.
-    LLVM_ABI SmallVector<std::pair<StringRef, StringRef>> getAsStrings() const;
-
-    bool operator==(const GlobalAsmProperties &Other) const {
-      return TargetFeatures == Other.TargetFeatures &&
-             TargetCPU == Other.TargetCPU;
-    }
-
-    bool operator!=(const GlobalAsmProperties &Other) const {
-      return !(*this == Other);
-    }
-  };
-
-  struct GlobalAsmFragment {
-    std::string Asm;
-    GlobalAsmProperties Props;
-
-    GlobalAsmFragment(StringRef Asm) : GlobalAsmFragment(Asm.str()) {}
-    GlobalAsmFragment(std::string AsmArg, GlobalAsmProperties Props = {})
-        : Asm(std::move(AsmArg)), Props(std::move(Props)) {
-      if (!Asm.empty() && Asm.back() != '\n')
-        Asm += '\n';
-    }
-
-    bool empty() const { return Asm.empty(); }
-
-    bool hasSameProperties(const GlobalAsmFragment &Other) const {
-      return Props == Other.Props;
-    }
-  };
-
 /// @}
 /// @name Member Variables
 /// @{
@@ -219,8 +180,7 @@ class LLVM_ABI Module {
   AliasListType AliasList;        ///< The Aliases in the module
   IFuncListType IFuncList;        ///< The IFuncs in the module
   NamedMDListType NamedMDList;    ///< The named metadata in the module
-  /// Inline Asm at the global scope.
-  SmallVector<GlobalAsmFragment, 0> GlobalScopeAsm;
+  std::string GlobalScopeAsm;     ///< Inline Asm at global scope.
   std::unique_ptr<ValueSymbolTable> ValSymTab; ///< Symbol table for values
   ComdatSymTabType ComdatSymTab;  ///< Symbol table for COMDATs
   std::unique_ptr<MemoryBuffer>
@@ -327,17 +287,8 @@ class LLVM_ABI Module {
   LLVMContext &getContext() const { return Context; }
 
   /// Get any module-scope inline assembly blocks.
-  ArrayRef<GlobalAsmFragment> getModuleInlineAsm() const {
-    return GlobalScopeAsm;
-  }
-
-  /// Get any module-scope inline assembly blocks.
-  MutableArrayRef<GlobalAsmFragment> getModuleInlineAsm() {
-    return GlobalScopeAsm;
-  }
-
-  /// Return whether there is any module-scope inline assembly.
-  bool hasModuleInlineAsm() const { return !GlobalScopeAsm.empty(); }
+  /// @returns a string containing the module-scope inline assembly blocks.
+  const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; }
 
   /// Get a RandomNumberGenerator salted for use with this module. The
   /// RNG can be seeded via -rng-seed=<uint64> and is salted with the
@@ -374,45 +325,20 @@ class LLVM_ABI Module {
   /// Set the target triple.
   void setTargetTriple(Triple T) { TargetTriple = std::move(T); }
 
-  void removeModuleInlineAsm() { GlobalScopeAsm.clear(); }
-
   /// Set the module-scope inline assembly blocks.
   /// A trailing newline is added if the input doesn't have one.
-  void setModuleInlineAsm(GlobalAsmFragment Fragment) {
-    GlobalScopeAsm.clear();
-    appendModuleInlineAsm(std::move(Fragment));
-  }
-
-  void setModuleInlineAsm(ArrayRef<GlobalAsmFragment> Fragments) {
-    GlobalScopeAsm.clear();
-    append_range(GlobalScopeAsm, Fragments);
+  void setModuleInlineAsm(StringRef Asm) {
+    GlobalScopeAsm = std::string(Asm);
+    if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
+      GlobalScopeAsm += '\n';
   }
 
   /// Append to the module-scope inline assembly blocks.
   /// A trailing newline is added if the input doesn't have one.
-  void appendModuleInlineAsm(GlobalAsmFragment Fragment) {
-    if (Fragment.empty())
-      return;
-
-    if (!GlobalScopeAsm.empty() &&
-        GlobalScopeAsm.back().hasSameProperties(Fragment)) {
-      GlobalScopeAsm.back().Asm += Fragment.Asm;
-    } else {
-      GlobalScopeAsm.emplace_back(std::move(Fragment));
-    }
-  }
-
-  /// Prepend to the module-scope inline assembly blocks.
-  void prependModuleInlineAsm(GlobalAsmFragment Fragment) {
-    if (Fragment.empty())
-      return;
-
-    if (!GlobalScopeAsm.empty() &&
-        GlobalScopeAsm.front().hasSameProperties(Fragment)) {
-      GlobalScopeAsm.front().Asm.insert(0, Fragment.Asm);
-    } else {
-      GlobalScopeAsm.insert(GlobalScopeAsm.begin(), std::move(Fragment));
-    }
+  void appendModuleInlineAsm(StringRef Asm) {
+    GlobalScopeAsm += Asm;
+    if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
+      GlobalScopeAsm += '\n';
   }
 
 /// @}
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 0a5b4c6c91879..75e6add0ec76f 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -641,49 +641,16 @@ bool LLParser::parseTopLevelEntities() {
 
 /// toplevelentity
 ///   ::= 'module' 'asm' STRINGCONSTANT
-///   ::= 'module' 'asm' '(' 'property_name1:' STRINGCONSTANT ','
-///                          'property_name2:' STRINGCONSTANT ')'
-///                      STRINGCONSTANT
 bool LLParser::parseModuleAsm() {
   assert(Lex.getKind() == lltok::kw_module);
   Lex.Lex();
 
   std::string AsmStr;
-  if (parseToken(lltok::kw_asm, "expected 'module asm'"))
+  if (parseToken(lltok::kw_asm, "expected 'module asm'") ||
+      parseStringConstant(AsmStr))
     return true;
 
-  Module::GlobalAsmProperties Props;
-  if (EatIfPresent(lltok::lparen)) {
-    while (true) {
-      std::string Key, Value;
-      SMLoc Loc = Lex.getLoc();
-      if (Lex.getKind() != lltok::LabelStr)
-        return error(Loc, "expected property name followed by ':'");
-
-      Key = Lex.getStrVal();
-      Lex.Lex();
-
-      if (parseStringConstant(Value))
-        return true;
-
-      if (!Props.set(Key, Value))
-        return error(Loc, "unknown property name");
-
-      if (EatIfPresent(lltok::rparen))
-        break;
-      if (parseToken(lltok::comma, "expected ',' or ')'"))
-        return true;
-    }
-  }
-
-  do {
-    std::string AsmStrPart;
-    if (parseStringConstant(AsmStrPart))
-      return true;
-    AsmStr += AsmStrPart + "...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/207399
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to