From 2a473f7d428da03b03eb0ce49a062c896eedfb2f Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 9 Sep 2025 11:42:12 +0300 Subject: [PATCH 1/2] spv: minimal `OpSpecConstantOp` support. --- src/print/mod.rs | 2 +- src/spv/print.rs | 41 ++++++++++++++++++++++++++++++++++++++++- src/spv/read.rs | 26 ++++++++++++++++++++++++++ src/spv/spec.rs | 1 + src/spv/write.rs | 27 +++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 2 deletions(-) diff --git a/src/print/mod.rs b/src/print/mod.rs index 55d87064..7dcdfe68 100644 --- a/src/print/mod.rs +++ b/src/print/mod.rs @@ -1806,7 +1806,7 @@ impl Printer<'_> { fn sanitize_spv_operand_name<'b>(&self, name: &'b str) -> Option> { Some(name).and_then(|name| { // HACK(eddyb) some operand names are useless. - if name == "Type" + if matches!(name, "Opcode" | "Operand" | "Type") || name .strip_prefix("Operand ") .is_some_and(|s| s.chars().all(|c| c.is_ascii_digit())) diff --git a/src/spv/print.rs b/src/spv/print.rs index cd80ccdd..29b51e93 100644 --- a/src/spv/print.rs +++ b/src/spv/print.rs @@ -77,6 +77,9 @@ impl TokensForOperand { // FIXME(eddyb) keep a `&'static spec::Spec` if that can even speed up anything. struct OperandPrinter, ID, IDS: Iterator> { + // FIXME(eddyb) use a field like this to interpret `Opcode`/`OperandKind`, too. + wk: &'static spv::spec::WellKnown, + /// Input immediate operands to print from (may be grouped e.g. into literals). imms: iter::Peekable, @@ -123,7 +126,41 @@ impl, ID, IDS: Iterator> OperandPrint let def = kind.def(); assert!(matches!(def, spec::OperandKindDef::Literal { .. })); - let literal_token = if kind == spec::Spec::get().well_known.LiteralString { + let literal_token = if kind == self.wk.LiteralSpecConstantOpInteger { + assert_eq!(words.len(), 1); + let (_, inner_name, inner_def) = match u16::try_from(first_word) + .ok() + .and_then(spec::Opcode::try_from_u16_with_name_and_def) + { + Some(opcode_name_and_def) => opcode_name_and_def, + None => { + self.out.tokens.push(Token::Error(format!( + "/* {first_word} not a valid `OpSpecConstantOp` opcode */" + ))); + return; + } + }; + + // FIXME(eddyb) deduplicate this with `enumerant_params`. + self.out.tokens.push(Token::EnumerandName(inner_name)); + + let mut first = true; + for (inner_mode, inner_name_and_kind) in inner_def.all_operands_with_names() { + if inner_mode == spec::OperandMode::Optional && self.is_exhausted() { + break; + } + + self.out.tokens.push(Token::Punctuation(if first { "(" } else { ", " })); + first = false; + + let (inner_name, inner_kind) = inner_name_and_kind.name_and_kind(); + self.operand(inner_name, inner_kind); + } + if !first { + self.out.tokens.push(Token::Punctuation(")")); + } + return; + } else if kind == self.wk.LiteralString { // FIXME(eddyb) deduplicate with `spv::extract_literal_string`. let bytes: SmallVec<[u8; 64]> = words .into_iter() @@ -262,6 +299,7 @@ pub fn operand( ids: impl IntoIterator, ) -> TokensForOperand { let mut printer = OperandPrinter { + wk: &spec::Spec::get().well_known, imms: imms.into_iter().peekable(), ids: ids.into_iter().peekable(), out: TokensForOperand::default(), @@ -285,6 +323,7 @@ pub fn inst_operands( ids: impl IntoIterator, ) -> impl Iterator> { OperandPrinter { + wk: &spec::Spec::get().well_known, imms: imms.into_iter().peekable(), ids: ids.into_iter().peekable(), out: TokensForOperand::default(), diff --git a/src/spv/read.rs b/src/spv/read.rs index 47220c73..8b8eb124 100644 --- a/src/spv/read.rs +++ b/src/spv/read.rs @@ -28,6 +28,9 @@ impl KnownIdDef { // FIXME(eddyb) keep a `&'static spec::Spec` if that can even speed up anything. struct InstParser<'a> { + // FIXME(eddyb) use a field like this to interpret `Opcode`/`OperandKind`, too. + wk: &'static spv::spec::WellKnown, + /// IDs defined so far in the module. known_ids: &'a FxHashMap, @@ -60,6 +63,9 @@ enum InstParseError { /// The type of a `LiteralContextDependentNumber` was not a supported type /// (one of either `OpTypeInt` or `OpTypeFloat`). UnsupportedContextSensitiveLiteralType { type_opcode: spec::Opcode }, + + /// Unsupported `OpSpecConstantOp` (`LiteralSpecConstantOpInteger`) opcode. + UnsupportedSpecConstantOpOpcode(u32), } impl InstParseError { @@ -94,6 +100,9 @@ impl InstParseError { Self::UnsupportedContextSensitiveLiteralType { type_opcode } => { format!("{} is not a supported literal type", type_opcode.name()).into() } + Self::UnsupportedSpecConstantOpOpcode(opcode) => { + format!("{opcode} is not a supported opcode (for `OpSpecConstantOp`)").into() + } } } } @@ -196,6 +205,22 @@ impl InstParser<'_> { } } + // HACK(eddyb) this isn't cleanly uniform because it's an odd special case. + if kind == self.wk.LiteralSpecConstantOpInteger { + // FIXME(eddyb) this partially duplicates the main instruction parsing. + let (_, _, inner_def) = u16::try_from(word) + .ok() + .and_then(spec::Opcode::try_from_u16_with_name_and_def) + .ok_or(Error::UnsupportedSpecConstantOpOpcode(word))?; + + for (inner_mode, inner_kind) in inner_def.all_operands() { + if inner_mode == spec::OperandMode::Optional && self.is_exhausted() { + break; + } + self.operand(inner_kind)?; + } + } + Ok(()) } @@ -322,6 +347,7 @@ impl Iterator for ModuleParser { } let parser = InstParser { + wk: &spec::Spec::get().well_known, known_ids: &self.known_ids, words: words[1..inst_len].iter().copied(), inst: spv::InstWithIds { diff --git a/src/spv/spec.rs b/src/spv/spec.rs index 744e2475..7b833bbe 100644 --- a/src/spv/spec.rs +++ b/src/spv/spec.rs @@ -184,6 +184,7 @@ def_well_known! { LiteralExtInstInteger, LiteralString, LiteralContextDependentNumber, + LiteralSpecConstantOpInteger, ], // FIXME(eddyb) find a way to namespace these to avoid conflicts. addressing_model: u32 = [ diff --git a/src/spv/write.rs b/src/spv/write.rs index b43b8b16..760823a2 100644 --- a/src/spv/write.rs +++ b/src/spv/write.rs @@ -7,6 +7,9 @@ use std::{fs, io, iter, slice}; // FIXME(eddyb) keep a `&'static spec::Spec` if that can even speed up anything. struct OperandEmitter<'a> { + // FIXME(eddyb) use a field like this to interpret `Opcode`/`OperandKind`, too. + wk: &'static spv::spec::WellKnown, + /// Input immediate operands of an instruction. imms: iter::Copied>, @@ -32,6 +35,9 @@ enum OperandEmitError { /// Unsupported enumerand value. UnsupportedEnumerand(spec::OperandKind, u32), + + /// Unsupported `OpSpecConstantOp` (`LiteralSpecConstantOpInteger`) opcode. + UnsupportedSpecConstantOpOpcode(u32), } impl OperandEmitError { @@ -60,6 +66,9 @@ impl OperandEmitError { _ => unreachable!(), } } + Self::UnsupportedSpecConstantOpOpcode(opcode) => { + format!("{opcode} is not a supported opcode (for `OpSpecConstantOp`)").into() + } } } } @@ -138,6 +147,23 @@ impl OperandEmitter<'_> { } } + // HACK(eddyb) this isn't cleanly uniform because it's an odd special case. + if kind == self.wk.LiteralSpecConstantOpInteger { + // FIXME(eddyb) this partially duplicates the main instruction emission. + let &word = self.out.last().unwrap(); + let (_, _, inner_def) = u16::try_from(word) + .ok() + .and_then(spec::Opcode::try_from_u16_with_name_and_def) + .ok_or(Error::UnsupportedSpecConstantOpOpcode(word))?; + + for (inner_mode, inner_kind) in inner_def.all_operands() { + if inner_mode == spec::OperandMode::Optional && self.is_exhausted() { + break; + } + self.operand(inner_kind)?; + } + } + Ok(()) } @@ -219,6 +245,7 @@ impl ModuleEmitter { ); OperandEmitter { + wk: &spec::Spec::get().well_known, imms: inst.imms.iter().copied(), ids: inst.ids.iter().copied(), out: &mut self.words, From 85fa656ccc05f076131008090b19ffdfcbfc4665 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 9 Sep 2025 11:42:12 +0300 Subject: [PATCH 2/2] spv: minimal `OpConstantFunctionPointerINTEL` support. --- src/lib.rs | 8 +- src/print/mod.rs | 7 +- src/qptr/lower.rs | 8 ++ src/spv/lift.rs | 13 +++- src/spv/lower.rs | 192 ++++++++++++++++++++++++++++++++++------------ src/spv/spec.rs | 3 + src/transform.rs | 4 + src/visit.rs | 1 + 8 files changed, 183 insertions(+), 53 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9a7e3d32..4428032d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -604,7 +604,13 @@ pub struct ConstDef { #[derive(Clone, PartialEq, Eq, Hash)] pub enum ConstKind { + // FIXME(eddyb) maybe merge these? however, their connection is somewhat + // tenuous (being one of the LLVM-isms SPIR-V inherited, among other things), + // there's still the need to rename "global variable" post-`Var`-refactor, + // and last but not least, `PtrToFunc` needs `SPV_INTEL_function_pointers`, + // an OpenCL-only extension Intel came up with for their own SPIR-V tooling. PtrToGlobalVar(GlobalVar), + PtrToFunc(Func), // HACK(eddyb) this is a fallback case that should become increasingly rare // (especially wrt recursive consts), `Rc` means it can't bloat `ConstDef`. @@ -696,7 +702,7 @@ pub struct FuncDecl { pub def: DeclDef, } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq)] pub struct FuncParam { pub attrs: AttrSet, diff --git a/src/print/mod.rs b/src/print/mod.rs index 7dcdfe68..1699cb61 100644 --- a/src/print/mod.rs +++ b/src/print/mod.rs @@ -3382,6 +3382,9 @@ impl Print for ConstDef { &ConstKind::PtrToGlobalVar(gv) => { pretty::Fragment::new(["&".into(), gv.print(printer)]) } + &ConstKind::PtrToFunc(func) => { + pretty::Fragment::new(["&".into(), func.print(printer)]) + } ConstKind::SpvInst { spv_inst_and_const_inputs } => { let (spv_inst, const_inputs) = &**spv_inst_and_const_inputs; pretty::Fragment::new([ @@ -4146,7 +4149,9 @@ impl Print for FuncAt<'_, DataInst> { } } } - ConstKind::PtrToGlobalVar(_) | ConstKind::SpvTypeOperand(_) => {} + ConstKind::PtrToGlobalVar(_) + | ConstKind::PtrToFunc(_) + | ConstKind::SpvTypeOperand(_) => {} } } None diff --git a/src/qptr/lower.rs b/src/qptr/lower.rs index 409ed07e..f1f318c9 100644 --- a/src/qptr/lower.rs +++ b/src/qptr/lower.rs @@ -161,6 +161,14 @@ impl<'a> LowerFromSpvPtrs<'a> { [spv::Imm::Short(_, sc)] => sc, _ => unreachable!(), }; + + // HACK(eddyb) keep function pointers separate, perhaps eventually + // adding an `OpTypeUntypedPointerKHR CodeSectionINTEL` equivalent + // to SPIR-T itself (after `SPV_KHR_untyped_pointers` support). + if sc == self.wk.CodeSectionINTEL { + return None; + } + let pointee = match type_and_const_inputs[..] { [TypeOrConst::Type(elem_type)] => elem_type, _ => unreachable!(), diff --git a/src/spv/lift.rs b/src/spv/lift.rs index 9d48425e..775abf8c 100644 --- a/src/spv/lift.rs +++ b/src/spv/lift.rs @@ -152,7 +152,7 @@ impl Visitor<'_> for NeedsIdsCollector<'_> { } let ct_def = &self.cx[ct]; match ct_def.kind { - ConstKind::PtrToGlobalVar(_) | ConstKind::SpvInst { .. } => { + ConstKind::PtrToGlobalVar(_) | ConstKind::PtrToFunc(_) | ConstKind::SpvInst { .. } => { self.visit_const_def(ct_def); self.globals.insert(global); } @@ -1073,7 +1073,9 @@ impl LazyInst<'_, '_> { }; (gv_decl.attrs, import) } - ConstKind::SpvInst { .. } => (ct_def.attrs, None), + ConstKind::PtrToFunc(_) | ConstKind::SpvInst { .. } => { + (ct_def.attrs, None) + } // Not inserted into `globals` while visiting. ConstKind::SpvTypeOperand(_) @@ -1192,6 +1194,13 @@ impl LazyInst<'_, '_> { } } + &ConstKind::PtrToFunc(func) => spv::InstWithIds { + without_ids: wk.OpConstantFunctionPointerINTEL.into(), + result_type_id: Some(ids.globals[&Global::Type(ct_def.ty)]), + result_id, + ids: [ids.funcs[&func].func_id].into_iter().collect(), + }, + ConstKind::SpvInst { spv_inst_and_const_inputs } => { let (spv_inst, const_inputs) = &**spv_inst_and_const_inputs; spv::InstWithIds { diff --git a/src/spv/lower.rs b/src/spv/lower.rs index 6f039ceb..4ea1ba82 100644 --- a/src/spv/lower.rs +++ b/src/spv/lower.rs @@ -28,6 +28,11 @@ enum IdDef { Func(Func), + // HACK(eddyb) despite `FuncBody` deferring ID resolution to allow forward + // references *between* functions, function pointer *constants* need a `Func` + // long before any `OpFunction`s, so they're pre-defined as dummy imports. + FuncForwardRef(Func), + SpvExtInstImport(InternedStr), SpvDebugString(InternedStr), } @@ -40,7 +45,7 @@ impl IdDef { IdDef::Type(_) => "a type".into(), IdDef::Const(_) | IdDef::PtrToGlobalVarForwardRef(_) => "a constant".into(), - IdDef::Func(_) => "a function".into(), + IdDef::Func(_) | IdDef::FuncForwardRef(_) => "a function".into(), IdDef::SpvExtInstImport(name) => { format!("`OpExtInstImport {:?}`", &cx[name]) @@ -172,6 +177,37 @@ impl Module { assert!(expected == found); }; + // HACK(eddyb) used as the `FuncDecl` for an `IdDef::FuncForwardRef`. + let dummy_decl_for_func_forward_ref = FuncDecl { + attrs: { + let mut attrs = AttrSet::default(); + attrs.push_diag( + &cx, + Diag::err(["function ID used as forward reference but never defined".into()]), + ); + attrs + }, + // FIXME(eddyb) this gets simpler w/ disaggregation. + ret_type: cx.intern(TypeKind::SpvInst { + spv_inst: wk.OpTypeVoid.into(), + type_and_const_inputs: [].into_iter().collect(), + }), + params: [].into_iter().collect(), + def: DeclDef::Imported(Import::LinkName(cx.intern(""))), + }; + // HACK(eddyb) no `PartialEq` on `FuncDecl`. + let assert_is_dummy_decl_for_func_forward_ref = |decl: &FuncDecl| { + let [expected, found] = [&dummy_decl_for_func_forward_ref, decl].map( + |FuncDecl { attrs, ret_type, params, def }| { + let DeclDef::Imported(import) = def else { + unreachable!(); + }; + (attrs, ret_type, params, import) + }, + ); + assert!(expected == found); + }; + let mut module = { let [magic, version, generator_magic, id_bound, reserved_inst_schema] = parser.header; @@ -678,7 +714,8 @@ impl Module { .map(|&id| match id_defs.get(&id) { Some(&IdDef::Type(ty)) => Ok(TypeOrConst::Type(ty)), Some(&IdDef::Const(ct)) => Ok(TypeOrConst::Const(ct)), - None | Some(IdDef::PtrToGlobalVarForwardRef(_)) => { + None + | Some(IdDef::PtrToGlobalVarForwardRef(_) | IdDef::FuncForwardRef(_)) => { Err(format!("a forward reference to %{id}")) } Some(id_def) => Err(id_def.descr(&cx)), @@ -696,6 +733,38 @@ impl Module { }); id_defs.insert(id, IdDef::Type(ty)); + Seq::TypeConstOrGlobalVar + } else if opcode == wk.OpConstantFunctionPointerINTEL { + use std::collections::hash_map::Entry; + + let id = inst.result_id.unwrap(); + + let func_id = inst.ids[0]; + let func = match id_defs.entry(func_id) { + Entry::Occupied(entry) => match entry.get() { + &IdDef::FuncForwardRef(func) => Ok(func), + id_def => Err(id_def.descr(&cx)), + }, + Entry::Vacant(entry) => { + let func = + module.funcs.define(&cx, dummy_decl_for_func_forward_ref.clone()); + entry.insert(IdDef::FuncForwardRef(func)); + Ok(func) + } + } + .map_err(|descr| { + invalid(&format!( + "unsupported use of {descr} as the `OpConstantFunctionPointerINTEL` operand" + )) + })?; + + let ct = cx.intern(ConstDef { + attrs: mem::take(&mut attrs), + ty: result_type.unwrap(), + kind: ConstKind::PtrToFunc(func), + }); + id_defs.insert(id, IdDef::Const(ct)); + Seq::TypeConstOrGlobalVar } else if inst_category == spec::InstructionCategory::Const || opcode == wk.OpUndef { let id = inst.result_id.unwrap(); @@ -790,7 +859,8 @@ impl Module { let initializer = initializer .map(|id| match id_defs.get(&id) { Some(&IdDef::Const(ct)) => Ok(ct), - None | Some(IdDef::PtrToGlobalVarForwardRef(_)) => { + None + | Some(IdDef::PtrToGlobalVarForwardRef(_) | IdDef::FuncForwardRef(_)) => { Err(format!("a forward reference to %{id}")) } Some(id_def) => Err(id_def.descr(&cx)), @@ -932,19 +1002,40 @@ impl Module { }) } }; + let decl = FuncDecl { + attrs: mem::take(&mut attrs), + ret_type: func_ret_type, + params: func_type_param_types + .map(|ty| FuncParam { attrs: AttrSet::default(), ty }) + .collect(), + def, + }; - let func = module.funcs.define( - &cx, - FuncDecl { - attrs: mem::take(&mut attrs), - ret_type: func_ret_type, - params: func_type_param_types - .map(|ty| FuncParam { attrs: AttrSet::default(), ty }) - .collect(), - def, - }, - ); - id_defs.insert(func_id, IdDef::Func(func)); + let func = { + use std::collections::hash_map::Entry; + + match id_defs.entry(func_id) { + Entry::Occupied(mut entry) => match entry.get() { + &IdDef::FuncForwardRef(func) => { + let decl_slot = &mut module.funcs[func]; + assert_is_dummy_decl_for_func_forward_ref(decl_slot); + *decl_slot = decl; + + entry.insert(IdDef::Func(func)); + Ok(func) + } + id_def => Err(id_def.descr(&cx)), + }, + Entry::Vacant(entry) => { + let func = module.funcs.define(&cx, decl); + entry.insert(IdDef::Func(func)); + Ok(func) + } + } + .map_err(|descr| { + invalid(&format!("invalid redefinition of {descr} as a new function")) + })? + }; current_func_body = Some(FuncBody { func_id, func, insts: vec![] }); @@ -1313,44 +1404,47 @@ impl Module { // FIXME(eddyb) find a more compact name and/or make this a method. // FIXME(eddyb) this returns `LocalIdDef` even for global values. - let lookup_global_or_local_id_for_data_or_control_inst_input = - |id| match id_defs.get(&id) { - Some(&IdDef::Type(ty)) => { - Ok(LocalIdDef::Value(Value::Const(spv_type_operand_as_const(ty)))) - } - Some(&IdDef::Const(ct)) => Ok(LocalIdDef::Value(Value::Const(ct))), - Some(id_def @ IdDef::Func(_)) => Err(invalid(&format!( - "unsupported use of {} outside `OpFunctionCall`", - id_def.descr(&cx), - ))), - Some(id_def @ IdDef::SpvDebugString(s)) => { - if opcode == wk.OpExtInst { - // HACK(eddyb) intern `OpString`s as `Const`s on - // the fly, as it's a less likely usage than the - // `OpLine` one. - let ct = cx.intern(ConstDef { - attrs: AttrSet::default(), - ty: cx.intern(TypeKind::SpvStringLiteralForExtInst), - kind: ConstKind::SpvStringLiteralForExtInst(*s), - }); - Ok(LocalIdDef::Value(Value::Const(ct))) - } else { - Err(invalid(&format!( - "unsupported use of {} outside `OpSource`, \ + let lookup_global_or_local_id_for_data_or_control_inst_input = |id| match id_defs + .get(&id) + { + Some(&IdDef::Type(ty)) => { + Ok(LocalIdDef::Value(Value::Const(spv_type_operand_as_const(ty)))) + } + Some(&IdDef::Const(ct)) => Ok(LocalIdDef::Value(Value::Const(ct))), + Some(id_def @ IdDef::Func(_)) => Err(invalid(&format!( + "unsupported use of {} outside `OpFunctionCall`", + id_def.descr(&cx), + ))), + Some(id_def @ IdDef::SpvDebugString(s)) => { + if opcode == wk.OpExtInst { + // HACK(eddyb) intern `OpString`s as `Const`s on + // the fly, as it's a less likely usage than the + // `OpLine` one. + let ct = cx.intern(ConstDef { + attrs: AttrSet::default(), + ty: cx.intern(TypeKind::SpvStringLiteralForExtInst), + kind: ConstKind::SpvStringLiteralForExtInst(*s), + }); + Ok(LocalIdDef::Value(Value::Const(ct))) + } else { + Err(invalid(&format!( + "unsupported use of {} outside `OpSource`, \ `OpLine`, or `OpExtInst`", - id_def.descr(&cx), - ))) - } + id_def.descr(&cx), + ))) } - Some(id_def @ IdDef::SpvExtInstImport(_)) => Err(invalid(&format!( - "unsupported use of {} outside `OpExtInst`", - id_def.descr(&cx), - ))), - None | Some(IdDef::PtrToGlobalVarForwardRef(_)) => local_id_defs + } + Some(id_def @ IdDef::SpvExtInstImport(_)) => Err(invalid(&format!( + "unsupported use of {} outside `OpExtInst`", + id_def.descr(&cx), + ))), + None | Some(IdDef::PtrToGlobalVarForwardRef(_) | IdDef::FuncForwardRef(_)) => { + local_id_defs .get(&id) .copied() - .ok_or_else(|| invalid(&format!("undefined ID %{id}",))), - }; + .ok_or_else(|| invalid(&format!("undefined ID %{id}",))) + } + }; if opcode == wk.OpFunctionParameter { if current_block.is_some() { diff --git a/src/spv/spec.rs b/src/spv/spec.rs index 7b833bbe..2e2539c3 100644 --- a/src/spv/spec.rs +++ b/src/spv/spec.rs @@ -138,6 +138,7 @@ def_well_known! { OpConstantTrue, OpConstant, OpUndef, + OpConstantFunctionPointerINTEL, OpVariable, @@ -202,6 +203,8 @@ def_well_known! { HitAttributeKHR, RayPayloadKHR, CallableDataKHR, + + CodeSectionINTEL, ], decoration: u32 = [ LinkageAttributes, diff --git a/src/transform.rs b/src/transform.rs index c691b5ac..804733f4 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -490,6 +490,10 @@ impl InnerTransform for ConstDef { gv -> transformer.transform_global_var_use(*gv), } => ConstKind::PtrToGlobalVar(gv)), + ConstKind::PtrToFunc(func) => transform!({ + func -> transformer.transform_func_use(*func), + } => ConstKind::PtrToFunc(func)), + ConstKind::SpvInst { spv_inst_and_const_inputs } => { let (spv_inst, const_inputs) = &**spv_inst_and_const_inputs; Transformed::map_iter( diff --git a/src/visit.rs b/src/visit.rs index d5577687..00e1ab17 100644 --- a/src/visit.rs +++ b/src/visit.rs @@ -351,6 +351,7 @@ impl InnerVisit for ConstDef { visitor.visit_type_use(*ty); match kind { &ConstKind::PtrToGlobalVar(gv) => visitor.visit_global_var_use(gv), + &ConstKind::PtrToFunc(func) => visitor.visit_func_use(func), ConstKind::SpvInst { spv_inst_and_const_inputs } => { let (_spv_inst, const_inputs) = &**spv_inst_and_const_inputs; for &ct in const_inputs {