[llvm-dev] allocsize: change from 3.9 to 4.0

Johan Engelen via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 30 04:56:56 PDT 2017


Hi all,
  I added support for the allocsize function attribute to our compiler
(LDC), thinking that that would enable removal of function calls when the
allocated memory is not used.

For example:
```
declare i8* @my_malloc(i32) allocsize(0)

define void @test_malloc() {
  %1 = call i8* @my_malloc(i32 100)
  ret void
}
```
I thought the my_alloc call in test_malloc would be removed, but `opt -O3`
doesn't do that (LLVM 4.0 and trunk). However, LLVM3.9's `opt` _does_
remove the call.

I can't find out why this was changed.
(if the call is to "malloc", it is removed because LLVM recognizes the
function name)

Thanks for the explanation,
Kind regards,
  Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170430/99f3199d/attachment.html>


More information about the llvm-dev mailing list