Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Fix a crash with __bulitin_unique_stable_name #3284

Merged
merged 3 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,11 @@ static ExprResult TransformUniqueStableName(TemplateInstantiator &TI,
TI.getSema(), Sema::ExpressionEvaluationContext::Unevaluated);
ExprResult SubExpr = TI.getDerived().TransformExpr(E->getExpr());

if (SubExpr.isInvalid())
return ExprError();

SubExpr = TI.getSema().CheckPlaceholderExpr(SubExpr.get());

if (SubExpr.isInvalid())
return ExprError();
bader marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
28 changes: 28 additions & 0 deletions clang/test/CodeGenSYCL/unique-stable-name-placeholder-crash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -internal-isystem %S/Inputs -std=c++17 -sycl-std=2020 -fsycl -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s

#include <sycl.hpp>

using namespace cl::sycl;

struct A {
int a = 0;
A() = default;
};
constexpr A THE_NAME;

template <auto &R> void temp() {}
template <auto &R> void foo(const char *out) {
out = __builtin_unique_stable_name(temp<R>);
}

int main() {
kernel_single_task<class kernel>(
[]() {
const char *c;
foo<THE_NAME>(c);
});
}

// Note: the mangling here is actually the 'typeinfo name for void ()'. That is
// because the type of temp<R> is actually the function type (which is void()).
// CHECK: @__builtin_unique_stable_name._Z3fooIL_ZL8THE_NAMEEEvPKc = private unnamed_addr addrspace(1) constant [9 x i8] c"_ZTSFvvE\00", align 1