Skip to content

Commit f26a3ec

Browse files
authored
Merge pull request #39 from schweitzpgi/release_60
merge LLVM.org changes, fix to Fortran debug onto Release 60
2 parents 1aee9d4 + 62fddc2 commit f26a3ec

File tree

133 files changed

+12764
-6642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+12764
-6642
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
2424
set(LLVM_VERSION_MINOR 0)
2525
endif()
2626
if(NOT DEFINED LLVM_VERSION_PATCH)
27-
set(LLVM_VERSION_PATCH 0)
27+
set(LLVM_VERSION_PATCH 1)
2828
endif()
2929
if(NOT DEFINED LLVM_VERSION_SUFFIX)
3030
set(LLVM_VERSION_SUFFIX "")

include/llvm/CodeGen/MachineBasicBlock.h

+7
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,13 @@ class MachineBasicBlock
449449
/// Replace successor OLD with NEW and update probability info.
450450
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New);
451451

452+
/// Copy a successor (and any probability info) from original block to this
453+
/// block's. Uses an iterator into the original blocks successors.
454+
///
455+
/// This is useful when doing a partial clone of successors. Afterward, the
456+
/// probabilities may need to be normalized.
457+
void copySuccessor(MachineBasicBlock *Orig, succ_iterator I);
458+
452459
/// Transfers all the successors from MBB to this machine basic block (i.e.,
453460
/// copies all the successors FromMBB and remove all the successors from
454461
/// FromMBB).

include/llvm/CodeGen/TargetInstrInfo.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ class TargetInstrInfo : public MCInstrInfo {
421421
/// Build the equivalent inputs of a REG_SEQUENCE for the given \p MI
422422
/// and \p DefIdx.
423423
/// \p [out] InputRegs of the equivalent REG_SEQUENCE. Each element of
424-
/// the list is modeled as <Reg:SubReg, SubIdx>.
424+
/// the list is modeled as <Reg:SubReg, SubIdx>. Operands with the undef
425+
/// flag are not added to this list.
425426
/// E.g., REG_SEQUENCE %1:sub1, sub0, %2, sub1 would produce
426427
/// two elements:
427428
/// - %1:sub1, sub0
@@ -446,7 +447,8 @@ class TargetInstrInfo : public MCInstrInfo {
446447
/// - %1:sub1, sub0
447448
///
448449
/// \returns true if it is possible to build such an input sequence
449-
/// with the pair \p MI, \p DefIdx. False otherwise.
450+
/// with the pair \p MI, \p DefIdx and the operand has no undef flag set.
451+
/// False otherwise.
450452
///
451453
/// \pre MI.isExtractSubreg() or MI.isExtractSubregLike().
452454
///
@@ -465,7 +467,8 @@ class TargetInstrInfo : public MCInstrInfo {
465467
/// - InsertedReg: %1:sub1, sub3
466468
///
467469
/// \returns true if it is possible to build such an input sequence
468-
/// with the pair \p MI, \p DefIdx. False otherwise.
470+
/// with the pair \p MI, \p DefIdx and the operand has no undef flag set.
471+
/// False otherwise.
469472
///
470473
/// \pre MI.isInsertSubreg() or MI.isInsertSubregLike().
471474
///

include/llvm/IR/IntrinsicsPowerPC.td

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ let TargetPrefix = "ppc" in { // All intrinsics start with "llvm.ppc.".
3636

3737
// Intrinsics used to generate ctr-based loops. These should only be
3838
// generated by the PowerPC backend!
39+
// The branch intrinsic is marked as NoDuplicate because loop rotation will
40+
// attempt to duplicate it forming loops where a block reachable from one
41+
// instance of it can contain another.
3942
def int_ppc_mtctr : Intrinsic<[], [llvm_anyint_ty], []>;
40-
def int_ppc_is_decremented_ctr_nonzero : Intrinsic<[llvm_i1_ty], [], []>;
43+
def int_ppc_is_decremented_ctr_nonzero :
44+
Intrinsic<[llvm_i1_ty], [], [IntrNoDuplicate]>;
4145

4246
// Intrinsics for [double]word extended forms of divide instructions
4347
def int_ppc_divwe : GCCBuiltin<"__builtin_divwe">,

lib/Analysis/GlobalsModRef.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ void GlobalsAAResult::AnalyzeCallGraph(CallGraph &CG, Module &M) {
502502
}
503503

504504
FunctionInfo &FI = FunctionInfos[F];
505+
Handles.emplace_front(*this, F);
506+
Handles.front().I = Handles.begin();
505507
bool KnowNothing = false;
506508

507509
// Collect the mod/ref properties due to called functions. We only compute

lib/Analysis/MemorySSA.cpp

+20-9
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,14 @@ class MemoryLocOrCall {
153153
if (IsCall != Other.IsCall)
154154
return false;
155155

156-
if (IsCall)
157-
return CS.getCalledValue() == Other.CS.getCalledValue();
158-
return Loc == Other.Loc;
156+
if (!IsCall)
157+
return Loc == Other.Loc;
158+
159+
if (CS.getCalledValue() != Other.CS.getCalledValue())
160+
return false;
161+
162+
return CS.arg_size() == Other.CS.arg_size() &&
163+
std::equal(CS.arg_begin(), CS.arg_end(), Other.CS.arg_begin());
159164
}
160165

161166
private:
@@ -179,12 +184,18 @@ template <> struct DenseMapInfo<MemoryLocOrCall> {
179184
}
180185

181186
static unsigned getHashValue(const MemoryLocOrCall &MLOC) {
182-
if (MLOC.IsCall)
183-
return hash_combine(MLOC.IsCall,
184-
DenseMapInfo<const Value *>::getHashValue(
185-
MLOC.getCS().getCalledValue()));
186-
return hash_combine(
187-
MLOC.IsCall, DenseMapInfo<MemoryLocation>::getHashValue(MLOC.getLoc()));
187+
if (!MLOC.IsCall)
188+
return hash_combine(
189+
MLOC.IsCall,
190+
DenseMapInfo<MemoryLocation>::getHashValue(MLOC.getLoc()));
191+
192+
hash_code hash =
193+
hash_combine(MLOC.IsCall, DenseMapInfo<const Value *>::getHashValue(
194+
MLOC.getCS().getCalledValue()));
195+
196+
for (const Value *Arg : MLOC.getCS().args())
197+
hash = hash_combine(hash, DenseMapInfo<const Value *>::getHashValue(Arg));
198+
return hash;
188199
}
189200

190201
static bool isEqual(const MemoryLocOrCall &LHS, const MemoryLocOrCall &RHS) {

lib/CodeGen/AsmPrinter/DwarfUnit.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1362,12 +1362,12 @@ void DwarfUnit::constructFortranSubrangeDIE(DIE &Buffer,
13621362

13631363
if (!SR->getLowerBound()) {
13641364
int64_t BVC = SR->getCLowerBound();
1365-
addSInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, BVC);
1365+
addSInt(DW_Subrange, dwarf::DW_AT_lower_bound, dwarf::DW_FORM_sdata, BVC);
13661366
}
13671367

13681368
if ((!SR->getUpperBound()) && (!SR->noUpperBound())) {
13691369
int64_t BVC = SR->getCUpperBound();
1370-
addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, None, BVC);
1370+
addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, dwarf::DW_FORM_sdata, BVC);
13711371
}
13721372
}
13731373

lib/CodeGen/IfConversion.cpp

+28-11
Original file line numberDiff line numberDiff line change
@@ -1714,20 +1714,25 @@ bool IfConverter::IfConvertDiamondCommon(
17141714
}
17151715

17161716
// Remove the duplicated instructions at the beginnings of both paths.
1717-
// Skip dbg_value instructions
1717+
// Skip dbg_value instructions.
17181718
MachineBasicBlock::iterator DI1 = MBB1.getFirstNonDebugInstr();
17191719
MachineBasicBlock::iterator DI2 = MBB2.getFirstNonDebugInstr();
17201720
BBI1->NonPredSize -= NumDups1;
17211721
BBI2->NonPredSize -= NumDups1;
17221722

17231723
// Skip past the dups on each side separately since there may be
1724-
// differing dbg_value entries.
1724+
// differing dbg_value entries. NumDups1 can include a "return"
1725+
// instruction, if it's not marked as "branch".
17251726
for (unsigned i = 0; i < NumDups1; ++DI1) {
1727+
if (DI1 == MBB1.end())
1728+
break;
17261729
if (!DI1->isDebugValue())
17271730
++i;
17281731
}
17291732
while (NumDups1 != 0) {
17301733
++DI2;
1734+
if (DI2 == MBB2.end())
1735+
break;
17311736
if (!DI2->isDebugValue())
17321737
--NumDups1;
17331738
}
@@ -1738,11 +1743,16 @@ bool IfConverter::IfConvertDiamondCommon(
17381743
Redefs.stepForward(MI, Dummy);
17391744
}
17401745
}
1746+
17411747
BBI.BB->splice(BBI.BB->end(), &MBB1, MBB1.begin(), DI1);
17421748
MBB2.erase(MBB2.begin(), DI2);
17431749

1744-
// The branches have been checked to match, so it is safe to remove the branch
1745-
// in BB1 and rely on the copy in BB2
1750+
// The branches have been checked to match, so it is safe to remove the
1751+
// branch in BB1 and rely on the copy in BB2. The complication is that
1752+
// the blocks may end with a return instruction, which may or may not
1753+
// be marked as "branch". If it's not, then it could be included in
1754+
// "dups1", leaving the blocks potentially empty after moving the common
1755+
// duplicates.
17461756
#ifndef NDEBUG
17471757
// Unanalyzable branches must match exactly. Check that now.
17481758
if (!BBI1->IsBrAnalyzable)
@@ -1768,11 +1778,14 @@ bool IfConverter::IfConvertDiamondCommon(
17681778
if (RemoveBranch)
17691779
BBI2->NonPredSize -= TII->removeBranch(*BBI2->BB);
17701780
else {
1771-
do {
1772-
assert(DI2 != MBB2.begin());
1773-
DI2--;
1774-
} while (DI2->isBranch() || DI2->isDebugValue());
1775-
DI2++;
1781+
// Make DI2 point to the end of the range where the common "tail"
1782+
// instructions could be found.
1783+
while (DI2 != MBB2.begin()) {
1784+
MachineBasicBlock::iterator Prev = std::prev(DI2);
1785+
if (!Prev->isBranch() && !Prev->isDebugValue())
1786+
break;
1787+
DI2 = Prev;
1788+
}
17761789
}
17771790
while (NumDups2 != 0) {
17781791
// NumDups2 only counted non-dbg_value instructions, so this won't
@@ -1833,11 +1846,15 @@ bool IfConverter::IfConvertDiamondCommon(
18331846
// a non-predicated in BBI2, then we don't want to predicate the one from
18341847
// BBI2. The reason is that if we merged these blocks, we would end up with
18351848
// two predicated terminators in the same block.
1849+
// Also, if the branches in MBB1 and MBB2 were non-analyzable, then don't
1850+
// predicate them either. They were checked to be identical, and so the
1851+
// same branch would happen regardless of which path was taken.
18361852
if (!MBB2.empty() && (DI2 == MBB2.end())) {
18371853
MachineBasicBlock::iterator BBI1T = MBB1.getFirstTerminator();
18381854
MachineBasicBlock::iterator BBI2T = MBB2.getFirstTerminator();
1839-
if (BBI1T != MBB1.end() && TII->isPredicated(*BBI1T) &&
1840-
BBI2T != MBB2.end() && !TII->isPredicated(*BBI2T))
1855+
bool BB1Predicated = BBI1T != MBB1.end() && TII->isPredicated(*BBI1T);
1856+
bool BB2NonPredicated = BBI2T != MBB2.end() && !TII->isPredicated(*BBI2T);
1857+
if (BB2NonPredicated && (BB1Predicated || !BBI2->IsBrAnalyzable))
18411858
--DI2;
18421859
}
18431860

lib/CodeGen/LiveDebugVariables.cpp

+40-1
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,39 @@ bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
514514
return false;
515515
}
516516

517+
// Detect invalid DBG_VALUE instructions, with a debug-use of a virtual
518+
// register that hasn't been defined yet. If we do not remove those here, then
519+
// the re-insertion of the DBG_VALUE instruction after register allocation
520+
// will be incorrect.
521+
// TODO: If earlier passes are corrected to generate sane debug information
522+
// (and if the machine verifier is improved to catch this), then these checks
523+
// could be removed or replaced by asserts.
524+
bool Discard = false;
525+
if (MI.getOperand(0).isReg() &&
526+
TargetRegisterInfo::isVirtualRegister(MI.getOperand(0).getReg())) {
527+
const unsigned Reg = MI.getOperand(0).getReg();
528+
if (!LIS->hasInterval(Reg)) {
529+
// The DBG_VALUE is described by a virtual register that does not have a
530+
// live interval. Discard the DBG_VALUE.
531+
Discard = true;
532+
DEBUG(dbgs() << "Discarding debug info (no LIS interval): "
533+
<< Idx << " " << MI);
534+
} else {
535+
// The DBG_VALUE is only valid if either Reg is live out from Idx, or Reg
536+
// is defined dead at Idx (where Idx is the slot index for the instruction
537+
// preceeding the DBG_VALUE).
538+
const LiveInterval &LI = LIS->getInterval(Reg);
539+
LiveQueryResult LRQ = LI.Query(Idx);
540+
if (!LRQ.valueOutOrDead()) {
541+
// We have found a DBG_VALUE with the value in a virtual register that
542+
// is not live. Discard the DBG_VALUE.
543+
Discard = true;
544+
DEBUG(dbgs() << "Discarding debug info (reg not live): "
545+
<< Idx << " " << MI);
546+
}
547+
}
548+
}
549+
517550
// Get or create the UserValue for (variable,offset) here.
518551
bool IsIndirect = MI.getOperand(1).isImm();
519552
if (IsIndirect)
@@ -522,7 +555,13 @@ bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
522555
const DIExpression *Expr = MI.getDebugExpression();
523556
UserValue *UV =
524557
getUserValue(Var, Expr, MI.getDebugLoc());
525-
UV->addDef(Idx, MI.getOperand(0), IsIndirect);
558+
if (!Discard)
559+
UV->addDef(Idx, MI.getOperand(0), IsIndirect);
560+
else {
561+
MachineOperand MO = MachineOperand::CreateReg(0U, false);
562+
MO.setIsDebug();
563+
UV->addDef(Idx, MO, false);
564+
}
526565
return true;
527566
}
528567

lib/CodeGen/MachineBasicBlock.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,14 @@ void MachineBasicBlock::replaceSuccessor(MachineBasicBlock *Old,
646646
removeSuccessor(OldI);
647647
}
648648

649+
void MachineBasicBlock::copySuccessor(MachineBasicBlock *Orig,
650+
succ_iterator I) {
651+
if (Orig->Probs.empty())
652+
addSuccessor(*I, Orig->getSuccProbability(I));
653+
else
654+
addSuccessorWithoutProb(*I);
655+
}
656+
649657
void MachineBasicBlock::addPredecessor(MachineBasicBlock *Pred) {
650658
Predecessors.push_back(Pred);
651659
}

lib/CodeGen/MachineBlockPlacement.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ class MachineBlockPlacement : public MachineFunctionPass {
513513

514514
bool runOnMachineFunction(MachineFunction &F) override;
515515

516+
bool allowTailDupPlacement() const {
517+
assert(F);
518+
return TailDupPlacement && !F->getTarget().requiresStructuredCFG();
519+
}
520+
516521
void getAnalysisUsage(AnalysisUsage &AU) const override {
517522
AU.addRequired<MachineBranchProbabilityInfo>();
518523
AU.addRequired<MachineBlockFrequencyInfo>();
@@ -1018,7 +1023,7 @@ MachineBlockPlacement::getBestTrellisSuccessor(
10181023
MachineBasicBlock *Succ1 = BestA.Dest;
10191024
MachineBasicBlock *Succ2 = BestB.Dest;
10201025
// Check to see if tail-duplication would be profitable.
1021-
if (TailDupPlacement && shouldTailDuplicate(Succ2) &&
1026+
if (allowTailDupPlacement() && shouldTailDuplicate(Succ2) &&
10221027
canTailDuplicateUnplacedPreds(BB, Succ2, Chain, BlockFilter) &&
10231028
isProfitableToTailDup(BB, Succ2, MBPI->getEdgeProbability(BB, Succ1),
10241029
Chain, BlockFilter)) {
@@ -1044,7 +1049,7 @@ MachineBlockPlacement::getBestTrellisSuccessor(
10441049
return Result;
10451050
}
10461051

1047-
/// When the option TailDupPlacement is on, this method checks if the
1052+
/// When the option allowTailDupPlacement() is on, this method checks if the
10481053
/// fallthrough candidate block \p Succ (of block \p BB) can be tail-duplicated
10491054
/// into all of its unplaced, unfiltered predecessors, that are not BB.
10501055
bool MachineBlockPlacement::canTailDuplicateUnplacedPreds(
@@ -1493,7 +1498,7 @@ MachineBlockPlacement::selectBestSuccessor(
14931498
if (hasBetterLayoutPredecessor(BB, Succ, SuccChain, SuccProb, RealSuccProb,
14941499
Chain, BlockFilter)) {
14951500
// If tail duplication would make Succ profitable, place it.
1496-
if (TailDupPlacement && shouldTailDuplicate(Succ))
1501+
if (allowTailDupPlacement() && shouldTailDuplicate(Succ))
14971502
DupCandidates.push_back(std::make_tuple(SuccProb, Succ));
14981503
continue;
14991504
}
@@ -1702,7 +1707,7 @@ void MachineBlockPlacement::buildChain(
17021707
auto Result = selectBestSuccessor(BB, Chain, BlockFilter);
17031708
MachineBasicBlock* BestSucc = Result.BB;
17041709
bool ShouldTailDup = Result.ShouldTailDup;
1705-
if (TailDupPlacement)
1710+
if (allowTailDupPlacement())
17061711
ShouldTailDup |= (BestSucc && shouldTailDuplicate(BestSucc));
17071712

17081713
// If an immediate successor isn't available, look for the best viable
@@ -1724,7 +1729,7 @@ void MachineBlockPlacement::buildChain(
17241729

17251730
// Placement may have changed tail duplication opportunities.
17261731
// Check for that now.
1727-
if (TailDupPlacement && BestSucc && ShouldTailDup) {
1732+
if (allowTailDupPlacement() && BestSucc && ShouldTailDup) {
17281733
// If the chosen successor was duplicated into all its predecessors,
17291734
// don't bother laying it out, just go round the loop again with BB as
17301735
// the chain end.
@@ -2758,7 +2763,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) {
27582763
TailDupSize = TailDupPlacementAggressiveThreshold;
27592764
}
27602765

2761-
if (TailDupPlacement) {
2766+
if (allowTailDupPlacement()) {
27622767
MPDT = &getAnalysis<MachinePostDominatorTree>();
27632768
if (MF.getFunction().optForSize())
27642769
TailDupSize = 1;

0 commit comments

Comments
 (0)