This commit extends the functionality of the SPIR-V module combiner
library by adding new deduplication capabilities. In particular,
implementation of deduplication of global variables and specialization
constants is introduced. For global variables, 2 variables are
considered duplicate if they either have the same descriptor set +
binding or the same built_in attribute. For specialization constants, 2
spec constants are considered duplicate if they have the same spec_id
attribute.
Details
- Reviewers
mravishankar antiagainst
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I am not familiar with the implicit conversion rules within the spv dialect (or MLIR in general). But, I was expecting that replacing all uses of bar with foo in the following to snippet to fail:
module { spv.module Logical GLSL450 { spv.specConstant @foo spec_id(5) = 1 : i1 spv.func @use_foo() -> (i1) "None" { %0 = spv._reference_of @foo : i1 spv.ReturnValue %0 : i1 } } spv.module Logical GLSL450 { spv.specConstant @bar spec_id(5) = 1. : f32 spv.func @use_bar() -> (f32) "None" { // expected-error @+1 {{floating point value not valid for specified type}} %0 = spv._reference_of @bar : f32 spv.ReturnValue %0 : f32 } } }
@antiagainst , just FYI in case we need more elaborate testing in this area.
General comment regarding this patch as well as this: https://reviews.llvm.org/D90932.
I think both can be greatly simplified and merged in a more compact patch if I introduce specialized functions to compute hash codes for each of: global vars, spec consts, and functions. Then we would need a single map that maps the hash code to the symbol op and deduplicate based on the hash code in a single walk through the module instead of separating things as I do now.
I will try to do that.