http://llvm.org/bugs/show_bug.cgi?id=3756

           Summary: __attribute__((always_inline)) and __builtin_constant_p
           Product: tools
           Version: 2.5
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


Created an attachment (id=2683)
 --> (http://llvm.org/bugs/attachment.cgi?id=2683)
the sample source

llvm-gcc doesn't fold __builtin_constant_p inside
__attribute__((always_inline)) functions. The example is simple, in our code we
have:

__attribute__((always_inline)) static inline
void ifree(void *mem, mem_flags_t flags)
{
    if (__builtin_constant_p(mem)) {
        if (mem == NULL)
            return;
    }
    if (__builtin_constant_p(flags)) {
        switch (flags & MEM_POOL_MASK) {
          case MEM_LIBC:
            free(mem);
            return;
          default:
            break;
        }
    }
    __ifree(mem, flags);
}

We have lots of calls that look like: ifree(some_pointer, MEM_LIBC), and gcc
properly does constant folding. but llvm-gcc does not.

Attached are a C file, the .S file generated by gcc and the .S file generated
by llvm, where you can see that the former sees it should use a straight free()
call, and the latter calls __ifree.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to