[llvm] [EarlyCSE] Remove void return restriction for call CSE (PR #145320)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 23 08:12:35 PDT 2025
================
@@ -146,6 +146,28 @@ define i32 @test5(ptr%P) {
ret i32 %Diff
}
+declare void @void_func()
+
+define void @void_func_cse_readonly(ptr %P) {
----------------
nikic wrote:
> Once upon a time, we had a baked in assumption that in order to throw, a routine must write memory. Have we changed that at some point?
I think this holds as a practical matter, because the implementation of the unwinding mechanism is probably going to involved writes in some form. But I don't think we ever make IR level assumptions that readonly calls cannot unwind.
> I'm asking because otherwise, a void readonly call would seem to have no observable effect and thus be trivially dead?
Even if we ignore the unwind case, you can have a non-willreturn readnone function, e.g. a function that only contains an infinite loop.
https://github.com/llvm/llvm-project/pull/145320
More information about the llvm-commits
mailing list