Skip to content

Commit

Permalink
[BOLT][TEST] Imported small tests
Browse files Browse the repository at this point in the history
Summary:
Imported small internal tests:
- cfi_instrs_reordered.s
- no_entry_reordering.test
- no_relocs.test
- pie.test

(cherry picked from FBD31514823)
  • Loading branch information
aaupov authored and maksfb committed Oct 8, 2021
1 parent d41b4e6 commit 872013e
Show file tree
Hide file tree
Showing 6 changed files with 1,122 additions and 0 deletions.
51 changes: 51 additions & 0 deletions bolt/test/X86/Inputs/entry.s
@@ -0,0 +1,51 @@
.globl _start
.type _start, %function
_start:
# FDATA: 0 [unknown] 0 1 _start 0 0 792
.cfi_startproc
LBB00:
movl $0x0, %eax
jmp Ltmp0

LFT0:
cmpl $0x0, %eax
jmp Ltmp1

Ltmp1:
jmp LBB00
# FDATA: 1 _start #Ltmp1# 1 _start #LBB00# 13 792

Ltmp0:
jmp Ltmp2

Ltmp2:
jmp Ltmp3

Ltmp3:
jmp Ltmp4

Ltmp4:
jmp Ltmp5

Ltmp5:
jmp Ltmp6

Ltmp6:
jmp Ltmp7

Ltmp7:
jmp Ltmp8

Ltmp8:
jmp Ltmp9

Ltmp9:
jmp Ltmp10

Ltmp10:
jmp Ltmp11

Ltmp11:
retq
.cfi_endproc
.size _start, .-_start
38 changes: 38 additions & 0 deletions bolt/test/X86/Inputs/jump_table_icp.cpp
@@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>

int total = 0;

int inc(int x) {
switch (x) {
case 0: total += 1 + 0; return 1;
case 1: total += 1 + 1; return 2;
case 2: total += 1 + 2; return 3;
case 3: total += 1 + 3; return 4;
case 4: total += 1 + 4; return 5;
case 5: total += 1 + 5; return 6;
default: return x + 1;
}
}

int inc_dup(int x) {
switch (x) {
case 0: total += 2 + 0; return 1;
case 1: total += 2 + 1; return 2;
case 2: total += 2 + 2; return 3;
case 3: total += 2 + 3; return 4;
case 4: total += 2 + 4; return 5;
case 5: total += 2 + 5; return 6;
default: return x + 1;
}
}

int main() {
int c = 0;
for (int i = 0; i < 10000000; ++i) {
int a = rand() % 7;
int b = rand() % 7;
c += inc(a) - 2*inc_dup(b);
}
return c == 0;
}

0 comments on commit 872013e

Please sign in to comment.