Skip to content

Commit 00a7e36

Browse files
authoredNov 28, 2023
[SYCL][ESIMD] Remove optnone from ESIMD functions (#11986)
Previously we never had optnone in the SPIR-V due to the issue in 993fe5b, but with that fixed we started seeing it and that broke some O0 tests. Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
1 parent 5a51c0a commit 00a7e36

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
 

‎llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,17 @@ size_t SYCLLowerESIMDPass::runOnFunction(Function &F,
18351835
SmallVector<CallInst *, 32> ESIMDIntrCalls;
18361836
SmallVector<Instruction *, 8> ToErase;
18371837

1838+
// The VC backend doesn't support debugging, and trying to use
1839+
// non-optimized code often produces crashes or wrong answers.
1840+
// The recommendation from the VC team was always optimize code,
1841+
// even if the user requested no optimization. We already drop
1842+
// debugging flags in the SYCL runtime, so also drop optnone and
1843+
// noinline here.
1844+
if (isESIMD(F) && F.hasFnAttribute(Attribute::OptimizeNone)) {
1845+
F.removeFnAttr(Attribute::OptimizeNone);
1846+
F.removeFnAttr(Attribute::NoInline);
1847+
}
1848+
18381849
for (Instruction &I : instructions(F)) {
18391850
if (auto CastOp = dyn_cast<llvm::CastInst>(&I)) {
18401851
llvm::Type *DstTy = CastOp->getDestTy();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; This ensures we remove optnone from ESIMD functions
2+
; RUN: opt < %s -passes=LowerESIMD -S | FileCheck %s
3+
4+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
5+
target triple = "spir64-unknown-unknown"
6+
7+
define dso_local spir_func void @esimd() #0 !sycl_explicit_simd !0 {
8+
; CHECK: void @esimd() #[[#ESIMDAttr:]]
9+
ret void
10+
}
11+
12+
define dso_local spir_func void @sycl() #0 {
13+
; CHECK: spir_func void @sycl() #[[#SYCLAttr:]]
14+
ret void
15+
}
16+
; CHECK: attributes #[[#ESIMDAttr]] =
17+
; CHECK-NOT: optnone
18+
; CHECK: attributes #[[#SYCLAttr]] = {{{.*}}optnone{{.*}}}
19+
attributes #0 = { noinline optnone convergent }
20+
!0 = !{}

0 commit comments

Comments
 (0)