Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 0 additions & 104 deletions bugs.md

This file was deleted.

2 changes: 2 additions & 0 deletions cc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Key source files:
| `parse/parser.rs` | Recursive descent parser producing AST |
| `parse/ast.rs` | AST node definitions |
| `types.rs` | C type system |
| `strings.rs` | String interning (StringId), pre-interns keywords at startup |
| `kw.rs` | Pre-interned keyword constants and tag-based classification |
| `symbol.rs` | Symbol table with scope management |
| `ir/linearize.rs` | AST → IR conversion, SSA construction |
| `ir/mod.rs` | Intermediate representation definitions |
Expand Down
3 changes: 2 additions & 1 deletion cc/arch/aarch64/regalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,8 @@ impl RegAlloc {

// Stack slot reuse uses block-level interference checks
// (live_in/live_out from dataflow fixpoint) which are correct
// for all CFG shapes. Addr-taken syms need stable addresses.
// for all CFG shapes. Addr-taken syms need stable addresses
// because symaddr-derived pointers may escape to callees.
let reusable = !self.addr_taken_syms.contains(&interval.pseudo);

self.alloc_stack_slot(&interval, aligned_size, alignment, reusable);
Expand Down
16 changes: 8 additions & 8 deletions cc/arch/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ mod tests {
fn test_run_mapping_empty() {
let target = Target::new(Arch::X86_64, Os::Linux);
let types = TypeTable::new(&target);
let mut module = Module::new();
let mut module = Module::default();

run_mapping(&mut module, &types, &target);
}
Expand All @@ -1848,7 +1848,7 @@ mod tests {
let target = Target::new(Arch::X86_64, Os::Linux);
let types = TypeTable::new(&target);

let mut module = Module::new();
let mut module = Module::default();
module.add_function(make_test_func(&types));
module.add_function(make_test_func(&types));

Expand All @@ -1860,7 +1860,7 @@ mod tests {
let target = Target::new(Arch::X86_64, Os::Linux);
let types = TypeTable::new(&target);

let mut module = Module::new();
let mut module = Module::default();
module.add_function(make_test_func(&types));

run_mapping(&mut module, &types, &target);
Expand All @@ -1879,7 +1879,7 @@ mod tests {

for target in &targets {
let types = TypeTable::new(target);
let mut module = Module::new();
let mut module = Module::default();
module.add_function(make_test_func(&types));
run_mapping(&mut module, &types, target);
}
Expand All @@ -1890,7 +1890,7 @@ mod tests {
let target = Target::new(Arch::X86_64, Os::Linux);
let types = TypeTable::new(&target);

let mut module = Module::new();
let mut module = Module::default();
module.add_function(make_test_func(&types));
let orig_insn_count = module.functions[0].blocks[0].insns.len();

Expand All @@ -1905,7 +1905,7 @@ mod tests {
let target = Target::new(Arch::Aarch64, Os::Linux);
let types = TypeTable::new(&target);

let mut module = Module::new();
let mut module = Module::default();
module.add_function(make_test_func(&types));
let orig_insn_count = module.functions[0].blocks[0].insns.len();

Expand Down Expand Up @@ -1943,7 +1943,7 @@ mod tests {
func.add_block(bb);
func.entry = BasicBlockId(0);

let mut module = Module::new();
let mut module = Module::default();
module.add_function(func);
run_mapping(&mut module, &types, &target);

Expand Down Expand Up @@ -1984,7 +1984,7 @@ mod tests {
func.add_block(bb);
func.entry = BasicBlockId(0);

let mut module = Module::new();
let mut module = Module::default();
module.add_function(func);
run_mapping(&mut module, &types, &target);

Expand Down
3 changes: 2 additions & 1 deletion cc/arch/x86_64/regalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,8 @@ impl RegAlloc {

// Stack slot reuse uses block-level interference checks
// (live_in/live_out from dataflow fixpoint) which are correct
// for all CFG shapes. Addr-taken syms need stable addresses.
// for all CFG shapes. Addr-taken syms need stable addresses
// because symaddr-derived pointers may escape to callees.
let reusable = !self.addr_taken_syms.contains(&interval.pseudo);

self.alloc_stack_slot(&interval, aligned_size, alignment, reusable);
Expand Down
41 changes: 16 additions & 25 deletions cc/cxref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,14 @@ struct SymbolRef {
}

/// Information about a symbol across files
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
struct SymbolInfo {
/// References organized by file, then by function scope
/// Map: file -> Map: function (or empty for global) -> refs
refs: BTreeMap<String, BTreeMap<String, BTreeSet<SymbolRef>>>,
}

impl SymbolInfo {
fn new() -> Self {
Self {
refs: BTreeMap::new(),
}
}

fn add_ref(&mut self, file: &str, function: &str, line: u32, is_definition: bool) {
self.refs
.entry(file.to_string())
Expand All @@ -105,6 +99,7 @@ impl SymbolInfo {
}

/// Cross-reference table
#[derive(Default)]
struct CrossRef {
/// All symbols: name -> info
symbols: BTreeMap<String, SymbolInfo>,
Expand All @@ -115,14 +110,6 @@ struct CrossRef {
}

impl CrossRef {
fn new() -> Self {
Self {
symbols: BTreeMap::new(),
current_file: String::new(),
current_function: String::new(),
}
}

fn set_file(&mut self, file: &str) {
self.current_file = file.to_string();
}
Expand All @@ -132,17 +119,21 @@ impl CrossRef {
}

fn add_definition(&mut self, name: &str, line: u32) {
self.symbols
.entry(name.to_string())
.or_insert_with(SymbolInfo::new)
.add_ref(&self.current_file, &self.current_function, line, true);
self.symbols.entry(name.to_string()).or_default().add_ref(
&self.current_file,
&self.current_function,
line,
true,
);
}

fn add_reference(&mut self, name: &str, line: u32) {
self.symbols
.entry(name.to_string())
.or_insert_with(SymbolInfo::new)
.add_ref(&self.current_file, &self.current_function, line, false);
self.symbols.entry(name.to_string()).or_default().add_ref(
&self.current_file,
&self.current_function,
line,
false,
);
}
}

Expand Down Expand Up @@ -561,7 +552,7 @@ fn main() -> ExitCode {
}

// Build cross-reference
let mut xref = CrossRef::new();
let mut xref = CrossRef::default();
let mut streams = StreamTable::new();

for file in &args.files {
Expand All @@ -586,7 +577,7 @@ fn main() -> ExitCode {
// In non-combined mode, print and reset after each file
if !args.combined {
print_xref(&xref, args.width, args.silent, &mut *output_file);
xref = CrossRef::new();
xref = CrossRef::default();
}
}
_ => {
Expand Down
Loading
Loading