Skip to content

Commit 58c9378

Browse files
rebase
Created using spr 1.3.7
2 parents 58890f9 + d4c8cfe commit 58c9378

File tree

59 files changed

+7950
-7885
lines changed

Some content is hidden

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

59 files changed

+7950
-7885
lines changed

lldb/bindings/python/python-typemaps.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

lldb/bindings/python/python-typemaps.swig

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ AND call SWIG_fail at the same time, because it will result in a double free.
66
77
*/
88

9-
%inline %{
10-
11-
#include "../bindings/python/python-typemaps.h"
12-
13-
%}
14-
159
%typemap(in) char ** {
1610
/* Check if is a list */
1711
if (PythonList::Check($input)) {
@@ -634,12 +628,21 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
634628
}
635629
}
636630

637-
// These two pybuffer macros are copied out of swig/Lib/python/pybuffer.i,
631+
#if SWIG_VERSION < 0x040100
632+
// The two pybuffer macros below are copied out of swig/Lib/python/pybuffer.i,
638633
// and fixed so they will not crash if PyObject_GetBuffer fails.
639634
// https://github.com/swig/swig/issues/1640
640-
//
641-
// I've also moved the call to PyBuffer_Release to the end of the SWIG wrapper,
642-
// doing it right away is not legal according to the python buffer protocol.
635+
636+
struct Py_buffer_RAII {
637+
Py_buffer buffer = {};
638+
Py_buffer_RAII(){};
639+
Py_buffer &operator=(const Py_buffer_RAII &) = delete;
640+
Py_buffer_RAII(const Py_buffer_RAII &) = delete;
641+
~Py_buffer_RAII() {
642+
if (buffer.obj)
643+
PyBuffer_Release(&buffer);
644+
}
645+
};
643646

644647
%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
645648
%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
@@ -674,6 +677,9 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
674677
$2 = ($2_ltype)(size / sizeof($*1_type));
675678
}
676679
%enddef
680+
#else
681+
%include <pybuffer.i>
682+
#endif
677683

678684
%pybuffer_binary(const uint8_t *buf, size_t num_bytes);
679685
%pybuffer_mutable_binary(uint8_t *buf, size_t num_bytes);

llvm/include/llvm/CodeGen/MachineTraceMetrics.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ class TargetRegisterInfo;
7373
// direction instructions are scanned, it could be the operand that defined the
7474
// regunit, or the highest operand to read the regunit.
7575
struct LiveRegUnit {
76-
unsigned RegUnit;
76+
MCRegUnit RegUnit;
7777
unsigned Cycle = 0;
7878
const MachineInstr *MI = nullptr;
7979
unsigned Op = 0;
8080

8181
unsigned getSparseSetIndex() const { return RegUnit; }
8282

83-
LiveRegUnit(unsigned RU) : RegUnit(RU) {}
83+
explicit LiveRegUnit(MCRegUnit RU) : RegUnit(RU) {}
8484
};
8585

8686
using LiveRegUnitSet = SparseSet<LiveRegUnit>;
@@ -158,13 +158,14 @@ class MachineTraceMetrics {
158158
/// successors.
159159
struct LiveInReg {
160160
/// The virtual register required, or a register unit.
161-
Register Reg;
161+
VirtRegOrUnit VRegOrUnit;
162162

163163
/// For virtual registers: Minimum height of the defining instruction.
164164
/// For regunits: Height of the highest user in the trace.
165165
unsigned Height;
166166

167-
LiveInReg(Register Reg, unsigned Height = 0) : Reg(Reg), Height(Height) {}
167+
explicit LiveInReg(VirtRegOrUnit VRegOrUnit, unsigned Height = 0)
168+
: VRegOrUnit(VRegOrUnit), Height(Height) {}
168169
};
169170

170171
/// Per-basic block information that relates to a specific trace through the

llvm/lib/CodeGen/MachineTraceMetrics.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,10 @@ computeCrossBlockCriticalPath(const TraceBlockInfo &TBI) {
800800
assert(TBI.HasValidInstrHeights && "Missing height info");
801801
unsigned MaxLen = 0;
802802
for (const LiveInReg &LIR : TBI.LiveIns) {
803-
if (!LIR.Reg.isVirtual())
803+
if (!LIR.VRegOrUnit.isVirtualReg())
804804
continue;
805-
const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
805+
const MachineInstr *DefMI =
806+
MTM.MRI->getVRegDef(LIR.VRegOrUnit.asVirtualReg());
806807
// Ignore dependencies outside the current trace.
807808
const TraceBlockInfo &DefTBI = BlockInfo[DefMI->getParent()->getNumber()];
808809
if (!DefTBI.isUsefulDominator(TBI))
@@ -1019,7 +1020,7 @@ addLiveIns(const MachineInstr *DefMI, unsigned DefOp,
10191020
return;
10201021
TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
10211022
// Just add the register. The height will be updated later.
1022-
TBI.LiveIns.push_back(Reg);
1023+
TBI.LiveIns.emplace_back(VirtRegOrUnit(Reg));
10231024
}
10241025
}
10251026

@@ -1056,15 +1057,16 @@ computeInstrHeights(const MachineBasicBlock *MBB) {
10561057
if (MBB) {
10571058
TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
10581059
for (LiveInReg &LI : TBI.LiveIns) {
1059-
if (LI.Reg.isVirtual()) {
1060+
if (LI.VRegOrUnit.isVirtualReg()) {
10601061
// For virtual registers, the def latency is included.
1061-
unsigned &Height = Heights[MTM.MRI->getVRegDef(LI.Reg)];
1062+
unsigned &Height =
1063+
Heights[MTM.MRI->getVRegDef(LI.VRegOrUnit.asVirtualReg())];
10621064
if (Height < LI.Height)
10631065
Height = LI.Height;
10641066
} else {
10651067
// For register units, the def latency is not included because we don't
10661068
// know the def yet.
1067-
RegUnits[LI.Reg.id()].Cycle = LI.Height;
1069+
RegUnits[LI.VRegOrUnit.asMCRegUnit()].Cycle = LI.Height;
10681070
}
10691071
}
10701072
}
@@ -1159,14 +1161,15 @@ computeInstrHeights(const MachineBasicBlock *MBB) {
11591161
// height because the final height isn't known until now.
11601162
LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " Live-ins:");
11611163
for (LiveInReg &LIR : TBI.LiveIns) {
1162-
const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
1164+
Register Reg = LIR.VRegOrUnit.asVirtualReg();
1165+
const MachineInstr *DefMI = MTM.MRI->getVRegDef(Reg);
11631166
LIR.Height = Heights.lookup(DefMI);
1164-
LLVM_DEBUG(dbgs() << ' ' << printReg(LIR.Reg) << '@' << LIR.Height);
1167+
LLVM_DEBUG(dbgs() << ' ' << printReg(Reg) << '@' << LIR.Height);
11651168
}
11661169

11671170
// Transfer the live regunits to the live-in list.
11681171
for (const LiveRegUnit &RU : RegUnits) {
1169-
TBI.LiveIns.push_back(LiveInReg(RU.RegUnit, RU.Cycle));
1172+
TBI.LiveIns.emplace_back(VirtRegOrUnit(RU.RegUnit), RU.Cycle);
11701173
LLVM_DEBUG(dbgs() << ' ' << printRegUnit(RU.RegUnit, MTM.TRI) << '@'
11711174
<< RU.Cycle);
11721175
}

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29031,9 +29031,9 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDValue LHS,
2903129031
// over-conservative. It would be beneficial to be able to remember
2903229032
// both potential memory locations. Since we are discarding
2903329033
// src value info, don't do the transformation if the memory
29034-
// locations are not in the default address space.
29035-
LLD->getPointerInfo().getAddrSpace() != 0 ||
29036-
RLD->getPointerInfo().getAddrSpace() != 0 ||
29034+
// locations are not in the same address space.
29035+
LLD->getPointerInfo().getAddrSpace() !=
29036+
RLD->getPointerInfo().getAddrSpace() ||
2903729037
// We can't produce a CMOV of a TargetFrameIndex since we won't
2903829038
// generate the address generation required.
2903929039
LLD->getBasePtr().getOpcode() == ISD::TargetFrameIndex ||
@@ -29115,6 +29115,9 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDValue LHS,
2911529115
// but the new load must be the minimum (most restrictive) alignment of the
2911629116
// inputs.
2911729117
Align Alignment = std::min(LLD->getAlign(), RLD->getAlign());
29118+
unsigned AddrSpace = LLD->getAddressSpace();
29119+
assert(AddrSpace == RLD->getAddressSpace());
29120+
2911829121
MachineMemOperand::Flags MMOFlags = LLD->getMemOperand()->getFlags();
2911929122
if (!RLD->isInvariant())
2912029123
MMOFlags &= ~MachineMemOperand::MOInvariant;
@@ -29123,15 +29126,16 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDValue LHS,
2912329126
if (LLD->getExtensionType() == ISD::NON_EXTLOAD) {
2912429127
// FIXME: Discards pointer and AA info.
2912529128
Load = DAG.getLoad(TheSelect->getValueType(0), SDLoc(TheSelect),
29126-
LLD->getChain(), Addr, MachinePointerInfo(), Alignment,
29127-
MMOFlags);
29129+
LLD->getChain(), Addr, MachinePointerInfo(AddrSpace),
29130+
Alignment, MMOFlags);
2912829131
} else {
2912929132
// FIXME: Discards pointer and AA info.
2913029133
Load = DAG.getExtLoad(
2913129134
LLD->getExtensionType() == ISD::EXTLOAD ? RLD->getExtensionType()
2913229135
: LLD->getExtensionType(),
2913329136
SDLoc(TheSelect), TheSelect->getValueType(0), LLD->getChain(), Addr,
29134-
MachinePointerInfo(), LLD->getMemoryVT(), Alignment, MMOFlags);
29137+
MachinePointerInfo(AddrSpace), LLD->getMemoryVT(), Alignment,
29138+
MMOFlags);
2913529139
}
2913629140

2913729141
// Users of the select now use the result of the load.

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18770,8 +18770,11 @@ SITargetLowering::getRegClassFor(MVT VT, bool isDivergent) const {
1877018770
: &AMDGPU::SReg_32RegClass;
1877118771
if (!TRI->isSGPRClass(RC) && !isDivergent)
1877218772
return TRI->getEquivalentSGPRClass(RC);
18773-
if (TRI->isSGPRClass(RC) && isDivergent)
18773+
if (TRI->isSGPRClass(RC) && isDivergent) {
18774+
if (Subtarget->hasGFX90AInsts())
18775+
return TRI->getEquivalentAVClass(RC);
1877418776
return TRI->getEquivalentVGPRClass(RC);
18777+
}
1877518778

1877618779
return RC;
1877718780
}

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,6 +3640,14 @@ SIRegisterInfo::getEquivalentAGPRClass(const TargetRegisterClass *SRC) const {
36403640
return ARC;
36413641
}
36423642

3643+
const TargetRegisterClass *
3644+
SIRegisterInfo::getEquivalentAVClass(const TargetRegisterClass *SRC) const {
3645+
unsigned Size = getRegSizeInBits(*SRC);
3646+
const TargetRegisterClass *ARC = getVectorSuperClassForBitWidth(Size);
3647+
assert(ARC && "Invalid register class size");
3648+
return ARC;
3649+
}
3650+
36433651
const TargetRegisterClass *
36443652
SIRegisterInfo::getEquivalentSGPRClass(const TargetRegisterClass *VRC) const {
36453653
unsigned Size = getRegSizeInBits(*VRC);

llvm/lib/Target/AMDGPU/SIRegisterInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo {
289289
const TargetRegisterClass *
290290
getEquivalentAGPRClass(const TargetRegisterClass *SRC) const;
291291

292+
/// \returns An AGPR+VGPR super reg class with the same width as \p SRC
293+
const TargetRegisterClass *
294+
getEquivalentAVClass(const TargetRegisterClass *SRC) const;
295+
292296
/// \returns A SGPR reg class with the same width as \p SRC
293297
const TargetRegisterClass *
294298
getEquivalentSGPRClass(const TargetRegisterClass *VRC) const;

0 commit comments

Comments
 (0)