r340772 - [OpenMP][NVPTX] Use appropriate _CALL_ELF macro when offloading

Gheorghe-Teodor Bercea via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 13:16:20 PDT 2018


Author: gbercea
Date: Mon Aug 27 13:16:20 2018
New Revision: 340772

URL: http://llvm.org/viewvc/llvm-project?rev=340772&view=rev
Log:
[OpenMP][NVPTX] Use appropriate _CALL_ELF macro when offloading

Summary: When offloading to a device and using the powerpc64le version of the auxiliary triple, the _CALL_ELF macro is not set correctly to 2 resulting in the attempt to include a header that does not exist. This patch fixes this problem.

Reviewers: Hahnfeld, ABataev, caomhin

Reviewed By: Hahnfeld

Subscribers: guansong, cfe-commits

Differential Revision: https://reviews.llvm.org/D51312

Modified:
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/Preprocessor/aux-triple.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=340772&r1=340771&r2=340772&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Aug 27 13:16:20 2018
@@ -1106,14 +1106,19 @@ static void InitializePredefinedAuxMacro
   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;

Modified: cfe/trunk/test/Preprocessor/aux-triple.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aux-triple.c?rev=340772&r1=340771&r2=340772&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/aux-triple.c (original)
+++ cfe/trunk/test/Preprocessor/aux-triple.c Mon Aug 27 13:16:20 2018
@@ -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,7 +24,7 @@
 // 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 \
@@ -33,13 +33,15 @@
 // 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




More information about the cfe-commits mailing list