forked from OSchip/llvm-project
[BOLT][TEST] Imported small tests
Summary: Imported small internal tests: - re-optimize.test - relaxed_tailcall.test - remove_unused.test - retpoline_synthetic.test (cherry picked from FBD31516680)
This commit is contained in:
parent
872013e077
commit
f44e1df9d0
|
@ -0,0 +1,21 @@
|
|||
.globl main
|
||||
.type main, %function
|
||||
main:
|
||||
pushq %rax
|
||||
callq foo
|
||||
movl $0x1, %eax
|
||||
popq %rdx
|
||||
retq
|
||||
.size main, .-main
|
||||
|
||||
.globl foo
|
||||
.type foo, %function
|
||||
foo:
|
||||
jmp bar
|
||||
.size foo, .-foo
|
||||
|
||||
.globl bar
|
||||
.type bar, %function
|
||||
bar:
|
||||
retq
|
||||
.size bar, .-bar
|
|
@ -0,0 +1,7 @@
|
|||
# Check that we detect re-optimization attempt.
|
||||
|
||||
RUN: %clang %S/Inputs/icf-jump-tables.c -o %t.exe
|
||||
RUN: llvm-bolt %t.exe -o %t 2>&1 > /dev/null
|
||||
RUN: not llvm-bolt %t -o %t.bolt 2>&1 | FileCheck %s
|
||||
|
||||
CHECK: BOLT-ERROR: input file was processed by BOLT. Cannot re-optimize.
|
|
@ -0,0 +1,7 @@
|
|||
# Check that tail calls can be 2 bytes in the output binary.
|
||||
|
||||
RUN: %clang %cflags %S/Inputs/relaxed_tc.s -o %t.exe -Wl,-q
|
||||
RUN: llvm-bolt %t.exe -relocs -o %t
|
||||
RUN: llvm-objdump -d --disassemble-symbols=foo %t | FileCheck %s
|
||||
|
||||
CHECK: eb 00 jmp {{.*}} <bar>
|
|
@ -0,0 +1,13 @@
|
|||
# Verifies that llvm-bolt is able to remove dead basic blocks. Also check that
|
||||
# the BB reordering ignores dead BBs.
|
||||
|
||||
RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %S/Inputs/entry.s -o %t.o
|
||||
RUN: link_fdata %S/Inputs/entry.s %t.o %t.fdata
|
||||
RUN: llvm-strip --strip-unneeded %t.o
|
||||
RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
|
||||
RUN: llvm-bolt %t.exe -data %t.fdata -o %t -funcs=_start \
|
||||
RUN: -eliminate-unreachable -reorder-blocks=none \
|
||||
RUN: -print-finalized -sequential-disassembly 2>&1 | FileCheck %s
|
||||
|
||||
# Optimized
|
||||
CHECK: BB Layout : .LBB00, .Ltmp0, .Ltmp2, .Ltmp3, .Ltmp4, .Ltmp5, .Ltmp6, .Ltmp7, .Ltmp8, .Ltmp9, .Ltmp10, .Ltmp11
|
|
@ -0,0 +1,46 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Base {
|
||||
public:
|
||||
virtual int Foo() = 0;
|
||||
};
|
||||
|
||||
class Derived1 : public Base {
|
||||
public:
|
||||
int Foo() override { return 1; }
|
||||
};
|
||||
|
||||
class Derived2 : public Base {
|
||||
public:
|
||||
int Foo() override { return 2; }
|
||||
};
|
||||
|
||||
class Derived3 : public Base {
|
||||
public:
|
||||
int Foo() override { return 3; }
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
long long sum = 0;
|
||||
int outerIters = atoi(argv[1]);
|
||||
int selector = atoi(argv[2]);
|
||||
|
||||
Base *obj1 = new Derived1();
|
||||
Base *obj2 = new Derived2();
|
||||
Base *obj3 = new Derived3();
|
||||
|
||||
for (int j = 0; j < outerIters; j++) {
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
switch (selector) {
|
||||
case 1: sum += obj1->Foo(); break;
|
||||
case 2: sum += obj2->Foo(); break;
|
||||
case 3: sum += obj3->Foo(); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%lld\n", sum);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
# Check that llvm-bolt retpoline all indirect branches and the resulting binary
|
||||
# correctly runs.
|
||||
|
||||
REQUIRES: x86_64-linux
|
||||
|
||||
RUN: %clangxx %S/Inputs/retpoline_synthetic.cpp -fno-jump-tables -Wl,-q,-znow \
|
||||
RUN: -O2 -o %t.exe
|
||||
RUN: llvm-bolt %t.exe -o %t -insert-retpolines -trap-old-code &> %t.log &&\
|
||||
RUN: (echo "callq count:" ; (llvm-objdump -d %t | grep -c "callq \*")) &>> %t.log ;\
|
||||
RUN: (echo "jmpq count:" ; (llvm-objdump -d -j ".text" %t | grep -c "jmpq \*")) &>> %t.log ;\
|
||||
RUN: (echo "running binary" ; %t 1000 3 ) &>> %t.log && FileCheck %s -input-file %t.log
|
||||
|
||||
CHECK: callq count:
|
||||
CHECK-NEXT: 0
|
||||
CHECK-NEXT: jmpq count:
|
||||
CHECK-NEXT: 0
|
||||
CHECK-NEXT: running binary
|
||||
CHECK-NEXT: 30000000
|
Loading…
Reference in New Issue