Skip to content

Commit f3d0788

Browse files
jayfoadchangpeng
andauthored
[AMDGPU] Remove functions with incompatible gws attribute (#78143)
This change is to remove incompatible gws related functions in order to make device-libs work correctly under -O0 for gfx1200+ Co-authored-by: Changpeng Fang <[email protected]>
1 parent c32d02e commit f3d0788

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ constexpr unsigned FeaturesToCheck[] = {AMDGPU::FeatureGFX11Insts,
105105
AMDGPU::FeatureDot8Insts,
106106
AMDGPU::FeatureExtendedImageInsts,
107107
AMDGPU::FeatureSMemRealTime,
108-
AMDGPU::FeatureSMemTimeInst};
108+
AMDGPU::FeatureSMemTimeInst,
109+
AMDGPU::FeatureGWS};
109110

110111
FeatureBitset expandImpliedFeatures(const FeatureBitset &Features) {
111112
FeatureBitset Result = Features;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -march=amdgcn -mcpu=gfx1030 -stop-after=amdgpu-remove-incompatible-functions\
3+
; RUN: -pass-remarks=amdgpu-remove-incompatible-functions %s -o - 2>%t | FileCheck -check-prefixes=COMPATIBLE,IR %s
4+
; RUN: FileCheck -allow-empty --check-prefix=WARN-COMPATIBLE %s < %t
5+
; RUN: llc -march=amdgcn -mcpu=gfx1030 -verify-machineinstrs < %s
6+
7+
; RUN: llc -march=amdgcn -mcpu=gfx1200 -stop-after=amdgpu-remove-incompatible-functions\
8+
; RUN: -pass-remarks=amdgpu-remove-incompatible-functions %s -o - 2>%t | FileCheck -check-prefixes=INCOMPATIBLE,IR %s
9+
; RUN: FileCheck --check-prefixes=WARN-INCOMPATIBLE %s < %t
10+
; RUN: llc -march=amdgcn -mcpu=gfx1200 -verify-machineinstrs < %s
11+
12+
; Note: This test checks the IR, but also has a run line to codegen the file just to check we
13+
; do not crash when trying to select those functions.
14+
15+
; WARN-COMPATIBLE-NOT: removing function 'needs_gws':
16+
; WARN-INCOMPATIBLE: removing function 'needs_gws': +gws is not supported on the current target
17+
18+
19+
; COMPATIBLE: @GVRefs {{.*}} [ptr @needs_gws]
20+
; INCOMPATIBLE: @GVRefs {{.*}} zeroinitializer
21+
@GVRefs = internal global [1 x ptr] [
22+
ptr @needs_gws
23+
]
24+
25+
26+
; COMPATIBLE: @ConstantExpr = internal global i64 ptrtoint (ptr @needs_gws to i64)
27+
; INCOMPATIBLE: @ConstantExpr = internal global i64 0
28+
@ConstantExpr = internal global i64 ptrtoint (ptr @needs_gws to i64)
29+
30+
31+
; COMPATIBLE: define void @needs_gws
32+
; INCOMPATIBLE-NOT: define void @needs_gws
33+
define void @needs_gws(i32 %val0, i32 %val1) #0 {
34+
call void @llvm.amdgcn.ds.gws.init(i32 %val0, i32 %val1)
35+
call void @llvm.amdgcn.ds.gws.barrier(i32 %val0, i32 %val1)
36+
ret void
37+
}
38+
39+
; IR: define void @gws_caller(
40+
define void @gws_caller(i32 %val0, i32 %val1) {
41+
; COMPATIBLE: call void @needs_gws(
42+
; INCOMPATIBLE: call void null
43+
call void @needs_gws(i32 %val0, i32 %val1)
44+
; IR: ret void
45+
ret void
46+
}
47+
48+
declare void @llvm.amdgcn.ds.gws.barrier(i32, i32) #1
49+
declare void @llvm.amdgcn.ds.gws.init(i32, i32) #2
50+
51+
52+
attributes #0 = { "target-features"="+gws"}
53+
attributes #1 = { convergent inaccessiblememonly nounwind }
54+
attributes #2 = { convergent inaccessiblememonly nounwind writeonly }

0 commit comments

Comments
 (0)