[LLVMbugs] [Bug 8731] New: Clang generates load of struct value.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 3 01:30:14 PST 2010


           Summary: Clang generates load of struct value.
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: fvbommel at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=5863)
 --> (http://llvm.org/bugs/attachment.cgi?id=5863)
The full .ll of the C++ code.

Compiling this C++ code with clang:
#include <utility>

std::pair<void*, long long> foo(void* a, long long b) {
    return std::make_pair(a, b);
generates the attached .ll (on x86-64 linux).

The relevant snippet:
%"struct.std::pair" = type { i8*, i64 }

define linkonce_odr %"struct.std::pair"
@_ZSt9make_pairIPvxESt4pairIT_T0_ES2_S3_(i8* %__x, i64 %__y) inlinehint {
  %retval = alloca %"struct.std::pair", align 8
  %__x.addr = alloca i8*, align 8
  %__y.addr = alloca i64, align 8
  store i8* %__x, i8** %__x.addr, align 8
  store i64 %__y, i64* %__y.addr, align 8
  call void @_ZNSt4pairIPvxEC1ERKS0_RKx(%"struct.std::pair"* %retval, i8**
%__x.addr, i64* %__y.addr)
  %0 = load %"struct.std::pair"* %retval
  ret %"struct.std::pair" %0

Notice that it generates a load of a struct value. At -O3, after inlining, a
later transformation (-scalarrepl?) can insert an extractvalue of such loads.
(this happens in LLVM's lib/CodeGen/PreAllocSplitting.cpp).

According to Dan Gohman (reference:
this merits a bug report.
(The problem apparently being that loads of aggregates are compiled less
efficiently than loads of their elements followed by 'insertvalue'

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