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] Remove noreturn function attribute #2165

Merged
merged 1 commit into from
Jul 28, 2020
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
13 changes: 12 additions & 1 deletion clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4971,10 +4971,21 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,

// 4. Finish the call.

// SYCL does not support C++ exceptions or termination in device code, so all
// functions have to return.
bool SyclSkipNoReturn = false;
if (getLangOpts().SYCLIsDevice && CI->doesNotReturn()) {
if (auto *F = CI->getCalledFunction())
F->removeFnAttr(llvm::Attribute::NoReturn);
CI->removeAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoReturn);
SyclSkipNoReturn = true;
}

// If the call doesn't return for non-sycl devices, finish the basic block and
// clear the insertion point; this allows the rest of IRGen to discard
// unreachable code.
if (CI->doesNotReturn() && !getLangOpts().SYCLIsDevice) {
if (!SyclSkipNoReturn && CI->doesNotReturn()) {
if (UnusedReturnSizePtr)
PopCleanupBlock();

Expand Down
4 changes: 3 additions & 1 deletion clang/test/CodeGenSYCL/remove-ur-inst.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-enable-optimizations -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s

SYCL_EXTERNAL void doesNotReturn() throw() __attribute__((__noreturn__));

Expand All @@ -11,6 +12,7 @@ int main() {
kernel<class test>([]() {
doesNotReturn();
// CHECK-NOT: unreachable
// CHECK-NOT: noreturn
});
return 0;
}
}