From b7c941bad9b77d1456c2f5d01fca58dd641a5c01 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Mon, 18 Jun 2012 16:04:04 +0000 Subject: add the 'alloc' metadata node to represent the size of offset of buffers pointed to by pointers. This metadata can be attached to any instruction returning a pointer llvm-svn: 158660 --- llvm/docs/LangRef.html | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'llvm/docs/LangRef.html') diff --git a/llvm/docs/LangRef.html b/llvm/docs/LangRef.html index 9cb7e6392ab..2b81279b6e5 100644 --- a/llvm/docs/LangRef.html +++ b/llvm/docs/LangRef.html @@ -105,6 +105,7 @@
  • 'tbaa' Metadata
  • 'fpmath' Metadata
  • 'range' Metadata
  • +
  • 'alloc' Metadata
  • @@ -3077,6 +3078,49 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25) + + +

    + 'alloc' Metadata +

    + +
    + +

    alloc metadata may be attached to any instruction returning a + pointer. It can be used to express the size and offset relative to the + beginning of the buffer pointed by.

    + +
    + +

    The first parameter is a function that returns the size of the buffer, and + the second (optional) parameter is a function that returns the offset from + the beginning of the buffer. If the second parameter is not present or null, + the offset is assumed to be null. Both functions must be either readonly or + readnone.

    +

    alloc metadata can have additional parameters, which are passed to + the size and offset functions when they are evaluated. Therefore the size and + offset functions must have the same signature.

    + +
    + + +

    Examples:

    +
    +
    +  ; size of buffer allocated by this call is my_malloc_size(%s), and offset=0
    +  %a = call my_malloc(%s), !alloc !{i32 (i32)* @my_malloc_size, null, i32 %s}
    +
    +  ; size of the buffer pointed by *ptr is size(%x), and offset=offset(%x)
    +  %b = load i8** %foo, !alloc !{i32 (i32)* @size, i32 (i32)* @offset, i32 %x}
    +
    +  ; size of buffer allocated by this call is foo_size(), and offset=0
    +  %a = call alloc_foo(%s), !alloc !0
    +...
    +!0 = metadata {i32 ()* @foo_size}
    +
    +
    +
    + -- cgit v1.2.3