This is an archive of the discontinued LLVM Phabricator instance.

Fix printing of alias instructions by removing redundant spacing
ClosedPublic

Authored by mstojanovic on Jul 27 2017, 9:02 AM.

Details

Summary

Some alias instructions are printed with with an extra space after the tab character.
Fix this by skipping that space when the tab character is printed so that the instructions are aligned with the rest of the code.

A simple output used to look like this:

 0:	27 bd ff f8 	addiu	$sp, $sp, -8
 4:	af be 00 04 	sw	$fp, 4($sp)
 8:	03 a0 f0 25 	move	 $fp, $sp
 c:	af c0 00 00 	sw	$zero, 0($fp)
10:	10 00 00 01 	b	8 <main+0x18>
14:	00 00 00 00 	nop
18:	24 02 00 00 	addiu	$2, $zero, 0
1c:	03 c0 e8 25 	move	 $sp, $fp
20:	8f be 00 04 	lw	$fp, 4($sp)
24:	27 bd 00 08 	addiu	$sp, $sp, 8
28:	03 e0 00 09 	jr	 $ra
2c:	00 00 00 00 	nop

With the new formatting, it looks like this:

 0:	27 bd ff f8 	addiu	$sp, $sp, -8
 4:	af be 00 04 	sw	$fp, 4($sp)
 8:	03 a0 f0 25 	move	$fp, $sp
 c:	af c0 00 00 	sw	$zero, 0($fp)
10:	10 00 00 01 	b	8 <main+0x18>
14:	00 00 00 00 	nop
18:	24 02 00 00 	addiu	$2, $zero, 0
1c:	03 c0 e8 25 	move	$sp, $fp
20:	8f be 00 04 	lw	$fp, 4($sp)
24:	27 bd 00 08 	addiu	$sp, $sp, 8
28:	03 e0 00 09 	jr	$ra
2c:	00 00 00 00 	nop

Diff Detail

Repository
rL LLVM

Event Timeline

mstojanovic created this revision.Jul 27 2017, 9:02 AM
mstojanovic retitled this revision from Fix redundant spacing in llvm-objdump disassemble output to Fix redundant spacing of mips alias instructions in llvm-objdump disassemble output.Sep 21 2017, 10:46 AM
mstojanovic edited the summary of this revision. (Show Details)
mstojanovic added a reviewer: sdardis.
sdardis edited edge metadata.
sdardis added subscribers: SjoerdMeijer, olista01.

This LGTM, but let's see if @SjoerdMeijer, @olista01 or @stoklund have any concerns.

Also, you may want to retitle this diff+update summary to reflect it affects the printing of instruction aliases in general, rather than for just mips or when objdump is used..

SjoerdMeijer edited edge metadata.Sep 22 2017, 4:04 AM

looks reasonable to me

sdardis accepted this revision.Sep 22 2017, 4:13 AM

Can you retitle this as it's more general than the output of llvm-objdump, i.e. it affects the output of llc and it's not specific?

Otherwise LGTM.

This revision is now accepted and ready to land.Sep 22 2017, 4:13 AM
mstojanovic retitled this revision from Fix redundant spacing of mips alias instructions in llvm-objdump disassemble output to Fix printing of alias instructions by removing redundant spacing.Sep 22 2017, 12:00 PM
mstojanovic edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.