MCPcopy Create free account
hub / github.com/IntegralPilot/rustc_codegen_jvm / meet_constants

Function meet_constants

src/optimise1/dataflow.rs:8–24  ·  view source on GitHub ↗

Meet operator for constant propagation: Merges information from multiple predecessors. A variable is constant only if it has the same constant value coming from all paths.

(map1: &ConstantMap, map2: &ConstantMap)

Source from the content-addressed store, hash-verified

6fn meet_constants(map1: &ConstantMap, map2: &ConstantMap) -> ConstantMap {
7 let mut result = ConstantMap::default();
8 // Consider variables present in map1
9 for (var, const1) in map1 {
10 match map2.get(var) {
11 Some(const2) if const1 == const2 => {
12 // Same constant value on both paths
13 result.insert(var.clone(), const1.clone());
14 }
15 _ => {
16 // Different constants or only constant on one path -> not constant after merge
17 }
18 }
19 }
20 // Variables only in map2 were already handled implicitly (won't be in result)
21 result
22}
23
24pub fn analyze_constant_propagation(
25 entry_label: &String,
26 cfg: &HashMap<String, BasicBlockInfo>,
27 // Potentially add function signature here if needed for argument constants

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected