[PATCH] D61458: [hip] Relax CUDA call restriction within `decltype` context.
Michael Liao via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 2 13:57:21 PDT 2019
hliao updated this revision to Diff 197860.
hliao added a comment.
simplify the logic using `llvm::any_of`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61458/new/
https://reviews.llvm.org/D61458
Files:
clang/include/clang/Sema/Sema.h
clang/test/CodeGenCUDA/function-overload.cu
Index: clang/test/CodeGenCUDA/function-overload.cu
===================================================================
--- clang/test/CodeGenCUDA/function-overload.cu
+++ clang/test/CodeGenCUDA/function-overload.cu
@@ -8,6 +8,8 @@
// RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-HOST %s
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-DEVICE %s
+// RUN: %clang_cc1 -std=c++11 -DCHECK_DECLTYPE -triple amdgcn -fcuda-is-device -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefix=CHECK-DECLTYPE %s
#include "Inputs/cuda.h"
@@ -53,3 +55,14 @@
// CHECK-BOTH: define linkonce_odr void @_ZN7s_cd_hdD2Ev(
// CHECK-BOTH: store i32 32,
// CHECK-BOTH: ret void
+
+#if defined(CHECK_DECLTYPE)
+int foo(float);
+// CHECK-DECLTYPE-LABEL: @_Z3barf
+// CHECK-DECLTYPE: fptosi
+// CHECK-DECLTYPE: sitofp
+__device__ float bar(float x) {
+ decltype(foo(x)) y = x;
+ return y + 3.f;
+}
+#endif
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10406,6 +10406,12 @@
/// semantically correct CUDA programs, but only if they're never codegen'ed.
bool IsAllowedCUDACall(const FunctionDecl *Caller,
const FunctionDecl *Callee) {
+ if (llvm::any_of(ExprEvalContexts,
+ [](const ExpressionEvaluationContextRecord &C) {
+ return C.ExprContext ==
+ ExpressionEvaluationContextRecord::EK_Decltype;
+ }))
+ return true;
return IdentifyCUDAPreference(Caller, Callee) != CFP_Never;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61458.197860.patch
Type: text/x-patch
Size: 1774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190502/820fb698/attachment-0001.bin>
More information about the cfe-commits
mailing list