[llvm-commits] [PATCH] Add malloc call utility functions

Victor Hernandez vhernandez at apple.com
Tue Sep 8 17:44:36 PDT 2009


On Sep 7, 2009, at 6:43 PM, Evan Cheng wrote:

> Hi Victor,
>
> Some comments:
>
> +// This family of functions help identify calls to malloc.
>
> This comment isn't accurate, right? Please update. Thanks.

Updated to:
+// This family of functions identifies calls to malloc, bitcasts of  
malloc
+// calls, and the types and array sizes associated with them.


> +const CallInst* IsMallocCall(const Value* I);
> +const PointerType* GetMallocType(const CallInst* CI);
>
> I don't have a strong opinion about this. But our naming convention  
> seems to be lower case 'is' and 'get'. See Constants.h.

Updated to:
+const PointerType* getMallocType(const CallInst* CI);

>
> +CallInst* IsMallocCall(Value* I);
> This is not a very good name for what is does. Perhaps  
> ExtractMallocCall

Changed to:
+CallInst* extractMallocCall(Value* I);

>
> IsMallocBitCast
> Perhaps isBitCastOfMallocCall?

Updated to:
+CallInst* extractMallocCallFromBitCast(Value* I);

>
> +  // Determine type only if there is only 1 bitcast use of CI
> Period at the end please. :-)

Fixed.

>
> +#if 1
>   return wrap(unwrap(B)->CreateMalloc(unwrap(Ty), 0, Name));
> +#else
>
> Please don't leave #if #else around.

These #if/#else patches are there to show how LLParser, BitCodeReader,  
and VMCore will be updated to avoid MallocInst.  I am fine not  
committing those patches because they are not built by default.  They  
are not included in the following patch.

Here is the new patch:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MallocHelper.diff
Type: application/octet-stream
Size: 22554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090908/ddc6895e/attachment.obj>
-------------- next part --------------



Victor


>
> Thanks,
>
> Evan
>
> On Sep 4, 2009, at 5:58 PM, Victor Hernandez wrote:
>
>> Here is an update to this patch to incorporate suggested changes.
>>
>> I also went ahead and started modifying the optimization passes and  
>> transforms to use the MallocHelper functions, so that I know I have  
>> the right helper functions.  The changes to the passes are not in  
>> this patch, but will be coming next.
>>
>> Also I have included the LLParser, BitCodeReader, and VMCore  
>> changes that use the new malloc codegen instead of MallocInst.   
>> Those changes are disabled by default until the changes to the  
>> passes are in.
>>
>> <MallocHelper.diff>
>>
>> Victor
>>
>>> I am working on fixing the MallocInst/i64 alloca bug:
>>> http://llvm.org/bugs/show_bug.cgi?id=715
>>>
>>> Here is the first of a series of patches that will result in  
>>> tearing out MallocInst.  Before I can tear it out, I need to  
>>> update all of the optimization passes and transforms that operate  
>>> on MallocInst to operate on malloc CallInst instead.
>>>
>>> This patch consists of a set of utility functions that create IR  
>>> for malloc calls and identify that IR.  It also rewrites  
>>> LowerAllocations to use the new utility function,  
>>> CallInst::CreateMalloc().
>>>
>>> <mallocUtils.diff>
>>>
>>> Victor
>>>
>>> ---
>>> Victor Hernandez          vhernandez at apple.com
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list