[llvm] 833393e - [asm] Correctly handle special names in variants
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 12:37:30 PST 2021
Author: Nico Weber
Date: 2021-11-15T15:37:09-05:00
New Revision: 833393e021dc1b3844ac6982455a32c2e55f748e
URL: https://github.com/llvm/llvm-project/commit/833393e021dc1b3844ac6982455a32c2e55f748e
DIFF: https://github.com/llvm/llvm-project/commit/833393e021dc1b3844ac6982455a32c2e55f748e.diff
LOG: [asm] Correctly handle special names in variants
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.
Differential Revision: https://reviews.llvm.org/D113909
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/test/CodeGen/Generic/inline-asm-special-strings.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 041a5d791f879..dd15ba515002c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -351,9 +351,10 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
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;
}
diff --git a/llvm/test/CodeGen/Generic/inline-asm-special-strings.ll b/llvm/test/CodeGen/Generic/inline-asm-special-strings.ll
index 5ef568863badd..5f9f34d1e78ce 100644
--- a/llvm/test/CodeGen/Generic/inline-asm-special-strings.ll
+++ b/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
}
More information about the llvm-commits
mailing list