Skip to content

Commit 05b3306

Browse files
committed
[NFC][MIR] Fix extra whitespace in MIR printing
1 parent 93d3260 commit 05b3306

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

llvm/include/llvm/ADT/StringExtras.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,13 +529,15 @@ inline std::string join_items(Sep Separator, Args &&... Items) {
529529
class ListSeparator {
530530
bool First = true;
531531
StringRef Separator;
532+
StringRef Prefix;
532533

533534
public:
534-
ListSeparator(StringRef Separator = ", ") : Separator(Separator) {}
535+
ListSeparator(StringRef Separator = ", ", StringRef Prefix = "")
536+
: Separator(Separator), Prefix(Prefix) {}
535537
operator StringRef() {
536538
if (First) {
537539
First = false;
538-
return {};
540+
return Prefix;
539541
}
540542
return Separator;
541543
}

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -866,48 +866,46 @@ static void printMI(raw_ostream &OS, MFPrintState &State,
866866

867867
OS << TII->getName(MI.getOpcode());
868868

869-
LS = ListSeparator();
869+
// Print a space after the opcode if any additional tokens are printed.
870+
LS = ListSeparator(", ", " ");
870871

871-
if (I < E) {
872-
OS << ' ';
873-
for (; I < E; ++I) {
874-
OS << LS;
875-
printMIOperand(OS, State, MI, I, TRI, TII, ShouldPrintRegisterTies,
876-
PrintedTypes, MRI, /*PrintDef=*/true);
877-
}
872+
for (; I < E; ++I) {
873+
OS << LS;
874+
printMIOperand(OS, State, MI, I, TRI, TII, ShouldPrintRegisterTies,
875+
PrintedTypes, MRI, /*PrintDef=*/true);
878876
}
879877

880878
// Print any optional symbols attached to this instruction as-if they were
881879
// operands.
882880
if (MCSymbol *PreInstrSymbol = MI.getPreInstrSymbol()) {
883-
OS << LS << " pre-instr-symbol ";
881+
OS << LS << "pre-instr-symbol ";
884882
MachineOperand::printSymbol(OS, *PreInstrSymbol);
885883
}
886884
if (MCSymbol *PostInstrSymbol = MI.getPostInstrSymbol()) {
887-
OS << LS << " post-instr-symbol ";
885+
OS << LS << "post-instr-symbol ";
888886
MachineOperand::printSymbol(OS, *PostInstrSymbol);
889887
}
890888
if (MDNode *HeapAllocMarker = MI.getHeapAllocMarker()) {
891-
OS << LS << " heap-alloc-marker ";
889+
OS << LS << "heap-alloc-marker ";
892890
HeapAllocMarker->printAsOperand(OS, State.MST);
893891
}
894892
if (MDNode *PCSections = MI.getPCSections()) {
895-
OS << LS << " pcsections ";
893+
OS << LS << "pcsections ";
896894
PCSections->printAsOperand(OS, State.MST);
897895
}
898896
if (MDNode *MMRA = MI.getMMRAMetadata()) {
899-
OS << LS << " mmra ";
897+
OS << LS << "mmra ";
900898
MMRA->printAsOperand(OS, State.MST);
901899
}
902900
if (uint32_t CFIType = MI.getCFIType())
903-
OS << LS << " cfi-type " << CFIType;
901+
OS << LS << "cfi-type " << CFIType;
904902

905903
if (auto Num = MI.peekDebugInstrNum())
906-
OS << LS << " debug-instr-number " << Num;
904+
OS << LS << "debug-instr-number " << Num;
907905

908906
if (PrintLocations) {
909907
if (const DebugLoc &DL = MI.getDebugLoc()) {
910-
OS << LS << " debug-location ";
908+
OS << LS << "debug-location ";
911909
DL->printAsOperand(OS, State.MST);
912910
}
913911
}

llvm/test/CodeGen/MIR/AArch64/return-address-signing.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: llc -mtriple=aarch64 -run-pass=prologepilog -run-pass=aarch64-ptrauth -o - %s 2>&1 | FileCheck %s
1+
# RUN: llc -mtriple=aarch64 -run-pass=prologepilog -run-pass=aarch64-ptrauth -o - %s 2>&1 | FileCheck --strict-whitespace %s
22
--- |
33
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
44
target triple = "aarch64"

0 commit comments

Comments
 (0)