Ticket #5750 (closed bug: fixed)

Opened 5 months ago

Last modified 5 months ago

Pretty-print LLVM .ll output files

Reported by: tibbe Owned by: dterei
Priority: normal Milestone:
Component: Compiler (LLVM) Version: 7.2.1
Keywords: Cc: johan.tibell@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Other Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When working on the LLVM backend you sometimes have to read the generated LLVM assembly (stored in .ll files). The current output is quite hard to read. I suggest we try to mimic the output of llvm-dis by:

  • indenting each instruction by one tab (or two spaces if we want to be identical to llvm-dis),
  • adding a newline after each basic block (this will also have the effect of separating defines from each other as they all have at least on basic block), and
  • adding a newline after each declare.

Change History

Changed 5 months ago by dterei

Hey one thing i forgot to mention Johan is to try out '-ddump-llvm'. This already prints the llvm code in a nicer, formatted manner. Can you see if this is good enough for your purposes?

Changed 5 months ago by tibbe

Only if it can be redirected to file (without redirecting everything else GHC outputs.)

Changed 5 months ago by dterei

So if you do this:

$ ghc -ddump-llvm -ddump-to-file ...

You should get what you are after. Let me know if its not good enough but it seems fine. I looked at changing the '-keep-llvm-files' output to be pretty printed but its actually a slightly harder change than you would think due to the way the pretty print in GHC is done.

Changed 5 months ago by dterei

OK I also improved the style of the output which affects both '-ddump-llvm' and '-keep-llvm-files'.

'-keep-llvm-files' is the same as '-ddump-llvm' except the indentation stuff is dropped.

Changed 5 months ago by tibbe

  • status changed from new to closed
  • resolution set to fixed

Works for me.

Changed 5 months ago by dterei

OK, more work done, found a very easy way to get the indent working for the '-keep-llvm-files' output. So I'd recommend just using '-keep-llvm-files' now.

Note: See TracTickets for help on using tickets.