[llvm-bugs] [Bug 36592] New: clang++ is inefficient in passing class as function parameter with x86 32-bit ABI

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 3 16:00:17 PST 2018


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

            Bug ID: 36592
           Summary: clang++ is inefficient in passing class as function
                    parameter with x86 32-bit ABI
           Product: libc++abi
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: handeng at cisco.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

clang++ is inefficient in passing class as function parameter with x86 32-bit
ABI.

Below is the example and output 

===================================
 test.cc
===================================
#include <stdint.h>
typedef struct {
    uint32_t v;
} struct_t;

class class_t {
public:
    uint32_t v;
};

#ifdef CLASS
    #define uint32_t class_t
#elif defined(STRUCT)
    #define uint32_t struct_t
#endif
uint32_t t1;
uint32_t t2;

void func1 (uint32_t w1, uint32_t w2);

void func2()
{
    func1(t1, t2);
}

===================================
clang -x c++ -m32 -O3 -c test.cc
objdump -d test.o
===================================

test.o:     file format elf32-i386


Disassembly of section .text:

00000000 <_Z5func2v>:
   0:   83 ec 0c                sub    $0xc,%esp
   3:   83 ec 08                sub    $0x8,%esp
   6:   ff 35 00 00 00 00       pushl  0x0
   c:   ff 35 00 00 00 00       pushl  0x0
  12:   e8 fc ff ff ff          call   13 <_Z5func2v+0x13>
  17:   83 c4 1c                add    $0x1c,%esp
  1a:   c3                      ret

===================================
clang -x c++ -m32 -O3 -c test.cc -DSTRUCT
objdump -d test.o
===================================

00000000 <_Z5func2v>:
   0:   83 ec 0c                sub    $0xc,%esp
   3:   83 ec 08                sub    $0x8,%esp
   6:   ff 35 00 00 00 00       pushl  0x0
   c:   ff 35 00 00 00 00       pushl  0x0
  12:   e8 fc ff ff ff          call   13 <_Z5func2v+0x13>
  17:   83 c4 1c                add    $0x1c,%esp
  1a:   c3                      ret

===================================
clang -x c++ -m32 -O3 -c test.cc -DCLASS
objdump -d test.o
===================================

00000000 <_Z5func2v>:
   0:   83 ec 1c                sub    $0x1c,%esp
   3:   a1 00 00 00 00          mov    0x0,%eax
   8:   89 44 24 18             mov    %eax,0x18(%esp)
   c:   a1 00 00 00 00          mov    0x0,%eax
  11:   89 44 24 10             mov    %eax,0x10(%esp)
  15:   8b 44 24 10             mov    0x10(%esp),%eax
  19:   89 44 24 04             mov    %eax,0x4(%esp)
  1d:   8b 44 24 18             mov    0x18(%esp),%eax
  21:   89 04 24                mov    %eax,(%esp)
  24:   e8 fc ff ff ff          call   25 <_Z5func2v+0x25>
  29:   83 c4 1c                add    $0x1c,%esp
  2c:   c3                      ret

===================================
icc -x c++ -m32 -O3 -c test.cc -DCLASS
objdump -d test.o
===================================

00000000 <_Z5func2v>:
   0:   83 ec 14                sub    $0x14,%esp
   3:   ff 35 00 00 00 00       pushl  0x0
   9:   ff 35 00 00 00 00       pushl  0x0
   f:   e8 fc ff ff ff          call   10 <_Z5func2v+0x10>
  14:   83 c4 1c                add    $0x1c,%esp
  17:   c3                      ret
  18:   0f 1f 84 00 00 00 00    nopl   0x0(%eax,%eax,1)
  1f:   00

-- 
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/20180304/3f6e4e10/attachment.html>


More information about the llvm-bugs mailing list