[PATCH] D99395: [Propeller] Do not generate the BB address map for empty functions.

Rahman Lavaee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 25 18:46:55 PDT 2021


rahmanl created this revision.
rahmanl added reviewers: shenhan, tmsriram.
Herald added subscribers: pengfei, hiraditya.
rahmanl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Empty functions (functions with no real code) are irrelevant for propeller optimizations and their addresses sometimes conflict with other functions which obfuscates the analysis.
This simple change skips the BB address map emission for such functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99395

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll


Index: llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll
@@ -0,0 +1,21 @@
+;; Verify that the BB address map is not emitted for empty functions.
+; RUN: llc < %s -mtriple=x86_64 -basic-block-sections=labels | FileCheck %s
+
+define void @empty_func() {
+entry:
+  unreachable
+}
+; CHECK:		{{^ *}}.text{{$}}
+; CHECK:	empty_func:
+; CHECK:	.Lfunc_begin0:
+; CHECK-NOT:	.section	.llvm_bb_addr_map
+
+define void @func() {
+entry:
+  ret void
+}
+
+; CHECK:	func:
+; CHECK:	.Lfunc_begin1:
+; CHECK:		.section	.llvm_bb_addr_map,"o", at llvm_bb_addr_map,.text{{$}}
+; CHECK:		.quad	.Lfunc_begin1
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1430,8 +1430,8 @@
   }
 
   // Emit section containing BB address offsets and their metadata, when
-  // BB labels are requested for this function.
-  if (MF->hasBBLabels())
+  // BB labels are requested for this function. Skip empty functions.
+  if (MF->hasBBLabels() && HasAnyRealCode)
     emitBBAddrMapSection(*MF);
 
   // Emit section containing stack size metadata.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99395.333482.patch
Type: text/x-patch
Size: 1351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210326/130d6b57/attachment.bin>


More information about the llvm-commits mailing list