[llvm-branch-commits] [llvm] c23212a - [IR] Keep a double break between functions when printing a module

Reid Kleckner via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 27 15:35:56 PST 2020


Author: Reid Kleckner
Date: 2020-01-27T15:34:05-08:00
New Revision: c23212a438f6ff20bf1d98e5ca23c5cd28591ce3

URL: https://github.com/llvm/llvm-project/commit/c23212a438f6ff20bf1d98e5ca23c5cd28591ce3
DIFF: https://github.com/llvm/llvm-project/commit/c23212a438f6ff20bf1d98e5ca23c5cd28591ce3.diff

LOG: [IR] Keep a double break between functions when printing a module

This behavior appears to have changed unintentionally in
b0e979724f2679e4e6f5b824144ea89289bd6d56.

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

(cherry picked from commit 9521c18438a9f09663f3dc68aa7581371c0653c9)

Added: 
    

Modified: 
    llvm/lib/IR/AsmWriter.cpp
    llvm/test/Feature/undefined.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index acf0e4afef27..1f978d136049 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2651,8 +2651,10 @@ void AssemblyWriter::printModule(const Module *M) {
   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
index e63ce41f681b..e01ed4c0f9c4 100644
--- 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           ; <i32*> [#uses=0]
 
@@ -15,3 +16,15 @@ define i32 @test2() {
         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: {{^[}]}}


        


More information about the llvm-branch-commits mailing list