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
}
// 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.
--- /dev/null
+;; 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",@llvm_bb_addr_map,.text{{$}}
+; CHECK: .quad .Lfunc_begin1