diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -2651,8 +2651,10 @@ printUseLists(nullptr); // Output all of the functions. - for (const Function &F : *M) + for (const Function &F : *M) { + Out << '\n'; printFunction(&F); + } assert(UseListOrders.empty() && "All use-lists should have been consumed"); // Output all attribute groups. diff --git a/llvm/test/Feature/undefined.ll b/llvm/test/Feature/undefined.ll --- a/llvm/test/Feature/undefined.ll +++ b/llvm/test/Feature/undefined.ll @@ -1,6 +1,7 @@ ; RUN: llvm-as < %s | llvm-dis > %t1.ll ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll ; RUN: diff %t1.ll %t2.ll +; RUN: FileCheck %s < %t1.ll @X = global i32 undef ; [#uses=0] @@ -15,3 +16,15 @@ ret i32 %X } + +; Check that there is a newline between functions. + +; CHECK: @X = global +; CHECK-EMPTY: +; CHECK: declare i32 @atoi(i8*) +; CHECK-EMPTY: +; CHECK: define i32 @test() { +; CHECK: {{^[}]}} +; CHECK-EMPTY: +; CHECK: define i32 @test2() { +; CHECK: {{^[}]}}