[LLVMbugs] [Bug 22843] New: Instructions for implicit copy constructor not generated on ARM64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 8 09:24:36 PDT 2015


http://llvm.org/bugs/show_bug.cgi?id=22843

            Bug ID: 22843
           Summary: Instructions for implicit copy constructor not
                    generated on ARM64
           Product: new-bugs
           Version: 3.5
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: aburnson at museami.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14008
  --> http://llvm.org/bugs/attachment.cgi?id=14008&action=edit
Reproduce case

In the below example, a color is defined through a base class RGB and a
subclass RGBA, which adds the A component. Both have constructors that
initialize their fields to 0.f. Then in the BuggySet function, an RGBA object
is passed by value (with implicit copy constructor) and then assigned to a
global color. The example sends a color with values of all 1.f into BuggySet.
However, when I build and run this on an iPhone 5s (arm64) in Xcode 6.1.1
(based on LLVM 3.5), I get the following output:
//BEFORE: 0.000000 0.000000 0.000000 0.000000
//AFTER:  131671817916329306678238380032.000000 0.000000 0.000000 1.000000

I have tried this in both Debug and Release builds (with and without
optimization enabled) and get the same error. Looking at the disassembled
output, it looks like the implicit copy constructor for the pass-by-value into
BuggySet is not called for the base class:

;;;Right before call to BuggySet
0x1000d2de8:  ldur   w8, [fp, #-24]
0x1000d2dec:  str    w8, [sp, #40]
0x1000d2df0:  ldur   w8, [fp, #-20]
0x1000d2df4:  str    w8, [sp, #44]
0x1000d2df8:  ldur   w8, [fp, #-16]
0x1000d2dfc:  str    w8, [sp, #48]
0x1000d2e00:  ldur   w8, [fp, #-12]
0x1000d2e04:  str    w8, [sp, #52]
0x1000d2e08:  ldr    s0, [sp, #52]
0x1000d2e0c:  bl     0x1000d2d3c               ; BuggySet(RGBA) at main.mm:34

BadBug`BuggySet(RGBA) at main.mm:34:
;;;Points sp to beginning of uninitialized RGBA object ('NewColor' param)
0x1000d2d3c:  sub    sp, sp, #16
0x1000d2d40:  adrp   x8, 2
0x1000d2d44:  add    x8, x8, #3336
;;;The .A component is copied here but sp, sp #4, sp #8, i.e. RGB are missing
0x1000d2d48:  str    s0, [sp, #12]
0x1000d2d4c:  ldr    w9, [sp]
0x1000d2d50:  str    w9, [x8]
0x1000d2d54:  ldr    w9, [sp, #4]
0x1000d2d58:  str    w9, [x8, #4]
0x1000d2d5c:  ldr    w9, [sp, #8]
0x1000d2d60:  str    w9, [x8, #8]
0x1000d2d64:  ldr    w9, [sp, #12]
0x1000d2d68:  str    w9, [x8, #12]
0x1000d2d6c:  add    sp, sp, #16
0x1000d2d70:  ret    


Code sample below (also attached):

//-----------------------------------

#import <Foundation/Foundation.h>

class RGB
{
  public:

  float R;
  float G;
  float B;

  RGB()
  {
    R = 0.f;
    G = 0.f;
    B = 0.f;
  };
};

class RGBA : public RGB
{
  public:

  float A;

  RGBA()
  {
    A = 0.f;
  }
};

RGBA Color;

void BuggySet(RGBA NewColor)
{
  Color = NewColor;
}

int main()
{
  RGBA TestColor;
  TestColor.R = 1.f;
  TestColor.G = 1.f;
  TestColor.B = 1.f;
  TestColor.A = 1.f;
  NSLog(@"BEFORE: %f %f %f %f", Color.R, Color.G, Color.B, Color.A);
  BuggySet(TestColor);
  NSLog(@"AFTER:  %f %f %f %f", Color.R, Color.G, Color.B, Color.A);
  return 0;
}

//-----------------------------------

-- 
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/20150308/209b8133/attachment.html>


More information about the llvm-bugs mailing list