[PATCH] D51312: [OpenMP][NVPTX] Use appropriate _CALL_ELF macro when offloading

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 10:44:05 PDT 2018


gtbercea updated this revision to Diff 162708.
gtbercea added a comment.

Add test.


Repository:
  rC Clang

https://reviews.llvm.org/D51312

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/aux-triple.c


Index: test/Preprocessor/aux-triple.c
===================================================================
--- test/Preprocessor/aux-triple.c
+++ test/Preprocessor/aux-triple.c
@@ -14,7 +14,7 @@
 // RUN: %clang_cc1 -x cuda -E -dM -ffreestanding < /dev/null \
 // RUN:     -triple nvptx64-none-none -aux-triple powerpc64le-unknown-linux-gnu \
 // RUN:   | FileCheck -match-full-lines %s \
-// RUN:     -check-prefixes NVPTX64,PPC64,LINUX,LINUX-CPP
+// RUN:     -check-prefixes NVPTX64,PPC64LE,LINUX,LINUX-CPP
 // RUN: %clang_cc1 -x cuda -E -dM -ffreestanding < /dev/null \
 // RUN:     -triple nvptx64-none-none -aux-triple x86_64-unknown-linux-gnu \
 // RUN:   | FileCheck -match-full-lines %s \
@@ -24,22 +24,24 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding < /dev/null \
 // RUN:     -fopenmp -fopenmp-is-device -triple nvptx64-none-none \
 // RUN:     -aux-triple powerpc64le-unknown-linux-gnu \
-// RUN:   | FileCheck -match-full-lines -check-prefixes NVPTX64,PPC64,LINUX %s
+// RUN:   | FileCheck -match-full-lines -check-prefixes NVPTX64,PPC64LE,LINUX %s
 // RUN: %clang_cc1 -E -dM -ffreestanding < /dev/null \
 // RUN:     -fopenmp -fopenmp-is-device -triple nvptx64-none-none \
 // RUN:     -aux-triple x86_64-unknown-linux-gnu \
 // RUN:   | FileCheck -match-full-lines -check-prefixes NVPTX64,X86_64,LINUX %s
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding < /dev/null \
 // RUN:     -fopenmp -fopenmp-is-device -triple nvptx64-none-none \
 // RUN:     -aux-triple powerpc64le-unknown-linux-gnu \
 // RUN:   | FileCheck -match-full-lines %s \
-// RUN:     -check-prefixes NVPTX64,PPC64,LINUX,LINUX-CPP
+// RUN:     -check-prefixes NVPTX64,PPC64LE,LINUX,LINUX-CPP
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding < /dev/null \
 // RUN:     -fopenmp -fopenmp-is-device -triple nvptx64-none-none \
 // RUN:     -aux-triple x86_64-unknown-linux-gnu \
 // RUN:   | FileCheck -match-full-lines %s \
 // RUN:     -check-prefixes NVPTX64,X86_64,LINUX,LINUX-CPP
 
+// PPC64LE:#define _CALL_ELF 2
+
 // NONE-NOT:#define _GNU_SOURCE
 // LINUX-CPP:#define _GNU_SOURCE 1
 
@@ -56,7 +58,7 @@
 // LINUX:#define __linux__ 1
 
 // NONE-NOT:#define __powerpc64__
-// PPC64:#define __powerpc64__ 1
+// PPC64LE:#define __powerpc64__ 1
 
 // NONE-NOT:#define __x86_64__
 // X86_64:#define __x86_64__ 1
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1106,14 +1106,19 @@
   auto AuxTriple = AuxTI.getTriple();
 
   // Define basic target macros needed by at least bits/wordsize.h and
-  // bits/mathinline.h
+  // bits/mathinline.h.
+  // On PowerPC, explicitely set _CALL_ELF macro needed for gnu/stubs.h.
   switch (AuxTriple.getArch()) {
   case llvm::Triple::x86_64:
     Builder.defineMacro("__x86_64__");
     break;
   case llvm::Triple::ppc64:
+    Builder.defineMacro("__powerpc64__");
+    Builder.defineMacro("_CALL_ELF", "1");
+    break;
   case llvm::Triple::ppc64le:
     Builder.defineMacro("__powerpc64__");
+    Builder.defineMacro("_CALL_ELF", "2");
     break;
   default:
     break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51312.162708.patch
Type: text/x-patch
Size: 3133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180827/0a1f5bda/attachment-0001.bin>


More information about the cfe-commits mailing list