Skip to content

Commit a102ed3

Browse files
[ESIMD] Honor noinline attribute in LowerESIMD pass (#3439)
1 parent db7cb6f commit a102ed3

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

llvm/lib/SYCLLowerIR/LowerESIMD.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,7 @@ size_t SYCLLowerESIMDPass::runOnFunction(Function &F,
12631263
// limitation, mark every function called from ESIMD kernel with
12641264
// 'alwaysinline' attribute.
12651265
if ((F.getCallingConv() != CallingConv::SPIR_KERNEL) &&
1266+
!F.hasFnAttribute(Attribute::NoInline) &&
12661267
!F.hasFnAttribute(Attribute::AlwaysInline))
12671268
F.addFnAttr(Attribute::AlwaysInline);
12681269

llvm/test/SYCLLowerIR/esimd_lower_inline_hint.ll

+16-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
; This test checks that LowerESIMD pass sets the 'alwaysinline'
44
; attribute for all non-kernel functions.
5+
; If the function already has noinline attribute -- honor that.
56

67
define spir_kernel void @EsimdKernel1() {
78
; CHECK: @EsimdKernel1(
@@ -15,25 +16,36 @@ define spir_kernel void @EsimdKernel1() {
1516
define spir_kernel void @EsimdKernel2() {
1617
; CHECK: @EsimdKernel2(
1718
; CHECK-NEXT: call void @foobar()
19+
; CHECK-NEXT: call void @noinline_func()
1820
call void @foobar()
21+
call void @noinline_func()
1922
ret void
2023
}
2124

2225
define spir_func void @foo() {
23-
; CHECK: @foo() #[[ATTR:[0-9]+]]
26+
; CHECK: @foo() #[[ATTR_INL:[0-9]+]]
2427
ret void
2528
}
2629

2730
define spir_func void @bar() {
28-
; CHECK: @bar() #[[ATTR]]
31+
; CHECK: @bar() #[[ATTR_INL]]
2932
; CHECK-NEXT: call void @foobar
33+
; CHECK-NEXT: call void @noinline_func()
3034
call void @foobar()
35+
call void @noinline_func()
3136
ret void
3237
}
3338

3439
define spir_func void @foobar() {
35-
; CHECK: @foobar() #[[ATTR]]
40+
; CHECK: @foobar() #[[ATTR_INL]]
3641
ret void
3742
}
3843

39-
; CHECK: attributes #[[ATTR]] = { alwaysinline }
44+
define spir_func void @noinline_func() #0 {
45+
; CHECK: @noinline_func() #[[ATTR_NOINL:[0-9]+]] {
46+
ret void
47+
}
48+
49+
attributes #0 = { noinline }
50+
; CHECK-DAG: attributes #[[ATTR_INL]] = { alwaysinline }
51+
; CHECK-DAG: attributes #[[ATTR_NOINL]] = { noinline }

sycl/test/esimd/vadd.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// RUN: %clangxx -I %sycl_include %s -o %t.out -lsycl
33
// RUN: %RUN_ON_HOST %t.out
44

5+
// Check that the code compiles with -O0 and -g
6+
// RUN: %clangxx -I %sycl_include %s -o %t.out -fsycl -fsycl-explicit-simd -O0
7+
// RUN: %clangxx -I %sycl_include %s -o %t.out -fsycl -fsycl-explicit-simd -O0 -g
8+
59
#include <CL/sycl.hpp>
610
#include <CL/sycl/INTEL/esimd.hpp>
711
#include <iostream>

0 commit comments

Comments
 (0)