@@ -879,36 +879,33 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
879
879
// Search the current function's instructions...
880
880
// FIXME(eddyb) this could get ridiculously expensive, at the very least
881
881
// it could use `.rev()`, hoping the base pointer was recently defined?
882
- let search_result = {
883
- let emit = self . emit ( ) ;
884
- let module = emit. module_ref ( ) ;
885
- emit. selected_function ( ) . and_then ( |func_idx| {
886
- module. functions . get ( func_idx) . and_then ( |func| {
887
- // Find the instruction that defined our base pointer `ptr_id`.
888
- func. all_inst_iter ( )
889
- . find ( |inst| inst. result_id == Some ( ptr_id) )
890
- . and_then ( |ptr_def_inst| {
891
- // Check if that instruction was an `AccessChain` or `InBoundsAccessChain`.
892
- if matches ! (
893
- ptr_def_inst. class. opcode,
894
- Op :: AccessChain | Op :: InBoundsAccessChain
895
- ) {
896
- // If yes, extract its base pointer and its indices.
897
- let base_ptr = ptr_def_inst. operands [ 0 ] . unwrap_id_ref ( ) ;
898
- let indices = ptr_def_inst. operands [ 1 ..]
899
- . iter ( )
900
- . map ( |op| op. unwrap_id_ref ( ) )
901
- . collect :: < Vec < _ > > ( ) ;
902
- Some ( ( base_ptr, indices) )
903
- } else {
904
- // The instruction defining ptr was not an `AccessChain`.
905
- None
906
- }
907
- } )
908
- } )
882
+ let emit = self . emit ( ) ;
883
+ let module = emit. module_ref ( ) ;
884
+ emit. selected_function ( ) . and_then ( |func_idx| {
885
+ module. functions . get ( func_idx) . and_then ( |func| {
886
+ // Find the instruction that defined our base pointer `ptr_id`.
887
+ func. all_inst_iter ( )
888
+ . find ( |inst| inst. result_id == Some ( ptr_id) )
889
+ . and_then ( |ptr_def_inst| {
890
+ // Check if that instruction was an `AccessChain` or `InBoundsAccessChain`.
891
+ if matches ! (
892
+ ptr_def_inst. class. opcode,
893
+ Op :: AccessChain | Op :: InBoundsAccessChain
894
+ ) {
895
+ // If yes, extract its base pointer and its indices.
896
+ let base_ptr = ptr_def_inst. operands [ 0 ] . unwrap_id_ref ( ) ;
897
+ let indices = ptr_def_inst. operands [ 1 ..]
898
+ . iter ( )
899
+ . map ( |op| op. unwrap_id_ref ( ) )
900
+ . collect :: < Vec < _ > > ( ) ;
901
+ Some ( ( base_ptr, indices) )
902
+ } else {
903
+ // The instruction defining ptr was not an `AccessChain`.
904
+ None
905
+ }
906
+ } )
909
907
} )
910
- } ;
911
- search_result
908
+ } )
912
909
} else {
913
910
// Input type `ty` doesn't match the pointer's actual type, cannot safely merge.
914
911
None
0 commit comments