[Bug] Fix incorrect CFG Graph structure due to missing Block wiith OffloadedStmts on LLVM backend #8113
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.
Issue: fix #8057
Brief Summary
🤖 Generated by Copilot at 33e01dc
This pull request refactors the codegen modules and the IR cloning mechanism to support the new IR structure that wraps offloaded tasks in
Block
nodes. It updates thecompile_task
functions of different backends to take anIRNode
pointer instead of anOffloadedStmt
pointer. It also adds a newclone
function totaichi/analysis/clone.cpp
and a newspecial
field toIRNode
to facilitate the cloning process.Walkthrough
🤖 Generated by Copilot at 33e01dc
clone
to deep copy statements (link, link)compile_task
and its subclasses to take anIRNode
pointer instead of anOffloadedStmt
pointer as the last argument (link, link, link, link, link, link, link, link, link)special
to classIRNode
to indicate whether the node is a special node that should not be cloned or modified by certain passes (link)special
field of the root node of the IR totrue
before cloning the offloaded statements and tofalse
after cloning them in the functionoffload_to_executable
intaichi/transforms/compile_to_offloads.cpp
(link, link)Block
node before passing them tocompile_task
in the functionscompile_kernel_to_module
intaichi/codegen/codegen.cpp
andcompile
intaichi/codegen/dx12/codegen_dx12.cpp
(link, link)task_name
method of theIRNode
to get the name of the offloaded task in the functioncompile
intaichi/codegen/dx12/codegen_dx12.cpp
, instead of assuming it is anOffloadedStmt
(link)scalarize
andfull_simplify
passes in the functionoffload_to_executable
intaichi/transforms/compile_to_offloads.cpp
, which are not needed after cloning the offloaded statements (link)