Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mips][AsmPrinter] Fix for assembler not printing a label #80666

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions llvm/lib/Target/Mips/MipsAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,23 @@ bool MipsAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
if (Pred->empty())
return true;

// Check the terminators in the previous block.
for (const auto &MI : Pred->terminators()) {
// If it is not a simple branch, we are in a table somewhere.
if (!MI.isBranch() || MI.isIndirectBranch())
return false;

// If we are the operands of one of the branches, this is not a fall
// through. Note that targets with delay slots will usually bundle
// terminators with the delay slot instruction.
for (ConstMIBundleOperands OP(MI); OP.isValid(); ++OP) {
if (OP->isJTI())
return false;
if (OP->isMBB() && OP->getMBB() == MBB)
return false;
}
}

// Otherwise, check the last instruction.
// Check if the last terminator is an unconditional branch.
MachineBasicBlock::const_iterator I = Pred->end();
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define void @test(i32 %x, ptr %p) nounwind {
; CHECK-NEXT: andi $1, $4, 1
; CHECK-NEXT: bgtz $1, $BB0_1
; CHECK-NEXT: nop
; CHECK-NEXT: # %bb.1: # %foo
; CHECK-NEXT: $BB0_1: # %foo
; CHECK-NEXT: jr $ra
; CHECK-NEXT: nop
%y = and i32 %x, 1
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/CodeGen/Mips/br_equal_labels.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc --filetype=asm -march=mips --relocation-model=pic -O0 < %s | FileCheck %s

define void @test(i32 %x) nounwind {
%y = icmp eq i32 %x, 1
br i1 %y, label %bb1, label %bb1

bb1:
ret void
}

; CHECK: bgtz ${{[0-9]+}}, $[[BB1:BB[0-9]+_[0-9]+]]
; CHECK-NEXT: nop
; CHECK-NEXT: $[[BB1]]:
Loading