Fix root CI regressions
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
48f43d634af91dc5c63b223a452051abf6c7b643- Parents
-
54e88fa - Tree
0a4bd08
48f43d6
48f43d634af91dc5c63b223a452051abf6c7b64354e88fa
0a4bd08| Status | File | + | - |
|---|---|---|---|
| M |
src/ir/lower.rs
|
24 | 13 |
| M |
src/parser/unit.rs
|
2 | 6 |
| M |
src/sema/resolve.rs
|
2 | 2 |
| M |
src/sema/type_layout.rs
|
4 | 4 |
| M |
tests/licm_lsf_audit_29_11.rs
|
35 | 2 |
src/ir/lower.rsmodified@@ -18,6 +18,8 @@ use std::collections::{HashMap, HashSet}; | ||
| 18 | 18 | use std::io::Write; |
| 19 | 19 | use std::rc::Rc; |
| 20 | 20 | |
| 21 | +type AmbiguousUseWarnings = Rc<RefCell<HashSet<(String, String, String)>>>; | |
| 22 | + | |
| 21 | 23 | /// Maximum array rank (Fortran allows up to 15). |
| 22 | 24 | const MAX_RANK: usize = 15; |
| 23 | 25 | |
@@ -164,7 +166,7 @@ struct LowerCtx<'a> { | ||
| 164 | 166 | /// install_globals_as_locals. Large fortsh units can otherwise print the |
| 165 | 167 | /// exact same ambiguity hundreds or thousands of times while lowering each |
| 166 | 168 | /// contained procedure separately. |
| 167 | - ambiguous_use_warnings: Rc<RefCell<HashSet<(String, String, String)>>>, | |
| 169 | + ambiguous_use_warnings: AmbiguousUseWarnings, | |
| 168 | 170 | } |
| 169 | 171 | |
| 170 | 172 | impl<'a> LowerCtx<'a> { |
@@ -179,7 +181,7 @@ impl<'a> LowerCtx<'a> { | ||
| 179 | 181 | elemental_funcs: &'a HashSet<String>, |
| 180 | 182 | char_len_star_params: &'a HashMap<String, Vec<bool>>, |
| 181 | 183 | contained_host_refs: &'a HashMap<String, Vec<String>>, |
| 182 | - ambiguous_use_warnings: Rc<RefCell<HashSet<(String, String, String)>>>, | |
| 184 | + ambiguous_use_warnings: AmbiguousUseWarnings, | |
| 183 | 185 | ) -> Self { |
| 184 | 186 | Self { |
| 185 | 187 | locals: HashMap::new(), |
@@ -287,8 +289,7 @@ pub fn lower_file( | ||
| 287 | 289 | ) -> (Module, HashMap<(String, String), ModuleGlobalInfo>) { |
| 288 | 290 | let mut module = Module::new("main".into()); |
| 289 | 291 | let mut globals: HashMap<(String, String), ModuleGlobalInfo> = external_globals; |
| 290 | - let ambiguous_use_warnings: Rc<RefCell<HashSet<(String, String, String)>>> = | |
| 291 | - Rc::new(RefCell::new(HashSet::new())); | |
| 292 | + let ambiguous_use_warnings: AmbiguousUseWarnings = Rc::new(RefCell::new(HashSet::new())); | |
| 292 | 293 | |
| 293 | 294 | // Pass 1: collect module-level variables. Submodule decls are |
| 294 | 295 | // installed under their parent module's name so the submodule's |
@@ -2554,7 +2555,7 @@ fn lower_unit( | ||
| 2554 | 2555 | // names it reads or writes. Drives both callee signature |
| 2555 | 2556 | // (hidden trailing pointer params) and call-site arg list. |
| 2556 | 2557 | contained_host_refs: &HashMap<String, Vec<String>>, |
| 2557 | - ambiguous_use_warnings: &Rc<RefCell<HashSet<(String, String, String)>>>, | |
| 2558 | + ambiguous_use_warnings: &AmbiguousUseWarnings, | |
| 2558 | 2559 | internal_only: bool, |
| 2559 | 2560 | ) { |
| 2560 | 2561 | match &unit.node { |
@@ -4796,7 +4797,7 @@ fn install_globals_as_locals( | ||
| 4796 | 4797 | required_names: Option<&HashSet<String>>, |
| 4797 | 4798 | host_module: Option<&str>, |
| 4798 | 4799 | st: &SymbolTable, |
| 4799 | - ambiguous_use_warnings: &Rc<RefCell<HashSet<(String, String, String)>>>, | |
| 4800 | + ambiguous_use_warnings: &AmbiguousUseWarnings, | |
| 4800 | 4801 | ) { |
| 4801 | 4802 | use crate::ast::decl::OnlyItem; |
| 4802 | 4803 | |
@@ -13368,7 +13369,6 @@ fn lower_stmt(b: &mut FuncBuilder, ctx: &mut LowerCtx, stmt: &SpannedStmt) { | ||
| 13368 | 13369 | vec![dest_ptr, dest_len, src_ptr, src_len], |
| 13369 | 13370 | IrType::Void, |
| 13370 | 13371 | ); |
| 13371 | - return; | |
| 13372 | 13372 | } |
| 13373 | 13373 | } |
| 13374 | 13374 | } |
@@ -13448,7 +13448,6 @@ fn lower_stmt(b: &mut FuncBuilder, ctx: &mut LowerCtx, stmt: &SpannedStmt) { | ||
| 13448 | 13448 | vec![dest_ptr, dest_len, src_ptr, src_len], |
| 13449 | 13449 | IrType::Void, |
| 13450 | 13450 | ); |
| 13451 | - return; | |
| 13452 | 13451 | } |
| 13453 | 13452 | } |
| 13454 | 13453 | } |
@@ -16129,7 +16128,7 @@ fn lower_stmt(b: &mut FuncBuilder, ctx: &mut LowerCtx, stmt: &SpannedStmt) { | ||
| 16129 | 16128 | if !tgt_field.pointer { |
| 16130 | 16129 | return; |
| 16131 | 16130 | } |
| 16132 | - if is_deferred_char_component_field(&tgt_field) { | |
| 16131 | + if is_deferred_char_component_field(tgt_field) { | |
| 16133 | 16132 | if let Expr::FunctionCall { callee, .. } = &value.node { |
| 16134 | 16133 | if let Expr::Name { name } = &callee.node { |
| 16135 | 16134 | if name.eq_ignore_ascii_case("null") { |
@@ -20335,8 +20334,14 @@ fn whole_array_expr_local_info( | ||
| 20335 | 20334 | .filter(|info| local_is_array_like(info)) |
| 20336 | 20335 | .cloned() |
| 20337 | 20336 | } |
| 20338 | - Expr::ComponentAccess { .. } => component_intrinsic_local_info(b, locals, expr, st, type_layouts) | |
| 20339 | - .filter(|info| local_is_array_like(info)), | |
| 20337 | + Expr::ComponentAccess { .. } => component_intrinsic_local_info( | |
| 20338 | + b, | |
| 20339 | + locals, | |
| 20340 | + expr, | |
| 20341 | + st, | |
| 20342 | + type_layouts, | |
| 20343 | + ) | |
| 20344 | + .filter(local_is_array_like), | |
| 20340 | 20345 | _ => None, |
| 20341 | 20346 | } |
| 20342 | 20347 | } |
@@ -21977,7 +21982,7 @@ fn component_intrinsic_local_info( | ||
| 21977 | 21982 | tl: &crate::sema::type_layout::TypeLayoutRegistry, |
| 21978 | 21983 | ) -> Option<LocalInfo> { |
| 21979 | 21984 | let (field_ptr, field) = resolve_component_field_access(b, locals, expr, st, tl)?; |
| 21980 | - if field.size == 384 && (field.allocatable || field.pointer) { | |
| 21985 | + if field_uses_array_descriptor(&field) { | |
| 21981 | 21986 | return Some(LocalInfo { |
| 21982 | 21987 | addr: field_ptr, |
| 21983 | 21988 | ty: field_storage_ir_type(&field, tl), |
@@ -22908,6 +22913,12 @@ fn field_storage_ir_type( | ||
| 22908 | 22913 | } |
| 22909 | 22914 | } |
| 22910 | 22915 | |
| 22916 | +fn field_uses_array_descriptor(field: &crate::sema::type_layout::FieldLayout) -> bool { | |
| 22917 | + field.size == 384 | |
| 22918 | + && (field.allocatable || field.pointer) | |
| 22919 | + && (field.declared_array || !field.dims.is_empty()) | |
| 22920 | +} | |
| 22921 | + | |
| 22911 | 22922 | fn component_array_local_info( |
| 22912 | 22923 | b: &mut FuncBuilder, |
| 22913 | 22924 | locals: &HashMap<String, LocalInfo>, |
@@ -22916,7 +22927,7 @@ fn component_array_local_info( | ||
| 22916 | 22927 | tl: &crate::sema::type_layout::TypeLayoutRegistry, |
| 22917 | 22928 | ) -> Option<LocalInfo> { |
| 22918 | 22929 | let (field_ptr, field) = resolve_component_field_access(b, locals, expr, st, tl)?; |
| 22919 | - if field.size != 384 || !(field.allocatable || field.pointer) { | |
| 22930 | + if !field_uses_array_descriptor(&field) { | |
| 22920 | 22931 | return None; |
| 22921 | 22932 | } |
| 22922 | 22933 | Some(LocalInfo { |
src/parser/unit.rsmodified@@ -731,12 +731,8 @@ impl<'a> Parser<'a> { | ||
| 731 | 731 | self.advance(); |
| 732 | 732 | } // consume :: |
| 733 | 733 | let mut names = Vec::new(); |
| 734 | - loop { | |
| 735 | - if let Some(name) = self.parse_access_list_item()? { | |
| 736 | - names.push(name); | |
| 737 | - } else { | |
| 738 | - break; | |
| 739 | - } | |
| 734 | + while let Some(name) = self.parse_access_list_item()? { | |
| 735 | + names.push(name); | |
| 740 | 736 | if !self.eat(&TokenKind::Comma) { |
| 741 | 737 | break; |
| 742 | 738 | } |
src/sema/resolve.rsmodified@@ -943,7 +943,7 @@ fn find_unit_scope(st: &SymbolTable, parent_scope: ScopeId, unit: &ProgramUnit) | ||
| 943 | 943 | fn exported_const_int_params( |
| 944 | 944 | st: &SymbolTable, |
| 945 | 945 | scope_id: ScopeId, |
| 946 | - visible_cache: &mut HashMap<ScopeId, HashMap<String, i64>>, | |
| 946 | + _visible_cache: &mut HashMap<ScopeId, HashMap<String, i64>>, | |
| 947 | 947 | exported_cache: &mut HashMap<ScopeId, HashMap<String, i64>>, |
| 948 | 948 | ) -> HashMap<String, i64> { |
| 949 | 949 | if let Some(cached) = exported_cache.get(&scope_id) { |
@@ -986,7 +986,7 @@ fn exported_const_int_params( | ||
| 986 | 986 | continue; |
| 987 | 987 | } |
| 988 | 988 | for (name, value) in |
| 989 | - exported_const_int_params(st, assoc.source_scope, visible_cache, exported_cache) | |
| 989 | + exported_const_int_params(st, assoc.source_scope, _visible_cache, exported_cache) | |
| 990 | 990 | { |
| 991 | 991 | out.entry(name).or_insert(value); |
| 992 | 992 | } |
src/sema/type_layout.rsmodified@@ -237,10 +237,10 @@ fn eval_const_logical_expr(expr: &crate::ast::expr::SpannedExpr) -> Option<bool> | ||
| 237 | 237 | match &expr.node { |
| 238 | 238 | Expr::LogicalLiteral { value, .. } => Some(*value), |
| 239 | 239 | Expr::ParenExpr { inner } => eval_const_logical_expr(inner), |
| 240 | - Expr::UnaryOp { op, operand } => match op { | |
| 241 | - crate::ast::expr::UnaryOp::Not => eval_const_logical_expr(operand).map(|v| !v), | |
| 242 | - _ => None, | |
| 243 | - }, | |
| 240 | + Expr::UnaryOp { | |
| 241 | + op: crate::ast::expr::UnaryOp::Not, | |
| 242 | + operand, | |
| 243 | + } => eval_const_logical_expr(operand).map(|v| !v), | |
| 244 | 244 | _ => None, |
| 245 | 245 | } |
| 246 | 246 | } |
tests/licm_lsf_audit_29_11.rsmodified@@ -96,6 +96,39 @@ fn block_section<'a>(func_section: &'a str, prefix: &str) -> &'a str { | ||
| 96 | 96 | &func_section[start..end] |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | +fn last_block_section<'a>(func_section: &'a str, prefix: &str) -> &'a str { | |
| 100 | + let mut starts = Vec::new(); | |
| 101 | + | |
| 102 | + for (idx, _line) in func_section.match_indices('\n') { | |
| 103 | + let line_start = idx + 1; | |
| 104 | + let tail = &func_section[line_start..]; | |
| 105 | + let line_text = tail.split_once('\n').map(|(line, _)| line).unwrap_or(tail); | |
| 106 | + if line_text.starts_with(" ") | |
| 107 | + && !line_text.starts_with(" ") | |
| 108 | + && line_text[4..].starts_with(prefix) | |
| 109 | + { | |
| 110 | + starts.push(line_start); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + let start = *starts | |
| 115 | + .last() | |
| 116 | + .unwrap_or_else(|| panic!("missing block with prefix {}", prefix)); | |
| 117 | + let tail = &func_section[start..]; | |
| 118 | + let end = tail | |
| 119 | + .match_indices('\n') | |
| 120 | + .find_map(|(idx, _)| { | |
| 121 | + let line_start = idx + 1; | |
| 122 | + let rest = &tail[line_start..]; | |
| 123 | + let line_text = rest.split_once('\n').map(|(line, _)| line).unwrap_or(rest); | |
| 124 | + ((line_text.starts_with(" ") && !line_text.starts_with(" ")) | |
| 125 | + || line_text == " }") | |
| 126 | + .then_some(idx) | |
| 127 | + }) | |
| 128 | + .unwrap_or(tail.len()); | |
| 129 | + &tail[..end] | |
| 130 | +} | |
| 131 | + | |
| 99 | 132 | fn tail_after<'a>(text: &'a str, needle: &str) -> &'a str { |
| 100 | 133 | let start = text |
| 101 | 134 | .find(needle) |
@@ -233,8 +266,8 @@ fn o2_forwards_branch_join_reuse_across_noalias_side_call() { | ||
| 233 | 266 | |
| 234 | 267 | let raw_branchy = function_section(&raw_ir, helper_names[2]); |
| 235 | 268 | let opt_branchy = function_section(&opt_ir, helper_names[2]); |
| 236 | - let raw_join = block_section(raw_branchy, "if_end_9"); | |
| 237 | - let opt_join = block_section(opt_branchy, "if_end_9"); | |
| 269 | + let raw_join = last_block_section(raw_branchy, "if_end_"); | |
| 270 | + let opt_join = last_block_section(opt_branchy, "if_end_"); | |
| 238 | 271 | |
| 239 | 272 | assert!( |
| 240 | 273 | raw_join.contains("gep") && raw_join.contains("load"), |