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

Nick Lewycky nicholas at mxc.ca
Wed May 6 20:02:37 PDT 2009


Duncan Sands wrote:
> Author: baldrick
> Date: Wed May  6 03:42:00 2009
> New Revision: 71077
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=71077&view=rev
> Log:
> 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?

> 
> Added:
>     llvm/trunk/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll
> Modified:
>     llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
> 
> Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=71077&r1=71076&r2=71077&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Wed May  6 03:42:00 2009
> @@ -152,6 +152,11 @@
>        if (I->mayWriteToMemory())
>          // Writes memory.  Just give up.
>          return false;
> +
> +      if (isa<MallocInst>(I))
> +        // MallocInst claims not to write memory!  PR3754.
> +        return false;
> +
>        // If this instruction may read memory, remember that.
>        ReadsMemory |= I->mayReadFromMemory();
>      }
> 
> Added: llvm/trunk/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll?rev=71077&view=auto
> 
> ==============================================================================
> --- llvm/trunk/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll (added)
> +++ llvm/trunk/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll Wed May  6 03:42:00 2009
> @@ -0,0 +1,7 @@
> +; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | not grep read
> +; PR3754
> +
> +define i8* @m(i32 %size) {
> +	%tmp = malloc i8, i32 %size		; <i8*> [#uses=1]
> +	ret i8* %tmp
> +}
> 
> 
> _______________________________________________
> 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