[llvm-dev] invariant.load metadata semantics

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 30 17:07:32 PDT 2016


On 8/30/2016 4:53 PM, Sanjoy Das via llvm-dev wrote:
> This seems fine, but it does disallow introduction of dead stores.
> That is, given:
>
> void f() {
>   %x = calloc()
>   call void @g(nocapture %x)
> }
>
> we cannot transform it to
>
> void f() {
>   %x = calloc()
>   *(%x) = 100
>   *(%x) = 0
>   call void @g(nocapture %x)
> }
>
> (after proving that %x is not visible to other threads), since @g
> could have invariant loads from %x.
>
> I don't have a good way of avoiding this issue, but given that the
> transform above does not seem very useful I'm inclined to say the
> definition above is okay for now.

LICM performs precisely this transformation... see "If this is a thread 
local location" etc. in LICM.cpp.  That said, I doubt this case matters; 
nobody is going to use invariant.load on the result of calloc().

-Eli


-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list