Files
clang-p2996/clang/test/CodeGenCUDA/lambda-noinline.cu
Pierre van Houtryve c05f1639f7 [clang][cuda/hip] Allow __noinline__ lambdas
D124866 seem to have had an unintended side effect: __noinline__ on lambdas was no longer accepted.

This fixes the regression and adds a test case for it.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D137251
2022-11-04 07:33:31 +00:00

24 lines
842 B
Plaintext

// RUN: %clang_cc1 -no-opaque-pointers -x hip -emit-llvm -std=c++11 %s -o - \
// RUN: -triple x86_64-linux-gnu \
// RUN: | FileCheck -check-prefix=HOST %s
// RUN: %clang_cc1 -no-opaque-pointers -x hip -emit-llvm -std=c++11 %s -o - \
// RUN: -triple amdgcn-amd-amdhsa -fcuda-is-device \
// RUN: | FileCheck -check-prefix=DEV %s
#include "Inputs/cuda.h"
// Checks noinline is correctly added to the lambda function.
// HOST: define{{.*}}@_ZZ4HostvENKUlvE_clEv({{.*}}) #[[ATTR:[0-9]+]]
// HOST: attributes #[[ATTR]]{{.*}}noinline
// DEV: define{{.*}}@_ZZ6DevicevENKUlvE_clEv({{.*}}) #[[ATTR:[0-9]+]]
// DEV: attributes #[[ATTR]]{{.*}}noinline
__device__ int a;
int b;
__device__ int Device() { return ([&] __device__ __noinline__ (){ return a; })(); }
__host__ int Host() { return ([&] __host__ __noinline__ (){ return b; })(); }