File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
Compiler/tests/LegalizeFunctionSignatures Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -478,8 +478,11 @@ void LegalizeFunctionSignatures::FixFunctionBody(Module &M) {
478478
479479 // Now that all instructions are transferred to the new func, delete the old func
480480 pFunc->removeDeadConstantUsers ();
481- pFunc->dropAllReferences ();
482- pFunc->removeFromParent ();
481+ // There may be cases where the old function was referenced by just metadata.
482+ // If we've cleaned up all "real" uses, then we can just update the metadata
483+ // with poison so we can delete the function.
484+ pFunc->replaceAllUsesWith (PoisonValue::get (pFunc->getType ()));
485+ pFunc->eraseFromParent ();
483486 }
484487}
485488
Original file line number Diff line number Diff line change 1+ ;=========================== begin_copyright_notice ============================
2+ ;
3+ ; Copyright (C) 2025 Intel Corporation
4+ ;
5+ ; SPDX-License-Identifier: MIT
6+ ;
7+ ;============================ end_copyright_notice =============================
8+ ;
9+ ; RUN: igc_opt --opaque-pointers --igc-legalize-function-signatures -S < %s 2>&1 | FileCheck %s
10+ ; ------------------------------------------------
11+ ; LegalizeFunctionSignatures
12+ ; ------------------------------------------------
13+
14+ ; Test that functions with illegal types referenced by metadata are handled correctly.
15+
16+ define spir_kernel void @test_kernel () {
17+ call void @foo (i1 true )
18+ ret void
19+ }
20+
21+ define internal void @foo (i1 ) {
22+ ret void
23+ }
24+
25+ !md = !{!0 }
26+ !0 = !{ptr @foo }
27+
28+ ; CHECK: !0 = !{ptr poison}
You can’t perform that action at this time.
0 commit comments