Skip to content

Commit b93ad3e

Browse files
authored
Merge pull request #132 from sx-aurora-dev/feature/merge-upstream-20211221
Feature/merge upstream 20211221
2 parents 5a37a35 + b6f54a9 commit b93ad3e

File tree

17 files changed

+310
-98
lines changed

17 files changed

+310
-98
lines changed

llvm/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- [Extension](#extension)
44
- [Heterogeneous Computing Devices](#heterogeneous-computing-devices)
55
- [DWARF 5](#dwarf-5)
6-
- [What is DWARF?](#what-is-dwarf)
6+
- [How DWARF Maps Source Language To Hardware](#how-dwarf-maps-source-language-to-hardware)
77
- [Examples](#examples)
88
- [Dynamic Array Size](#dynamic-array-size)
99
- [Variable Location in Register](#variable-location-in-register)
@@ -29,15 +29,22 @@
2929

3030
# Extension
3131

32-
This extension is to generalize the DWARF expression evaluation model to allow
33-
location descriptions to be manipulated on the stack. It is done in a manner
34-
that is backwards compatible with DWARF 5. This permits operations to act on
35-
location descriptions in an incremental, consistent, and composable manner.
36-
37-
It allows a small number of operations to be defined to address the requirements
38-
of heterogeneous devices as well as providing benefits to non-heterogeneous
39-
devices. It also acts as a foundation to provide support for other issues that
40-
have been raised that would benefit all devices.
32+
In DWARF 5, expressions are evaluated using a typed value stack, a separate
33+
location area, and an independent loclist mechanism. This extension unifies all
34+
three mechanisms into a single generalized DWARF expression evaluation model
35+
that allows both typed values and location descriptions to be manipulated on the
36+
evaluation stack. Both single and multiple location descriptions are supported
37+
on the stack. In addition, the call frame information (CFI) is extended to
38+
support the full generality of location descriptions. This is done in a manner
39+
that is backwards compatible with DWARF 5. The extension involves changes to the
40+
DWARF 5 sections 2.5 (pp 26-38), 2.6 (pp 38-45), and 6.4 (pp 171-182).
41+
42+
The extension permits operations to act on location descriptions in an
43+
incremental, consistent, and composable manner. It allows a small number of
44+
operations to be defined to address the requirements of heterogeneous devices as
45+
well as providing benefits to non-heterogeneous devices. It acts as a foundation
46+
to provide support for other issues that have been raised that would benefit all
47+
devices.
4148

4249
Other approaches were explored that involved adding specialized operations and
4350
rules. However, these resulted in the need for more operations that did not
@@ -100,7 +107,7 @@ Before presenting the proposed solution to supporting heterogeneous devices, a
100107
brief overview of the DWARF 5 expression evaluation model will be given to
101108
highlight the aspects being addressed by the extension.
102109

103-
## What is DWARF?
110+
## How DWARF Maps Source Language To Hardware
104111

105112
DWARF is a standardized way to specify debug information. It describes source
106113
language entities such as compilation units, functions, types, variables, etc.

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
884884
InnermostGEP = GEP;
885885
InBounds &= GEP->isInBounds();
886886

887-
SmallVector<Value *, 4> NestedOps(GEP->op_begin() + 1, GEP->op_end());
887+
SmallVector<Value *, 4> NestedOps(llvm::drop_begin(GEP->operands()));
888888

889889
// Do not try the incorporate the sub-GEP if some index is not a number.
890890
bool AllConstantInt = true;

llvm/lib/CodeGen/Analysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
712712
// The manipulations performed when we're looking through an insertvalue or
713713
// an extractvalue would happen at the front of the RetPath list, so since
714714
// we have to copy it anyway it's more efficient to create a reversed copy.
715-
SmallVector<unsigned, 4> TmpRetPath(RetPath.rbegin(), RetPath.rend());
716-
SmallVector<unsigned, 4> TmpCallPath(CallPath.rbegin(), CallPath.rend());
715+
SmallVector<unsigned, 4> TmpRetPath(llvm::reverse(RetPath));
716+
SmallVector<unsigned, 4> TmpCallPath(llvm::reverse(CallPath));
717717

718718
// Finally, we can check whether the value produced by the tail call at this
719719
// index is compatible with the value we return.

llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
4747
InlinedAt = InlinedAt->getInlinedAt();
4848
}
4949

50-
SmallVector<InlineSite, 8> InlineStack(ReversedInlineStack.rbegin(),
51-
ReversedInlineStack.rend());
50+
SmallVector<InlineSite, 8> InlineStack(llvm::reverse(ReversedInlineStack));
5251
Asm->OutStreamer->emitPseudoProbe(Guid, Index, Type, Attr, InlineStack);
5352
}

llvm/lib/IR/Operator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool GEPOperator::accumulateConstantOffset(
9090
assert(Offset.getBitWidth() ==
9191
DL.getIndexSizeInBits(getPointerAddressSpace()) &&
9292
"The offset bit width does not match DL specification.");
93-
SmallVector<const Value *> Index(value_op_begin() + 1, value_op_end());
93+
SmallVector<const Value *> Index(llvm::drop_begin(operand_values()));
9494
return GEPOperator::accumulateConstantOffset(getSourceElementType(), Index,
9595
DL, Offset, ExternalAnalysis);
9696
}

llvm/lib/Target/ARM/A15SDOptimizer.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,16 +592,15 @@ bool A15SDOptimizer::runOnInstruction(MachineInstr *MI) {
592592
SmallVector<unsigned, 8> Defs = getReadDPRs(MI);
593593
bool Modified = false;
594594

595-
for (SmallVectorImpl<unsigned>::iterator I = Defs.begin(), E = Defs.end();
596-
I != E; ++I) {
595+
for (unsigned I : Defs) {
597596
// Follow the def-use chain for this DPR through COPYs, and also through
598597
// PHIs (which are essentially multi-way COPYs). It is because of PHIs that
599598
// we can end up with multiple defs of this DPR.
600599

601600
SmallVector<MachineInstr *, 8> DefSrcs;
602-
if (!Register::isVirtualRegister(*I))
601+
if (!Register::isVirtualRegister(I))
603602
continue;
604-
MachineInstr *Def = MRI->getVRegDef(*I);
603+
MachineInstr *Def = MRI->getVRegDef(I);
605604
if (!Def)
606605
continue;
607606

@@ -628,18 +627,17 @@ bool A15SDOptimizer::runOnInstruction(MachineInstr *MI) {
628627

629628
if (NewReg != 0) {
630629
Modified = true;
631-
for (SmallVectorImpl<MachineOperand *>::const_iterator I = Uses.begin(),
632-
E = Uses.end(); I != E; ++I) {
630+
for (MachineOperand *Use : Uses) {
633631
// Make sure to constrain the register class of the new register to
634632
// match what we're replacing. Otherwise we can optimize a DPR_VFP2
635633
// reference into a plain DPR, and that will end poorly. NewReg is
636634
// always virtual here, so there will always be a matching subclass
637635
// to find.
638-
MRI->constrainRegClass(NewReg, MRI->getRegClass((*I)->getReg()));
636+
MRI->constrainRegClass(NewReg, MRI->getRegClass(Use->getReg()));
639637

640-
LLVM_DEBUG(dbgs() << "Replacing operand " << **I << " with "
638+
LLVM_DEBUG(dbgs() << "Replacing operand " << *Use << " with "
641639
<< printReg(NewReg) << "\n");
642-
(*I)->substVirtReg(NewReg, 0, *TRI);
640+
Use->substVirtReg(NewReg, 0, *TRI);
643641
}
644642
}
645643
Replacements[MI] = NewReg;

llvm/lib/Target/ARM/ARMCallingConv.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,9 @@ static bool CC_ARM_AAPCS_Custom_Aggregate(unsigned ValNo, MVT ValVT,
230230

231231
unsigned RegResult = State.AllocateRegBlock(RegList, PendingMembers.size());
232232
if (RegResult) {
233-
for (SmallVectorImpl<CCValAssign>::iterator It = PendingMembers.begin();
234-
It != PendingMembers.end(); ++It) {
235-
It->convertToReg(RegResult);
236-
State.addLoc(*It);
233+
for (CCValAssign &PendingMember : PendingMembers) {
234+
PendingMember.convertToReg(RegResult);
235+
State.addLoc(PendingMember);
237236
++RegResult;
238237
}
239238
PendingMembers.clear();

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ void ARMConstantIslands::verify() {
310310
BBInfo[RHS.getNumber()].postOffset();
311311
}));
312312
LLVM_DEBUG(dbgs() << "Verifying " << CPUsers.size() << " CP users.\n");
313-
for (unsigned i = 0, e = CPUsers.size(); i != e; ++i) {
314-
CPUser &U = CPUsers[i];
313+
for (CPUser &U : CPUsers) {
315314
unsigned UserOffset = getUserOffset(U);
316315
// Verify offset using the real max displacement without the safety
317316
// adjustment.
@@ -697,10 +696,9 @@ ARMConstantIslands::findConstPoolEntry(unsigned CPI,
697696
std::vector<CPEntry> &CPEs = CPEntries[CPI];
698697
// Number of entries per constpool index should be small, just do a
699698
// linear search.
700-
for (unsigned i = 0, e = CPEs.size(); i != e; ++i) {
701-
if (CPEs[i].CPEMI == CPEMI)
702-
return &CPEs[i];
703-
}
699+
for (CPEntry &CPE : CPEs)
700+
if (CPE.CPEMI == CPEMI)
701+
return &CPE;
704702
return nullptr;
705703
}
706704

@@ -1234,27 +1232,27 @@ int ARMConstantIslands::findInRangeCPEntry(CPUser& U, unsigned UserOffset) {
12341232
// No. Look for previously created clones of the CPE that are in range.
12351233
unsigned CPI = getCombinedIndex(CPEMI);
12361234
std::vector<CPEntry> &CPEs = CPEntries[CPI];
1237-
for (unsigned i = 0, e = CPEs.size(); i != e; ++i) {
1235+
for (CPEntry &CPE : CPEs) {
12381236
// We already tried this one
1239-
if (CPEs[i].CPEMI == CPEMI)
1237+
if (CPE.CPEMI == CPEMI)
12401238
continue;
12411239
// Removing CPEs can leave empty entries, skip
1242-
if (CPEs[i].CPEMI == nullptr)
1240+
if (CPE.CPEMI == nullptr)
12431241
continue;
1244-
if (isCPEntryInRange(UserMI, UserOffset, CPEs[i].CPEMI, U.getMaxDisp(),
1245-
U.NegOk)) {
1246-
LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#"
1247-
<< CPEs[i].CPI << "\n");
1242+
if (isCPEntryInRange(UserMI, UserOffset, CPE.CPEMI, U.getMaxDisp(),
1243+
U.NegOk)) {
1244+
LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" << CPE.CPI
1245+
<< "\n");
12481246
// Point the CPUser node to the replacement
1249-
U.CPEMI = CPEs[i].CPEMI;
1247+
U.CPEMI = CPE.CPEMI;
12501248
// Change the CPI in the instruction operand to refer to the clone.
12511249
for (MachineOperand &MO : UserMI->operands())
12521250
if (MO.isCPI()) {
1253-
MO.setIndex(CPEs[i].CPI);
1251+
MO.setIndex(CPE.CPI);
12541252
break;
12551253
}
12561254
// Adjust the refcount of the clone...
1257-
CPEs[i].RefCount++;
1255+
CPE.RefCount++;
12581256
// ...and the original. If we didn't remove the old entry, none of the
12591257
// addresses changed, so we don't need another pass.
12601258
return decrementCPEReferenceCount(CPI, CPEMI) ? 2 : 1;
@@ -1675,15 +1673,14 @@ void ARMConstantIslands::removeDeadCPEMI(MachineInstr *CPEMI) {
16751673
/// are zero.
16761674
bool ARMConstantIslands::removeUnusedCPEntries() {
16771675
unsigned MadeChange = false;
1678-
for (unsigned i = 0, e = CPEntries.size(); i != e; ++i) {
1679-
std::vector<CPEntry> &CPEs = CPEntries[i];
1680-
for (unsigned j = 0, ee = CPEs.size(); j != ee; ++j) {
1681-
if (CPEs[j].RefCount == 0 && CPEs[j].CPEMI) {
1682-
removeDeadCPEMI(CPEs[j].CPEMI);
1683-
CPEs[j].CPEMI = nullptr;
1684-
MadeChange = true;
1685-
}
1676+
for (std::vector<CPEntry> &CPEs : CPEntries) {
1677+
for (CPEntry &CPE : CPEs) {
1678+
if (CPE.RefCount == 0 && CPE.CPEMI) {
1679+
removeDeadCPEMI(CPE.CPEMI);
1680+
CPE.CPEMI = nullptr;
1681+
MadeChange = true;
16861682
}
1683+
}
16871684
}
16881685
return MadeChange;
16891686
}
@@ -1829,8 +1826,7 @@ bool ARMConstantIslands::optimizeThumb2Instructions() {
18291826
bool MadeChange = false;
18301827

18311828
// Shrink ADR and LDR from constantpool.
1832-
for (unsigned i = 0, e = CPUsers.size(); i != e; ++i) {
1833-
CPUser &U = CPUsers[i];
1829+
for (CPUser &U : CPUsers) {
18341830
unsigned Opcode = U.MI->getOpcode();
18351831
unsigned NewOpc = 0;
18361832
unsigned Scale = 1;

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8400,9 +8400,8 @@ static SDValue LowerVECTOR_SHUFFLEv8i8(SDValue Op,
84008400
SDLoc DL(Op);
84018401

84028402
SmallVector<SDValue, 8> VTBLMask;
8403-
for (ArrayRef<int>::iterator
8404-
I = ShuffleMask.begin(), E = ShuffleMask.end(); I != E; ++I)
8405-
VTBLMask.push_back(DAG.getConstant(*I, DL, MVT::i32));
8403+
for (int I : ShuffleMask)
8404+
VTBLMask.push_back(DAG.getConstant(I, DL, MVT::i32));
84068405

84078406
if (V2.getNode()->isUndef())
84088407
return DAG.getNode(ARMISD::VTBL1, DL, MVT::v8i8, V1,
@@ -10682,25 +10681,23 @@ void ARMTargetLowering::EmitSjLjDispatchBlock(MachineInstr &MI,
1068210681
// associated with.
1068310682
DenseMap<unsigned, SmallVector<MachineBasicBlock*, 2>> CallSiteNumToLPad;
1068410683
unsigned MaxCSNum = 0;
10685-
for (MachineFunction::iterator BB = MF->begin(), E = MF->end(); BB != E;
10686-
++BB) {
10687-
if (!BB->isEHPad()) continue;
10684+
for (MachineBasicBlock &BB : *MF) {
10685+
if (!BB.isEHPad())
10686+
continue;
1068810687

1068910688
// FIXME: We should assert that the EH_LABEL is the first MI in the landing
1069010689
// pad.
10691-
for (MachineBasicBlock::iterator
10692-
II = BB->begin(), IE = BB->end(); II != IE; ++II) {
10693-
if (!II->isEHLabel()) continue;
10690+
for (MachineInstr &II : BB) {
10691+
if (!II.isEHLabel())
10692+
continue;
1069410693

10695-
MCSymbol *Sym = II->getOperand(0).getMCSymbol();
10694+
MCSymbol *Sym = II.getOperand(0).getMCSymbol();
1069610695
if (!MF->hasCallSiteLandingPad(Sym)) continue;
1069710696

1069810697
SmallVectorImpl<unsigned> &CallSiteIdxs = MF->getCallSiteLandingPad(Sym);
10699-
for (SmallVectorImpl<unsigned>::iterator
10700-
CSI = CallSiteIdxs.begin(), CSE = CallSiteIdxs.end();
10701-
CSI != CSE; ++CSI) {
10702-
CallSiteNumToLPad[*CSI].push_back(&*BB);
10703-
MaxCSNum = std::max(MaxCSNum, *CSI);
10698+
for (unsigned Idx : CallSiteIdxs) {
10699+
CallSiteNumToLPad[Idx].push_back(&BB);
10700+
MaxCSNum = std::max(MaxCSNum, Idx);
1070410701
}
1070510702
break;
1070610703
}

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,8 +1328,8 @@ bool ARMLowOverheadLoops::ProcessLoop(MachineLoop *ML) {
13281328
bool Changed = false;
13291329

13301330
// Process inner loops first.
1331-
for (auto I = ML->begin(), E = ML->end(); I != E; ++I)
1332-
Changed |= ProcessLoop(*I);
1331+
for (MachineLoop *L : *ML)
1332+
Changed |= ProcessLoop(L);
13331333

13341334
LLVM_DEBUG({
13351335
dbgs() << "ARM Loops: Processing loop containing:\n";

0 commit comments

Comments
 (0)