[llvm-bugs] [Bug 50482] New: optimizer malloc

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 26 05:56:58 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50482

            Bug ID: 50482
           Summary: optimizer malloc
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: victor.yodaiken at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

#include <stdlib.h>
int is_any_memory_available(int n){
    char *x = malloc(n);
    int y = (x != NULL);
    free(x);
    return y;
}

Works with -O0
With -O3 is optmized to 

is_any_memory_available:                # @is_any_memory_available
        mov     eax, 1
        ret


https://godbolt.org/z/4fr7Wz7n7

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210526/93a790d5/attachment-0001.html>


More information about the llvm-bugs mailing list