[llvm-branch-commits] [llvm-branch] r371057 - Merging r371048:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Sep 5 04:33:27 PDT 2019
Author: hans
Date: Thu Sep 5 04:33:27 2019
New Revision: 371057
URL: http://llvm.org/viewvc/llvm-project?rev=371057&view=rev
Log:
Merging r371048:
------------------------------------------------------------------------
r371048 | jonpa | 2019-09-05 12:20:05 +0200 (Thu, 05 Sep 2019) | 7 lines
[SystemZ] Recognize INLINEASM_BR in backend
Handle the remaining cases also by handling asm goto in
SystemZInstrInfo::getBranchInfo().
Review: Ulrich Weigand
https://reviews.llvm.org/D67151
------------------------------------------------------------------------
Modified:
llvm/branches/release_90/ (props changed)
llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.cpp
llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.h
llvm/branches/release_90/lib/Target/SystemZ/SystemZLongBranch.cpp
llvm/branches/release_90/lib/Target/SystemZ/SystemZMachineScheduler.cpp
llvm/branches/release_90/test/CodeGen/SystemZ/asm-20.ll
Propchange: llvm/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 5 04:33:27 2019
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,366431,366447,366481,366487,366527,366570,366660,366868,366925,367019,367030,367062,367084,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367412,367417,367429,367580,367662,367750,367753,367846-367847,367898,367941,368004,368164,368230,368300,368315,368324,368477-368478,368517-368519,368554,368572,368873,369011,369026,369084,369095,369097,369168,369199,369310,369426,369443,369886,370036,370176,370204,370271,370355,370404,370430,370720-370721,370753
+/llvm/trunk:155241,366431,366447,366481,366487,366527,366570,366660,366868,366925,367019,367030,367062,367084,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367412,367417,367429,367580,367662,367750,367753,367846-367847,367898,367941,368004,368164,368230,368300,368315,368324,368477-368478,368517-368519,368554,368572,368873,369011,369026,369084,369095,369097,369168,369199,369310,369426,369443,369886,370036,370176,370204,370271,370355,370404,370430,370720-370721,370753,371048
Modified: llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.cpp?rev=371057&r1=371056&r2=371057&view=diff
==============================================================================
--- llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.cpp (original)
+++ llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.cpp Thu Sep 5 04:33:27 2019
@@ -462,13 +462,13 @@ bool SystemZInstrInfo::analyzeBranch(Mac
break;
// A terminator that isn't a branch can't easily be handled by this
- // analysis. Asm goto is not understood / optimized.
- if (!I->isBranch() || I->getOpcode() == SystemZ::INLINEASM_BR)
+ // analysis.
+ if (!I->isBranch())
return true;
// Can't handle indirect branches.
SystemZII::Branch Branch(getBranchInfo(*I));
- if (!Branch.Target->isMBB())
+ if (!Branch.hasMBBTarget())
return true;
// Punt on compound branches.
@@ -478,7 +478,7 @@ bool SystemZInstrInfo::analyzeBranch(Mac
if (Branch.CCMask == SystemZ::CCMASK_ANY) {
// Handle unconditional branches.
if (!AllowModify) {
- TBB = Branch.Target->getMBB();
+ TBB = Branch.getMBBTarget();
continue;
}
@@ -490,7 +490,7 @@ bool SystemZInstrInfo::analyzeBranch(Mac
FBB = nullptr;
// Delete the JMP if it's equivalent to a fall-through.
- if (MBB.isLayoutSuccessor(Branch.Target->getMBB())) {
+ if (MBB.isLayoutSuccessor(Branch.getMBBTarget())) {
TBB = nullptr;
I->eraseFromParent();
I = MBB.end();
@@ -498,7 +498,7 @@ bool SystemZInstrInfo::analyzeBranch(Mac
}
// TBB is used to indicate the unconditinal destination.
- TBB = Branch.Target->getMBB();
+ TBB = Branch.getMBBTarget();
continue;
}
@@ -506,7 +506,7 @@ bool SystemZInstrInfo::analyzeBranch(Mac
if (Cond.empty()) {
// FIXME: add X86-style branch swap
FBB = TBB;
- TBB = Branch.Target->getMBB();
+ TBB = Branch.getMBBTarget();
Cond.push_back(MachineOperand::CreateImm(Branch.CCValid));
Cond.push_back(MachineOperand::CreateImm(Branch.CCMask));
continue;
@@ -517,7 +517,7 @@ bool SystemZInstrInfo::analyzeBranch(Mac
// Only handle the case where all conditional branches branch to the same
// destination.
- if (TBB != Branch.Target->getMBB())
+ if (TBB != Branch.getMBBTarget())
return true;
// If the conditions are the same, we can leave them alone.
@@ -547,7 +547,7 @@ unsigned SystemZInstrInfo::removeBranch(
continue;
if (!I->isBranch())
break;
- if (!getBranchInfo(*I).Target->isMBB())
+ if (!getBranchInfo(*I).hasMBBTarget())
break;
// Remove the branch.
I->eraseFromParent();
@@ -1545,6 +1545,10 @@ SystemZInstrInfo::getBranchInfo(const Ma
return SystemZII::Branch(SystemZII::BranchCLG, SystemZ::CCMASK_ICMP,
MI.getOperand(2).getImm(), &MI.getOperand(3));
+ case SystemZ::INLINEASM_BR:
+ // Don't try to analyze asm goto, so pass nullptr as branch target argument.
+ return SystemZII::Branch(SystemZII::AsmGoto, 0, 0, nullptr);
+
default:
llvm_unreachable("Unrecognized branch opcode");
}
Modified: llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.h?rev=371057&r1=371056&r2=371057&view=diff
==============================================================================
--- llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.h (original)
+++ llvm/branches/release_90/lib/Target/SystemZ/SystemZInstrInfo.h Thu Sep 5 04:33:27 2019
@@ -100,11 +100,18 @@ enum BranchType {
// An instruction that decrements a 64-bit register and branches if
// the result is nonzero.
- BranchCTG
+ BranchCTG,
+
+ // An instruction representing an asm goto statement.
+ AsmGoto
};
// Information about a branch instruction.
-struct Branch {
+class Branch {
+ // The target of the branch. In case of INLINEASM_BR, this is nullptr.
+ const MachineOperand *Target;
+
+public:
// The type of the branch.
BranchType Type;
@@ -114,12 +121,15 @@ struct Branch {
// CCMASK_<N> is set if the branch should be taken when CC == N.
unsigned CCMask;
- // The target of the branch.
- const MachineOperand *Target;
-
Branch(BranchType type, unsigned ccValid, unsigned ccMask,
const MachineOperand *target)
- : Type(type), CCValid(ccValid), CCMask(ccMask), Target(target) {}
+ : Target(target), Type(type), CCValid(ccValid), CCMask(ccMask) {}
+
+ bool isIndirect() { return Target != nullptr && Target->isReg(); }
+ bool hasMBBTarget() { return Target != nullptr && Target->isMBB(); }
+ MachineBasicBlock *getMBBTarget() {
+ return hasMBBTarget() ? Target->getMBB() : nullptr;
+ }
};
// Kinds of fused compares in compare-and-* instructions. Together with type
Modified: llvm/branches/release_90/lib/Target/SystemZ/SystemZLongBranch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/lib/Target/SystemZ/SystemZLongBranch.cpp?rev=371057&r1=371056&r2=371057&view=diff
==============================================================================
--- llvm/branches/release_90/lib/Target/SystemZ/SystemZLongBranch.cpp (original)
+++ llvm/branches/release_90/lib/Target/SystemZ/SystemZLongBranch.cpp Thu Sep 5 04:33:27 2019
@@ -257,7 +257,7 @@ TerminatorInfo SystemZLongBranch::descri
}
Terminator.Branch = &MI;
Terminator.TargetBlock =
- TII->getBranchInfo(MI).Target->getMBB()->getNumber();
+ TII->getBranchInfo(MI).getMBBTarget()->getNumber();
}
return Terminator;
}
Modified: llvm/branches/release_90/lib/Target/SystemZ/SystemZMachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/lib/Target/SystemZ/SystemZMachineScheduler.cpp?rev=371057&r1=371056&r2=371057&view=diff
==============================================================================
--- llvm/branches/release_90/lib/Target/SystemZ/SystemZMachineScheduler.cpp (original)
+++ llvm/branches/release_90/lib/Target/SystemZ/SystemZMachineScheduler.cpp Thu Sep 5 04:33:27 2019
@@ -108,8 +108,8 @@ void SystemZPostRASchedStrategy::enterMB
I != SinglePredMBB->end(); I++) {
LLVM_DEBUG(dbgs() << "** Emitting incoming branch: "; I->dump(););
bool TakenBranch = (I->isBranch() &&
- (TII->getBranchInfo(*I).Target->isReg() || // Relative branch
- TII->getBranchInfo(*I).Target->getMBB() == MBB));
+ (TII->getBranchInfo(*I).isIndirect() ||
+ TII->getBranchInfo(*I).getMBBTarget() == MBB));
HazardRec->emitInstruction(&*I, TakenBranch);
if (TakenBranch)
break;
Modified: llvm/branches/release_90/test/CodeGen/SystemZ/asm-20.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/test/CodeGen/SystemZ/asm-20.ll?rev=371057&r1=371056&r2=371057&view=diff
==============================================================================
--- llvm/branches/release_90/test/CodeGen/SystemZ/asm-20.ll (original)
+++ llvm/branches/release_90/test/CodeGen/SystemZ/asm-20.ll Thu Sep 5 04:33:27 2019
@@ -1,10 +1,10 @@
; Test that asm goto can be compiled.
;
-; RUN: llc < %s -mtriple=s390x-linux-gnu
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14
define i32 @c() {
entry:
- callbr void asm sideeffect "", "X"(i8* blockaddress(@c, %d))
+ callbr void asm sideeffect "j d", "X"(i8* blockaddress(@c, %d))
to label %asm.fallthrough [label %d]
asm.fallthrough: ; preds = %entry
More information about the llvm-branch-commits
mailing list