From abd707848bcd52d55e9c203f96a0a826ba56f26f Mon Sep 17 00:00:00 2001 From: TH3CHARLie Date: Fri, 3 Jan 2020 14:04:01 +0800 Subject: [PATCH] [llvm-size] print a blank line between archieve members when using sysv format Summary: This patch is related to https://bugs.llvm.org/show_bug.cgi?id=42967 and it fixes llvm-size's sysv format output by adding a blank line between archieve members Reviewers: jhenderson, Jim, MaskRay Reviewed By: jhenderson, Jim, MaskRay Subscribers: MaskRay, Jim, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71957 --- llvm/test/tools/llvm-size/archive.test | 7 +++++-- llvm/test/tools/llvm-size/multiple-inputs.test | 1 + llvm/test/tools/llvm-size/radix.test | 3 +++ llvm/tools/llvm-size/llvm-size.cpp | 6 ++---- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/llvm/test/tools/llvm-size/archive.test b/llvm/test/tools/llvm-size/archive.test index b750f08..23c4cd1 100644 --- a/llvm/test/tools/llvm-size/archive.test +++ b/llvm/test/tools/llvm-size/archive.test @@ -8,8 +8,7 @@ # RUN: llvm-ar rc %t1.a # RUN: llvm-size -B %t1.a | count 0 -## Sysv output prints a single blank line in this case. -# RUN: llvm-size -A %t1.a | FileCheck %s --implicit-check-not={{.}} +# RUN: llvm-size -A %t1.a | count 0 ## Case 2: Single member. # RUN: rm -f %t2.a @@ -48,6 +47,7 @@ # SYSV-3-NEXT: .bss 4 1 # SYSV-3-NEXT: Total 7 # SYSV-3-EMPTY: +# SYSV-3-EMPTY: # SYSV-3-NEXT: archive.test.tmp1 (ex [[ARCHIVE2]]): # SYSV-3-NEXT: section size addr # SYSV-3-NEXT: .text 1 4 @@ -55,6 +55,7 @@ # SYSV-3-NEXT: .bss 4 1 # SYSV-3-NEXT: Total 7 # SYSV-3-EMPTY: +# SYSV-3-EMPTY: # SYSV-3-NEXT: [[FILE2]] : # SYSV-3-NEXT: section size addr # SYSV-3-NEXT: .text 8 32 @@ -69,6 +70,8 @@ # SYSV-1-NEXT: .data 2 2 # SYSV-1-NEXT: .bss 4 1 # SYSV-1-NEXT: Total 7 +# SYSV-1-EMPTY: +# SYSV-1-EMPTY: # SYSV-2-NEXT: archive.test.tmp2 (ex [[ARCHIVE]]): # SYSV-2-NEXT: section size addr diff --git a/llvm/test/tools/llvm-size/multiple-inputs.test b/llvm/test/tools/llvm-size/multiple-inputs.test index 96c3c21..7fc2d14 100644 --- a/llvm/test/tools/llvm-size/multiple-inputs.test +++ b/llvm/test/tools/llvm-size/multiple-inputs.test @@ -17,6 +17,7 @@ # SYSV-NEXT: .bss 4 1 # SYSV-NEXT: Total 7 # SYSV-EMPTY: +# SYSV-EMPTY: # SYSV-NEXT: [[FILE2]] : # SYSV-NEXT: section size addr # SYSV-NEXT: .text 8 32 diff --git a/llvm/test/tools/llvm-size/radix.test b/llvm/test/tools/llvm-size/radix.test index e8fea8b..0211335 100644 --- a/llvm/test/tools/llvm-size/radix.test +++ b/llvm/test/tools/llvm-size/radix.test @@ -49,6 +49,7 @@ # OCT-SYSV-NEXT: .bss 04 01 # OCT-SYSV-NEXT: Total 07 # OCT-SYSV-EMPTY: +# OCT-SYSV-EMPTY: # OCT-SYSV-NEXT: [[FILE2]] : # OCT-SYSV-NEXT: section size addr # OCT-SYSV-NEXT: .blob 010 040 @@ -69,6 +70,7 @@ # DEC-SYSV-NEXT: .bss 4 1 # DEC-SYSV-NEXT: Total 7 # DEC-SYSV-EMPTY: +# DEC-SYSV-EMPTY: # DEC-SYSV-NEXT: [[FILE2]] : # DEC-SYSV-NEXT: section size addr # DEC-SYSV-NEXT: .blob 8 32 @@ -89,6 +91,7 @@ # HEX-SYSV-NEXT: .bss 0x4 0x1 # HEX-SYSV-NEXT: Total 0x7 # HEX-SYSV-EMPTY: +# HEX-SYSV-EMPTY: # HEX-SYSV-NEXT: [[FILE2]] : # HEX-SYSV-NEXT: section size addr # HEX-SYSV-NEXT: .blob 0x8 0x20 diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp index 7c63bc2..46ece5a 100644 --- a/llvm/tools/llvm-size/llvm-size.cpp +++ b/llvm/tools/llvm-size/llvm-size.cpp @@ -446,7 +446,8 @@ static void printObjectSectionSizes(ObjectFile *Obj) { fmt << "%-" << max_name_len << "s " << "%#" << max_size_len << radix_fmt << "\n"; outs() << format(fmt.str().c_str(), static_cast("Total"), - total); + total) + << "\n\n"; } else { // The Berkeley format does not display individual section sizes. It // displays the cumulative size for each section type. @@ -839,9 +840,6 @@ static void printFileSectionSizes(StringRef file) { } else { error("unsupported file type", file); } - // System V adds an extra newline at the end of each file. - if (OutputFormat == sysv) - outs() << "\n"; } static void printBerkeleyTotals() { -- 2.7.4