[llvm] 90c401c - [Propeller] Do not generate the BB address map for empty functions.
Rahman Lavaee via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 29 20:15:09 PDT 2021
Author: Rahman Lavaee
Date: 2021-03-29T20:15:01-07:00
New Revision: 90c401cab63459334785f61076d4f05e4e487c1f
URL: https://github.com/llvm/llvm-project/commit/90c401cab63459334785f61076d4f05e4e487c1f
DIFF: https://github.com/llvm/llvm-project/commit/90c401cab63459334785f61076d4f05e4e487c1f.diff
LOG: [Propeller] Do not generate the BB address map for empty functions.
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.
Reviewed By: tmsriram
Differential Revision: https://reviews.llvm.org/D99395
Added:
llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 160eaefeaf90..c1416cd20553 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1430,8 +1430,8 @@ void AsmPrinter::emitFunctionBody() {
}
// 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.
diff --git a/llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll b/llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll
new file mode 100644
index 000000000000..4d814b5b61c7
--- /dev/null
+++ b/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
More information about the llvm-commits
mailing list