unnamed-types.cu 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-linux-gnu -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
  2. // RUN: %clang_cc1 -std=c++11 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE
  3. #include "Inputs/cuda.h"
  4. // HOST: @0 = private unnamed_addr constant [43 x i8] c"_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_\00", align 1
  5. __device__ float d0(float x) {
  6. return [](float x) { return x + 2.f; }(x);
  7. }
  8. __device__ float d1(float x) {
  9. return [](float x) { return x * 2.f; }(x);
  10. }
  11. // DEVICE: amdgpu_kernel void @_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_(
  12. template <typename F>
  13. __global__ void k0(float *p, F f) {
  14. p[0] = f(p[0]) + d0(p[1]) + d1(p[2]);
  15. }
  16. void f0(float *p) {
  17. [](float *p) {
  18. *p = 1.f;
  19. }(p);
  20. }
  21. // The inner/outer lambdas are required to be mangled following ODR but their
  22. // linkages are still required to keep the original `internal` linkage.
  23. // HOST: define internal void @_ZZ2f1PfENKUlS_E_clES_(
  24. // DEVICE: define internal float @_ZZZ2f1PfENKUlS_E_clES_ENKUlfE_clEf(
  25. void f1(float *p) {
  26. [](float *p) {
  27. k0<<<1,1>>>(p, [] __device__ (float x) { return x + 1.f; });
  28. }(p);
  29. }
  30. // HOST: @__hip_register_globals
  31. // HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0