xref: /llvm-project/bolt/test/reorder-data-writable-ptload.c (revision 8592241e29e29f0e7e407e0989489c6e70c91c42)
1207ea5f2SVladislav Khmelevsky // This test checks that reorder-data pass puts new hot .data section
2207ea5f2SVladislav Khmelevsky // to the writable segment.
3207ea5f2SVladislav Khmelevsky 
4*8592241eSJob Noorman // Use -fPIC -pie to prevent the globals being put in .sdata instead of .data on
5*8592241eSJob Noorman // RISC-V.
6*8592241eSJob Noorman // RUN: %clang %cflags -fPIC -pie -O3 -nostdlib -Wl,-q %s -o %t.exe
7207ea5f2SVladislav Khmelevsky // RUN: llvm-bolt %t.exe -o %t.bolt --reorder-data=".data" \
8207ea5f2SVladislav Khmelevsky // RUN:   -data %S/Inputs/reorder-data-writable-ptload.fdata
9207ea5f2SVladislav Khmelevsky // RUN: llvm-readelf -SlW %t.bolt | FileCheck %s
10207ea5f2SVladislav Khmelevsky 
11207ea5f2SVladislav Khmelevsky // CHECK: .bolt.org.data
12207ea5f2SVladislav Khmelevsky // CHECK: {{.*}} .data PROGBITS [[#%x,ADDR:]] [[#%x,OFF:]]
13207ea5f2SVladislav Khmelevsky // CHECK: LOAD 0x{{.*}}[[#OFF]] 0x{{.*}}[[#ADDR]] {{.*}} RW
14207ea5f2SVladislav Khmelevsky 
15207ea5f2SVladislav Khmelevsky volatile int cold1 = 42;
16207ea5f2SVladislav Khmelevsky volatile int hot1 = 42;
17207ea5f2SVladislav Khmelevsky volatile int cold2 = 42;
18207ea5f2SVladislav Khmelevsky volatile int cold3 = 42;
19207ea5f2SVladislav Khmelevsky 
_start()20207ea5f2SVladislav Khmelevsky void _start() {
21207ea5f2SVladislav Khmelevsky   hot1++;
22207ea5f2SVladislav Khmelevsky   _start();
23207ea5f2SVladislav Khmelevsky }
24