mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 18:16:04 +00:00

CUDA/HIP programs use __noinline__ like a keyword e.g. __noinline__ void foo() {} since __noinline__ is defined as a macro __attribute__((noinline)) in CUDA/HIP runtime header files. However, gcc and clang supports __attribute__((__noinline__)) the same as __attribute__((noinline)). Some C++ libraries use __attribute__((__noinline__)) in their header files. When CUDA/HIP programs include such header files, clang will emit error about invalid attributes. This patch fixes this issue by supporting __noinline__ as a keyword, so that CUDA/HIP runtime could remove the macro definition. Reviewed by: Aaron Ballman, Artem Belevich Differential Revision: https://reviews.llvm.org/D124866
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
// Uses -O2 since the defalt -O0 option adds noinline to all functions.
|
|
|
|
// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
|
|
// RUN: -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
|
|
// RUN: -O2 -disable-llvm-passes -emit-llvm -o - -x hip %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-gnu-linux \
|
|
// RUN: -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
|
|
|
|
#include "Inputs/cuda.h"
|
|
|
|
__noinline__ __device__ __host__ void fun1() {}
|
|
|
|
__attribute__((noinline)) __device__ __host__ void fun2() {}
|
|
|
|
__attribute__((__noinline__)) __device__ __host__ void fun3() {}
|
|
|
|
[[gnu::__noinline__]] __device__ __host__ void fun4() {}
|
|
|
|
#define __noinline__ __attribute__((__noinline__))
|
|
__noinline__ __device__ __host__ void fun5() {}
|
|
|
|
__device__ __host__ void fun6() {}
|
|
|
|
// CHECK: define{{.*}}@_Z4fun1v{{.*}}#[[ATTR1:[0-9]*]]
|
|
// CHECK: define{{.*}}@_Z4fun2v{{.*}}#[[ATTR1:[0-9]*]]
|
|
// CHECK: define{{.*}}@_Z4fun3v{{.*}}#[[ATTR1:[0-9]*]]
|
|
// CHECK: define{{.*}}@_Z4fun4v{{.*}}#[[ATTR1:[0-9]*]]
|
|
// CHECK: define{{.*}}@_Z4fun5v{{.*}}#[[ATTR1:[0-9]*]]
|
|
// CHECK: define{{.*}}@_Z4fun6v{{.*}}#[[ATTR2:[0-9]*]]
|
|
// CHECK: attributes #[[ATTR1]] = {{.*}}noinline
|
|
// CHECK-NOT: attributes #[[ATTR2]] = {{.*}}noinline
|