Skip to content

Commit

Permalink
New structurizer: now with ∞% more φ!
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Nov 30, 2020
1 parent c097297 commit ea577b9
Show file tree
Hide file tree
Showing 7 changed files with 519 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/rustc_codegen_spirv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use-compiled-tools = ["spirv-tools/use-compiled-tools"]

[dependencies]
bimap = "0.5"
indexmap = "1.6.0"
rspirv = { git = "https:/gfx-rs/rspirv.git", rev = "01ca0d2e5b667a0e4ff1bc1804511e38f9a08759" }
rustc-demangle = "0.1.18"
spirv-tools = { version = "0.1.0", default-features = false }
Expand Down
7 changes: 1 addition & 6 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
else_llbb: Self::BasicBlock,
cases: impl ExactSizeIterator<Item = (u128, Self::BasicBlock)>,
) {
if !self.kernel_mode {
// TODO: Remove once structurizer is done.
self.zombie(else_llbb, "OpSwitch before structurizer is done");
}

fn construct_8(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
if v > u8::MAX as u128 {
self_.fatal(&format!(
Expand Down Expand Up @@ -700,7 +695,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
OverflowOp::Mul => (self.mul(lhs, rhs), fals),
};
self.zombie(
result.1.def(self),
result.0.def(self),
match oop {
OverflowOp::Add => "checked add is not supported yet",
OverflowOp::Sub => "checked sub is not supported yet",
Expand Down
12 changes: 11 additions & 1 deletion crates/rustc_codegen_spirv/src/linker/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ pub fn mem2reg(
pub fn compute_preds(blocks: &[Block]) -> Vec<Vec<usize>> {
let mut result = vec![vec![]; blocks.len()];
for (source_idx, source) in blocks.iter().enumerate() {
for dest_id in outgoing_edges(source) {
let mut edges = outgoing_edges(source);
// HACK(eddyb) treat `OpSelectionMerge` as an edge, in case it points
// to an otherwise-unreachable block.
if let Some(before_last_idx) = source.instructions.len().checked_sub(2) {
if let Some(before_last) = source.instructions.get(before_last_idx) {
if before_last.class.opcode == Op::SelectionMerge {
edges.push(before_last.operands[0].unwrap_id_ref());
}
}
}
for dest_id in edges {
let dest_idx = blocks
.iter()
.position(|b| b.label_id().unwrap() == dest_id)
Expand Down
7 changes: 6 additions & 1 deletion crates/rustc_codegen_spirv/src/linker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod duplicates;
mod import_export_link;
mod inline;
mod mem2reg;
mod new_structurizer;
mod simple_passes;
mod structurizer;
mod zombies;
Expand Down Expand Up @@ -136,7 +137,11 @@ pub fn link(sess: &Session, mut inputs: Vec<Module>, opts: &Options) -> Result<M

let mut output = if opts.structurize {
let _timer = sess.timer("link_structurize");
structurizer::structurize(sess, output)
if false {
structurizer::structurize(sess, output)
} else {
new_structurizer::structurize(output)
}
} else {
output
};
Expand Down
Loading

0 comments on commit ea577b9

Please sign in to comment.