-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit OpLine instructions #616
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, approving for when you get windows working, the comments I left could probably turn into issues?
@@ -517,6 +517,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { | |||
|
|||
fn set_span(&mut self, span: Span) { | |||
self.current_span = Some(span); | |||
let loc = self.cx.tcx.sess.source_map().lookup_char_pos(span.lo()); | |||
let file = self.builder.def_string(format!("{}", loc.file.name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, we should cache this (keying on Rc<SourceFile>
might work, but idk if it ==
's by address).
EDIT: oh, I see, def_string
already caches by string. I was imagining something more aggressive but this is probably fine for now.
let loc = self.cx.tcx.sess.source_map().lookup_char_pos(span.lo()); | ||
let file = self.builder.def_string(format!("{}", loc.file.name)); | ||
self.emit() | ||
.line(file, loc.line as u32, loc.col_display as u32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should track the fact that we're not using the debuginfo infrastructure for this.
On the one hand, we should integrate it and eventually support a lot of debuginfo through extensions like NonSemantic.Shader.DebugInfo.100
.
OTOH, we do need to always annotate certain things (probably most instructions tbh, given how many of them can fail validation) if we want to have a chance at nice error reporting.
Definitely fine with it landing as-is FWIW.
if i + 1 < block.instructions.len() | ||
&& block.instructions[i].class.opcode == Op::Line | ||
&& block.instructions[i + 1].class.opcode == Op::Line | ||
{ | ||
block.instructions.remove(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, this is pretty much dedup_by
, but we need to keep the last not first in a group of OpLine
s.
I don't know if it's going to be more efficient but if you did want to use dedup_by
you'd have to reverse the entire block.instructions
, dedup_by
, then reverse it again, ughhh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking about this did make me realize that reversing a list is actually pretty much the same number of reads/writes as removing index 0 of a list, neat, that's a little unintuitive, haha.
Anyway, uh, dedup_by
passes in the arguments as &mut
, so a cursed solution that I think I'll do is mem::swap
them if they're both OpLines :3
Update dependencies (both rspirv and spirv-tools-rs) to be able to use OpLine, and do so.
The
remove_duplicate_lines
for loop is absolute garbage,O(n^2)
terribleness, so if someone wants to hack up a clever thing, please do so~