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

            Bug ID: 47266
           Summary: using known return value of std functions
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

There's something a bit wonky about clang's use of e.g. memcpy() being known to
return its dst argument. Both gcc and clang does seem to know this, and in fact
both compilers seem to compile

  memcpy(p, q, y);
  do_stuff(p, 5);

to exactly the same thing as when one writes this as

  do_stuff(memcpy(p, q, y), 5);

The weird thing is that clang decides to use a callee-saved register for p,
even in the latter case; that's even more pronounced on ppc where the return
register is also the first argument register. Godbolt:
https://godbolt.org/z/W6W3od

In the powerpc case, all the instruction involving r30 could be elided. Similar
for x86. And clearly clang must know about the semantics of the return value,
or it couldn't possibly compile the second one with referring to eax.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to