[LLVMbugs] [Bug 23280] New: objectsize should not be lowered to unknown before inlining

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Apr 18 10:44:57 PDT 2015


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

            Bug ID: 23280
           Summary: objectsize should not be lowered to unknown before
                    inlining
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: danielmicay at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This will output 2 with `gcc -O2` but (size_t)-1 with Clang:

  #include <stdio.h>
  #include <stdlib.h>

  static inline __attribute__((always_inline)) size_t object_size(char *p) {
    return __builtin_object_size(p, 0);
  }

  int main(int argc, char **argv) {
    char buf[2];
    printf("%zu\n", object_size(buf));
    return 0;
  }

This means that _FORTIFY_SOURCE buffer size checks do not currently work with
Clang because it lowers the __builtin_object_size calls to (size_t)-1 before
the wrappers are inlined into the call sites. This will also break other
compelling use cases for this feature. It makes a lot of sense to lower it to a
*known* value pre-inlining to get more work done in the early function passes,
but replacing it with -1 before then isn't good.

-- 
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/20150418/256bd8f9/attachment.html>


More information about the llvm-bugs mailing list