[Openmp-commits] [PATCH] D67190: Fix openmp on PowerPC64-BE-ELFv2 ABI on FreeBSD

Alfredo Dal'Ava JĂșnior via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Sep 4 11:49:03 PDT 2019


adalava created this revision.
adalava added reviewers: jlpeyton, AndreyChurbanov, hbae.
Herald added subscribers: openmp-commits, steven.zhang, shchenz, jsji, guansong, krytarowski, nemanjai, emaste.
Herald added a reviewer: jdoerfert.
Herald added a project: OpenMP.

openmp library incorrectly assumes OpenPower ELF v2 ABI is only used on little endian systems. This is not true, since ELFv2 ABI supports both big and little.

This patch correct this assumption by checking CALL_ELF variable instead of endiannes, and unbreaks openmp on FreeBSD/powerpc64-ELFv2 port (https://wiki.freebsd.org/powerpc/llvm-elfv2)

*I set the reviewers based on git log. Please feel free to change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67190

Files:
  openmp/runtime/src/kmp_platform.h
  openmp/runtime/src/z_Linux_asm.S


Index: openmp/runtime/src/z_Linux_asm.S
===================================================================
--- openmp/runtime/src/z_Linux_asm.S
+++ openmp/runtime/src/z_Linux_asm.S
@@ -1367,12 +1367,12 @@
 // return:	r3	(always 1/TRUE)
 //
 	.text
-# if KMP_ARCH_PPC64_LE
+# if KMP_ARCH_PPC64_ELFV2
 	.abiversion 2
 # endif
 	.globl	__kmp_invoke_microtask
 
-# if KMP_ARCH_PPC64_LE
+# if KMP_ARCH_PPC64_ELFv2
 	.p2align	4
 # else
 	.p2align	2
@@ -1380,7 +1380,7 @@
 
 	.type	__kmp_invoke_microtask, at function
 
-# if KMP_ARCH_PPC64_LE
+# if KMP_ARCH_PPC64_ELFv2
 __kmp_invoke_microtask:
 .Lfunc_begin0:
 .Lfunc_gep0:
@@ -1424,7 +1424,7 @@
 	.cfi_offset lr, 16
 
 // Compute the size necessary for the local stack frame.
-# if KMP_ARCH_PPC64_LE
+# if KMP_ARCH_PPC64_ELFv2
 	li 12, 72
 # else
 	li 12, 88
@@ -1502,7 +1502,7 @@
 // for the microtask begins 48 + 8*8 == 112 bytes above r1 for ELFv1 and
 // 32 + 8*8 == 96 bytes above r1 for ELFv2.
 	addi 4, 4, 40
-# if KMP_ARCH_PPC64_LE
+# if KMP_ARCH_PPC64_ELFv2
 	addi 12, 1, 88
 # else
 	addi 12, 1, 104
@@ -1514,7 +1514,7 @@
 	bdnz .Lnext
 
 .Lcall:
-# if KMP_ARCH_PPC64_LE
+# if KMP_ARCH_PPC64_ELFv2
 	std 2, 24(1)
 	mr 12, 3
 #else
@@ -1530,7 +1530,7 @@
 
 	mtctr 12
 	bctrl
-# if KMP_ARCH_PPC64_LE
+# if KMP_ARCH_PPC64_ELFv2
 	ld 2, 24(1)
 # else
 	ld 2, 40(1)
Index: openmp/runtime/src/kmp_platform.h
===================================================================
--- openmp/runtime/src/kmp_platform.h
+++ openmp/runtime/src/kmp_platform.h
@@ -93,9 +93,9 @@
 #define KMP_ARCH_X86 0
 #define KMP_ARCH_X86_64 0
 #define KMP_ARCH_AARCH64 0
-#define KMP_ARCH_PPC64_BE 0
-#define KMP_ARCH_PPC64_LE 0
-#define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_LE || KMP_ARCH_PPC64_BE)
+#define KMP_ARCH_PPC64_ELFv1 0
+#define KMP_ARCH_PPC64_ELFv2 0
+#define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_ELFv2 || KMP_ARCH_PPC64_ELFv1)
 #define KMP_ARCH_MIPS 0
 #define KMP_ARCH_MIPS64 0
 #define KMP_ARCH_RISCV64 0
@@ -118,12 +118,12 @@
 #undef KMP_ARCH_X86
 #define KMP_ARCH_X86 1
 #elif defined __powerpc64__
-#if defined __LITTLE_ENDIAN__
-#undef KMP_ARCH_PPC64_LE
-#define KMP_ARCH_PPC64_LE 1
+#if defined(_CALL_ELF) && _CALL_ELF == 2
+#undef KMP_ARCH_PPC64_ELFv2
+#define KMP_ARCH_PPC64_ELFv2 1
 #else
-#undef KMP_ARCH_PPC64_BE
-#define KMP_ARCH_PPC64_BE 1
+#undef KMP_ARCH_PPC64_ELFv1
+#define KMP_ARCH_PPC64_ELFv1 1
 #endif
 #elif defined __aarch64__
 #undef KMP_ARCH_AARCH64


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67190.218759.patch
Type: text/x-patch
Size: 2403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190904/275f8e35/attachment-0001.bin>


More information about the Openmp-commits mailing list