51#ifndef COMPILER_DATAFLOW_H
52#define COMPILER_DATAFLOW_H
87 for (
size_t i = 0; i <
count; ++i)
96 size_t size() const noexcept
108 bool test(
const size_t index)
const noexcept
121 bool set(
const size_t index,
const bool value =
true)
124 <<
"Compiler_Dataflow_Bit_Set::set(): index out of bounds";
126 const auto encoded =
static_cast<unsigned char>(
value ? 1u : 0u);
223 namespace Compiler_Dataflow_Detail
236 value.text =
"undef";
256 constant.
text =
value ?
"true" :
"false";
265 constant.
text =
"unit";
273 if (lhs.kind != rhs.kind)
281 return lhs.bool_value == rhs.bool_value;
294 switch (constant.
kind)
304 return constant.
bool_value ?
"true" :
"false";
314 long long &
value)
noexcept
319 char * end =
nullptr;
321 const long long result = std::strtoll(text.c_str(), &end, 10);
322 if (end == text.c_str() or *end !=
'\0')
336 if (inst.
text ==
"unit")
338 if (inst.
text ==
"true")
340 if (inst.
text ==
"false")
381 for (
size_t i = 0; i <
count; ++i)
390 if (lhs.size() != rhs.size())
393 for (
size_t i = 0; i < lhs.size(); ++i)
394 if (lhs.bits.access(i) != rhs.bits.access(i))
403 if (lhs.size() != rhs.size())
406 for (
size_t i = 0; i < lhs.size(); ++i)
417 <<
"Compiler_Dataflow: union requires sets with the same size";
420 for (
size_t i = 0; i < lhs.
size(); ++i)
421 result.bits.access(i) =
static_cast<unsigned char>(lhs.
test(i) or rhs.
test(i));
430 <<
"Compiler_Dataflow: intersection requires sets with the same size";
433 for (
size_t i = 0; i < lhs.
size(); ++i)
434 result.bits.access(i) =
static_cast<unsigned char>(lhs.
test(i)
and rhs.
test(i));
443 <<
"Compiler_Dataflow: subtraction requires sets with the same size";
446 for (
size_t i = 0; i < lhs.
size(); ++i)
447 result.bits.access(i) =
static_cast<unsigned char>(lhs.
test(i)
and not rhs.
test(i));
455 for (
size_t i = 0; i < function.
local_slots.size(); ++i)
457 assigned.set(i,
true);
466 for (
size_t i = 0; i < function.
local_slots.size(); ++i)
476 if (
id == 0 or
id >= values.
size())
485 if (
id != 0
and id < used_values.
size())
486 used_values.
access(
id) = 1u;
493 return id != 0
and id < used_values.size()
and used_values.access(
id) != 0;
583 long long result = 0;
584#if defined(__has_builtin) && __has_builtin(__builtin_add_overflow)
589 const auto ul =
static_cast<unsigned long long>(lhs.
integer_value);
590 const auto ur =
static_cast<unsigned long long>(rhs.
integer_value);
591 result =
static_cast<long long>(ul + ur);
600 long long result = 0;
601#if defined(__has_builtin) && __has_builtin(__builtin_sub_overflow)
606 const auto ul =
static_cast<unsigned long long>(lhs.
integer_value);
607 const auto ur =
static_cast<unsigned long long>(rhs.
integer_value);
608 result =
static_cast<long long>(ul - ur);
617 long long result = 0;
618#if defined(__has_builtin) && __has_builtin(__builtin_mul_overflow)
629 const auto ul =
static_cast<unsigned long long>(
632 const auto ur =
static_cast<unsigned long long>(
635 const unsigned long long uresult = ul * ur;
637 if (ul != 0
and uresult / ul != ur)
639 if (neg
and uresult >
static_cast<unsigned long long>(LLONG_MAX) + 1ULL)
641 if (not neg
and uresult >
static_cast<unsigned long long>(LLONG_MAX))
643 if (neg
and uresult ==
static_cast<unsigned long long>(LLONG_MAX) + 1ULL)
646 result = neg ? -
static_cast<long long>(uresult)
647 :
static_cast<long long>(uresult);
732 info.
use.
set(inst.local_slot_id,
true);
737 info.
def.
set(inst.local_slot_id,
true);
747 for (
size_t i = 0; i < function.
blocks.size(); ++i)
757 const auto current = worklist.
pop();
758 if (current >= function.
blocks.size() or reachable.
access(current))
761 reachable.
access(current) =
true;
762 const auto & block = function.
blocks.access(current);
812 and findings !=
nullptr)
813 findings->append({block.
id, i, inst.local_slot_id, inst.span});
826 inst.operands.is_empty()
828 : inst.operands.access(0)));
834 inst.operands.size() > 0
835 ? inst.operands.access(0)
838 inst.operands.size() > 1
839 ? inst.operands.access(1)
855 inst.operands.is_empty()
857 : inst.operands.access(0));
878 std::ostringstream
out;
880 for (
size_t i = 0; i < set.
size(); ++i)
889 return first ?
"<none>" :
out.str();
896 std::ostringstream
out;
897 for (
size_t i = 0; i < constants.
size(); ++i)
905 return constants.
is_empty() ?
"<none>" :
out.str();
911 for (
size_t i = 0; i < function.
blocks.size(); ++i)
912 function.
blocks.access(i).predecessors.clear();
914 for (
size_t i = 0; i < function.
blocks.size(); ++i)
915 for (
size_t j = 0; j < function.
blocks.access(i).terminator.successors.size(); ++j)
917 const auto succ = function.
blocks.access(i).terminator.successors.access(j);
918 if (succ < function.
blocks.size())
919 function.
blocks.access(succ).predecessors.append(i);
927 for (
size_t i = 0; i < function.
blocks.size(); ++i)
930 for (
size_t i = 0; i < function.
blocks.size(); ++i)
931 for (
size_t j = 0; j < function.
blocks.access(i).terminator.successors.size(); ++j)
933 const auto succ = function.
blocks.access(i).terminator.successors.access(j);
934 if (succ < function.
blocks.size())
935 predecessors.
access(succ).append(i);
945 for (
size_t i = 0; i < function.
blocks.size(); ++i)
946 total += function.
blocks.access(i).instructions.size();
958 and inst.local_slot_id < function.local_slots.size())
959 return not live_after.test(inst.local_slot_id);
984 const auto predecessors =
989 for (
size_t i = 0; i < function.
blocks.size(); ++i)
991 function.
blocks.access(i)));
993 for (
size_t i = 0; i < function.
blocks.size(); ++i)
1005 bool changed =
true;
1009 for (
size_t index = function.
blocks.size(); index > 0; --index)
1011 const auto block_id = index - 1;
1012 if (block_id >= reachable.size() or not reachable.access(block_id))
1016 const auto & block = function.
blocks.access(block_id);
1020 if (succ >= function.
blocks.size() or not reachable.access(succ))
1026 const auto live_in =
1030 block_sets.
access(block_id).def));
1052 for (
size_t block_id = 0; block_id < function.
blocks.size(); ++block_id)
1054 if (block_id >= reachable.size() or not reachable.access(block_id))
1059 assigned_in = initial_assigned;
1062 bool have_predecessor =
false;
1064 const auto & block_predecessors = predecessors.access(block_id);
1065 for (
size_t i = 0; i < block_predecessors.size(); ++i)
1067 const auto pred = block_predecessors.access(i);
1068 if (
pred >= function.
blocks.size() or not reachable.access(
pred))
1070 if (not have_predecessor)
1073 have_predecessor =
true;
1081 if (not have_predecessor)
1087 function.
blocks.access(block_id),
1113 for (
size_t block_id = 0; block_id < function.
blocks.size(); ++block_id)
1115 if (block_id >= reachable.size() or not reachable.access(block_id))
1120 constant_in = initial_constants;
1123 bool have_predecessor =
false;
1128 const auto & block_predecessors = predecessors.access(block_id);
1129 for (
size_t i = 0; i < block_predecessors.size(); ++i)
1131 const auto pred = block_predecessors.access(i);
1132 if (
pred >= function.
blocks.size() or not reachable.access(
pred))
1135 if (not have_predecessor)
1138 have_predecessor =
true;
1142 for (
size_t slot = 0; slot < constant_in.
size(); ++slot)
1143 constant_in.
access(slot) =
1148 if (not have_predecessor)
1154 const auto simulation =
1156 function.
blocks.access(block_id),
1175 for (
size_t block_id = 0; block_id < function.
blocks.size(); ++block_id)
1177 if (block_id >= reachable.size() or not reachable.access(block_id))
1181 const auto simulation =
1183 function.
blocks.access(block_id),
1187 for (
size_t i = 0; i < findings.size(); ++i)
1211 auto fail = [&report](
const std::string &
message)
1213 report.
valid =
false;
1218 fail(
"Dataflow analysis for '" + function.
name
1219 +
"' has mismatched reachability size");
1226 fail(
"Dataflow analysis for '" + function.
name
1227 +
"' has mismatched per-block arrays");
1229 if (not report.
valid)
1232 for (
size_t block_id = 0; block_id < function.
blocks.size(); ++block_id)
1234 const auto check_set = [&fail, &function, block_id](
const char * label,
1237 if (set.size() != function.local_slots.size())
1238 fail(std::string(
"Dataflow ") + label +
" for "
1240 +
" in function '" + function.name +
"' has wrong slot-domain size");
1243 check_set(
"live-in", analysis.
live_in_slots.access(block_id));
1248 if (analysis.
constant_in_slots.access(block_id).size() != function.local_slots.size())
1249 fail(
"Dataflow constant-in state for "
1251 +
" in function '" + function.name +
"' has wrong slot-domain size");
1252 if (analysis.
constant_out_slots.access(block_id).size() != function.local_slots.size())
1253 fail(
"Dataflow constant-out state for "
1255 +
" in function '" + function.name +
"' has wrong slot-domain size");
1260 fail(
"Dataflow analysis for '" + function.
name
1261 +
"' does not mark the entry block as reachable");
1266 if (finding.block_id >= function.
blocks.size())
1267 fail(
"Dataflow analysis for '" + function.
name
1268 +
"' contains an uninitialized-read finding with an invalid block id");
1269 else if (finding.instruction_index
1270 >= function.
blocks.access(finding.block_id).instructions.size())
1271 fail(
"Dataflow analysis for '" + function.
name
1272 +
"' contains an uninitialized-read finding with an invalid instruction index");
1274 if (finding.slot_id >= function.
local_slots.size())
1275 fail(
"Dataflow analysis for '" + function.
name
1276 +
"' contains an uninitialized-read finding with an invalid slot id");
1298 std::ostringstream
out;
1299 if (function ==
nullptr)
1301 out <<
"<null-dataflow-function>\n";
1305 out <<
"Dataflow(" << function->
name <<
")\n";
1307 out <<
" LocalSlots: <none>\n";
1310 out <<
" LocalSlots:\n";
1311 for (
size_t i = 0; i < function->
local_slots.size(); ++i)
1313 const auto & slot = function->
local_slots.access(i);
1317 if (types !=
nullptr and slot.type_id != 0)
1318 out <<
": " << types->to_string(slot.type_id);
1323 out <<
" ReachableBlocks:";
1328 out << (first ?
" " :
", ");
1337 out <<
" UninitializedReads:";
1347 <<
"/I" << finding.instruction_index
1353 for (
size_t block_id = 0; block_id < function->
blocks.size(); ++block_id)
1355 const auto & block = function->
blocks.access(block_id);
1357 <<
" [" << block.
label <<
"]\n";
1358 out <<
" Reachable: "
1372 out <<
" AssignedIn: "
1376 out <<
" AssignedOut: "
1380 out <<
" ConstantsIn: "
1384 out <<
" ConstantsOut: "
1413 const auto original_instruction_count =
1423 size_t pass_folded = 0;
1424 size_t pass_removed_instructions = 0;
1426 for (
size_t block_id = 0; block_id < provisional.
blocks.size(); ++block_id)
1428 provisional.
blocks.access(block_id).predecessors.clear();
1430 if (block_id >= analysis.reachable_blocks.size()
1431 or not analysis.reachable_blocks.access(block_id))
1434 const auto simulation =
1436 provisional.
blocks.access(block_id),
1437 analysis.assigned_in_slots.access(block_id),
1438 analysis.constant_in_slots.access(block_id));
1440 auto & block = provisional.
blocks.access(block_id);
1445 auto live_slots = analysis.live_out_slots.access(block_id);
1449 and terminator.successors.size() == 2)
1451 const auto chosen = simulation.branch_constant.bool_value
1453 : terminator.successors.access(1);
1455 terminator.condition_value = 0;
1456 terminator.successors.clear();
1457 terminator.successors.append(chosen);
1464 if (chosen < analysis.live_in_slots.size())
1465 live_slots = analysis.live_in_slots.access(chosen);
1470 terminator.condition_value);
1473 terminator.return_value);
1479 for (
size_t index = block.
instructions.size(); index > 0; --index)
1481 const auto instruction_index = index - 1;
1482 const auto & inst = block.
instructions.access(instruction_index);
1488 and not live_slots.test(inst.local_slot_id))
1491 and inst.result_id != 0
1496 keep_flags.
access(instruction_index) =
static_cast<unsigned char>(keep ? 1u : 0u);
1499 ++pass_removed_instructions;
1503 for (
size_t operand = 0; operand < inst.operands.size(); ++operand)
1505 inst.operands.
access(operand));
1510 live_slots.set(inst.local_slot_id,
false);
1514 and inst.result_id != 0)
1515 live_slots.set(inst.local_slot_id,
true);
1520 if (keep_flags.
access(i) != 0)
1527 const auto reachable_now =
1529 size_t pass_removed_blocks = 0;
1531 compacted = provisional;
1532 compacted.
blocks.clear();
1534 for (
size_t i = 0; i < provisional.
blocks.size(); ++i)
1536 for (
size_t block_id = 0; block_id < provisional.
blocks.size(); ++block_id)
1538 const bool keep_exit_block = block_id == provisional.
exit_block;
1539 if (not keep_exit_block
1540 and (block_id >= reachable_now.size() or not reachable_now.access(block_id)))
1542 ++pass_removed_blocks;
1546 auto blk = provisional.
blocks.access(block_id);
1547 blk.id = compacted.
blocks.size();
1548 blk.predecessors.clear();
1549 compacted.
blocks.append(std::move(blk));
1551 for (
size_t block_id = 0; block_id < compacted.
blocks.size(); ++block_id)
1553 auto & blk = compacted.
blocks.access(block_id);
1555 for (
size_t i = 0; i < blk.terminator.successors.size(); ++i)
1557 const auto old_s = blk.terminator.successors.
access(i);
1558 if (old_s < pass_remap.
size()
1562 blk.terminator.successors = succs;
1573 provisional = std::move(compacted);
1575 if (pass_folded == 0
and pass_removed_instructions == 0
and pass_removed_blocks == 0)
1580 result.
function = std::move(provisional);
1606 auto fail = [&report](
const std::string &
message)
1608 report.
valid =
false;
1613 if (not ir_report.valid)
1615 report.
valid =
false;
1616 for (
size_t i = 0; i < ir_report.errors.size(); ++i)
1621 const auto expected_exit_unreachable_warning =
1626 +
" in function '" + result.
function.
name +
"' is unreachable from entry"
1629 for (
size_t i = 0; i < ir_report.warnings.size(); ++i)
1630 if (ir_report.warnings.access(i).find(
"unreachable") != std::string::npos)
1632 if (not expected_exit_unreachable_warning.empty()
1633 and ir_report.warnings.access(i) == expected_exit_unreachable_warning)
1637 +
"' still contains unreachable blocks");
1643 if (analysis.foldable_branch_count != 0)
1645 +
"' still contains foldable branches");
1647 for (
size_t block_id = 0; block_id < result.
function.
blocks.size(); ++block_id)
1649 if (block_id >= analysis.reachable_blocks.size()
1650 or not analysis.reachable_blocks.access(block_id))
1654 auto live_slots = analysis.live_out_slots.access(block_id);
1666 for (
size_t index = block.
instructions.size(); index > 0; --index)
1668 const auto instruction_index = index - 1;
1669 const auto & inst = block.
instructions.access(instruction_index);
1676 +
"' still contains removable code in "
1678 +
" at instruction #" + std::to_string(instruction_index));
1680 for (
size_t operand = 0; operand < inst.operands.size(); ++operand)
1682 inst.operands.
access(operand));
1687 live_slots.set(inst.local_slot_id,
false);
1691 and inst.result_id != 0)
1692 live_slots.set(inst.local_slot_id,
true);
Reusable explicit-value IR model, validation, and deterministic dumps.
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_unless(C)
Throws std::runtime_error if condition does NOT hold.
size_t size_t int32_t value
size_t size_t int32_t * out
Context owning all compiler type nodes.
void clear() noexcept
Empties the container.
size_t size() const noexcept
Return the current dimension of array.
T & access(const size_t i) noexcept
Fast access without checking allocation and bound_min_clock checking.
T pop()
Remove the last item of array (as if this was a stack)
T & append()
Allocate a new entry to the end of array.
bool is_empty() const noexcept
Return true if the array is empty.
Freq_Node * pred
Predecessor node in level-order traversal.
Compiler_Dataflow_Bit_Set initial_assigned_state(const Compiler_IR_Function &function)
DynArray< bool > compute_reachability(const Compiler_IR_Function &function)
Compiler_Dataflow_Bit_Set bit_set_union(const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs)
std::string format_slot_set(const Compiler_IR_Function &function, const Compiler_Dataflow_Bit_Set &set)
Compiler_Dataflow_Bit_Set make_bit_set(const size_t count, const bool value=false)
void mark_value_used(DynArray< unsigned char > &used_values, const Compiler_IR_Value_Id id)
Compiler_Dataflow_Constant integer_constant(const long long value)
size_t count_instructions(const Compiler_IR_Function &function)
Compiler_Dataflow_Constant constant_from_instruction(const Compiler_IR_Instruction &inst)
DynArray< Compiler_Dataflow_Constant > make_constant_vector(const size_t count, const Compiler_Dataflow_Constant &fill)
Compiler_Dataflow_Constant unknown_constant()
Compiler_Dataflow_Constant evaluate_binary(const Compiler_Operator_Kind op, const Compiler_Dataflow_Constant &lhs, const Compiler_Dataflow_Constant &rhs)
Compiler_Dataflow_Bit_Set bit_set_subtract(const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs)
void rebuild_predecessors(Compiler_IR_Function &function)
std::string format_slot_constants(const Compiler_IR_Function &function, const DynArray< Compiler_Dataflow_Constant > &constants)
Compiler_Dataflow_Constant unit_constant()
Compiler_Dataflow_Constant undefined_constant()
Compiler_Dataflow_Constant evaluate_unary(const Compiler_Operator_Kind op, const Compiler_Dataflow_Constant &operand)
Block_Use_Def compute_block_use_def(const Compiler_IR_Function &function, const Compiler_IR_Block &block)
DynArray< Compiler_Dataflow_Constant > initial_constant_state(const Compiler_IR_Function &function)
bool can_stop_program(const Compiler_IR_Instruction &inst) noexcept
Returns whether inst is integer arithmetic that can stop the program.
bool is_pure_instruction(const Compiler_IR_Instruction &inst) noexcept
Block_Simulation simulate_block(const Compiler_IR_Function &function, const Compiler_IR_Block &block, const Compiler_Dataflow_Bit_Set &assigned_in, const DynArray< Compiler_Dataflow_Constant > &constants_in, DynArray< Compiler_Dataflow_Uninitialized_Read > *findings=nullptr)
Compiler_Dataflow_Constant meet_constants(const Compiler_Dataflow_Constant &lhs, const Compiler_Dataflow_Constant &rhs)
DynArray< DynArray< Compiler_IR_Block_Id > > compute_predecessor_lists(const Compiler_IR_Function &function)
bool instruction_is_trivially_dead(const Compiler_IR_Instruction &inst, const Compiler_Dataflow_Bit_Set &live_after, const DynArray< unsigned char > &used_values, const Compiler_IR_Function &function) noexcept
Compiler_Dataflow_Constant boolean_constant(const bool value)
bool bit_set_equals(const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs) noexcept
Compiler_Dataflow_Bit_Set bit_set_intersection(const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs)
std::string constant_to_string(const Compiler_Dataflow_Constant &constant)
bool constant_vector_equals(const DynArray< Compiler_Dataflow_Constant > &lhs, const DynArray< Compiler_Dataflow_Constant > &rhs) noexcept
bool same_constant(const Compiler_Dataflow_Constant &lhs, const Compiler_Dataflow_Constant &rhs) noexcept
bool parse_integer_constant(const std::string &text, long long &value) noexcept
bool is_value_used(const DynArray< unsigned char > &used_values, const Compiler_IR_Value_Id id) noexcept
Compiler_Dataflow_Constant value_constant(const DynArray< Compiler_Dataflow_Constant > &values, const Compiler_IR_Value_Id id)
std::string local_slot_name(const Compiler_IR_Local_Slot_Id id)
std::string block_name(const Compiler_IR_Block_Id id)
Main namespace for Aleph-w library functions.
Compiler_Dataflow_Constant_Kind
Constant-lattice states used by local constant propagation.
@ Boolean
Boolean constant.
@ Unknown
A value exists but is not known to be constant.
@ Integer
Integer constant.
@ Undefined
A slot has not been definitely initialized yet.
void message(const char *file, int line, const char *format,...)
Print an informational message with file and line info.
Compiler_Dataflow_Validation_Report validate_dead_code_elimination(const Compiler_Dead_Code_Elimination_Result &result, const Compiler_IR_Module *module=nullptr)
Validates the result of dead-code elimination.
Compiler_Dataflow_Function_Analysis analyze_dataflow_function(const Compiler_IR_Function &function)
Computes reachability, liveness, definite assignment, and constant propagation for one IR function.
void fill(Itor beg, const Itor &end, const T &value)
Fill a range with a value.
const char * compiler_dataflow_constant_kind_name(const Compiler_Dataflow_Constant_Kind kind) noexcept
Returns a stable debug name for one constant-lattice kind.
size_t Compiler_IR_Value_Id
constexpr size_t compiler_ir_invalid_id() noexcept
Returns the sentinel invalid IR id.
and
Check uniqueness with explicit hash + equality functors.
Compiler_Dead_Code_Elimination_Result eliminate_dead_code(const Compiler_IR_Function &function)
Eliminates unreachable blocks, dead pure instructions, dead local stores, and folds constant-conditio...
Compiler_Dataflow_Validation_Report validate_dataflow_analysis(const Compiler_IR_Function &function, const Compiler_Dataflow_Function_Analysis &analysis)
Validates structural invariants of a dataflow result against its source function.
size_t Compiler_IR_Block_Id
const char * compiler_ir_slot_kind_name(const Compiler_IR_Slot_Kind kind) noexcept
Stable debug name for one slot kind.
Compiler_IR_Validation_Report validate_ir_function(const Compiler_IR_Function &function, const Compiler_IR_Module *module=nullptr)
Validates one lowered IR function structurally.
std::string compiler_dump_dataflow_analysis(const Compiler_IR_Function *function, const Compiler_Dataflow_Function_Analysis &analysis, const Compiler_Type_Context *types=nullptr)
Produces a deterministic, human-readable dump of a dataflow result.
Compiler_Operator_Kind
Stable operator kinds shared by reusable compiler layers.
size_t Compiler_IR_Local_Slot_Id
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Small reusable bit-set for slot-domain dataflow analyses.
bool test(const size_t index) const noexcept
Returns whether bit index is set.
size_t size() const noexcept
Returns the number of tracked bits.
bool set(const size_t index, const bool value=true)
Sets or clears bit index.
void resize(const size_t count, const bool value=false)
Clears all existing bits and resizes the set to count elements.
DynArray< unsigned char > bits
One byte per tracked element.
One propagated constant value in the local-slot lattice.
Compiler_Dataflow_Constant_Kind kind
Lattice kind.
bool is_known() const noexcept
Returns whether the lattice state represents a known constant.
long long integer_value
Integer payload when kind == Integer.
bool bool_value
Boolean payload when kind == Boolean.
std::string text
Stable textual spelling for deterministic dumps.
Compiler_Dataflow_Constant branch_constant
DynArray< Compiler_Dataflow_Constant > constant_out
Compiler_Dataflow_Bit_Set assigned_out
DynArray< Compiler_Dataflow_Constant > value_constants
Compiler_Dataflow_Bit_Set def
Compiler_Dataflow_Bit_Set use
Full dataflow result for one IR function or top-level body.
DynArray< Compiler_Dataflow_Bit_Set > assigned_in_slots
Local slots definitely assigned at block entry.
DynArray< Compiler_Dataflow_Bit_Set > assigned_out_slots
Local slots definitely assigned at block exit.
size_t local_slot_count
Number of tracked local slots.
DynArray< Compiler_Dataflow_Bit_Set > live_out_slots
Local slots live at block exit.
DynArray< DynArray< Compiler_Dataflow_Constant > > constant_in_slots
Per-block constant state at entry.
DynArray< bool > reachable_blocks
Reachability from entry for each block id.
DynArray< DynArray< Compiler_Dataflow_Constant > > constant_out_slots
Per-block constant state at exit.
DynArray< Compiler_Dataflow_Bit_Set > live_in_slots
Local slots live at block entry.
DynArray< Compiler_Dataflow_Uninitialized_Read > uninitialized_reads
Local reads that are not definitely assigned.
size_t foldable_branch_count
Reachable branches whose condition is statically known.
One definite-assignment finding for an uninitialized local read.
Source_Span span
Source span associated with the load.
Compiler_IR_Local_Slot_Id slot_id
Read local slot.
Compiler_IR_Block_Id block_id
Block containing the read.
size_t instruction_index
Zero-based instruction index inside the block.
Validation report for analysis and optimization passes.
bool valid
Whether the checked invariants hold.
DynArray< std::string > warnings
Non-fatal observations.
DynArray< std::string > errors
Hard invariant violations.
Result of applying dead-code elimination to one IR function.
size_t removed_instructions
Number of removed instructions.
Compiler_IR_Function function
Optimized function copy.
size_t removed_blocks
Number of removed blocks.
size_t folded_branches
Number of branches folded to jumps.
One basic block of IR instructions.
Lowered IR for one function or top-level body.
Compiler_IR_Value_Id next_value_id
Next value id to allocate while lowering.
DynArray< Compiler_IR_Block > blocks
Basic blocks in deterministic id order.
std::string name
Debug or source-level name.
Compiler_IR_Block_Id exit_block
Canonical exit block.
Compiler_IR_Block_Id entry_block
Canonical entry block.
DynArray< Compiler_IR_Slot > local_slots
Parameter/local slots in stable order.
One instruction producing an optional explicit result value.
std::string text
Constant spelling or debug payload.
Compiler_IR_Instruction_Kind kind
Instruction category.
Lowered IR module with shared global slots and functions.
Compiler_SSA_Block_Id id
Dense SSA block id.
DynArray< Compiler_SSA_Instruction > instructions
Linear SSA instruction list.
std::string label
Deterministic debug label.
Compiler_SSA_Terminator terminator
Explicit block terminator.
Compiler_SSA_Value_Id return_value
Return value, when relevant.
DynArray< Compiler_SSA_Block_Id > successors
Successors in deterministic order.
Compiler_IR_Terminator_Kind kind
Terminator category.
Compiler_SSA_Value_Id condition_value
Branch condition, when relevant.
Half-open byte range inside a source file.
Lazy and scalable dynamic array implementation.