Add some assertions.

- Thin and fat LTO can't happen together.
- `NeedsLink` and (non-allocator) `Compiled` work item results can't
  happen together.
This commit is contained in:
Nicholas Nethercote 2023-07-20 11:48:11 +10:00
parent 4f598b852c
commit fd017d3c17

View File

@ -1535,6 +1535,7 @@ enum CodegenState {
Ok(WorkItemResult::Finished(compiled_module)) => { Ok(WorkItemResult::Finished(compiled_module)) => {
match compiled_module.kind { match compiled_module.kind {
ModuleKind::Regular => { ModuleKind::Regular => {
assert!(needs_link.is_empty());
compiled_modules.push(compiled_module); compiled_modules.push(compiled_module);
} }
ModuleKind::Allocator => { ModuleKind::Allocator => {
@ -1545,14 +1546,17 @@ enum CodegenState {
} }
} }
Ok(WorkItemResult::NeedsLink(module)) => { Ok(WorkItemResult::NeedsLink(module)) => {
assert!(compiled_modules.is_empty());
needs_link.push(module); needs_link.push(module);
} }
Ok(WorkItemResult::NeedsFatLTO(fat_lto_input)) => { Ok(WorkItemResult::NeedsFatLTO(fat_lto_input)) => {
assert!(!started_lto); assert!(!started_lto);
assert!(needs_thin_lto.is_empty());
needs_fat_lto.push(fat_lto_input); needs_fat_lto.push(fat_lto_input);
} }
Ok(WorkItemResult::NeedsThinLTO(name, thin_buffer)) => { Ok(WorkItemResult::NeedsThinLTO(name, thin_buffer)) => {
assert!(!started_lto); assert!(!started_lto);
assert!(needs_fat_lto.is_empty());
needs_thin_lto.push((name, thin_buffer)); needs_thin_lto.push((name, thin_buffer));
} }
Err(Some(WorkerFatalError)) => { Err(Some(WorkerFatalError)) => {