Skip to content

Commit 3ae0889

Browse files
authored
[ESIMD] Make sure metadata references new function in ESIMDLowerVecArg… (#8496)
In ESIMDLowerVecArg, we change the type of a function and fix uses to use the new one. However, we forgot to handle metadata, so any metadata referencing the old function would end up as null after this pass, as we also delete the function. Make sure to fixup metadata uses too. Note this pass only runs with opaque pointers off, so we may not need it much longer. Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 2dcc581 commit 3ae0889

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

llvm/lib/SYCLLowerIR/ESIMD/LowerESIMDVecArg.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ Function *ESIMDLowerVecArgPass::rewriteFunc(Function &F) {
213213
ReplaceInstWithInst(OldInst, NewInst);
214214
}
215215

216+
// Make sure to update any metadata as well
217+
if(F.isUsedByMetadata()) {
218+
// The old function is about to be destroyed, so
219+
// just change its type so all replacement works.
220+
F.mutateType(NF->getType());
221+
ValueAsMetadata::handleRAUW(&F, NF);
222+
}
216223
F.eraseFromParent();
217224

218225
return NF;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: opt < %s -passes=ESIMDLowerVecArg -S | FileCheck %s
2+
3+
; Check that we correctly update metadata to reference the new function
4+
5+
%"class.sycl::_V1::vec" = type { <2 x double> }
6+
7+
$foo = comdat any
8+
9+
define weak_odr dso_local spir_kernel void @foo(%"class.sycl::_V1::vec" addrspace(1)* noundef align 16 %_arg_out) local_unnamed_addr comdat {
10+
entry:
11+
ret void
12+
}
13+
14+
;CHECK: !genx.kernels = !{![[GenXMD:[0-9]+]]}
15+
!genx.kernels = !{!0}
16+
17+
;CHECK: ![[GenXMD]] = !{void (<2 x double> addrspace(1)*)* @foo, {{.*}}}
18+
!0 = !{void (%"class.sycl::_V1::vec" addrspace(1)*)* @foo, !"foo", !1, i32 0, i32 0, !1, !2, i32 0, i32 0}
19+
!1 = !{i32 0}
20+
!2 = !{!"svmptr_t"}

0 commit comments

Comments
 (0)