[LLVMbugs] [Bug 7428] New: clang hits UNREACHABLE on i128 bit computation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jun 20 11:07:19 PDT 2010


           Summary: clang hits UNREACHABLE on i128 bit computation
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: kaffeemonster at googlemail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=5064)
 --> (http://llvm.org/bugs/attachment.cgi?id=5064)
bugpoint reduced problem

Build myself a fresh clang today TOT at 106404.

Compiling my source i got this:

$ clang -DHAVE_CONFIG_H -O2 -pthread -c lib/vsnprintf.c -o lib/vsnprintf.o
Stack dump:
0.      Program arguments: /usr/bin/clang -cc1 -triple i386-pc-linux-gnu -S
-disable-free -disable-llvm-verifier -main-file-name vsnprintf.c
-mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu
pentium4 -resource-dir /usr/lib/clang/2.0 -D HAVE_CONFIG_H -O2 -ferror-limit 19
-fmessage-length 114 -pthread -fgnu-runtime -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/cc-SHeyFV.s -x c lib/vsnprintf.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@vdtoa'
clang: error: clang frontend command failed due to signal 6 (use -v to see

The reason seems to be, that my configure script detects that clang supports
__attribute__((mode(TI))), even on 32 bit. If this happens some code uses it to
do 64Bit arithmetic with overflow. An example:
#define MUL_BIG(x, y, z, k) \
{ \
    __uint128 a_res = (__uint128)(x) * (y) + (k); \
    (k) = a_res >> 64; \
    (z) = a_res; \

IMHO there is no reason the compiler should not handle this on 32 Bit (if i
lower it or the compiler does it, but i think the compiler can do a better job
than me clumsily describing the same thing in C).

bugpoint reduced .ll:

; ModuleID = 'bugpoint-reduced-simplified.bc'
target datalayout =
target triple = "i386-pc-linux-gnu"

define void @vdtoa() nounwind {
  br i1 undef, label %._crit_edge431, label %add_cmp.exit152

._crit_edge431:                                   ; preds = %bb.nph.i154, %0
  ret void

add_cmp.exit152:                                  ; preds = %0
  %1 = icmp sgt i32 undef, -1                     ; <i1> [#uses=1]
  br i1 %1, label %bb.nph.i154, label %mul10.exit162

bb.nph.i154:                                      ; preds = %bb.nph.i154,
  %2 = zext i64 undef to i128                     ; <i128> [#uses=0]
  br i1 undef, label %._crit_edge431, label %bb.nph.i154

mul10.exit162:                                    ; preds = %add_cmp.exit152
  br i1 undef, label %bb.nph.i188, label %bb.nph.i

bb.nph.i188:                                      ; preds = %bb.nph.i188,
  br label %bb.nph.i188

bb.nph.i:                                         ; preds = %bb.nph.i,
  br label %bb.nph.i

Hmmm, and from a peek at it, and what i understand of ll (nothing...) the only
i128 is the zero extention from i64, the rest is IMHO just fluff.
I will attach the .bc, you guys are the gurus.


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