Run DCE twice (#556)

This commit is contained in:
Ashley Hauck 2021-03-30 09:44:01 +02:00 committed by GitHub
parent 5e429866da
commit d6ff9cd439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View File

@ -277,7 +277,10 @@ pub fn link(sess: &Session, mut inputs: Vec<Module>, opts: &Options) -> Result<L
.write_all(spirv_tools::binary::from_binary(&output.assemble()))
.unwrap();
}
if opts.dce && opts.emit_multiple_modules {
// Run DCE again, even if emit_multiple_modules==false - the first DCE ran before
// structurization and mem2reg (for perf reasons), and mem2reg may remove references to
// invalid types, so we need to DCE again.
if opts.dce {
let _timer = sess.timer("link_dce_2");
dce::dce(output);
}

View File

@ -189,15 +189,14 @@ OpDecorate %5 Binding 0
%6 = OpTypeVoid
%7 = OpTypeFunction %6
%8 = OpTypeInt 32 0
%9 = OpTypePointer Function %8
%10 = OpConstant %8 1
%11 = OpTypeFloat 32
%12 = OpTypeImage %11 2D 0 0 0 1 Unknown
%13 = OpTypeSampledImage %12
%4 = OpTypeRuntimeArray %13
%14 = OpTypePointer UniformConstant %4
%5 = OpVariable %14 UniformConstant
%15 = OpTypePointer UniformConstant %13"#,
%9 = OpConstant %8 1
%10 = OpTypeFloat 32
%11 = OpTypeImage %10 2D 0 0 0 1 Unknown
%12 = OpTypeSampledImage %11
%4 = OpTypeRuntimeArray %12
%13 = OpTypePointer UniformConstant %4
%5 = OpVariable %13 UniformConstant
%14 = OpTypePointer UniformConstant %12"#,
);
}