[llvm] r322125 - [IPSCCP] Remove calls without side effects

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 14:01:47 PST 2018



On 01/11/2018 12:38 PM, Friedman, Eli wrote:
> On 1/10/2018 3:36 PM, Philip Reames via llvm-commits wrote:
>> I think this is wrong.  In particular, an ordered memory operation is 
>> NOT safe to remove during constant propagation, even if it's result 
>> is known.  The ordered load has a side effect of ordering other loads 
>> which is not safe to remove.  The entire *point* of having side 
>> effects is that there's an effect other than the result of the 
>> instruction.
>
> An atomic load with no users is trivially dead.  Per the atomics 
> model, the only "side-effect" of a load is the potential 
> synchronizes-with edge with an earlier store.  But there is no edge 
> unless the load reads a value produced by a "release" store... and you 
> can't prove it does without using the value. 
> wouldInstructionBeTriviallyDead should handle this, but currently 
> doesn't.
>
> I don't think SCCP tries to fold any other atomic operations.
>
> -Eli
>
Let's not get into the details of the concurrency model.  We don't need 
to understand this bug.  As an example, cmpxchg is plenty. Even if we 
know the value loaded, we still need to preserve the side effect of the 
store.  The current code wouldn't, and thus is buggy.

Philip



More information about the llvm-commits mailing list