Skip to content
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

Merged
merged 2 commits into from
May 7, 2021
Merged

Emit OpLine instructions #616

merged 2 commits into from
May 7, 2021

Conversation

khyperia
Copy link
Contributor

@khyperia khyperia commented May 6, 2021

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~

@khyperia khyperia requested a review from eddyb as a code owner May 6, 2021 09:03
Copy link
Contributor

@eddyb eddyb left a 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));
Copy link
Contributor

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.

Comment on lines +520 to +523
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);
Copy link
Contributor

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.

Comment on lines 286 to 290
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);
Copy link
Contributor

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 OpLines.

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.

Copy link
Contributor Author

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

@khyperia khyperia enabled auto-merge (squash) May 7, 2021 08:29
@khyperia khyperia merged commit 943f09f into main May 7, 2021
@khyperia khyperia deleted the emit-opline branch May 7, 2021 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants