Skip to content

Commit 6d88f58

Browse files
YixingZhang007igcbot
authored andcommitted
Remove Original Functions After Joint Matrix Function Resolution
In the JointMatrixFuncsResolution pass, functions with joint matrix arguments were resolved into new functions; however, the original functions were not deleted. This commit addresses the issue by ensuring that the original functions, once resolved, are properly removed.
1 parent 60d2552 commit 6d88f58

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ bool JointMatrixFuncsResolutionPass::runOnModule(Module &M)
226226
Changed |= runOnFunction(F);
227227
}
228228

229+
for (const auto& ResolvedFunctionPair : ResolvedFuncSignatures) {
230+
Function *OriginalFunction = ResolvedFunctionPair.first;
231+
232+
if (OriginalFunction->use_empty()) {
233+
OriginalFunction->eraseFromParent();
234+
}
235+
}
236+
229237
return Changed;
230238
}
231239

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2024 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
;
9+
; RUN: igc_opt -igc-joint-matrix-resolution --platformpvc -S 2>&1 < %s | FileCheck %s
10+
; ------------------------------------------------
11+
; JointMatrixFuncsResolutionPass - Verify whether the original function is removed
12+
; after resolving function with joint matrix arguments
13+
; into new function.
14+
; ------------------------------------------------
15+
16+
; CHECK-NOT: define internal spir_func void @test
17+
; CHECK: define internal spir_func void @test_resolved
18+
19+
%"struct.sycl::_V1::ext::oneapi::experimental::matrix::joint_matrix" = type { %spirv.JointMatrixINTEL._float_8_16_3_3_2 addrspace(1)* }
20+
%spirv.JointMatrixINTEL._float_8_16_3_3_2 = type opaque
21+
22+
;Function Attrs: nounwind
23+
define internal spir_func void @test(%"struct.sycl::_V1::ext::oneapi::experimental::matrix::joint_matrix" addrspace(4)* nocapture align 8 dereferenceable(8) %m){
24+
ret void
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2024 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
;
9+
; REQUIRES: opaque-ptr-fix, llvm-14-plus
10+
; RUN: igc_opt -igc-joint-matrix-resolution --platformpvc -S 2>&1 < %s | FileCheck %s
11+
; ------------------------------------------------
12+
; JointMatrixFuncsResolutionPass - Verify whether the original function is removed
13+
; after resolving function with joint matrix arguments
14+
; into new function.
15+
; ------------------------------------------------
16+
17+
; CHECK-NOT: define internal spir_func void @test
18+
; CHECK: define internal spir_func void @test_resolved
19+
20+
%"struct.sycl::_V1::ext::oneapi::experimental::matrix::joint_matrix" = type { %spirv.JointMatrixINTEL._float_8_16_3_3_2 addrspace(1)* }
21+
%spirv.JointMatrixINTEL._float_8_16_3_3_2 = type opaque
22+
23+
;Function Attrs: nounwind
24+
define internal spir_func void @test(%"struct.sycl::_V1::ext::oneapi::experimental::matrix::joint_matrix" addrspace(4)* nocapture align 8 dereferenceable(8) %m){
25+
ret void
26+
}

0 commit comments

Comments
 (0)