diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -677,7 +677,7 @@ size_t e = CFI.getValues().size() - 1; for (size_t i = 0; i < e; ++i) OS << format("0x%02x", uint8_t(CFI.getValues()[i])) << ", "; - OS << format("0x%02x", uint8_t(CFI.getValues()[e])) << ", "; + OS << format("0x%02x", uint8_t(CFI.getValues()[e])); } break; } diff --git a/llvm/test/CodeGen/MIR/AArch64/cfi.mir b/llvm/test/CodeGen/MIR/AArch64/cfi.mir --- a/llvm/test/CodeGen/MIR/AArch64/cfi.mir +++ b/llvm/test/CodeGen/MIR/AArch64/cfi.mir @@ -44,7 +44,7 @@ CFI_INSTRUCTION restore_state ; CHECK: CFI_INSTRUCTION restore_state CFI_INSTRUCTION escape 0x61, 0x62, 0x63 - ; CHECK: CFI_INSTRUCTION escape 0x61, 0x62, 0x63 + ; CHECK: CFI_INSTRUCTION escape 0x61, 0x62, 0x63{{$}} CFI_INSTRUCTION window_save ; CHECK: CFI_INSTRUCTION window_save CFI_INSTRUCTION negate_ra_sign_state diff --git a/llvm/test/CodeGen/MIR/Generic/cfi-escape.mir b/llvm/test/CodeGen/MIR/Generic/cfi-escape.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/cfi-escape.mir @@ -0,0 +1,20 @@ +# RUN: llc -x=mir -run-pass none -o %t < %s +# RUN: llc -x=mir -run-pass none -o - < %t | FileCheck %s + +# Check that we don't print a trailing comma for CFI escape indices, and that +# in general we can round trip them. + +--- | + + define void @func() { + ret void + } + +... +--- +name: func +# CHECK-LABEL: name: func +body: | + bb.0: + CFI_INSTRUCTION escape 0x61, 0x62, 0x63 + ; CHECK: CFI_INSTRUCTION escape 0x61, 0x62, 0x63{{$}}