[llvm-bugs] [Bug 47266] New: using known return value of std functions
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Aug 21 01:38:43 PDT 2020
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: unassignedclangbugs at nondot.org
Reporter: linux at rasmusvillemoes.dk
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200821/e733e09e/attachment.html>
More information about the llvm-bugs
mailing list