aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorjeanPerier <jperier@nvidia.com>2024-07-22 12:51:30 +0200
committerGitHub <noreply@github.com>2024-07-22 12:51:30 +0200
commitbf08d0e1182c94b6fe14b8915df6a7e5e755e5f2 (patch)
tree3b1d3b5c5ef977612577b6bb54096793653181fd /clang/lib/CodeGen
parent102d16809b2cf79b5e1ff4728ef6164cd92f90d5 (diff)
downloadllvm-bf08d0e1182c94b6fe14b8915df6a7e5e755e5f2.zip
llvm-bf08d0e1182c94b6fe14b8915df6a7e5e755e5f2.tar.gz
llvm-bf08d0e1182c94b6fe14b8915df6a7e5e755e5f2.tar.bz2
[flang] fix cg-rewrite DCE (#99653)
cg-rewrite runs regionDCE to get rid of the unused fir.shape/shift/slice before codegen since those operations have no codegen. I came across an issue where unreachable code would cause the pass to fail with `error: loc(...): null operand found`. It turns out `mlir::RegionDCE` does not work properly in presence of unreachable code because it delete operations in reachable code that are unused in reachable code, but still used in unreachable code (like the constant in the added test case). It seems `mlir::RegionDCE` is always run after `mlir::eraseUnreachableBlock` outside of this pass. A solution could be to run `mlir::eraseUnreachableBlock` here or to try modifying `mlir::RegionDCE`. But the current behavior may be intentional, and both of these calls are actually quite expensive. For instance, RegionDCE will does liveness analysis, and removes unused block arguments, which is way more than what is needed here. I am not very found of having this rather heavy transformation inside this pass (they should be run after or before if they matter in the overall pipeline). Do a naïve backward deletion of the trivially dead operations instead. It is cheaper, and works with unreachable code.
Diffstat (limited to 'clang/lib/CodeGen')
0 files changed, 0 insertions, 0 deletions