Skip to content

Bad machine code: PHI operand is not live-out from predecessor #44902

@pkubaj

Description

@pkubaj
Bugzilla Link 45557
Resolution FIXED
Resolved on May 07, 2020 07:31
Version 10.0
OS FreeBSD
Blocks #44654
CC @DMG862,@DimitryAndric,@bzEq,@nemanjai,@tstellar
Fixed by commit(s) 44c4ba3 bab8d17

Extended Description

FreeBSD head, LLVM 10.0.0, powerpc architecture (32-bit)

Reduced test case:
a, b;
c() {
int d;
int e[] = {0, &a};
if (b)
e[0] = f();
d = 0;
for (; d < 2; d++)
if (e[d])
g();
}

Compile with:
/usr/bin/cc -cc1 -triple powerpc-unknown-freebsd13.0 -emit-obj -O2 -mrelocation-model static -x c pbx_variables-3bff13.c

Problem:

Machine code for function c: IsSSA, TracksLiveness

bb.0.entry:
successors: %bb.2(0x30000000), %bb.1(0x50000000); %bb.2(37.50%), %bb.1(62.50%)

%4:gprc_and_gprc_nor0 = LIS target-flags(ppc-ha) @​__const.c.e
%6:gprc_and_gprc_nor0 = LIS target-flags(ppc-ha) @​b
%7:gprc = LWZ target-flags(ppc-lo) @​b, killed %6:gprc_and_gprc_nor0 :: (dereferenceable load 4 from @​b, !tbaa !​2)
%8:crrc = CMPLWI killed %7:gprc, 0
BCC 76, killed %8:crrc, %bb.2
B %bb.1

bb.1.if.then:
; predecessors: %bb.0
successors: %bb.2(0x80000000); %bb.2(100.00%)

ADJCALLSTACKDOWN 8, 0, implicit-def dead $r1, implicit $r1
BL @​f, <regmask $cr2 $cr3 $cr4 $f14 $f15 $f16 $f17 $f18 $f19 $f20 $f21 $f22 $f23 $f24 $f25 $f26 $f27 $f28 $f29 $f30 $f31 $r14 $r15 $r16 $r17 $r18 $r19 $r20 $r21 $r22 $r23 $r24 $r25 and 18 more...>, implicit-def dead $lr, implicit $rm, implicit-def $r1, implicit-def $r3
ADJCALLSTACKUP 8, 0, implicit-def dead $r1, implicit $r1
%9:gprc = COPY $r3
%2:gprc = COPY %9:gprc

bb.2.if.end:
; predecessors: %bb.0, %bb.1
successors: %bb.4(0x30000000), %bb.3(0x50000000); %bb.4(37.50%), %bb.3(62.50%)

%3:gprc = PHI %0:gprc, %bb.0, %2:gprc, %bb.1
%0:gprc, %5:gprc_and_gprc_nor0 = LWZU target-flags(ppc-lo) @​__const.c.e, %4:gprc_and_gprc_nor0(tied-def 1) :: (load 4 from i64* bitcast ([2 x i32]* @&#8203;__const.c.e to i64*), align 8)
%1:gprc = LWZ 4, %5:gprc_and_gprc_nor0 :: (dereferenceable load 4 from i64* bitcast ([2 x i32]* @&#8203;__const.c.e to i64*) + 4)
%10:crrc = CMPLWI %3:gprc, 0
BCC 76, killed %10:crrc, %bb.4
B %bb.3

bb.3.if.then3:
; predecessors: %bb.2
successors: %bb.4(0x80000000); %bb.4(100.00%)

ADJCALLSTACKDOWN 8, 0, implicit-def dead $r1, implicit $r1
BL @​g, <regmask $cr2 $cr3 $cr4 $f14 $f15 $f16 $f17 $f18 $f19 $f20 $f21 $f22 $f23 $f24 $f25 $f26 $f27 $f28 $f29 $f30 $f31 $r14 $r15 $r16 $r17 $r18 $r19 $r20 $r21 $r22 $r23 $r24 $r25 and 18 more...>, implicit-def dead $lr, implicit $rm, implicit-def $r1, implicit-def $r3
ADJCALLSTACKUP 8, 0, implicit-def dead $r1, implicit $r1

bb.4.for.inc:
; predecessors: %bb.2, %bb.3
successors: %bb.6(0x30000000), %bb.5(0x50000000); %bb.6(37.50%), %bb.5(62.50%)

%12:crrc = CMPLWI %1:gprc, 0
BCC 76, killed %12:crrc, %bb.6
B %bb.5

bb.5.if.then3.1:
; predecessors: %bb.4
successors: %bb.6(0x80000000); %bb.6(100.00%)

ADJCALLSTACKDOWN 8, 0, implicit-def dead $r1, implicit $r1
BL @​g, <regmask $cr2 $cr3 $cr4 $f14 $f15 $f16 $f17 $f18 $f19 $f20 $f21 $f22 $f23 $f24 $f25 $f26 $f27 $f28 $f29 $f30 $f31 $r14 $r15 $r16 $r17 $r18 $r19 $r20 $r21 $r22 $r23 $r24 $r25 and 18 more...>, implicit-def dead $lr, implicit $rm, implicit-def $r1, implicit-def $r3
ADJCALLSTACKUP 8, 0, implicit-def dead $r1, implicit $r1

bb.6.for.inc.1:
; predecessors: %bb.4, %bb.5

%14:gprc = IMPLICIT_DEF
$r3 = COPY %14:gprc
BLR implicit $lr, implicit $rm, implicit $r3

End machine code for function c.

*** Bad machine code: PHI operand is not live-out from predecessor ***

  • function: c
  • basic block: %bb.2 if.end (0x8168a95e0)
  • instruction: %3:gprc = PHI %0:gprc, %bb.0, %2:gprc, %bb.1
  • operand 1: %0:gprc
    fatal error: error in backend: Found 1 machine code errors.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions