[llvm] [BOLT] Fix comparison function for Linux ORC entries (PR #79921)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 16:46:49 PST 2024
https://github.com/maksfb created https://github.com/llvm/llvm-project/pull/79921
Fix ORC entry comparison function to cover a case with multiple terminator entries matching at the same IP.
>From c6d6a611d5de3e45f7944a7bb2ab3c45fed35689 Mon Sep 17 00:00:00 2001
From: Maksim Panchenko <maks at fb.com>
Date: Mon, 29 Jan 2024 15:22:34 -0800
Subject: [PATCH] [BOLT] Fix comparison function for Linux ORC entries
Fix ORC entry comparison function to cover a case with multiple
terminator entries matching at the same IP.
---
bolt/lib/Rewrite/LinuxKernelRewriter.cpp | 2 +-
bolt/test/X86/{orc_unwind.s => linux-orc.s} | 26 +++++++++++++++++----
2 files changed, 22 insertions(+), 6 deletions(-)
rename bolt/test/X86/{orc_unwind.s => linux-orc.s} (84%)
diff --git a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
index 2f449da6206f2..8459a48b5ac92 100644
--- a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
+++ b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
@@ -95,7 +95,7 @@ class LinuxKernelRewriter final : public MetadataRewriter {
return 1;
if (IP > Other.IP)
return 0;
- return ORC == NullORC;
+ return ORC == NullORC && Other.ORC != NullORC;
}
};
diff --git a/bolt/test/X86/orc_unwind.s b/bolt/test/X86/linux-orc.s
similarity index 84%
rename from bolt/test/X86/orc_unwind.s
rename to bolt/test/X86/linux-orc.s
index 4f8b9332dfef1..bb3ab10754544 100644
--- a/bolt/test/X86/orc_unwind.s
+++ b/bolt/test/X86/linux-orc.s
@@ -1,6 +1,6 @@
# REQUIRES: system-linux
-## Check that BOLT correctly reads ORC unwind information used by Linux Kernel.
+## Check that BOLT correctly reads ORC unwind information used by Linux kernel.
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe
@@ -15,6 +15,7 @@
# CHECK-NEXT: {sp: 16, bp: -16, info: 0x15}: foo
# CHECK-NEXT: {sp: 16, bp: -16, info: 0x14}: foo
# CHECK-NEXT: {sp: 8, bp: 0, info: 0x5}: foo
+# CHECK-NEXT: {sp: 0, bp: 0, info: 0x0}: bar
# CHECK-NEXT: {sp: 0, bp: 0, info: 0x0}: bar
.text
@@ -50,7 +51,7 @@ foo:
bar:
.cfi_startproc
ret
-# Same ORC info propagated from foo above.
+## Same ORC info propagated from foo above.
# CHECK: retq # ORC: {sp: 8, bp: 0, info: 0x5}
.L4:
.cfi_endproc
@@ -61,7 +62,7 @@ bar:
.section .orc_unwind_ip,"a", at progbits
.align 4
-# ORC for _start
+## ORC for _start.
.section .orc_unwind
.2byte 8
.2byte 0
@@ -76,7 +77,7 @@ bar:
.section .orc_unwind_ip
.long foo - .
-# ORC for foo
+## ORC for foo.
.section .orc_unwind
.2byte 8
.2byte 0
@@ -112,7 +113,22 @@ bar:
.section .orc_unwind_ip
.long .L4 - .
-# Fake Linux Kernel sections
+## Duplicate terminator entries to test ORC reader.
+ .section .orc_unwind
+ .2byte 0
+ .2byte 0
+ .2byte 0
+ .section .orc_unwind_ip
+ .long .L4 - .
+
+ .section .orc_unwind
+ .2byte 0
+ .2byte 0
+ .2byte 0
+ .section .orc_unwind_ip
+ .long .L4 - .
+
+## Fake Linux Kernel sections.
.section __ksymtab,"a", at progbits
.section __ksymtab_gpl,"a", at progbits
.section .pci_fixup,"a", at progbits
More information about the llvm-commits
mailing list