[llvm-bugs] [Bug 25931] New: WebAssembly miscompiles global structs with multiple data members

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 22 17:07:36 PST 2015


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

            Bug ID: 25931
           Summary: WebAssembly miscompiles global structs with multiple
                    data members
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: jfb at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

(filing under lib/CodeGen, since we don't have a component for WebAssembly at
the moment)

The following GCC torture test:
 
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.c-torture/execute/20010924-1.c

Has the following code:

struct {
  char a1c;
  char *a1p;
} a1 = {
  '4',
  "62"
};

struct {
  char a2c;
  char a2p[2];
} a2 = {
  'v',
  "cq"
};

/* The tests.  */
struct {
  char a3c;
  char a3p[];
} a3 = {
  'o',
  "wx"
};

struct {
  char a4c;
  char a4p[];
} a4 = {
  '9',
  { 'e', 'b' }
};


Which WebAssembly's backend miscompiles as:

.str:
    .asciz    "62"
    .size    .str, 3

    .type    a1, at object              # @a1
    .globl    a1
    .align    2
a1:
    .int8    52                      # 0x34
    .zero    3
    .int32    .str
    .size    a1, 8

    .type    a2, at object              # @a2
    .globl    a2
a2:
    .int8    118                     # 0x76
    .ascii    "cq"
    .size    a2, 3

    .type    a3, at object              # @a3
    .globl    a3
a3:
    .int8    111                     # 0x6f
    .asciz    "wx"
    .size    a3, 4

    .type    a4, at object              # @a4
    .globl    a4
a4:
    .int8    57                      # 0x39
    .ascii    "eb"
    .size    a4, 3


Note the missing initialization (but surprisingly, correct size!).

-- 
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/20151223/eff647e7/attachment.html>


More information about the llvm-bugs mailing list