[llvm-bugs] [Bug 49262] New: suboptimal handling of very simple vararg use

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 19 04:07:21 PST 2021


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

            Bug ID: 49262
           Summary: suboptimal handling of very simple vararg use
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: linux at rasmusvillemoes.dk
                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

godbolt https://godbolt.org/z/b35xr5

gcc does seem to realize that it's irrelevant whether any floating point
arguments were passed as they're not accessed anyway. In theory, f() could be
compiled as simply as g(), but gcc doesn't manage to get rid of the minimal
va_list setup.

However, clang emits a lot more unnecessary instructions, only some of which
are skipped over (i.e. dead) at runtime. Apart from the float handling, there's
for example 

       movl    $8, %ecx
       cmpq    $40, %rcx

with no way to reach that cmpq other than through the preceding load-immediate.
Stashing of registers beyond %rdx are dead stores.

-- 
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/20210219/ea88caf7/attachment.html>


More information about the llvm-bugs mailing list