-
Notifications
You must be signed in to change notification settings - Fork 153
[CIR][Lowering] Erase op through rewriter instead of directly #853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Both this and #819 were caused by incorrectly erasing a redundant op during lowering. A potential alternative would be leaving those ops alone during lowering and running DCE afterwards to eliminate them. Would that be workable, and if so, what would be the pros and cons compared to the current way? |
Apparently if the operation you are lowering has side effects, you have to erase it or DCE won't help. On the other hand, it may (?) work to keep only those pure operations and rely on DCE to eliminate them after lowering, but we may hit verification errors since after lowering all value types are converted to LLVM types and CIR operations don't accept LLVM value types. BTW I also met this problem before in #809, see #809 (comment). However I was working on the CIR simplify pass rather than the LLVM lowering pass. In the context of any kind of rewriting you have to erase operations through the rewriter or UAF could occur. I believe we don't have to introduce an additional round of DCE to just avoid such a programming error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Directly erasing the op causes a use after free later on, presumably
because the lowering framework isn't aware of the op being deleted. This
fixes
clang/test/CIR/CodeGen/pointer-arith-ext.c
with ASAN.