[llvm-commits] [PATCH] extend analysis passes to treat malloc calls the same as MallocInst (patch #2)

Nick Lewycky nicholas at mxc.ca
Fri Sep 18 09:03:59 PDT 2009


Victor Hernandez wrote:
> Thanks for the feedback, Eli.
> 
> Eli Friedman wrote:
> 
>> On Tue, Sep 15, 2009 at 1:44 PM, Victor Hernandez 
>> <vhernandez at apple.com <mailto:vhernandez at apple.com>> wrote:
>>> These are the changes to make all the analysis passes apply the same
>>> analysis to malloc calls as to MallocInst.
>>
>> Index: lib/Analysis/AliasAnalysis.cpp
>> ===================================================================
>> --- lib/Analysis/AliasAnalysis.cpp (revision 81898)
>> +++ lib/Analysis/AliasAnalysis.cpp (working copy)
>> @@ -31,6 +31,7 @@
>> #include "llvm/IntrinsicInst.h"
>> #include "llvm/Instructions.h"
>> #include "llvm/Type.h"
>> +#include "llvm/Analysis/MallocHelper.h"
>> #include "llvm/Target/TargetData.h"
>> using namespace llvm;
>>
>> @@ -239,7 +240,7 @@
>> ///    NoAlias returns
>> ///
>> bool llvm::isIdentifiedObject(const Value *V) {
>> -  if (isa<AllocationInst>(V) || isNoAliasCall(V))
>> +  if (isa<AllocationInst>(V) || isMalloc(V) || isNoAliasCall(V))
>>     return true;
>>   if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
>>     return true;
>>
>> Unnecessary change, assuming malloc gets a noalias attribute;
>> isIdentifiedObject is only used on values with the bitcasts stripped
>> off.
> 
> -simplify-libcalls gives malloc the noalias attribute.  So I'll remove 
> this change and update any tests that rely on malloc being noalias to 
> run -simplify-libcalls as well.

No, either update the tests to put a noalias attribute on @malloc, or 
update the 'MallocInst -> call @malloc' code to ensure that @malloc has 
a noalias return attribute.

Nick




More information about the llvm-commits mailing list