Skip to content

Commit 253b9ba

Browse files
anoopkg6anoopkg6uweigand
authored andcommitted
Fix Linux kernel build failure for SytemZ. (llvm#165274)
Linux kernel build fails for SystemZ as output of INLINEASM was GR32Bit general-purpose register instead of SystemZ::CC. --------- Co-authored-by: anoopkg6 <[email protected]> Co-authored-by: Ulrich Weigand <[email protected]>
1 parent ccd4ac6 commit 253b9ba

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ SystemZTargetLowering::getRegForInlineAsmConstraint(
17141714
}
17151715
if (Constraint[1] == '@') {
17161716
if (StringRef("{@cc}").compare(Constraint) == 0)
1717-
return std::make_pair(0u, &SystemZ::GR32BitRegClass);
1717+
return std::make_pair(SystemZ::CC, &SystemZ::CCRRegClass);
17181718
}
17191719
}
17201720
return TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
@@ -1766,10 +1766,6 @@ SDValue SystemZTargetLowering::LowerAsmOutputForConstraint(
17661766
OpInfo.ConstraintVT.getSizeInBits() < 8)
17671767
report_fatal_error("Glue output operand is of invalid type");
17681768

1769-
MachineFunction &MF = DAG.getMachineFunction();
1770-
MachineRegisterInfo &MRI = MF.getRegInfo();
1771-
MRI.addLiveIn(SystemZ::CC);
1772-
17731769
if (Glue.getNode()) {
17741770
Glue = DAG.getCopyFromReg(Chain, DL, SystemZ::CC, MVT::i32, Glue);
17751771
Chain = Glue.getValue(1);

llvm/test/CodeGen/SystemZ/inline-asm-flag-output-01.ll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,3 +736,40 @@ exit:
736736
ret void
737737
}
738738

739+
; Test INLINEASM defines CC.
740+
@wait_fence = global i32 0, align 4
741+
@bit_cc = global i32 0, align 4
742+
define void @test_inlineasm_define_cc() {
743+
; CHECK-LABEL: test_inlineasm_define_cc:
744+
; CHECK: # %bb.0: # %entry
745+
; CHECK-NEXT: lgrl %r1, wait_fence@GOT
746+
; CHECK-NEXT: chsi 0(%r1), 0
747+
; CHECK-NEXT: ber %r14
748+
; CHECK-NEXT: .LBB29_1: # %while.body.lr.ph
749+
; CHECK-NEXT: lgrl %r1, bit_cc@GOT
750+
; CHECK-NEXT: #APP
751+
; CHECK-NEXT: #NO_APP
752+
; CHECK-NEXT: ipm %r0
753+
; CHECK-NEXT: srl %r0, 28
754+
; CHECK-NEXT: st %r0, 0(%r1)
755+
; CHECK-NEXT: .LBB29_2: # %while.body
756+
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
757+
; CHECK-NEXT: j .LBB29_2
758+
entry:
759+
%0 = load i32, ptr @wait_fence, align 4
760+
%tobool.not = icmp eq i32 %0, 0
761+
br i1 %tobool.not, label %while.end, label %while.body.lr.ph
762+
763+
while.body.lr.ph:
764+
%1 = tail call i32 asm "", "={@cc}"()
765+
%2 = icmp ult i32 %1, 4
766+
tail call void @llvm.assume(i1 %2)
767+
store i32 %1, ptr @bit_cc, align 4
768+
br label %while.body
769+
770+
while.body:
771+
br label %while.body
772+
773+
while.end:
774+
ret void
775+
}

0 commit comments

Comments
 (0)