Skip to content

Commit c5eefca

Browse files
committed
qptr/lift: do not add redundant errors to qptr::analyze bugs.
1 parent afebdee commit c5eefca

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/qptr/lift.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::qptr::{shapes, QPtrAttr, QPtrMemUsage, QPtrMemUsageKind, QPtrOp, QPtr
88
use crate::transform::{InnerInPlaceTransform, InnerTransform, Transformed, Transformer};
99
use crate::{
1010
spv, AddrSpace, Attr, AttrSet, AttrSetDef, Const, ConstCtor, ConstDef, Context, ControlNode,
11-
ControlNodeKind, DataInst, DataInstDef, DataInstKind, DeclDef, Diag, EntityDefs,
11+
ControlNodeKind, DataInst, DataInstDef, DataInstKind, DeclDef, Diag, DiagLevel, EntityDefs,
1212
EntityOrientedDenseMap, Func, FuncDecl, FxIndexMap, GlobalVar, GlobalVarDecl, Module, Type,
1313
TypeCtor, TypeCtorArg, TypeDef, Value,
1414
};
@@ -1156,7 +1156,28 @@ impl Transformer for LiftToSpvPtrInstsInFunc<'_> {
11561156
self.add_value_uses(&data_inst_def.inputs);
11571157
}
11581158
Err(LiftError(e)) => {
1159-
func_at_inst.def().attrs.push_diag(&self.lifter.cx, e);
1159+
let data_inst_def = func_at_inst.def();
1160+
1161+
// HACK(eddyb) do not add redundant errors to `qptr::analyze` bugs.
1162+
let has_qptr_analysis_bug_diags = self.lifter.cx[data_inst_def.attrs]
1163+
.attrs
1164+
.iter()
1165+
.any(|attr| match attr {
1166+
Attr::Diagnostics(diags) => {
1167+
diags.0.iter().any(|diag| match diag.level {
1168+
DiagLevel::Bug(loc) => {
1169+
loc.file().ends_with("qptr/analyze.rs")
1170+
|| loc.file().ends_with("qptr\\analyze.rs")
1171+
}
1172+
_ => false,
1173+
})
1174+
}
1175+
_ => false,
1176+
});
1177+
1178+
if !has_qptr_analysis_bug_diags {
1179+
data_inst_def.attrs.push_diag(&self.lifter.cx, e);
1180+
}
11601181
}
11611182
}
11621183
}

0 commit comments

Comments
 (0)