aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2025-08-27 11:21:22 +0800
committerGitHub <noreply@github.com>2025-08-27 11:21:22 +0800
commit5d111a20c566d16f80faaa8eed1a382aacd045de (patch)
tree5c29e7542cbcbcc0a01e5d75b833bea74d911008 /clang/lib/CodeGen/CodeGenModule.cpp
parentfe78a9a75d726e253b45923f5d4000e0c17e15da (diff)
downloadllvm-5d111a20c566d16f80faaa8eed1a382aacd045de.zip
llvm-5d111a20c566d16f80faaa8eed1a382aacd045de.tar.gz
llvm-5d111a20c566d16f80faaa8eed1a382aacd045de.tar.bz2
[DAGCombiner] Avoid double deletion when replacing multiple frozen/unfrozen uses (#155427)
Closes https://github.com/llvm/llvm-project/issues/155345. In the original case, we have one frozen use and two unfrozen uses: ``` t73: i8 = select t81, Constant:i8<0>, t18 t75: i8 = select t10, t18, t73 t59: i8 = freeze t18 (combining) t80: i8 = freeze t59 (another user of t59) ``` In `DAGCombiner::visitFREEZE`, we replace all uses of `t18` with `t59`. After updating the uses, `t59: i8 = freeze t18` will be updated to `t59: i8 = freeze t59` (`AddModifiedNodeToCSEMaps`) and CSEed into `t80: i8 = freeze t59` (`ReplaceAllUsesWith`). As the previous call to `AddModifiedNodeToCSEMaps` already removed `t59` from the CSE map, `ReplaceAllUsesWith` cannot remove `t59` again. For clarity, see the following call graph: ``` ReplaceAllUsesOfValueWith(t18, t59) ReplaceAllUsesWith(t18, t59) RemoveNodeFromCSEMaps(t73) update t73 AddModifiedNodeToCSEMaps(t73) RemoveNodeFromCSEMaps(t75) update t75 AddModifiedNodeToCSEMaps(t75) RemoveNodeFromCSEMaps(t59) <- first delection update t59 AddModifiedNodeToCSEMaps(t59) ReplaceAllUsesWith(t59, t80) RemoveNodeFromCSEMaps(t59) <- second delection Boom! ``` This patch unfreezes all the uses first to avoid triggering CSE when introducing cycles.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions