[LLVMbugs] [Bug 16691] New: Bitfield overflow on big-endian architectures

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 24 05:44:22 PDT 2013


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

            Bug ID: 16691
           Summary: Bitfield overflow on big-endian architectures
           Product: clang
           Version: 3.3
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hausen at gmx.at
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10919
  --> http://llvm.org/bugs/attachment.cgi?id=10919&action=edit
Test case pr55750 from gcc.c-torture/execute

For big-endian architectures (Mips, Sparc, ...), clang -O1 produces the
following code for function foo() in the attached test case (pr55750.c from
gcc.c-torture/execute):

define void @foo(i32 %i) #0 {
entry:
  %0 = getelementptr inbounds [2 x %struct.S]* @arr, i32 0, i32 %i, i32 0
  %bf.load = load i8* %0, align 4
  %bf.ashr2 = and i8 %bf.load, 127
  %addconv = add nsw i8 %bf.ashr2, 1
  %bf.clear = and i8 %bf.load, -128
  %bf.set = or i8 %addconv, %bf.clear
  store i8 %bf.set, i8* %0, align 4
  ret void
}

If the addition to field arr[i].n (%addconv) overflows 7 bits, field arr[i].m
is set to one instead of being left unchanged. The code for little-endian
architectures is okay, because field n occupies the upper 7 bits and overflows
can be ignored.

-- 
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/20130724/69ecc538/attachment.html>


More information about the llvm-bugs mailing list