Skip to content

Commit 9521c18

Browse files
committed
[IR] Keep a double break between functions when printing a module
This behavior appears to have changed unintentionally in b0e9797. Instead of printing the leading newline in printFunction, print it when printing a module. This ensures that `OS << *Func` starts printing immediately on the current line, but whole modules are printed nicely. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D73505
1 parent c7feb6b commit 9521c18

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

llvm/lib/IR/AsmWriter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2651,8 +2651,10 @@ void AssemblyWriter::printModule(const Module *M) {
26512651
printUseLists(nullptr);
26522652

26532653
// Output all of the functions.
2654-
for (const Function &F : *M)
2654+
for (const Function &F : *M) {
2655+
Out << '\n';
26552656
printFunction(&F);
2657+
}
26562658
assert(UseListOrders.empty() && "All use-lists should have been consumed");
26572659

26582660
// Output all attribute groups.

llvm/test/Feature/undefined.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; RUN: llvm-as < %s | llvm-dis > %t1.ll
22
; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
33
; RUN: diff %t1.ll %t2.ll
4+
; RUN: FileCheck %s < %t1.ll
45

56
@X = global i32 undef ; <i32*> [#uses=0]
67

@@ -15,3 +16,15 @@ define i32 @test2() {
1516
ret i32 %X
1617
}
1718

19+
20+
; Check that there is a newline between functions.
21+
22+
; CHECK: @X = global
23+
; CHECK-EMPTY:
24+
; CHECK: declare i32 @atoi(i8*)
25+
; CHECK-EMPTY:
26+
; CHECK: define i32 @test() {
27+
; CHECK: {{^[}]}}
28+
; CHECK-EMPTY:
29+
; CHECK: define i32 @test2() {
30+
; CHECK: {{^[}]}}

0 commit comments

Comments
 (0)