From 5b2fef88c72a175e62e812842b3acaf509523785 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Mon, 24 Feb 2025 10:45:47 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?= =?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- bolt/lib/Core/BinaryFunction.cpp | 5 +++-- bolt/test/X86/entry-point-fallthru.s | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 bolt/test/X86/entry-point-fallthru.s diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 8385551576098..ff5eb5cf6e1eb 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -15,6 +15,7 @@ #include "bolt/Core/DynoStats.h" #include "bolt/Core/HashUtilities.h" #include "bolt/Core/MCPlusBuilder.h" +#include "bolt/Utils/CommandLineOpts.h" #include "bolt/Utils/NameResolver.h" #include "bolt/Utils/NameShortener.h" #include "bolt/Utils/Utils.h" @@ -1753,8 +1754,8 @@ void BinaryFunction::postProcessEntryPoints() { // In non-relocation mode there's potentially an external undetectable // reference to the entry point and hence we cannot move this entry // point. Optimizing without moving could be difficult. - // In BAT mode, register any known entry points for CFG construction. - if (!BC.HasRelocations && !BC.HasBATSection) + // In aggregation, register any known entry points for CFG construction. + if (!BC.HasRelocations && !opts::AggregateOnly) setSimple(false); const uint32_t Offset = KV.first; diff --git a/bolt/test/X86/entry-point-fallthru.s b/bolt/test/X86/entry-point-fallthru.s new file mode 100644 index 0000000000000..edf14247b0c43 --- /dev/null +++ b/bolt/test/X86/entry-point-fallthru.s @@ -0,0 +1,24 @@ +## Checks that fallthroughs spanning entry points are accepted in aggregation +## mode. + +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: link_fdata %s %t %t.preagg PREAGG +# RUN: perf2bolt %t -p %t.preagg --pa -o %t.fdata | FileCheck %s +# CHECK: traces mismatching disassembled function contents: 0 + + .globl main +main: + .cfi_startproc + vmovaps %zmm31,%zmm3 + +next: + add $0x4,%r9 + add $0x40,%r10 + dec %r14 +Ljmp: + jne main +# PREAGG: T #Ljmp# #main# #Ljmp# 1 + ret + .cfi_endproc +.size main,.-main