[LLVMbugs] [Bug 19166] New: -O2 and above producing unaligned movdqa on amd64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 17 11:37:02 PDT 2014


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

            Bug ID: 19166
           Summary: -O2 and above producing unaligned movdqa on amd64
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: OpenBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: oga+llvm at nicotinebsd.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12244
  --> http://llvm.org/bugs/attachment.cgi?id=12244&action=edit
A C file that exhibits the bug, there at at least 3 more in mesa.

Building Mesa 9.2.5 with clang on Bitrig or OpenBSD at least causes a bus error
caused by a GPF pretty quickly.

Investigation showed that in a number of places (an example is attached) an
array initialisation is being optimised to a movdqa. The memory target of this
is unaligned.

For example with this array:
/* ubyte -> float conversion */
GLfloat _mesa_ubyte_to_float_color_tab[256];


set by this code:
      for (i = 0; i < 256; i++) {
         _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
      }

nm on the sybmbol with -O0 shows a sane alignment:
16:47 < oga> 008f4e00 B _mesa_ubyte_to_float_color_tab
whereas with -O3 it produces:
16:57 < oga> without -O0 - 008f21d0 B _mesa_ubyte_to_float_color_tab

I attach the C file in question, which when built with the following flags
exhibits this bug:

clang -O3 -pipe  -std=c99  
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mesa/drivers/dri/common

-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/gallium/auxiliary

-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/gallium/include
 -I/usr/xenocara/lib/libGL/mesa/libmesagallium/../generated 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../generated/main 
-D__NOT_HAVE_DRM_H -I. 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mapi 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/include 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/include/GL/internal
 -I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mesa 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mesa/main

-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mesa/math

-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mesa/tnl
 -I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/glsl 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/obj/shader/slang 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../generated 
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../generated/main 
-I/usr/X11R6/include  -DHAVE_UNISTD_H  -DHAVE_PTHREAD  -DHAVE_ALIAS 
-DHAVE_DLOPEN  -DHAVE_POSIX_MEMALIGN  -D_REENTRANT  -DIN_DRI_DRIVER 
-DPACKAGE_VERSION="9.2.5"  -DPACKAGE_BUGREPORT="bugs at openbsd.org"
-I/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mesa/x86
 -D__GLX_ALIGN64 -DUSE_X86_64_ASM -c -fpic -DPIC
/usr/xenocara/lib/libGL/mesa/libmesagallium/../../../../dist/Mesa/src/mesa/main/context.c
-o context.ll

I also attach the .ll file produced. The bug is still there with -O2 but -O1
removes it.

-- 
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/20140317/c09c1b2d/attachment.html>


More information about the llvm-bugs mailing list