[llvm-branch-commits] [llvm] [BOLT] Ignore hot markers as function references in updateELFSymbolTable (PR #92713)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 20 15:06:30 PDT 2024


https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/92713

>From a32bf63f61f6d382f09982d992f3cabc8dc55cfd Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Sun, 19 May 2024 19:44:20 -0700
Subject: [PATCH 1/3] drop changes to bolt/test/AArch64/text-data.c

Created using spr 1.3.4
---
 bolt/test/AArch64/text-data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/test/AArch64/text-data.c b/bolt/test/AArch64/text-data.c
index 17e507a7cc1b4..2986fe7840078 100644
--- a/bolt/test/AArch64/text-data.c
+++ b/bolt/test/AArch64/text-data.c
@@ -3,7 +3,7 @@
 
 // RUN: %clang %cflags %s -o %t.exe -Wl,-q
 // RUN: llvm-bolt %t.exe -o %t.bolt --lite=0 --use-old-text=0
-// RUN: llvm-objdump -j .bolt.org.text -d --disassemble-symbols=arr %t.bolt | \
+// RUN: llvm-objdump -j .text -d --disassemble-symbols=arr %t.bolt | \
 // RUN:   FileCheck %s
 
 // CHECK: {{.*}} <arr>:

>From d09b18df4eb75879ef528bfcb43604b86d56860c Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Sun, 19 May 2024 20:13:19 -0700
Subject: [PATCH 2/3] Address comments

Created using spr 1.3.4
---
 bolt/lib/Rewrite/RewriteInstance.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 0d11bdc46fa5a..ba5cec7d9c596 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -4789,7 +4789,6 @@ void RewriteInstance::updateELFSymbolTable(
       continue;
 
     Expected<StringRef> SymbolName = Symbol.getName(StringSection);
-    assert(SymbolName && "cannot get symbol name");
 
     const BinaryFunction *Function =
         BC->getBinaryFunctionAtAddress(Symbol.st_value);
@@ -4798,8 +4797,11 @@ void RewriteInstance::updateELFSymbolTable(
     if (Function && Symbol.getType() == ELF::STT_SECTION)
       Function = nullptr;
 
-    // Ignore input hot markers as function aliases – markers are handled
-    // separately.
+    // Ignore input hot markers as function aliases.
+    // If hot markers are treated as function aliases, we may create
+    // non-sensical __hot_start.cold symbols which would not have a parent
+    // when read by BOLT as we don't register them as function aliases
+    // (explicitly ignored in parsing symbol table in discoverFileObjects).
     if (Function &&
         (*SymbolName == "__hot_start" || *SymbolName == "__hot_end"))
       Function = nullptr;

>From b36c250836607410246e6ddf2f855d43df77e80d Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Sun, 19 May 2024 20:17:15 -0700
Subject: [PATCH 3/3] keep assert

Created using spr 1.3.4
---
 bolt/lib/Rewrite/RewriteInstance.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index ba5cec7d9c596..e788ca7afd5ad 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -4789,6 +4789,7 @@ void RewriteInstance::updateELFSymbolTable(
       continue;
 
     Expected<StringRef> SymbolName = Symbol.getName(StringSection);
+    assert(SymbolName && "cannot get symbol name");
 
     const BinaryFunction *Function =
         BC->getBinaryFunctionAtAddress(Symbol.st_value);



More information about the llvm-branch-commits mailing list