[llvm] [JITLink][PowerPC] Port rtdyld's tests to jitlink. NFC. (PR #65739)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 04:11:26 PDT 2023


https://github.com/bzEq created https://github.com/llvm/llvm-project/pull/65739:

None

>From 8667ad2bbdecff07638b20f084f9275e076ed616 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail at cn.ibm.com>
Date: Fri, 8 Sep 2023 19:09:32 +0800
Subject: [PATCH] Port rtdyld's tests

---
 .../JITLink/ppc64/Inputs/ppc64_elf_module_b.s | 42 ++++++++++++++++
 .../ExecutionEngine/JITLink/ppc64/ppc64_elf.s | 47 +++++++++++++++++
 .../JITLink/ppc64/ppc64_reloc.s               | 50 +++++++++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 llvm/test/ExecutionEngine/JITLink/ppc64/Inputs/ppc64_elf_module_b.s
 create mode 100644 llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_elf.s
 create mode 100644 llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_reloc.s

diff --git a/llvm/test/ExecutionEngine/JITLink/ppc64/Inputs/ppc64_elf_module_b.s b/llvm/test/ExecutionEngine/JITLink/ppc64/Inputs/ppc64_elf_module_b.s
new file mode 100644
index 000000000000000..f47ddbd4136869f
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/ppc64/Inputs/ppc64_elf_module_b.s
@@ -0,0 +1,42 @@
+# This module contains a function with its local and global entry points
+# exposed. It is used by the ppc64_elf test to verify that functions with
+# different TOCs are called via their global entry points.
+	.text
+	.abiversion 2
+	.file	"ppc64_elf_module_b.ll"
+	.section	.rodata.cst4,"aM", at progbits,4
+	.p2align	2               # -- Begin function foo
+.LCPI0_0:
+	.long	1093664768              # float 11
+	.text
+	.globl	foo
+	.p2align	4
+	.type	foo, at function
+.Lfunc_toc0:                            # @foo
+	.quad	.TOC.-foo_gep
+foo:
+.Lfunc_begin0:
+	.cfi_startproc
+        .globl  foo_gep
+foo_gep:
+	ld 2, .Lfunc_toc0-foo_gep(12)
+	add 2, 2, 12
+        .globl  foo_lep
+foo_lep:
+	.localentry	foo, foo_lep-foo_gep
+# %bb.0:
+	addis 3, 2, .LC0 at toc@ha
+	ld 3, .LC0 at toc@l(3)
+	lfsx 1, 0, 3
+	blr
+	.long	0
+	.quad	0
+.Lfunc_end0:
+	.size	foo, .Lfunc_end0-.Lfunc_begin0
+	.cfi_endproc
+                                        # -- End function
+	.section	.toc,"aw", at progbits
+.LC0:
+	.tc .LCPI0_0[TC],.LCPI0_0
+
+	.section	".note.GNU-stack","", at progbits
diff --git a/llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_elf.s b/llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_elf.s
new file mode 100644
index 000000000000000..85043c1c4b77d62
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_elf.s
@@ -0,0 +1,47 @@
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj -o %t/ppc64_elf.o %s
+# RUN: llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj -o %t/ppc64_elf_module_b.o %S/Inputs/ppc64_elf_module_b.s
+# RUN: llvm-jitlink -noexec -check %s %t/ppc64_elf.o %t/ppc64_elf_module_b.o
+	.text
+	.abiversion 2
+	.file	"Module2.ll"
+	.global main
+	.p2align 4
+	.type main, at function
+main:
+	li 3, 0
+	blr
+	.size main, .-main
+
+	.globl	bar                     # -- Begin function bar
+	.p2align	4
+	.type	bar, at function
+.Lfunc_toc0:                            # @bar
+	.quad	.TOC.-.Lfunc_gep0
+bar:
+.Lfunc_begin0:
+.Lfunc_gep0:
+	ld 2, .Lfunc_toc0-.Lfunc_gep0(12)
+	add 2, 2, 12
+.Lfunc_lep0:
+	.localentry	bar, .Lfunc_lep0-.Lfunc_gep0
+# %bb.0:
+	mflr 0
+	std 0, 16(1)
+	stdu 1, -32(1)
+# jitlink-check: (*{8}got_addr(ppc64_elf.o, foo)) = foo_gep
+# jitlink-check: decode_operand(bar+20, 0) = (stub_addr(ppc64_elf.o, foo) - (bar+20)) >> 2
+foo_call:
+	bl foo
+	nop
+	addi 1, 1, 32
+	ld 0, 16(1)
+	mtlr 0
+	blr
+	.long	0
+	.quad	0
+.Lfunc_end0:
+	.size	bar, .Lfunc_end0-.Lfunc_begin0
+                                        # -- End function
+
+	.section	".note.GNU-stack","", at progbits
diff --git a/llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_reloc.s b/llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_reloc.s
new file mode 100644
index 000000000000000..bfee1724993355d
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/ppc64/ppc64_reloc.s
@@ -0,0 +1,50 @@
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj -o %t/ppc64_reloc.o %s
+# RUN: llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj -o %t/ppc64_elf_module_b.o %S/Inputs/ppc64_elf_module_b.s
+# RUN: llvm-jitlink -noexec -check %s %t/ppc64_reloc.o %t/ppc64_elf_module_b.o
+
+	.text
+	.abiversion 2
+	.file	"test.c"
+	.globl main
+	.p2align	4
+	.type main, at function
+main:
+	li 3, 0
+	blr
+	.size main, .-main
+
+	.globl	func
+	.p2align	4
+	.type	func, at function
+func:                                   # @func
+.Lfunc_begin0:
+.Lfunc_gep0:
+	addis 2, 12, .TOC.-.Lfunc_gep0 at ha
+	addi 2, 2, .TOC.-.Lfunc_gep0 at l
+.Lfunc_lep0:
+	.localentry	func, .Lfunc_lep0-.Lfunc_gep0
+	mflr 0
+	std 31, -8(1)
+	std 0, 16(1)
+	stdu 1, -112(1)
+	mr 31, 1
+# confirm that LK flag is set for bl
+# jitlink-check: (*{4}(func+28)) & 1 = 1
+call_bl:
+	bl foo
+	nop
+	li 3, 0
+	addi 1, 1, 112
+	ld 0, 16(1)
+	ld 31, -8(1)
+	mtlr 0
+# confirm that LK flag is not set for b
+# jitlink-check: (*{4}(func+56)) & 1 = 0
+call_b:
+	b foo
+	nop
+	.long	0
+	.quad	0
+.Lfunc_end0:
+	.size	func, .Lfunc_end0-.Lfunc_begin0



More information about the llvm-commits mailing list