Conversation
…nt (compile-time and SizeExpr-evaluated)
…skCodeGenLLVM into TaskCodeGenLLVMAdStack
Coverage Report (
|
| File | Coverage | Missing |
|---|
Diff coverage: 0% · Overall: 74% · 0 lines, 0 missing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extract per-task adstack codegen state into
TaskCodeGenLLVMAdStackWhy
codegen_llvm.hhad a ~110-line block of adstack-only state (19 fields: heap strides, per-stack offsets, cached SSA bases, lazy-claim row id, bootstrap pushes, captured bound-expr, ...) plus 9 helper method declarations.codegen_llvm.cpphad the matching 184 field accesses / method definitions interleaved with the rest of the LLVM codegen. Hard to read, hard to extend, dragged the heavystatic_adstack_analysis.h/adstack_size_expr.hincludes into every translation unit that pulls incodegen_llvm.h.Mechanism
quadrants/codegen/llvm/codegen_llvm_adstack.hdeclaresTaskCodeGenLLVMAdStack. Owns the 19 state fields and the 9 helper methods (ensure_heap_base_split_llvm,ensure_metadata_llvm,ensure_metadata_split_llvm,ensure_row_id_var_float_llvm,emit_row_claim_llvm,ensure_count_alloca_llvm,emit_single_slot_ptr,get_base_llvm,emit_top_slot_ptr). Holds aTaskCodeGenLLVM&back-reference for accessingbuilder/entry_block/llvm_context/call/get_runtime/task_codegen_id/llvm_valfrom the helpers.quadrants/codegen/llvm/codegen_llvm_adstack.cppdefines the helpers. Bodies are mechanical translations of the originals withbuilder->codegen_.builder,entry_block->codegen_.entry_block, etc.codegen_llvm.h: the 110-line state / method block becomesstd::unique_ptr<TaskCodeGenLLVMAdStack> adstack_;plus a forward-declaredTaskCodeGenLLVMAdStack.~TaskCodeGenLLVM()switched from= defaultin the header to an out-of-line definition in the .cpp (PIMPL pattern: required because the unique_ptr holds a forward-declared type, also keeps the heavy adstack includes confined to the .cpp side).codegen_llvm.cpp: 184 field-access / method-call references rewired toadstack_->...; the 9 helper definitions deleted (now living in the new .cpp); the constructor adds one lineadstack_ = std::make_unique<TaskCodeGenLLVMAdStack>(*this);at the end.CMakeLists.txt: new .cpp added to thellvm_codegentarget sources.The
is_compile_time_single_slotstatic helper incodegen_llvm.cppstays where it is (used by thevisit(AdStack*Stmt)visitors that remain onTaskCodeGenLLVM).Tests
No new tests: pure refactor with mechanical renames. Local Metal serial: 674 passed, 1 skipped, 7 xfailed (same xfail set as
origin/main); mpm_grid repro still capturessrc=reducer_count effective_rows=128 required_bytes=32768. Existingtest_adstack_*covers every adstack codegen path through the renamed accessors.Side-effect audit
field->codegen_.fieldrewrites.LLVMRuntime_get_adstack_*getter calls, sameentry_blockinsertion order, same atomic-rmw / clamp / store sequence at the LCA-block claim site, same per-stackalloca i64count emission.codegen_llvm.hno longer transitively pullsstatic_adstack_analysis.h/adstack_size_expr.h. Compile-time savings are small but real for unrelated TUs (codegen_cpu, codegen_cuda, codegen_amdgpu, kernel_compiler, struct_llvm).