[llvm-bugs] [Bug 35638] New: clang crashes with both "-mllvm -enable-newgvn" and "-mllvm -polly" enabled: Bad machine code: Reading virtual register without a def

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 11 23:31:27 PST 2017


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

            Bug ID: 35638
           Summary: clang crashes with both "-mllvm -enable-newgvn" and
                    "-mllvm -polly" enabled: Bad machine code: Reading
                    virtual register without a def
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: helloqirun at gmail.com
                CC: llvm-bugs at lists.llvm.org

It happens with both polly and newgvn enabled. Enabling either polly or newgvn
works fine.


$ clang-trunk -v
clang version 6.0.0 (trunk 320345)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin


$ clang-trunk -O3 -mllvm -polly abc.c
<some warnings>

$ clang-trunk -O3 -mllvm -enable-newgvn abc.c
<some warnings>


$ clang-trunk -O3 -mllvm -enable-newgvn -mllvm -polly abc.c
abc.c:17:9: warning: incompatible pointer types assigning to 'char *' from
'unsigned int *' [-Wincompatible-pointer-types]
      g = &c;
        ^ ~~
abc.c:23:11: warning: expression result unused [-Wunused-value]
          *j ?: (*k += e);
          ^~~~~~~~~~~~~~~
abc.c:24:11: warning: expression result unused [-Wunused-value]
          (*k ? 1 < *k : a) ?: (c = e);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Machine code for function fn1: NoPHIs, TracksLiveness
Frame Objects:
  fi#0: size=8, align=8, at location [SP+8]

%bb.0: derived from LLVM BB %for.body
        %0:gr32 = MOVSX32rm16 %rip, 1, %noreg, <ga:@e>, %noreg;
mem:LD2[@e](dereferenceable) GR32:%0
        %43:gr64 = LEA64r <fi#0>, 1, %noreg, 0, %noreg; GR64:%43
        CMP8mi %rip, 1, %noreg, <ga:@a>, %noreg, 0, implicit-def %eflags;
mem:LD1[@a](tbaa=!3)(dereferenceable)
        %153:gr64 = COPY %43; GR64:%153,%43
        JE_1 %bb.2, implicit killed %eflags
        JMP_1 %bb.1
    Successors according to CFG: %bb.2(0x30000000 / 0x80000000 = 37.50%)
%bb.1(0x50000000 / 0x80000000 = 62.50%)

%bb.1: derived from LLVM BB %for.cond1.for.body6.thread_crit_edge
    Predecessors according to CFG: %bb.0
        MOV8mi %rip, 1, %noreg, <ga:@a>, %noreg, 0; mem:ST1[@a](tbaa=!3)
        %45:gr32 = MOV32ri64 <ga:@f>; GR32:%45
        %44:gr64 = SUBREG_TO_REG 0, killed %45, sub_32bit; GR64:%44 GR32:%45
        %153:gr64 = COPY killed %44; GR64:%153,%44
    Successors according to CFG: %bb.2(?%)

%bb.2: derived from LLVM BB %for.body11.lr.ph
    Predecessors according to CFG: %bb.0 %bb.1
        %1:gr64 = COPY killed %153; GR64:%1,%153
        MOV32mi %rip, 1, %noreg, <ga:@b>, %noreg, 0; mem:ST4[@b](tbaa=!6)
        MOV32mi %rip, 1, %noreg, <ga:@c>, %noreg, 1; mem:ST4[@c](tbaa=!6)
        MOV64mi32 %rip, 1, %noreg, <ga:@g>, %noreg, <ga:@c>;
mem:ST8[@g](tbaa=!8)
        %47:gr32 = COPY %0; GR32:%47,%0
        %47:gr32 = OR32ri8 %47, 8, implicit-def dead %eflags; GR32:%47
        %2:gr16 = COPY %47.sub_16bit; GR16:%2 GR32:%47
        MOV16mr %rip, 1, %noreg, <ga:@h>, %noreg, %2; mem:ST2[@h](tbaa=!10)
GR16:%2
        %48:gr8 = COPY killed %47.sub_8bit; GR8:%48 GR32:%47
        MOV8mr %rip, 1, %noreg, <ga:@a>, %noreg, %48; mem:ST1[@a](tbaa=!3)
GR8:%48
        MOV64mi32 %rip, 1, %noreg, <ga:@f>, %noreg, 4; mem:ST8[@f](tbaa=!12)
        MOV16mr %rip, 1, %noreg, <ga:@d>, %noreg, undef %3:gr16;
mem:ST2[@d](tbaa=!10) GR16:%3
        %4:gr32 = MOVSX32rr8 killed %48; GR32:%4 GR8:%48
        %50:gr64 = LEA64r %1, 1, %noreg, 8, %noreg; GR64:%50,%1
        CMP64rr killed %50, killed %43, implicit-def %eflags; GR64:%50,%43
        %53:gr8 = SETBEr implicit killed %eflags; GR8:%53
        %54:gr64 = LEA64r <fi#0>, 1, %noreg, 8, %noreg; GR64:%54
        CMP64rr killed %54, %1, implicit-def %eflags; GR64:%54,%1
        %56:gr8 = SETBEr implicit killed %eflags; GR8:%56
        TEST16rr %2, %2, implicit-def %eflags; GR16:%2
        JNS_1 %bb.4, implicit killed %eflags
        JMP_1 %bb.3
    Successors according to CFG: %bb.3(0x60000000 / 0x80000000 = 75.00%)
%bb.4(0x20000000 / 0x80000000 = 25.00%)

%bb.3: derived from LLVM BB %for.body11.lr.ph
    Predecessors according to CFG: %bb.2
        %46:gr8 = COPY killed %56; GR8:%46,%56
        dead %46:gr8 = OR8rr %46, killed %53, implicit-def %eflags; GR8:%46,%53
        JNE_1 %bb.28, implicit killed %eflags
        JMP_1 %bb.4
    Successors according to CFG: %bb.28(0x55555555 / 0x80000000 = 66.67%)
%bb.4(0x2aaaaaab / 0x80000000 = 33.33%)

%bb.4: derived from LLVM BB %for.body11.pre_entry_bb
    Predecessors according to CFG: %bb.2 %bb.3
        CMP64mi8 %1, 1, %noreg, 0, %noreg, 0, implicit-def %eflags;
mem:LD8[%j.1.lcssa](tbaa=!12) GR64:%1
        JNE_1 %bb.13, implicit killed %eflags
        JMP_1 %bb.5
    Successors according to CFG: %bb.5(0x30000000 / 0x80000000 = 37.50%)
%bb.13(0x50000000 / 0x80000000 = 62.50%)

%bb.5: derived from LLVM BB %for.body11.us.preheader
    Predecessors according to CFG: %bb.4
        %72:gr8 = COPY %0.sub_8bit; GR8:%72 GR32:%0
        TEST8ri killed %72, 1, implicit-def %eflags; GR8:%72
        %154:gr16 = IMPLICIT_DEF; GR16:%154
        %155:gr16 = IMPLICIT_DEF; GR16:%155
        %156:gr16 = COPY %2; GR16:%156,%2
        JE_1 %bb.9, implicit killed %eflags
        JMP_1 %bb.6
    Successors according to CFG: %bb.9(0x40000000 / 0x80000000 = 50.00%)
%bb.6(0x40000000 / 0x80000000 = 50.00%)

%bb.6: derived from LLVM BB %for.body11.us.prol
    Predecessors according to CFG: %bb.5
        %73:gr16 = COPY %0.sub_16bit; GR16:%73 GR32:%0
        %170:gr64_nosp = IMPLICIT_DEF; GR64_NOSP:%170
        %170.sub_16bit:gr64_nosp = COPY %73; GR64_NOSP:%170 GR16:%73
        %171:gr64_nosp = IMPLICIT_DEF; GR64_NOSP:%171
        %171.sub_16bit:gr64_nosp = COPY %3:gr16; GR64_NOSP:%171 GR16:%3
        %169:gr32 = LEA64_32r killed %170, 1, killed %171, 0, %noreg; GR32:%169
GR64_NOSP:%170,%171
        %74:gr16 = COPY killed %169.sub_16bit; GR16:%74 GR32:%169
        %75:gr32 = MOVSX32rr16 killed %74; GR32:%75 GR16:%74
        %141:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%141
        CMP32ri8 killed %75, 1, implicit-def %eflags; GR32:%75
        %77:gr8 = SETGr implicit killed %eflags; GR8:%77
        %78:gr16 = COPY killed %73; GR16:%78,%73
        %78:gr16 = ADD16rr %78, undef %3:gr16, implicit-def %eflags;
GR16:%78,%3
        %142:gr32 = COPY killed %141; GR32:%142,%141
        %142.sub_8bit:gr32 = COPY killed %77; GR32:%142 GR8:%77
        %80:gr32 = COPY killed %142; GR32:%80,%142
        %80:gr32 = CMOVE32rr %80, %4, implicit killed %eflags; GR32:%80,%4
        TEST32rr killed %80, %80, implicit-def %eflags; GR32:%80
        JNE_1 %bb.8, implicit killed %eflags
        JMP_1 %bb.7
    Successors according to CFG: %bb.7(0x30000000 / 0x80000000 = 37.50%)
%bb.8(0x50000000 / 0x80000000 = 62.50%)

%bb.7: derived from LLVM BB %cond.false28.us.prol
    Predecessors according to CFG: %bb.6
        MOV32mr %rip, 1, %noreg, <ga:@c>, %noreg, %0; mem:ST4[@c](tbaa=!6)
GR32:%0
    Successors according to CFG: %bb.8(?%)

%bb.8: derived from LLVM BB %for.inc38.us.prol
    Predecessors according to CFG: %bb.6 %bb.7
        undef %81.sub_16bit:gr32 = COPY %2; GR32:%81 GR16:%2
        undef %172.sub_32bit:gr64 = COPY killed %81; GR64:%172 GR32:%81
        %83:gr32 = LEA64_32r killed %172, 1, %noreg, 1, %noreg; GR32:%83
GR64:%172
        %6:gr16 = COPY killed %83.sub_16bit; GR16:%6 GR32:%83
        %154:gr16 = COPY %78; GR16:%154,%78
        %155:gr16 = COPY killed %78; GR16:%155,%78
        %156:gr16 = COPY killed %6; GR16:%156,%6
    Successors according to CFG: %bb.9(?%)

%bb.9: derived from LLVM BB %for.body11.us.prol.loopexit
    Predecessors according to CFG: %bb.5 %bb.8
        %9:gr16 = COPY killed %156; GR16:%9,%156
        %8:gr16 = COPY killed %155; GR16:%8,%155
        %7:gr16 = COPY killed %154; GR16:%7,%154
        %84:gr32 = MOVZX32rr16 %2; GR32:%84 GR16:%2
        CMP32ri killed %84, 65535, implicit-def %eflags; GR32:%84
        %165:gr16 = COPY killed %7; GR16:%165,%7
        JE_1 %bb.23, implicit killed %eflags
        JMP_1 %bb.10
    Successors according to CFG: %bb.23(0x30000000 / 0x80000000 = 37.50%)
%bb.10(0x50000000 / 0x80000000 = 62.50%)

%bb.10: derived from LLVM BB %for.body11.us.preheader.new
    Predecessors according to CFG: %bb.9
        undef %86.sub_16bit:gr32 = COPY killed %8; GR32:%86 GR16:%8
        %88:gr32 = COPY %86; GR32:%88,%86
        %88:gr32 = NEG32r %88, implicit-def dead %eflags; GR32:%88
        %10:gr16 = COPY killed %88.sub_16bit; GR16:%10 GR32:%88
        undef %173.sub_32bit:gr64 = COPY %0; GR64:%173 GR32:%0
        undef %174.sub_32bit:gr64_nosp = COPY %0; GR64_NOSP:%174 GR32:%0
        %89:gr32 = LEA64_32r killed %173, 1, killed %174, 0, %noreg; GR32:%89
GR64:%173 GR64_NOSP:%174
        %11:gr16 = COPY killed %89.sub_16bit; GR16:%11 GR32:%89
        %90:gr64 = SUBREG_TO_REG 0, %86, sub_32bit; GR64:%90 GR32:%86
        %91:gr64_nosp = SUBREG_TO_REG 0, %0, sub_32bit; GR64_NOSP:%91 GR32:%0
        %92:gr32 = LEA64_32r killed %90, 2, killed %91, 0, %noreg; GR32:%92
GR64:%90 GR64_NOSP:%91
        %12:gr16 = COPY killed %92.sub_16bit; GR16:%12 GR32:%92
        %93:gr32 = COPY %0; GR32:%93,%0
        %93:gr32 = NEG32r %93, implicit-def dead %eflags; GR32:%93
        %13:gr16 = COPY killed %93.sub_16bit; GR16:%13 GR32:%93
        %94:gr32 = COPY killed %86; GR32:%94,%86
        %94:gr32 = ADD32rr %94, %0, implicit-def dead %eflags; GR32:%94,%0
        %14:gr16 = COPY killed %94.sub_16bit; GR16:%14 GR32:%94
        undef %106.sub_16bit:gr32 = COPY killed %11; GR32:%106 GR16:%11
        %157:gr16 = COPY killed %14; GR16:%157,%14
        %158:gr16 = COPY killed %12; GR16:%158,%12
        %159:gr16 = COPY killed %10; GR16:%159,%10
        %160:gr16 = COPY killed %9; GR16:%160,%9
    Successors according to CFG: %bb.11(?%)

%bb.11: derived from LLVM BB %for.body11.us
    Predecessors according to CFG: %bb.10 %bb.38
        %18:gr16 = COPY killed %160; GR16:%18,%160
        %17:gr16 = COPY killed %159; GR16:%17,%159
        %16:gr16 = COPY killed %158; GR16:%16,%158
        %15:gr16 = COPY killed %157; GR16:%15,%157
        %96:gr32 = MOVSX32rr16 %15; GR32:%96 GR16:%15
        %143:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%143
        CMP32ri8 killed %96, 1, implicit-def %eflags; GR32:%96
        %98:gr8 = SETGr implicit killed %eflags; GR8:%98
        %99:gr16 = COPY %13; GR16:%99,%13
        dead %99:gr16 = ADD16rr %99, %17, implicit-def %eflags; GR16:%99,%17
        %144:gr32 = COPY killed %143; GR32:%144,%143
        %144.sub_8bit:gr32 = COPY killed %98; GR32:%144 GR8:%98
        %101:gr32 = COPY killed %144; GR32:%101,%144
        %101:gr32 = CMOVE32rr %101, %4, implicit killed %eflags; GR32:%101,%4
        %102:gr32 = MOVSX32rr16 %16; GR32:%102 GR16:%16
        %145:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%145
        CMP32ri8 %102, 1, implicit-def %eflags; GR32:%102
        %104:gr8 = SETGr implicit killed %eflags; GR8:%104
        %139:gr16 = COPY killed %102.sub_16bit; GR16:%139 GR32:%102
        TEST16rr killed %139, %139, implicit-def %eflags; GR16:%139
        %146:gr32 = COPY killed %145; GR32:%146,%145
        %146.sub_8bit:gr32 = COPY killed %104; GR32:%146 GR8:%104
        %95:gr32 = COPY killed %146; GR32:%95,%146
        %95:gr32 = CMOVE32rr %95, %4, implicit killed %eflags; GR32:%95,%4
        TEST32rr killed %101, %101, implicit-def %eflags; GR32:%101
        JE_1 %bb.37, implicit killed %eflags
        JMP_1 %bb.12
    Successors according to CFG: %bb.37(0x20000000 / 0x80000000 = 25.00%)
%bb.12(0x60000000 / 0x80000000 = 75.00%)

%bb.12: derived from LLVM BB %for.body11.us
    Predecessors according to CFG: %bb.11
        TEST32rr killed %95, %95, implicit-def %eflags; GR32:%95
        JE_1 %bb.37, implicit killed %eflags
        JMP_1 %bb.38
    Successors according to CFG: %bb.37(0x2aaaaaab / 0x80000000 = 33.33%)
%bb.38(0x55555555 / 0x80000000 = 66.67%)

%bb.13: derived from LLVM BB %for.body11.pre_entry_bb.split
    Predecessors according to CFG: %bb.4
        %57:gr32 = MOVSX32rr16 undef %3:gr16; GR32:%57 GR16:%3
        %147:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%147
        CMP32ri8 killed %57, 1, implicit-def %eflags; GR32:%57
        %59:gr8 = SETGr implicit killed %eflags; GR8:%59
        TEST16rr undef %3:gr16, undef %3:gr16, implicit-def %eflags; GR16:%3
        %148:gr32 = COPY killed %147; GR32:%148,%147
        %148.sub_8bit:gr32 = COPY killed %59; GR32:%148 GR8:%59
        %19:gr32 = COPY killed %148; GR32:%19,%148
        %19:gr32 = CMOVE32rr %19, killed %4, implicit killed %eflags;
GR32:%19,%4
        %61:gr32 = COPY %0; GR32:%61,%0
        %61:gr32 = NEG32r %61, implicit-def dead %eflags; GR32:%61
        %62:gr16 = COPY killed %61.sub_16bit; GR16:%62 GR32:%61
        %20:gr16 = COPY killed %62; GR16:%20,%62
        %20:gr16 = AND16ri8 %20, 3, implicit-def %eflags; GR16:%20
        %163:gr16 = COPY %2; GR16:%163,%2
        JE_1 %bb.18, implicit killed %eflags
        JMP_1 %bb.14
    Successors according to CFG: %bb.18(0x30000000 / 0x80000000 = 37.50%)
%bb.14(0x50000000 / 0x80000000 = 62.50%)

%bb.14: derived from LLVM BB %for.body11.prol.preheader
    Predecessors according to CFG: %bb.13
        undef %63.sub_16bit:gr32 = COPY killed %20; GR32:%63 GR16:%20
        %65:gr32 = COPY killed %63; GR32:%65,%63
        %65:gr32 = NEG32r %65, implicit-def dead %eflags; GR32:%65
        %21:gr16 = COPY killed %65.sub_16bit; GR16:%21 GR32:%65
        %161:gr16 = COPY killed %21; GR16:%161,%21
        %162:gr16 = COPY %2; GR16:%162,%2
    Successors according to CFG: %bb.15(?%)

%bb.15: derived from LLVM BB %for.body11.prol
    Predecessors according to CFG: %bb.14 %bb.17
        %23:gr16 = COPY killed %162; GR16:%23,%162
        %22:gr16 = COPY killed %161; GR16:%22,%161
        TEST32rr %19, %19, implicit-def %eflags; GR32:%19
        JNE_1 %bb.17, implicit killed %eflags
        JMP_1 %bb.16
    Successors according to CFG: %bb.16(0x30000000 / 0x80000000 = 37.50%)
%bb.17(0x50000000 / 0x80000000 = 62.50%)

%bb.16: derived from LLVM BB %cond.false28.prol
    Predecessors according to CFG: %bb.15
        MOV32mr %rip, 1, %noreg, <ga:@c>, %noreg, %0; mem:ST4[@c](tbaa=!6)
GR32:%0
    Successors according to CFG: %bb.17(?%)

%bb.17: derived from LLVM BB %for.inc38.prol
    Predecessors according to CFG: %bb.15 %bb.16
        undef %66.sub_16bit:gr32 = COPY killed %23; GR32:%66 GR16:%23
        %68:gr32 = COPY killed %66; GR32:%68,%66
        %68:gr32 = ADD32ri8 %68, 1, implicit-def dead %eflags; GR32:%68
        %24:gr16 = COPY killed %68.sub_16bit; GR16:%24 GR32:%68
        %25:gr16 = COPY killed %22; GR16:%25,%22
        %25:gr16 = ADD16ri8 %25, 1, implicit-def %eflags; GR16:%25
        %161:gr16 = COPY killed %25; GR16:%161,%25
        %162:gr16 = COPY %24; GR16:%162,%24
        %163:gr16 = COPY killed %24; GR16:%163,%24
        JNE_1 %bb.15, implicit killed %eflags
        JMP_1 %bb.18
    Successors according to CFG: %bb.18(0x04000000 / 0x80000000 = 3.12%)
%bb.15(0x7c000000 / 0x80000000 = 96.88%)

%bb.18: derived from LLVM BB %for.body11.prol.loopexit
    Predecessors according to CFG: %bb.13 %bb.17
        %26:gr16 = COPY killed %163; GR16:%26,%163
        %69:gr32 = MOVZX32rr16 %2; GR32:%69 GR16:%2
        CMP32ri killed %69, 65532, implicit-def %eflags; GR32:%69
        JA_1 %bb.24, implicit killed %eflags
        JMP_1 %bb.19
    Successors according to CFG: %bb.24(0x40000000 / 0x80000000 = 50.00%)
%bb.19(0x40000000 / 0x80000000 = 50.00%)

%bb.19: derived from LLVM BB %for.body11.pre_entry_bb.split.new
    Predecessors according to CFG: %bb.18
        %164:gr16 = COPY killed %26; GR16:%164,%26
    Successors according to CFG: %bb.20(?%)

%bb.20: derived from LLVM BB %for.body11
    Predecessors according to CFG: %bb.19 %bb.39
        %27:gr16 = COPY killed %164; GR16:%27,%164
        TEST32rr %19, %19, implicit-def %eflags; GR32:%19
        JNE_1 %bb.39, implicit killed %eflags
        JMP_1 %bb.21
    Successors according to CFG: %bb.21(0x30000000 / 0x80000000 = 37.50%)
%bb.39(0x50000000 / 0x80000000 = 62.50%)

%bb.21: derived from LLVM BB %cond.false28
    Predecessors according to CFG: %bb.20
        MOV32mr %rip, 1, %noreg, <ga:@c>, %noreg, %0; mem:ST4[@c](tbaa=!6)
GR32:%0
        JMP_1 %bb.39
    Successors according to CFG: %bb.39(?%)

%bb.22: derived from LLVM BB %for.cond9.for.end40_crit_edge.loopexit.loopexit
    Predecessors according to CFG: %bb.38
        undef %117.sub_16bit:gr32 = COPY killed %39; GR32:%117 GR16:%39
        %119:gr32 = COPY killed %117; GR32:%119,%117
        %119:gr32 = NEG32r %119, implicit-def dead %eflags; GR32:%119
        %28:gr16 = COPY killed %119.sub_16bit; GR16:%28 GR32:%119
        %165:gr16 = COPY killed %28; GR16:%165,%28
    Successors according to CFG: %bb.23(?%)

%bb.23: derived from LLVM BB %for.cond9.for.end40_crit_edge.loopexit
    Predecessors according to CFG: %bb.9 %bb.22
        %29:gr16 = COPY killed %165; GR16:%29,%165
        MOV16mr %rip, 1, %noreg, <ga:@d>, %noreg, killed %29;
mem:ST2[@d](tbaa=!10) GR16:%29
    Successors according to CFG: %bb.24(?%)

%bb.24: derived from LLVM BB %for.cond9.for.end40_crit_edge
    Predecessors according to CFG: %bb.18 %bb.39 %bb.23
        MOV16mi %rip, 1, %noreg, <ga:@h>, %noreg, 0; mem:ST2[@h](tbaa=!10)
        JMP_1 %bb.26
    Successors according to CFG: %bb.26(?%)

%bb.25: derived from LLVM BB %for.end40.loopexit
    Predecessors according to CFG: %bb.32
        MOV16mr %rip, 1, %noreg, <ga:@d>, %noreg, killed %135;
mem:ST2[@d](alias.scope=!15,!16,!"polly.alias.scope.MemRef1")(noalias=!18,!19,!20,!21)
GR16:%135
    Successors according to CFG: %bb.26(?%)

%bb.26: derived from LLVM BB %for.cond41.preheader
    Predecessors according to CFG: %bb.24 %bb.36 %bb.25
    Successors according to CFG: %bb.27(?%)

%bb.27: derived from LLVM BB %for.cond41
    Predecessors according to CFG: %bb.26 %bb.27
        JMP_1 %bb.27
    Successors according to CFG: %bb.27(?%)

%bb.28: derived from LLVM BB %polly.stmt.for.cond9.for.end40_crit_edge
    Predecessors according to CFG: %bb.3
        %120:gr64 = MOVSX64rr16 %2; GR64:%120 GR16:%2
        MOV16mi %rip, 1, %noreg, <ga:@h>, %noreg, 0;
mem:ST2[@h](alias.scope=!21,!16,!"polly.alias.scope.MemRef4")(noalias=!18,!15,!19,!20)
        %30:gr64 = COPY killed %120; GR64:%30,%120
        %30:gr64 = NEG64r %30, implicit-def dead %eflags; GR64:%30
        CMP64mi8 %1, 1, %noreg, 0, %noreg, 0, implicit-def %eflags;
mem:LD8[%j.1.lcssa](alias.scope=!18,!16,!"polly.alias.scope.MemRef0")(noalias=!15,!19,!20,!21)
GR64:%1
        JNE_1 %bb.33, implicit killed %eflags
        JMP_1 %bb.29
    Successors according to CFG: %bb.29(0x30000000 / 0x80000000 = 37.50%)
%bb.33(0x50000000 / 0x80000000 = 62.50%)

%bb.29: derived from LLVM BB %polly.loop_header.us.preheader
    Predecessors according to CFG: %bb.28
        %129:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%129
        %128:gr64 = SUBREG_TO_REG 0, killed %129, sub_32bit; GR64:%128
GR32:%129
        %166:gr16 = IMPLICIT_DEF; GR16:%166
        %167:gr64 = COPY killed %128; GR64:%167,%128
    Successors according to CFG: %bb.30(?%)

%bb.30: derived from LLVM BB %polly.loop_header.us
    Predecessors according to CFG: %bb.29 %bb.32
        %32:gr64 = COPY killed %167; GR64:%32,%167
        %31:gr16 = COPY killed %166; GR16:%31,%166
        %130:gr16 = COPY %0.sub_16bit; GR16:%130 GR32:%0
        %176:gr64_nosp = IMPLICIT_DEF; GR64_NOSP:%176
        %176.sub_16bit:gr64_nosp = COPY %31; GR64_NOSP:%176 GR16:%31
        %177:gr64_nosp = IMPLICIT_DEF; GR64_NOSP:%177
        %177.sub_16bit:gr64_nosp = COPY %130; GR64_NOSP:%177 GR16:%130
        %175:gr32 = LEA64_32r killed %176, 1, killed %177, 0, %noreg; GR32:%175
GR64_NOSP:%176,%177
        %131:gr16 = COPY killed %175.sub_16bit; GR16:%131 GR32:%175
        %132:gr32 = MOVSX32rr16 killed %131; GR32:%132 GR16:%131
        %149:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%149
        CMP32ri8 killed %132, 1, implicit-def %eflags; GR32:%132
        %134:gr8 = SETGr implicit killed %eflags; GR8:%134
        %135:gr16 = COPY killed %130; GR16:%135,%130
        %135:gr16 = ADD16rr %135, killed %31, implicit-def %eflags;
GR16:%135,%31
        %150:gr32 = COPY killed %149; GR32:%150,%149
        %150.sub_8bit:gr32 = COPY killed %134; GR32:%150 GR8:%134
        %137:gr32 = COPY killed %150; GR32:%137,%150
        %137:gr32 = CMOVE32rr %137, %4, implicit killed %eflags; GR32:%137,%4
        TEST32rr killed %137, %137, implicit-def %eflags; GR32:%137
        JNE_1 %bb.32, implicit killed %eflags
        JMP_1 %bb.31
    Successors according to CFG: %bb.31(0x30000000 / 0x80000000 = 37.50%)
%bb.32(0x50000000 / 0x80000000 = 62.50%)

%bb.31: derived from LLVM BB %polly.stmt.cond.false28.us
    Predecessors according to CFG: %bb.30
        MOV32mr %rip, 1, %noreg, <ga:@c>, %noreg, %0;
mem:ST4[@c](alias.scope=!19,!16,!"polly.alias.scope.MemRef2")(noalias=!18,!15,!20,!21)
GR32:%0
    Successors according to CFG: %bb.32(?%)

%bb.32: derived from LLVM BB %polly.stmt.cond.end30.exit.us
    Predecessors according to CFG: %bb.30 %bb.31
        %34:gr64 = COPY killed %32; GR64:%34,%32
        %34:gr64 = ADD64ri8 %34, 1, implicit-def dead %eflags; GR64:%34
        CMP64rr %34, %30, implicit-def %eflags; GR64:%34,%30
        %166:gr16 = COPY %135; GR16:%166,%135
        %167:gr64 = COPY killed %34; GR64:%167,%34
        JL_1 %bb.30, implicit killed %eflags
        JMP_1 %bb.25
    Successors according to CFG: %bb.30(0x7c000000 / 0x80000000 = 96.88%)
%bb.25(0x04000000 / 0x80000000 = 3.12%)

%bb.33: derived from LLVM BB %polly.stmt.for.cond9.for.end40_crit_edge.split
    Predecessors according to CFG: %bb.28
        %122:gr32 = MOVSX32rr16 undef %3:gr16; GR32:%122 GR16:%3
        %151:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%151
        CMP32ri8 killed %122, 1, implicit-def %eflags; GR32:%122
        %124:gr8 = SETGr implicit killed %eflags; GR8:%124
        TEST16rr undef %3:gr16, undef %3:gr16, implicit-def %eflags; GR16:%3
        %152:gr32 = COPY killed %151; GR32:%152,%151
        %152.sub_8bit:gr32 = COPY killed %124; GR32:%152 GR8:%124
        %35:gr32 = COPY killed %152; GR32:%35,%152
        %35:gr32 = CMOVE32rr %35, killed %4, implicit killed %eflags;
GR32:%35,%4
        %126:gr32 = MOV32r0 implicit-def dead %eflags; GR32:%126
        %121:gr64 = SUBREG_TO_REG 0, killed %126, sub_32bit; GR64:%121
GR32:%126
        %168:gr64 = COPY killed %121; GR64:%168,%121
    Successors according to CFG: %bb.34(?%)

%bb.34: derived from LLVM BB %polly.loop_header
    Predecessors according to CFG: %bb.33 %bb.36
        %36:gr64 = COPY killed %168; GR64:%36,%168
        TEST32rr %35, %35, implicit-def %eflags; GR32:%35
        JNE_1 %bb.36, implicit killed %eflags
        JMP_1 %bb.35
    Successors according to CFG: %bb.35(0x30000000 / 0x80000000 = 37.50%)
%bb.36(0x50000000 / 0x80000000 = 62.50%)

%bb.35: derived from LLVM BB %polly.stmt.cond.false28
    Predecessors according to CFG: %bb.34
        MOV32mr %rip, 1, %noreg, <ga:@c>, %noreg, %0;
mem:ST4[@c](alias.scope=!19,!16,!"polly.alias.scope.MemRef2")(noalias=!18,!15,!20,!21)
GR32:%0
    Successors according to CFG: %bb.36(?%)

%bb.36: derived from LLVM BB %polly.stmt.cond.end30.exit
    Predecessors according to CFG: %bb.34 %bb.35
        %37:gr64 = COPY killed %36; GR64:%37,%36
        %37:gr64 = ADD64ri8 %37, 1, implicit-def dead %eflags; GR64:%37
        CMP64rr %37, %30, implicit-def %eflags; GR64:%37,%30
        %168:gr64 = COPY killed %37; GR64:%168,%37
        JL_1 %bb.34, implicit killed %eflags
        JMP_1 %bb.26
    Successors according to CFG: %bb.34(0x7c000000 / 0x80000000 = 96.88%)
%bb.26(0x04000000 / 0x80000000 = 3.12%)

%bb.37: derived from LLVM BB %42
    Predecessors according to CFG: %bb.11 %bb.12
        MOV32mr %rip, 1, %noreg, <ga:@c>, %noreg, %0; mem:ST4[@c](tbaa=!6)
GR32:%0
    Successors according to CFG: %bb.38(?%)

%bb.38: derived from LLVM BB %43
    Predecessors according to CFG: %bb.12 %bb.37
        undef %108.sub_16bit:gr32 = COPY killed %17; GR32:%108 GR16:%17
        %110:gr32 = COPY killed %108; GR32:%110,%108
        %110:gr32 = SUB32rr %110, %106, implicit-def dead %eflags;
GR32:%110,%106
        undef %111.sub_16bit:gr32 = COPY killed %16; GR32:%111 GR16:%16
        %113:gr32 = COPY killed %111; GR32:%113,%111
        %113:gr32 = ADD32rr %113, %106, implicit-def dead %eflags;
GR32:%113,%106
        undef %114.sub_16bit:gr32 = COPY killed %15; GR32:%114 GR16:%15
        %116:gr32 = COPY killed %114; GR32:%116,%114
        %116:gr32 = ADD32rr %116, %106, implicit-def dead %eflags;
GR32:%116,%106
        %38:gr16 = COPY killed %18; GR16:%38,%18
        %38:gr16 = ADD16ri8 %38, 2, implicit-def %eflags; GR16:%38
        %39:gr16 = COPY killed %110.sub_16bit; GR16:%39 GR32:%110
        %40:gr16 = COPY killed %113.sub_16bit; GR16:%40 GR32:%113
        %41:gr16 = COPY killed %116.sub_16bit; GR16:%41 GR32:%116
        %157:gr16 = COPY killed %41; GR16:%157,%41
        %158:gr16 = COPY killed %40; GR16:%158,%40
        %159:gr16 = COPY %39; GR16:%159,%39
        %160:gr16 = COPY killed %38; GR16:%160,%38
        JE_1 %bb.22, implicit killed %eflags
        JMP_1 %bb.11
    Successors according to CFG: %bb.22(0x04000000 / 0x80000000 = 3.12%)
%bb.11(0x7c000000 / 0x80000000 = 96.88%)

%bb.39: derived from LLVM BB %for.inc38.3
    Predecessors according to CFG: %bb.20 %bb.21
        %42:gr16 = COPY killed %27; GR16:%42,%27
        %42:gr16 = ADD16ri8 %42, 4, implicit-def %eflags; GR16:%42
        %164:gr16 = COPY killed %42; GR16:%164,%42
        JE_1 %bb.24, implicit killed %eflags
        JMP_1 %bb.20
    Successors according to CFG: %bb.24(0x04000000 / 0x80000000 = 3.12%)
%bb.20(0x7c000000 / 0x80000000 = 96.88%)

# End machine code for function fn1.

*** Bad machine code: Reading virtual register without a def ***
- function:    fn1
- basic block: %bb.6 for.body11.us.prol (0x753aee8)
- instruction: %171.sub_16bit:gr64_nosp = COPY
- operand 1:   %3:gr16
fatal error: error in backend: Found 1 machine code errors.
clang-6.0: error: clang frontend command failed with exit code 70 (use -v to
see invocation)
clang version 6.0.0 (trunk 320345)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-6.0: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /tmp/abc-164033.c
clang-6.0: note: diagnostic msg: /tmp/abc-164033.sh
clang-6.0: note: diagnostic msg:

********************


$ cat abc.c
char a;
int b;
unsigned c;
short d, e, h;
long f;
char *g;
void fn1() {
  long i;
  long *j = &i;
  for (; j;) {
    for (; a; a++)
      j = &f;
    c = b = 0;
    h = 8;
    for (; h;) {
      short *k = &d;
      g = &c;
      if (b) {
        long l = 200;
      l1:
        d = 60 / (l %= c);
        for (; h; h++) {
          *j ?: (*k += e);
          (*k ? 1 < *k : a) ?: (c = e);
          for (; i; i++)
            ;
        }
        for (;;)
          ;
      }
      a = h |= e;
      f = 4;
      for (; f;) {
        *g = 1;
        goto l1;
      l2:;
      }
    }
  }
  goto l2;
}
int main() {}

-- 
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/20171212/124d25d6/attachment-0001.html>


More information about the llvm-bugs mailing list