Closed Quuxplusone closed 4 years ago
Looks like a bug of MachineSink, need to investigate more.
https://reviews.llvm.org/D78297 is posted to fix it.
https://reviews.llvm.org/rG44c4ba34d001dcf538d7396007b5611d6f697f86 is now in, and hopefully fixed this issue (it no longer runs into the same verifier problem). Let us know if it needs to be reopened.
@dim
Can you merge that to FreeBSD head? It should fix build of net/asterisk16 on
powerpc.
It would be good to merge it for 10.0.1.
Sjoerd, you reviewed this patch. Do you think it is safe to backport?
https://reviews.llvm.org/rG44c4ba34d001dcf538d7396007b5611d6f697f86
This is on trunk for a few weeks now, we didn't hear any complaints about it, it is a small and low risk patch I think, so looks like a good candidate for a backport to me.
Merged: bab8d1790a3
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]* @__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] @const.c.e to i64*)` + 4) %10:crrc = CMPLWI %3:gprc, 0 BCC 76, killed %10:crrc, %bb.4 B %bb.3bb.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