[PATCH] D108123: [Local] Move isFreeCall() before willReturn()

guopeilin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 06:47:43 PDT 2021


guopeilin added a comment.

In D108123#2946738 <https://reviews.llvm.org/D108123#2946738>, @lebedev.ri wrote:

> In D108123#2946733 <https://reviews.llvm.org/D108123#2946733>, @guopeilin wrote:
>
>> In D108123#2946665 <https://reviews.llvm.org/D108123#2946665>, @lebedev.ri wrote:
>>
>>> This test already passes without the code change: https://godbolt.org/z/48TnbeKj1
>>
>> The store is not expected, which will become unreachable after SimplifyCFG.
>
> Right, but that is the correct outcome.
> Why is it not UB to free an `undef` (a.k.a. any random pointer)?
> It is as per the current langref: https://alive2.llvm.org/ce/z/jBqe-E
>
> Also, i would like to note that the patch's description doesn't mention that this wants to make `free(undef)` non-UB.

The key point is that function `free` can be overload, take this test case as an example, we can overload function `_ZdlPv` with an empty body. So the result becomes that we call a `free` function which actually does not free anything.  Absolutely this is not a way that `free an undef`.
So it is better to delete an instruction that calling an empty function with an undefined argument.
I will update this test case later, also the description.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108123/new/

https://reviews.llvm.org/D108123



More information about the llvm-commits mailing list