[llvm] [BOLT] Fix reorder data test for RISC-V (PR #68996)

Job Noorman via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 13 08:02:32 PDT 2023


https://github.com/mtvec created https://github.com/llvm/llvm-project/pull/68996

On RISC-V, small data objects are put in the `.sdata` section by default. This causes the `reorder-data-writable-ptload.c` test to fail since it hard-codes the section to optimize to `.data`.

This patch passes the `-msmall-data-limit=0` option to clang on RISC-V to ensure the objects are added to `.data`.

>From e1805ef952a3a92a24358ab9d36b645055e7dbe7 Mon Sep 17 00:00:00 2001
From: Job Noorman <jnoorman at igalia.com>
Date: Fri, 13 Oct 2023 16:57:40 +0200
Subject: [PATCH] [BOLT] Fix reorder data test for RISC-V

On RISC-V, small data objects are put in the `.sdata` section by
default. This causes the `reorder-data-writable-ptload.c` to fail since
it hard-codes the section to optimize to `.data`.

This patch passes the `-msmall-data-limit=0` option to clang on RISC-V
to ensure the objects are added to `.data`.
---
 bolt/test/reorder-data-writable-ptload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bolt/test/reorder-data-writable-ptload.c b/bolt/test/reorder-data-writable-ptload.c
index 7b384e9655a3283..0447beba057f9ec 100644
--- a/bolt/test/reorder-data-writable-ptload.c
+++ b/bolt/test/reorder-data-writable-ptload.c
@@ -1,7 +1,8 @@
 // This test checks that reorder-data pass puts new hot .data section
 // to the writable segment.
 
-// RUN: %clang %cflags -O3 -nostdlib -Wl,-q %s -o %t.exe
+// RUN: %clang %cflags %if target=riscv64{{.*}} %{ -msmall-data-limit=0 %} \
+// RUN:     -O3 -nostdlib -Wl,-q %s -o %t.exe
 // RUN: llvm-bolt %t.exe -o %t.bolt --reorder-data=".data" \
 // RUN:   -data %S/Inputs/reorder-data-writable-ptload.fdata
 // RUN: llvm-readelf -SlW %t.bolt | FileCheck %s



More information about the llvm-commits mailing list