[llvm-commits] [llvm] r71077 - in /llvm/trunk: lib/Transforms/IPO/FunctionAttrs.cpp test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll

Owen Anderson resistor at mac.com
Thu May 7 09:57:36 PDT 2009


On May 7, 2009, at 9:45 AM, Duncan Sands wrote:

> Hi,
>
>>>> Fix PR3754: don't mark functions that wrap MallocInst with
>>>> the readnone.  Since MallocInst is scheduled for deletion
>>>> it doesn't seem worth doing anything more subtle, such as
>>>> having mayWriteToMemory return true for MallocInst.
>>>
>>> I don't like this fix at all. What's wrong with just making
>>> mayWriteToMemory return true on MallocInst?
>>
>> I agree, that seems like the obvious fix...?
>
> because that would possibly pessimize places that may start
> thinking that a MallocInst can modify local memory etc.  Rather
> than analyzing all such places etc, I'd prefer to spend my time
> on deleting MallocInst altogether.  In the meantime, this small
> patch fixes a real problem.
>

We don't do much in the way of optimization of MallocInst anyways.   
The only thing that this helps is that it prevents a call to malloc()  
from clobbering results of a memory dependence query.  As I've  
advocated on IRC,  I think we should just add  LibCallAA support for  
saying that malloc() clobbers no known pointers, just like we can use  
it to say that libm functions only clobber errno.  This seems like the  
"right" way to go to me.

--Owen



More information about the llvm-commits mailing list