[llvm] Treat "\n" as a separator for asm instructions, instead of "\n\t". (PR #149365)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 10:44:17 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-llvm-transforms
Author: Rahman Lavaee (rlavaee)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/149365.diff
3 Files Affected:
- (modified) llvm/lib/IR/InlineAsm.cpp (+2-2)
- (modified) llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll (+1-1)
- (modified) llvm/test/Transforms/Inline/inline-call-with-asm-call.ll (+1-1)
``````````diff
diff --git a/llvm/lib/IR/InlineAsm.cpp b/llvm/lib/IR/InlineAsm.cpp
index 922081468a775..baa814d06e28a 100644
--- a/llvm/lib/IR/InlineAsm.cpp
+++ b/llvm/lib/IR/InlineAsm.cpp
@@ -63,14 +63,14 @@ FunctionType *InlineAsm::getFunctionType() const {
void InlineAsm::collectAsmStrs(SmallVectorImpl<StringRef> &AsmStrs) const {
StringRef AsmStr(AsmString);
AsmStrs.clear();
-
// TODO: 1) Unify delimiter for inline asm, we also meet other delimiters
// for example "\0A", ";".
// 2) Enhance StringRef. Some of the special delimiter ("\0") can't be
// split in StringRef. Also empty StringRef can not call split (will stuck).
if (AsmStr.empty())
return;
- AsmStr.split(AsmStrs, "\n\t", -1, false);
+ AsmStr.split(AsmStrs, "\n", -1, false);
+ errs() << "Num Asm Strs: " << AsmStrs.size() << "\n";
}
/// Parse - Analyze the specified string (e.g. "==&{eax}") and fill in the
diff --git a/llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll b/llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll
index d3ca872509ad5..f5bebfb058db6 100644
--- a/llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll
+++ b/llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll
@@ -59,7 +59,7 @@ define void @func() local_unnamed_addr #0 {
entry:
%call = tail call i32 @static_func()
;; We test call, CALL, and jmp.
- tail call void asm sideeffect inteldialect "call ${0:P}\0A\09CALL ${1:P}\0A\09jmp ${1:P}\0A\09shr eax, $$0\0A\09shr ebx, $$0\0A\09shr ecx, $$0\0A\09shr edx, $$0\0A\09shr edi, $$0\0A\09shr esi, $$0\0A\09shr ebp, $$0\0A\09shr esp, $$0", "*m,*m,~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{flags},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32 (...)) @static_func, ptr nonnull elementtype(i32 (...)) @extern_func) #0
+ tail call void asm sideeffect inteldialect "call ${0:P}\0ACALL ${1:P}\0Ajmp ${1:P}\0Ashr eax, $$0\0Ashr ebx, $$0\0Ashr ecx, $$0\0Ashr edx, $$0\0Ashr edi, $$0\0Ashr esi, $$0\0Ashr ebp, $$0\0Ashr esp, $$0", "*m,*m,~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{flags},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32 (...)) @static_func, ptr nonnull elementtype(i32 (...)) @extern_func) #0
ret void
}
diff --git a/llvm/test/Transforms/Inline/inline-call-with-asm-call.ll b/llvm/test/Transforms/Inline/inline-call-with-asm-call.ll
index 7d8121d04996e..a536eca072d42 100644
--- a/llvm/test/Transforms/Inline/inline-call-with-asm-call.ll
+++ b/llvm/test/Transforms/Inline/inline-call-with-asm-call.ll
@@ -27,7 +27,7 @@ define void @caller(i32 %a, i1 %b) #0 {
;; destination section and two assembly instructions in the outlined "other"
;; section.
define void @callee(i32 %a, i1 %b) {
- call void asm sideeffect "s_nop 1\0A\09.pushsection other\0A\09s_nop 2\0A\09s_nop 3\0A\09.popsection\0A\09s_nop 4\0A\09.align 32", ""()
+ call void asm sideeffect "s_nop 1\0A.pushsection other\0A\09s_nop 2\0A\09s_nop 3\0A\09.popsection\0A\09s_nop 4\0A.align 32", ""()
ret void
}
; CHECK: define void @callee
``````````
</details>
https://github.com/llvm/llvm-project/pull/149365
More information about the llvm-commits
mailing list