Fix for duplicate OpMemberName, and add OpMemberName for ScalarPairs (#814)

This commit is contained in:
Ashley Hauck 2021-12-01 11:25:23 +01:00 committed by GitHub
parent 2e4de94a66
commit d5d0c90652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -381,13 +381,26 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
} else {
Some(self.size)
};
let mut field_names = Vec::new();
if let TyKind::Adt(adt, _) = self.ty.kind() {
if let Variants::Single { index } = self.variants {
for i in self.fields.index_by_increasing_offset() {
let field = &adt.variants[index].fields[i];
field_names.push(field.ident.name.to_ident_string());
}
}
}
SpirvType::Adt {
def_id: def_id_for_spirv_type_adt(*self),
size,
align: self.align.abi,
field_types: vec![a, b],
field_offsets: vec![a_offset, b_offset],
field_names: None,
field_names: if field_names.len() == 2 {
Some(field_names)
} else {
None
},
}
.def_with_name(cx, span, TyLayoutNameKey::from(*self))
}

View File

@ -269,8 +269,14 @@ pub fn remove_duplicate_types(module: &mut Module) {
.retain(|inst| anno_set.insert(inst.assemble()));
// Same thing with OpName
let mut name_ids = FxHashSet::default();
let mut member_name_ids = FxHashSet::default();
module.debug_names.retain(|inst| {
inst.class.opcode != Op::Name || name_ids.insert(inst.operands[0].unwrap_id_ref())
(inst.class.opcode != Op::Name || name_ids.insert(inst.operands[0].unwrap_id_ref()))
&& (inst.class.opcode != Op::MemberName
|| member_name_ids.insert((
inst.operands[0].unwrap_id_ref(),
inst.operands[1].unwrap_literal_int32(),
)))
});
}