-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Orc][PowerPC] Enable ELFNixPlatform support for ppc64le
Since jitlink for ppc64le is ready for general use, test cases in compiler-rt for ELFNixPlatform support can be enabled. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D156399
- Loading branch information
Showing
13 changed files
with
554 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
compiler-rt/test/orc/TestCases/Linux/ppc64/ehframe-default.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// RUN: %clangxx -fexceptions -fPIC -c -o %t %s | ||
// RUN: %llvm_jitlink %t | ||
|
||
extern "C" void llvm_jitlink_setTestResultOverride(long Value); | ||
|
||
int main(int argc, char *argv[]) { | ||
llvm_jitlink_setTestResultOverride(1); | ||
try { | ||
throw 0; | ||
} catch (int X) { | ||
llvm_jitlink_setTestResultOverride(X); | ||
} | ||
return 0; | ||
} |
15 changes: 15 additions & 0 deletions
15
compiler-rt/test/orc/TestCases/Linux/ppc64/ehframe-libunwind.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// REQUIRES: libunwind-available | ||
// RUN: %clangxx -fexceptions -fPIC -c -o %t %s | ||
// RUN: env LD_PRELOAD=%shared_libunwind %llvm_jitlink %t | ||
|
||
extern "C" void llvm_jitlink_setTestResultOverride(long Value); | ||
|
||
int main(int argc, char *argv[]) { | ||
llvm_jitlink_setTestResultOverride(1); | ||
try { | ||
throw 0; | ||
} catch (int X) { | ||
llvm_jitlink_setTestResultOverride(X); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# TODO: jitlink for ppc64/powerpc64 hasn't been well tested yet. | ||
# We should support it in the future. | ||
if config.root.host_arch != "ppc64le": | ||
config.unsupported = True | ||
|
||
if config.target_arch != "powerpc64le": | ||
config.unsupported = True |
15 changes: 15 additions & 0 deletions
15
compiler-rt/test/orc/TestCases/Linux/ppc64/lljit-ehframe.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// RUN: %clangxx -fPIC -emit-llvm -c -o %t %s | ||
// RUN: %lli_orc_jitlink -relocation-model=pic %t | FileCheck %s | ||
|
||
// CHECK: catch | ||
|
||
#include <stdio.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
try { | ||
throw 0; | ||
} catch (int X) { | ||
puts("catch"); | ||
} | ||
return 0; | ||
} |
32 changes: 32 additions & 0 deletions
32
compiler-rt/test/orc/TestCases/Linux/ppc64/lljit-initialize-deinitialize.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; RUN: %lli_orc_jitlink %s | FileCheck %s | ||
|
||
; CHECK: constructor | ||
; CHECK-NEXT: main | ||
; CHECK-NEXT: destructor | ||
|
||
@__dso_handle = external hidden global i8 | ||
@.str = private unnamed_addr constant [5 x i8] c"main\00", align 1 | ||
@.str.1 = private unnamed_addr constant [12 x i8] c"constructor\00", align 1 | ||
@.str.2 = private unnamed_addr constant [11 x i8] c"destructor\00", align 1 | ||
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @constructor, i8* null }] | ||
|
||
define dso_local void @destructor(i8* %0) { | ||
%2 = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0)) | ||
ret void | ||
} | ||
|
||
declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) | ||
|
||
; Function Attrs: nofree norecurse nounwind uwtable | ||
define dso_local i32 @main(i32 %0, i8** nocapture readnone %1) local_unnamed_addr #2 { | ||
%3 = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)) | ||
ret i32 0 | ||
} | ||
|
||
declare i32 @puts(i8* nocapture readonly) | ||
|
||
define internal void @constructor() { | ||
%1 = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0)) #5 | ||
%2 = tail call i32 @__cxa_atexit(void (i8*)* @destructor, i8* null, i8* nonnull @__dso_handle) #5 | ||
ret void | ||
} |
188 changes: 188 additions & 0 deletions
188
compiler-rt/test/orc/TestCases/Linux/ppc64/priority-static-initializer.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
// Test that ELF static initializers with different constructor priorities work | ||
// and are executed in the proper order. | ||
// | ||
// RUN: %clang -c -o %t %s | ||
// RUN: %llvm_jitlink %t | FileCheck %s | ||
|
||
// CHECK: constructor 100 | ||
// CHECK-NEXT: constructor 200 | ||
// CHECK-NEXT: constructor 65535 | ||
// CHECK-NEXT: main | ||
// CHECK-NEXT: destructor | ||
|
||
.text | ||
.abiversion 2 | ||
.globl constructor.100 | ||
.p2align 4 | ||
.type constructor.100,@function | ||
constructor.100: | ||
.Lfunc_begin0: | ||
.Lfunc_gep0: | ||
addis 2, 12, .TOC.-.Lfunc_gep0@ha | ||
addi 2, 2, .TOC.-.Lfunc_gep0@l | ||
.Lfunc_lep0: | ||
.localentry constructor.100, .Lfunc_lep0-.Lfunc_gep0 | ||
mflr 0 | ||
stdu 1, -32(1) | ||
std 0, 48(1) | ||
addis 3, 2, .L.str@toc@ha | ||
addi 3, 3, .L.str@toc@l | ||
bl puts | ||
nop | ||
addi 1, 1, 32 | ||
ld 0, 16(1) | ||
mtlr 0 | ||
blr | ||
.long 0 | ||
.quad 0 | ||
.Lfunc_end0: | ||
.size constructor.100, .Lfunc_end0-.Lfunc_begin0 | ||
|
||
.globl constructor.200 | ||
.p2align 4 | ||
.type constructor.200,@function | ||
constructor.200: | ||
.Lfunc_begin1: | ||
.Lfunc_gep1: | ||
addis 2, 12, .TOC.-.Lfunc_gep1@ha | ||
addi 2, 2, .TOC.-.Lfunc_gep1@l | ||
.Lfunc_lep1: | ||
.localentry constructor.200, .Lfunc_lep1-.Lfunc_gep1 | ||
mflr 0 | ||
stdu 1, -32(1) | ||
std 0, 48(1) | ||
addis 3, 2, .L.str.1@toc@ha | ||
addi 3, 3, .L.str.1@toc@l | ||
bl puts | ||
nop | ||
addi 1, 1, 32 | ||
ld 0, 16(1) | ||
mtlr 0 | ||
blr | ||
.long 0 | ||
.quad 0 | ||
.Lfunc_end1: | ||
.size constructor.200, .Lfunc_end1-.Lfunc_begin1 | ||
|
||
.globl constructor.65535 | ||
.p2align 4 | ||
.type constructor.65535,@function | ||
constructor.65535: | ||
.Lfunc_begin2: | ||
.Lfunc_gep2: | ||
addis 2, 12, .TOC.-.Lfunc_gep2@ha | ||
addi 2, 2, .TOC.-.Lfunc_gep2@l | ||
.Lfunc_lep2: | ||
.localentry constructor.65535, .Lfunc_lep2-.Lfunc_gep2 | ||
mflr 0 | ||
stdu 1, -32(1) | ||
std 0, 48(1) | ||
addis 3, 2, .L.str.2@toc@ha | ||
addi 3, 3, .L.str.2@toc@l | ||
bl puts | ||
nop | ||
addis 3, 2, destructor@toc@ha | ||
addi 3, 3, destructor@toc@l | ||
addis 5, 2, __dso_handle@toc@ha | ||
addi 5, 5, __dso_handle@toc@l | ||
li 4, 0 | ||
bl __cxa_atexit | ||
nop | ||
addi 1, 1, 32 | ||
ld 0, 16(1) | ||
mtlr 0 | ||
blr | ||
.long 0 | ||
.quad 0 | ||
.Lfunc_end2: | ||
.size constructor.65535, .Lfunc_end2-.Lfunc_begin2 | ||
|
||
.globl destructor | ||
.p2align 4 | ||
.type destructor,@function | ||
destructor: | ||
.Lfunc_begin3: | ||
.Lfunc_gep3: | ||
addis 2, 12, .TOC.-.Lfunc_gep3@ha | ||
addi 2, 2, .TOC.-.Lfunc_gep3@l | ||
.Lfunc_lep3: | ||
.localentry destructor, .Lfunc_lep3-.Lfunc_gep3 | ||
mflr 0 | ||
stdu 1, -32(1) | ||
std 0, 48(1) | ||
addis 3, 2, .L.str.3@toc@ha | ||
addi 3, 3, .L.str.3@toc@l | ||
bl puts | ||
nop | ||
addi 1, 1, 32 | ||
ld 0, 16(1) | ||
mtlr 0 | ||
blr | ||
.long 0 | ||
.quad 0 | ||
.Lfunc_end3: | ||
.size destructor, .Lfunc_end3-.Lfunc_begin3 | ||
|
||
.globl main | ||
.p2align 4 | ||
.type main,@function | ||
main: | ||
.Lfunc_begin4: | ||
.Lfunc_gep4: | ||
addis 2, 12, .TOC.-.Lfunc_gep4@ha | ||
addi 2, 2, .TOC.-.Lfunc_gep4@l | ||
.Lfunc_lep4: | ||
.localentry main, .Lfunc_lep4-.Lfunc_gep4 | ||
mflr 0 | ||
stdu 1, -32(1) | ||
std 0, 48(1) | ||
addis 3, 2, .L.str.4@toc@ha | ||
addi 3, 3, .L.str.4@toc@l | ||
bl puts | ||
nop | ||
li 3, 0 | ||
addi 1, 1, 32 | ||
ld 0, 16(1) | ||
mtlr 0 | ||
blr | ||
.long 0 | ||
.quad 0 | ||
.Lfunc_end4: | ||
.size main, .Lfunc_end4-.Lfunc_begin4 | ||
|
||
.hidden __dso_handle | ||
.type .L.str,@object | ||
.section .rodata.str1.1,"aMS",@progbits,1 | ||
.L.str: | ||
.asciz "constructor 100" | ||
.size .L.str, 16 | ||
|
||
.type .L.str.1,@object | ||
.L.str.1: | ||
.asciz "constructor 200" | ||
.size .L.str.1, 16 | ||
|
||
.type .L.str.2,@object | ||
.L.str.2: | ||
.asciz "constructor 65535" | ||
.size .L.str.2, 18 | ||
|
||
.type .L.str.3,@object | ||
.L.str.3: | ||
.asciz "destructor" | ||
.size .L.str.3, 11 | ||
|
||
.type .L.str.4,@object | ||
.L.str.4: | ||
.asciz "main" | ||
.size .L.str.4, 5 | ||
|
||
.section .init_array.100,"aw",@init_array | ||
.p2align 3 | ||
.quad constructor.100 | ||
.section .init_array.200,"aw",@init_array | ||
.p2align 3 | ||
.quad constructor.200 | ||
.section .init_array,"aw",@init_array | ||
.p2align 3 | ||
.quad constructor.65535 |
63 changes: 63 additions & 0 deletions
63
compiler-rt/test/orc/TestCases/Linux/ppc64/trivial-atexit.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Test that the runtime correctly interposes atexit. | ||
// | ||
// RUN: %clang -c -o %t %s | ||
// RUN: %llvm_jitlink %t | ||
|
||
.text | ||
.abiversion 2 | ||
// on_exit_hook destructor resets the test result override to zero. | ||
.globl on_exit_hook | ||
.p2align 4 | ||
.type on_exit_hook,@function | ||
on_exit_hook: | ||
.Lfunc_begin0: | ||
.Lfunc_gep0: | ||
addis 2, 12, .TOC.-.Lfunc_gep0@ha | ||
addi 2, 2, .TOC.-.Lfunc_gep0@l | ||
.Lfunc_lep0: | ||
.localentry on_exit_hook, .Lfunc_lep0-.Lfunc_gep0 | ||
mflr 0 | ||
stdu 1, -32(1) | ||
std 0, 48(1) | ||
li 3, 0 | ||
bl llvm_jitlink_setTestResultOverride | ||
nop | ||
addi 1, 1, 32 | ||
ld 0, 16(1) | ||
mtlr 0 | ||
blr | ||
.long 0 | ||
.quad 0 | ||
.Lfunc_end0: | ||
.size on_exit_hook, .Lfunc_end0-.Lfunc_begin0 | ||
|
||
// main registers the atexit and sets the test result to one. | ||
.globl main | ||
.p2align 4 | ||
.type main,@function | ||
main: | ||
.Lfunc_begin1: | ||
.Lfunc_gep1: | ||
addis 2, 12, .TOC.-.Lfunc_gep1@ha | ||
addi 2, 2, .TOC.-.Lfunc_gep1@l | ||
.Lfunc_lep1: | ||
.localentry main, .Lfunc_lep1-.Lfunc_gep1 | ||
mflr 0 | ||
stdu 1, -32(1) | ||
std 0, 48(1) | ||
addis 3, 2, on_exit_hook@toc@ha | ||
addi 3, 3, on_exit_hook@toc@l | ||
bl atexit | ||
nop | ||
li 3, 1 | ||
bl llvm_jitlink_setTestResultOverride | ||
nop | ||
li 3, 0 | ||
addi 1, 1, 32 | ||
ld 0, 16(1) | ||
mtlr 0 | ||
blr | ||
.long 0 | ||
.quad 0 | ||
.Lfunc_end1: | ||
.size main, .Lfunc_end1-.Lfunc_begin1 |
Oops, something went wrong.