Add a CRLF character before printing an IR Module in IRPrintingPasses
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
So for now, with -print-after-all or -print-before-all options in opt, we have the banner and the first line of the IR Module on a same line, e.g:
*** IR Dump After Force set function attributes *** ; ModuleID = '<stdin>' source_filename = "main.c" ...
This PR should fix this and we'll have:
*** IR Dump After Force set function attributes *** ; ModuleID = '<stdin>' source_filename = "main.c" ...
That doesn’t seem like the right place for the newline; instead, it should be wherever the asterisks were printed.
Also, please add a test.
Hmmm, the problem is in AssemblyWriter::printFunction(), we already print a newline character at the start of the function, so in fact this issue only raises when we print ModulePasses. Removing the newline character printing in AssemblyWriter::printFunction() will lead to this:
@x = common dso_local global i32 0, align 4 @y = common dso_local global i32 0, align 4 @z = common dso_local global i32 0, align 4 ; Function Attrs: noinline nounwind uwtable
instead of this:
@x = common dso_local global i32 0, align 4 @y = common dso_local global i32 0, align 4 @z = common dso_local global i32 0, align 4 ; Function Attrs: noinline nounwind uwtable
What would be the best way to fix this?
Another high-level note (besides adding tests): please resubmit the patch with full context (e.g., git diff -U9999999 HEAD^..).
I suspect you can change the appropriate callers of printFunction to add a newline in between functions. E.g., something like this would work:
bool IsFirst = true; for (auto &F : functions()) { if (IsFirst) IsFirst = false; else OS << "\n"; printFunction(F); }