Skip to content

Commit 3139f5c

Browse files
authored
Fix crash when using -ffp-accuracy and std:: trigonometric functions. (#11606)
This is to fix a crash in the host compilation when calling any std:: trigonometric function.
1 parent 4cf7087 commit 3139f5c

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5688,10 +5688,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
56885688
if (!getLangOpts().FPAccuracyFuncMap.empty() ||
56895689
!getLangOpts().FPAccuracyVal.empty()) {
56905690
const auto *FD = dyn_cast_if_present<FunctionDecl>(TargetDecl);
5691-
assert(FD && "expecting a function");
5692-
CI = EmitFPBuiltinIndirectCall(IRFuncTy, IRCallArgs, CalleePtr, FD);
5693-
if (CI)
5694-
return RValue::get(CI);
5691+
if (FD) {
5692+
CI = EmitFPBuiltinIndirectCall(IRFuncTy, IRCallArgs, CalleePtr, FD);
5693+
if (CI)
5694+
return RValue::get(CI);
5695+
}
56955696
}
56965697
CI = Builder.CreateCall(IRFuncTy, CalleePtr, IRCallArgs, BundleList);
56975698
} else {

sycl/test/basic_tests/fp-accuracy.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clangxx -%fsycl-host-only -c -ffp-accuracy=high -faltmathlib=SVMLAltMathLibrary -fno-math-errno %s
2+
3+
#include <sycl/sycl.hpp>
4+
using namespace sycl;
5+
6+
int main() {
7+
queue deviceQueue;
8+
double Value = 5.;
9+
10+
deviceQueue.submit([&](handler &cgh) {
11+
cgh.single_task<class Kernel0>([=]() { double res = std::sin(Value); });
12+
});
13+
14+
deviceQueue.submit([&](handler &cgh) {
15+
cgh.single_task<class Kernel1>([=]() { double res = sycl::sin(Value); });
16+
});
17+
return 0;
18+
}

0 commit comments

Comments
 (0)