[LLVMbugs] [Bug 5801] New: clang doesn't codegen calls to memset to use llvm.memset

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Dec 16 01:25:55 PST 2009


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

           Summary: clang doesn't codegen calls to memset to use llvm.memset
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: code-quality
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: clattner at apple.com
                CC: llvmbugs at cs.uiuc.edu, regehr at cs.utah.edu


In this testcase, llvm-gcc is able to optimize away the entire function but
clang can't.  The difference is that llvm-gcc compiles the user call to memset
to use the intrinsic.  This exposes the intrinsic to the first run of
scalarrepl, where clang doesn't get to hack on it until simplifylibcalls
handles it.

----
typedef unsigned int size_t;
void _gcry_burn_stack (int bytes);
extern 
     void *
     memset (void *__s, int __c, size_t __n);
     void
     _gcry_burn_stack (int bytes)
{
  char buf[64];
  int _cil_inline_tmp_0;

  {
    memset ((void *) (buf), 0, 64U);
    bytes = (int) ((unsigned int) bytes - 64U);
    if (bytes > 0)
      {
        _cil_inline_tmp_0 = bytes;
        if (bytes > 0)
          {
            _gcry_burn_stack (bytes);
          }
      }
    return;
  }
}
----

$ llvm-gcc t.c -S -o - -m32 -march=core2 -mtune=core2 -fomit-frame-pointer
-fno-stack-protector -O0 -emit-llvm | opt -O3 -S
<empty>

$ clang t.c -S -o - -m32 -march=core2 -mtune=core2 -fomit-frame-pointer
-fno-stack-protector -O0 -emit-llvm | opt -O3 -S
<stuff>

This comes from John's code size comparison testsuite.


-- 
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.



More information about the llvm-bugs mailing list