Files
clang-p2996/llvm/test/CodeGen/X86/basic-block-sections_2.ll
Sriraman Tallam 34e70d722d Append ".__part." to every basic block section symbol.
Every basic block section symbol created by -fbasic-block-sections will contain
".__part." to know that this symbol corresponds to a basic block fragment of
the function.

This patch solves two problems:

a) Like D89617, we want function symbols with suffixes to be properly qualified
   so that external tools like profile aggregators know exactly what this
   symbol corresponds to.
b) The current basic block naming just adds a ".N" to the symbol name where N is
   some integer. This collides with how clang creates __cxx_global_var_init.N.
   clang creates these symbol names to call constructor functions and basic
   block symbol naming should not use the same style.

Fixed all the test cases and added an extra test for __cxx_global_var_init
breakage.

Differential Revision: https://reviews.llvm.org/D93082
2020-12-23 11:35:44 -08:00

62 lines
2.0 KiB
LLVM

; Check that the basic block sections suffix naming does not conflict with __cxx_global_var_init.N naming.
; How to generate this file:
;; class A {
;; public:
;; A(bool a) { }
;; };
;;
;; extern bool bar(int);
;; A g_a(bar(5) ? bar(3) : false), g_b(true);
;;
;; $ clang -O1 -emit-llvm -S
;;
; __cxx_global_var_init has multiple basic blocks which will produce many sections.
; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=all -unique-basic-block-section-names | FileCheck %s
; CHECK-LABEL: __cxx_global_var_init:
; CHECK-LABEL: __cxx_global_var_init.__part.1:
; CHECK-LABEL: __cxx_global_var_init.1:
%class.A = type { i8 }
$_ZN1AC2Eb = comdat any
@g_a = dso_local global %class.A zeroinitializer, align 1
@g_b = dso_local global %class.A zeroinitializer, align 1
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_symcollision.cc, i8* null }]
define internal fastcc void @__cxx_global_var_init() unnamed_addr section ".text.startup" {
entry:
%call = call zeroext i1 @_Z3bari(i32 5)
br i1 %call, label %cond.true, label %cond.end
cond.true: ; preds = %entry
%call1 = call zeroext i1 @_Z3bari(i32 3)
br label %cond.end
cond.end: ; preds = %entry, %cond.true
%cond = phi i1 [ %call1, %cond.true ], [ false, %entry ]
call void @_ZN1AC2Eb(%class.A* nonnull @g_a, i1 zeroext %cond)
ret void
}
declare dso_local zeroext i1 @_Z3bari(i32) local_unnamed_addr
define linkonce_odr dso_local void @_ZN1AC2Eb(%class.A* %this, i1 zeroext %a) unnamed_addr comdat align 2 {
entry:
ret void
}
define internal fastcc void @__cxx_global_var_init.1() unnamed_addr section ".text.startup" {
entry:
call void @_ZN1AC2Eb(%class.A* nonnull @g_b, i1 zeroext true)
ret void
}
define internal void @_GLOBAL__sub_I_symcollision.cc() section ".text.startup" {
entry:
call fastcc void @__cxx_global_var_init()
call fastcc void @__cxx_global_var_init.1()
ret void
}