[PATCH] D113909: [asm] Correctly handle special names in variants
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 09:10:44 PST 2021
thakis created this revision.
thakis added a reviewer: hans.
Herald added a subscriber: hiraditya.
thakis requested review of this revision.
Herald added a project: LLVM.
There's really no reason why anyone should use these special names in a variant.
I noticed this while reading the code: all other writes to OS are guarded by
this conditional, and the behavior with the check seems more correct, so
let's add the check.
https://reviews.llvm.org/D113909
Files:
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/test/CodeGen/Generic/inline-asm-special-strings.ll
Index: llvm/test/CodeGen/Generic/inline-asm-special-strings.ll
===================================================================
--- llvm/test/CodeGen/Generic/inline-asm-special-strings.ll
+++ llvm/test/CodeGen/Generic/inline-asm-special-strings.ll
@@ -1,6 +1,9 @@
-; RUN: llc -no-integrated-as < %s | grep "foo 0 0"
+; RUN: llc -no-integrated-as < %s | FileCheck %s
define void @bar() nounwind {
- tail call void asm sideeffect "foo ${:uid} ${:uid}", ""() nounwind
- ret void
+ ; CHECK: foo 0 0{{$}}
+ tail call void asm sideeffect "foo ${:uid} ${:uid}", ""() nounwind
+ ; CHECK: bar 1 x{{$}}
+ tail call void asm sideeffect "bar $(${:uid} x$| ${:uid} x$)", ""() nounwind
+ ret void
}
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -351,9 +351,10 @@
if (!StrEnd)
report_fatal_error("Unterminated ${:foo} operand in inline asm"
" string: '" + Twine(AsmStr) + "'");
-
- std::string Val(StrStart, StrEnd);
- AP->PrintSpecial(MI, OS, Val.c_str());
+ if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
+ std::string Val(StrStart, StrEnd);
+ AP->PrintSpecial(MI, OS, Val.c_str());
+ }
LastEmitted = StrEnd+1;
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113909.387292.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/e26fec1b/attachment.bin>
More information about the llvm-commits
mailing list