2008-12-09 01:50:35 +08:00
|
|
|
//===---- ScheduleDAGInstrs.cpp - MachineInstr Rescheduling ---------------===//
|
2008-11-20 07:18:57 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2017-01-28 02:53:00 +08:00
|
|
|
/// \file This implements the ScheduleDAGInstrs class, which implements
|
|
|
|
/// re-scheduling of MachineInstrs.
|
2008-11-20 07:18:57 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/CodeGen/ScheduleDAGInstrs.h"
|
2015-12-04 09:51:19 +08:00
|
|
|
#include "llvm/ADT/IntEqClasses.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
|
|
|
#include "llvm/ADT/SmallSet.h"
|
2009-01-30 10:49:14 +08:00
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
2010-12-16 04:02:24 +08:00
|
|
|
#include "llvm/Analysis/ValueTracking.h"
|
2016-01-20 08:23:32 +08:00
|
|
|
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
2008-12-16 11:25:46 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2015-05-09 07:52:00 +08:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2013-12-29 05:56:55 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2009-09-26 04:36:54 +08:00
|
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
2008-12-16 11:25:46 +08:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2008-12-04 09:35:46 +08:00
|
|
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
2012-06-07 03:47:35 +08:00
|
|
|
#include "llvm/CodeGen/RegisterPressure.h"
|
2012-11-28 13:13:24 +08:00
|
|
|
#include "llvm/CodeGen/ScheduleDFS.h"
|
2016-02-04 01:52:29 +08:00
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/Type.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Operator.h"
|
2012-05-16 02:59:41 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2008-11-20 07:18:57 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
2012-10-16 02:02:27 +08:00
|
|
|
#include "llvm/Support/Format.h"
|
2008-11-20 07:18:57 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
2013-08-24 01:48:43 +08:00
|
|
|
|
2008-11-20 07:18:57 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:02:50 +08:00
|
|
|
#define DEBUG_TYPE "misched"
|
|
|
|
|
2012-05-16 02:59:41 +08:00
|
|
|
static cl::opt<bool> EnableAASchedMI("enable-aa-sched-mi", cl::Hidden,
|
|
|
|
cl::ZeroOrMore, cl::init(false),
|
2015-01-07 21:20:57 +08:00
|
|
|
cl::desc("Enable use of AA during MI DAG construction"));
|
2012-05-16 02:59:41 +08:00
|
|
|
|
2014-01-26 03:24:54 +08:00
|
|
|
static cl::opt<bool> UseTBAA("use-tbaa-in-sched-mi", cl::Hidden,
|
2015-01-07 21:20:57 +08:00
|
|
|
cl::init(true), cl::desc("Enable use of TBAA during MI DAG construction"));
|
2014-01-26 03:24:54 +08:00
|
|
|
|
2016-02-04 01:52:29 +08:00
|
|
|
// Note: the two options below might be used in tuning compile time vs
|
|
|
|
// output quality. Setting HugeRegion so large that it will never be
|
|
|
|
// reached means best-effort, but may be slow.
|
|
|
|
|
|
|
|
// When Stores and Loads maps (or NonAliasStores and NonAliasLoads)
|
|
|
|
// together hold this many SUs, a reduction of maps will be done.
|
|
|
|
static cl::opt<unsigned> HugeRegion("dag-maps-huge-region", cl::Hidden,
|
|
|
|
cl::init(1000), cl::desc("The limit to use while constructing the DAG "
|
|
|
|
"prior to scheduling, at which point a trade-off "
|
|
|
|
"is made to avoid excessive compile time."));
|
|
|
|
|
2016-04-16 12:58:30 +08:00
|
|
|
static cl::opt<unsigned> ReductionSize(
|
|
|
|
"dag-maps-reduction-size", cl::Hidden,
|
2016-02-04 01:52:29 +08:00
|
|
|
cl::desc("A huge scheduling region will have maps reduced by this many "
|
2016-04-16 12:58:30 +08:00
|
|
|
"nodes at a time. Defaults to HugeRegion / 2."));
|
|
|
|
|
|
|
|
static unsigned getReductionSize() {
|
|
|
|
// Always reduce a huge region with half of the elements, except
|
|
|
|
// when user sets this number explicitly.
|
|
|
|
if (ReductionSize.getNumOccurrences() == 0)
|
|
|
|
return HugeRegion / 2;
|
|
|
|
return ReductionSize;
|
|
|
|
}
|
2016-02-04 01:52:29 +08:00
|
|
|
|
|
|
|
static void dumpSUList(ScheduleDAGInstrs::SUList &L) {
|
|
|
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
|
|
|
dbgs() << "{ ";
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const SUnit *su : L) {
|
2016-02-04 01:52:29 +08:00
|
|
|
dbgs() << "SU(" << su->NodeNum << ")";
|
|
|
|
if (su != L.back())
|
|
|
|
dbgs() << ", ";
|
|
|
|
}
|
|
|
|
dbgs() << "}\n";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-01-16 03:20:50 +08:00
|
|
|
ScheduleDAGInstrs::ScheduleDAGInstrs(MachineFunction &mf,
|
2014-08-21 03:36:05 +08:00
|
|
|
const MachineLoopInfo *mli,
|
2015-11-03 09:53:29 +08:00
|
|
|
bool RemoveKillFlags)
|
2015-12-05 03:54:24 +08:00
|
|
|
: ScheduleDAG(mf), MLI(mli), MFI(mf.getFrameInfo()),
|
2015-11-03 09:53:29 +08:00
|
|
|
RemoveKillFlags(RemoveKillFlags), CanHandleTerminators(false),
|
2016-02-04 01:52:29 +08:00
|
|
|
TrackLaneMasks(false), AAForDep(nullptr), BarrierChain(nullptr),
|
|
|
|
UnknownValue(UndefValue::get(
|
|
|
|
Type::getVoidTy(mf.getFunction()->getContext()))),
|
|
|
|
FirstDbgValue(nullptr) {
|
2011-06-03 04:07:12 +08:00
|
|
|
DbgValues.clear();
|
2012-09-19 02:20:00 +08:00
|
|
|
|
2015-01-27 15:54:39 +08:00
|
|
|
const TargetSubtargetInfo &ST = mf.getSubtarget();
|
2014-09-03 01:43:54 +08:00
|
|
|
SchedModel.init(ST.getSchedModel(), &ST, TII);
|
2009-10-19 03:58:47 +08:00
|
|
|
}
|
2008-11-20 07:18:57 +08:00
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// This is the function that does the work of looking through basic
|
|
|
|
/// ptrtoint+arithmetic+inttoptr sequences.
|
2009-01-30 10:49:14 +08:00
|
|
|
static const Value *getUnderlyingObjectFromInt(const Value *V) {
|
|
|
|
do {
|
2009-07-18 04:58:59 +08:00
|
|
|
if (const Operator *U = dyn_cast<Operator>(V)) {
|
2009-01-30 10:49:14 +08:00
|
|
|
// If we find a ptrtoint, we can transfer control back to the
|
|
|
|
// regular getUnderlyingObjectFromInt.
|
2009-07-18 04:58:59 +08:00
|
|
|
if (U->getOpcode() == Instruction::PtrToInt)
|
2009-01-30 10:49:14 +08:00
|
|
|
return U->getOperand(0);
|
2012-11-28 11:42:49 +08:00
|
|
|
// If we find an add of a constant, a multiplied value, or a phi, it's
|
2009-01-30 10:49:14 +08:00
|
|
|
// likely that the other operand will lead us to the base
|
|
|
|
// object. We don't have to worry about the case where the
|
2009-08-07 09:26:06 +08:00
|
|
|
// object address is somehow being computed by the multiply,
|
2009-01-30 10:49:14 +08:00
|
|
|
// because our callers only care when the result is an
|
2012-10-26 12:27:49 +08:00
|
|
|
// identifiable object.
|
2009-07-18 04:58:59 +08:00
|
|
|
if (U->getOpcode() != Instruction::Add ||
|
2009-01-30 10:49:14 +08:00
|
|
|
(!isa<ConstantInt>(U->getOperand(1)) &&
|
2012-11-28 11:42:49 +08:00
|
|
|
Operator::getOpcode(U->getOperand(1)) != Instruction::Mul &&
|
|
|
|
!isa<PHINode>(U->getOperand(1))))
|
2009-01-30 10:49:14 +08:00
|
|
|
return V;
|
|
|
|
V = U->getOperand(0);
|
|
|
|
} else {
|
|
|
|
return V;
|
|
|
|
}
|
2010-02-16 19:11:14 +08:00
|
|
|
assert(V->getType()->isIntegerTy() && "Unexpected operand type!");
|
2009-01-30 10:49:14 +08:00
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// This is a wrapper around GetUnderlyingObjects and adds support for basic
|
|
|
|
/// ptrtoint+arithmetic+inttoptr sequences.
|
2012-12-11 02:49:16 +08:00
|
|
|
static void getUnderlyingObjects(const Value *V,
|
2015-03-10 10:37:25 +08:00
|
|
|
SmallVectorImpl<Value *> &Objects,
|
|
|
|
const DataLayout &DL) {
|
2014-04-15 15:22:52 +08:00
|
|
|
SmallPtrSet<const Value *, 16> Visited;
|
2012-12-11 02:49:16 +08:00
|
|
|
SmallVector<const Value *, 4> Working(1, V);
|
2009-01-30 10:49:14 +08:00
|
|
|
do {
|
2012-12-11 02:49:16 +08:00
|
|
|
V = Working.pop_back_val();
|
|
|
|
|
|
|
|
SmallVector<Value *, 4> Objs;
|
2015-03-10 10:37:25 +08:00
|
|
|
GetUnderlyingObjects(const_cast<Value *>(V), Objs, DL);
|
2012-12-11 02:49:16 +08:00
|
|
|
|
2016-10-01 07:08:07 +08:00
|
|
|
for (Value *V : Objs) {
|
2014-11-19 15:49:26 +08:00
|
|
|
if (!Visited.insert(V).second)
|
2012-12-11 02:49:16 +08:00
|
|
|
continue;
|
|
|
|
if (Operator::getOpcode(V) == Instruction::IntToPtr) {
|
|
|
|
const Value *O =
|
|
|
|
getUnderlyingObjectFromInt(cast<User>(V)->getOperand(0));
|
|
|
|
if (O->getType()->isPointerTy()) {
|
|
|
|
Working.push_back(O);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Objects.push_back(const_cast<Value *>(V));
|
|
|
|
}
|
|
|
|
} while (!Working.empty());
|
2009-01-30 10:49:14 +08:00
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// If this machine instr has memory reference information and it can be tracked
|
|
|
|
/// to a normal reference to a known object, return the Value for that object.
|
2012-12-11 02:49:16 +08:00
|
|
|
static void getUnderlyingObjectsForInstr(const MachineInstr *MI,
|
2016-07-29 02:40:00 +08:00
|
|
|
const MachineFrameInfo &MFI,
|
2015-03-10 10:37:25 +08:00
|
|
|
UnderlyingObjectsVector &Objects,
|
|
|
|
const DataLayout &DL) {
|
2016-04-15 05:31:07 +08:00
|
|
|
auto allMMOsOkay = [&]() {
|
|
|
|
for (const MachineMemOperand *MMO : MI->memoperands()) {
|
|
|
|
if (MMO->isVolatile())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (const PseudoSourceValue *PSV = MMO->getPseudoValue()) {
|
|
|
|
// Function that contain tail calls don't have unique PseudoSourceValue
|
|
|
|
// objects. Two PseudoSourceValues might refer to the same or
|
|
|
|
// overlapping locations. The client code calling this function assumes
|
|
|
|
// this is not the case. So return a conservative answer of no known
|
|
|
|
// object.
|
2016-07-29 02:40:00 +08:00
|
|
|
if (MFI.hasTailCall())
|
2016-04-15 05:31:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// For now, ignore PseudoSourceValues which may alias LLVM IR values
|
|
|
|
// because the code that uses this function has no way to cope with
|
|
|
|
// such aliases.
|
2016-07-29 02:40:00 +08:00
|
|
|
if (PSV->isAliased(&MFI))
|
2016-04-15 05:31:07 +08:00
|
|
|
return false;
|
|
|
|
|
2016-07-29 02:40:00 +08:00
|
|
|
bool MayAlias = PSV->mayAlias(&MFI);
|
2016-04-15 05:31:07 +08:00
|
|
|
Objects.push_back(UnderlyingObjectsVector::value_type(PSV, MayAlias));
|
|
|
|
} else if (const Value *V = MMO->getValue()) {
|
|
|
|
SmallVector<Value *, 4> Objs;
|
|
|
|
getUnderlyingObjects(V, Objs, DL);
|
|
|
|
|
|
|
|
for (Value *V : Objs) {
|
|
|
|
if (!isIdentifiedObject(V))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Objects.push_back(UnderlyingObjectsVector::value_type(V, true));
|
2016-04-12 23:50:19 +08:00
|
|
|
}
|
2016-04-15 05:31:07 +08:00
|
|
|
} else
|
|
|
|
return false;
|
2012-12-11 02:49:16 +08:00
|
|
|
}
|
2016-04-15 05:31:07 +08:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!allMMOsOkay())
|
|
|
|
Objects.clear();
|
2009-01-30 10:49:14 +08:00
|
|
|
}
|
|
|
|
|
2012-04-21 04:05:21 +08:00
|
|
|
void ScheduleDAGInstrs::startBlock(MachineBasicBlock *bb) {
|
|
|
|
BB = bb;
|
2009-02-11 07:27:53 +08:00
|
|
|
}
|
|
|
|
|
2012-03-08 07:00:49 +08:00
|
|
|
void ScheduleDAGInstrs::finishBlock() {
|
2012-04-21 04:24:33 +08:00
|
|
|
// Subclasses should no longer refer to the old block.
|
2014-04-14 08:51:57 +08:00
|
|
|
BB = nullptr;
|
2012-03-07 13:21:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::enterRegion(MachineBasicBlock *bb,
|
|
|
|
MachineBasicBlock::iterator begin,
|
|
|
|
MachineBasicBlock::iterator end,
|
2013-08-24 01:48:33 +08:00
|
|
|
unsigned regioninstrs) {
|
2012-04-21 04:05:21 +08:00
|
|
|
assert(bb == BB && "startBlock should set BB");
|
2012-03-09 12:29:02 +08:00
|
|
|
RegionBegin = begin;
|
|
|
|
RegionEnd = end;
|
2013-08-24 01:48:33 +08:00
|
|
|
NumRegionInstrs = regioninstrs;
|
2012-03-07 13:21:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::exitRegion() {
|
|
|
|
// Nothing to do.
|
|
|
|
}
|
|
|
|
|
2012-03-08 07:00:49 +08:00
|
|
|
void ScheduleDAGInstrs::addSchedBarrierDeps() {
|
2014-04-14 08:51:57 +08:00
|
|
|
MachineInstr *ExitMI = RegionEnd != BB->end() ? &*RegionEnd : nullptr;
|
2010-10-23 10:10:46 +08:00
|
|
|
ExitSU.setInstr(ExitMI);
|
2016-11-11 09:34:21 +08:00
|
|
|
// Add dependencies on the defs and uses of the instruction.
|
|
|
|
if (ExitMI) {
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const MachineOperand &MO : ExitMI->operands()) {
|
2010-10-23 10:10:46 +08:00
|
|
|
if (!MO.isReg() || MO.isDef()) continue;
|
|
|
|
unsigned Reg = MO.getReg();
|
2016-11-11 06:11:00 +08:00
|
|
|
if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
2013-01-22 02:18:53 +08:00
|
|
|
Uses.insert(PhysRegSUOper(&ExitSU, -1, Reg));
|
2016-11-11 06:11:00 +08:00
|
|
|
} else if (TargetRegisterInfo::isVirtualRegister(Reg) && MO.readsReg()) {
|
2016-10-01 07:08:07 +08:00
|
|
|
addVRegUseDeps(&ExitSU, ExitMI->getOperandNo(&MO));
|
2016-11-11 06:11:00 +08:00
|
|
|
}
|
2010-10-23 10:10:46 +08:00
|
|
|
}
|
2016-11-11 09:34:21 +08:00
|
|
|
}
|
|
|
|
if (!ExitMI || (!ExitMI->isCall() && !ExitMI->isBarrier())) {
|
2010-10-23 10:10:46 +08:00
|
|
|
// For others, e.g. fallthrough, conditional branch, assume the exit
|
2010-10-28 07:17:17 +08:00
|
|
|
// uses all the registers that are livein to the successor blocks.
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const MachineBasicBlock *Succ : BB->successors()) {
|
|
|
|
for (const auto &LI : Succ->liveins()) {
|
2015-09-10 02:08:03 +08:00
|
|
|
if (!Uses.contains(LI.PhysReg))
|
|
|
|
Uses.insert(PhysRegSUOper(&ExitSU, -1, LI.PhysReg));
|
2010-10-28 07:17:17 +08:00
|
|
|
}
|
2016-10-01 07:08:07 +08:00
|
|
|
}
|
2010-10-23 10:10:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// MO is an operand of SU's instruction that defines a physical register. Adds
|
2012-02-23 09:52:38 +08:00
|
|
|
/// data dependencies from SU to any uses of the physical register.
|
2012-08-23 08:39:43 +08:00
|
|
|
void ScheduleDAGInstrs::addPhysRegDataDeps(SUnit *SU, unsigned OperIdx) {
|
|
|
|
const MachineOperand &MO = SU->getInstr()->getOperand(OperIdx);
|
2012-02-23 09:52:38 +08:00
|
|
|
assert(MO.isDef() && "expect physreg def");
|
2012-01-14 10:17:15 +08:00
|
|
|
|
|
|
|
// Ask the target if address-backscheduling is desirable, and if so how much.
|
2015-01-27 15:54:39 +08:00
|
|
|
const TargetSubtargetInfo &ST = MF.getSubtarget();
|
2012-01-14 10:17:15 +08:00
|
|
|
|
2012-06-02 07:28:30 +08:00
|
|
|
for (MCRegAliasIterator Alias(MO.getReg(), TRI, true);
|
|
|
|
Alias.isValid(); ++Alias) {
|
2012-02-24 15:04:55 +08:00
|
|
|
if (!Uses.contains(*Alias))
|
2012-02-23 09:52:38 +08:00
|
|
|
continue;
|
2013-01-22 02:18:53 +08:00
|
|
|
for (Reg2SUnitsMap::iterator I = Uses.find(*Alias); I != Uses.end(); ++I) {
|
|
|
|
SUnit *UseSU = I->SU;
|
2012-01-14 10:17:15 +08:00
|
|
|
if (UseSU == SU)
|
|
|
|
continue;
|
2012-10-09 02:54:00 +08:00
|
|
|
|
|
|
|
// Adjust the dependence latency using operand def/use information,
|
|
|
|
// then allow the target to perform its own adjustments.
|
2013-01-22 02:18:53 +08:00
|
|
|
int UseOp = I->OpIdx;
|
2014-04-14 08:51:57 +08:00
|
|
|
MachineInstr *RegUse = nullptr;
|
2012-11-13 03:28:57 +08:00
|
|
|
SDep Dep;
|
|
|
|
if (UseOp < 0)
|
|
|
|
Dep = SDep(SU, SDep::Artificial);
|
|
|
|
else {
|
2013-04-13 14:07:40 +08:00
|
|
|
// Set the hasPhysRegDefs only for physreg defs that have a use within
|
|
|
|
// the scheduling region.
|
|
|
|
SU->hasPhysRegDefs = true;
|
2012-11-13 03:28:57 +08:00
|
|
|
Dep = SDep(SU, SDep::Data, *Alias);
|
|
|
|
RegUse = UseSU->getInstr();
|
|
|
|
}
|
|
|
|
Dep.setLatency(
|
2013-06-15 12:49:57 +08:00
|
|
|
SchedModel.computeOperandLatency(SU->getInstr(), OperIdx, RegUse,
|
|
|
|
UseOp));
|
2012-10-09 02:53:57 +08:00
|
|
|
|
2012-11-13 03:28:57 +08:00
|
|
|
ST.adjustSchedDependency(SU, UseSU, Dep);
|
|
|
|
UseSU->addPred(Dep);
|
2012-01-14 10:17:15 +08:00
|
|
|
}
|
2012-02-23 09:52:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// \brief Adds register dependencies (data, anti, and output) from this SUnit
|
|
|
|
/// to following instructions in the same scheduling region that depend the
|
|
|
|
/// physical register referenced at OperIdx.
|
2012-02-23 09:52:38 +08:00
|
|
|
void ScheduleDAGInstrs::addPhysRegDeps(SUnit *SU, unsigned OperIdx) {
|
2013-12-29 05:56:55 +08:00
|
|
|
MachineInstr *MI = SU->getInstr();
|
|
|
|
MachineOperand &MO = MI->getOperand(OperIdx);
|
2016-11-11 06:11:00 +08:00
|
|
|
unsigned Reg = MO.getReg();
|
2016-11-11 07:46:44 +08:00
|
|
|
// We do not need to track any dependencies for constant registers.
|
|
|
|
if (MRI.isConstantPhysReg(Reg))
|
|
|
|
return;
|
2012-02-23 09:52:38 +08:00
|
|
|
|
|
|
|
// Optionally add output and anti dependencies. For anti
|
|
|
|
// dependencies we use a latency of 0 because for a multi-issue
|
|
|
|
// target we want to allow the defining instruction to issue
|
|
|
|
// in the same cycle as the using instruction.
|
|
|
|
// TODO: Using a latency of 1 here for output dependencies assumes
|
|
|
|
// there's no cost for reusing registers.
|
|
|
|
SDep::Kind Kind = MO.isUse() ? SDep::Anti : SDep::Output;
|
2016-11-11 06:11:00 +08:00
|
|
|
for (MCRegAliasIterator Alias(Reg, TRI, true); Alias.isValid(); ++Alias) {
|
2012-02-24 15:04:55 +08:00
|
|
|
if (!Defs.contains(*Alias))
|
2012-02-23 09:52:38 +08:00
|
|
|
continue;
|
2013-01-22 02:18:53 +08:00
|
|
|
for (Reg2SUnitsMap::iterator I = Defs.find(*Alias); I != Defs.end(); ++I) {
|
|
|
|
SUnit *DefSU = I->SU;
|
2012-02-23 09:52:38 +08:00
|
|
|
if (DefSU == &ExitSU)
|
|
|
|
continue;
|
|
|
|
if (DefSU != SU &&
|
|
|
|
(Kind != SDep::Output || !MO.isDead() ||
|
2014-12-05 10:07:35 +08:00
|
|
|
!DefSU->getInstr()->registerDefIsDead(*Alias))) {
|
2012-02-23 09:52:38 +08:00
|
|
|
if (Kind == SDep::Anti)
|
2012-11-06 11:13:46 +08:00
|
|
|
DefSU->addPred(SDep(SU, Kind, /*Reg=*/*Alias));
|
2012-02-23 09:52:38 +08:00
|
|
|
else {
|
2012-11-06 11:13:46 +08:00
|
|
|
SDep Dep(SU, Kind, /*Reg=*/*Alias);
|
2013-06-15 12:49:57 +08:00
|
|
|
Dep.setLatency(
|
|
|
|
SchedModel.computeOutputLatency(MI, OperIdx, DefSU->getInstr()));
|
2012-11-06 11:13:46 +08:00
|
|
|
DefSU->addPred(Dep);
|
2012-01-14 10:17:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-23 09:52:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!MO.isDef()) {
|
2013-04-13 14:07:40 +08:00
|
|
|
SU->hasPhysRegUses = true;
|
2012-02-23 09:52:38 +08:00
|
|
|
// Either insert a new Reg2SUnits entry with an empty SUnits list, or
|
|
|
|
// retrieve the existing SUnits list for this register's uses.
|
|
|
|
// Push this SUnit on the use list.
|
2016-11-11 06:11:00 +08:00
|
|
|
Uses.insert(PhysRegSUOper(SU, OperIdx, Reg));
|
2013-12-29 05:56:55 +08:00
|
|
|
if (RemoveKillFlags)
|
|
|
|
MO.setIsKill(false);
|
2016-11-11 06:11:00 +08:00
|
|
|
} else {
|
2012-08-23 08:39:43 +08:00
|
|
|
addPhysRegDataDeps(SU, OperIdx);
|
2012-01-14 10:17:15 +08:00
|
|
|
|
2012-02-23 09:52:38 +08:00
|
|
|
// clear this register's use list
|
2013-01-22 02:18:53 +08:00
|
|
|
if (Uses.contains(Reg))
|
|
|
|
Uses.eraseAll(Reg);
|
|
|
|
|
|
|
|
if (!MO.isDead()) {
|
|
|
|
Defs.eraseAll(Reg);
|
|
|
|
} else if (SU->isCall) {
|
|
|
|
// Calls will not be reordered because of chain dependencies (see
|
|
|
|
// below). Since call operands are dead, calls may continue to be added
|
|
|
|
// to the DefList making dependence checking quadratic in the size of
|
|
|
|
// the block. Instead, we leave only one call at the back of the
|
|
|
|
// DefList.
|
|
|
|
Reg2SUnitsMap::RangePair P = Defs.equal_range(Reg);
|
|
|
|
Reg2SUnitsMap::iterator B = P.first;
|
|
|
|
Reg2SUnitsMap::iterator I = P.second;
|
|
|
|
for (bool isBegin = I == B; !isBegin; /* empty */) {
|
|
|
|
isBegin = (--I) == B;
|
|
|
|
if (!I->SU->isCall)
|
|
|
|
break;
|
|
|
|
I = Defs.erase(I);
|
|
|
|
}
|
2012-01-14 10:17:15 +08:00
|
|
|
}
|
2013-01-22 02:18:53 +08:00
|
|
|
|
2012-02-23 09:52:38 +08:00
|
|
|
// Defs are pushed in the order they are visited and never reordered.
|
2013-01-22 02:18:53 +08:00
|
|
|
Defs.insert(PhysRegSUOper(SU, OperIdx, Reg));
|
2012-01-14 10:17:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-04 09:51:19 +08:00
|
|
|
LaneBitmask ScheduleDAGInstrs::getLaneMaskForMO(const MachineOperand &MO) const
|
|
|
|
{
|
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
// No point in tracking lanemasks if we don't have interesting subregisters.
|
|
|
|
const TargetRegisterClass &RC = *MRI.getRegClass(Reg);
|
|
|
|
if (!RC.HasDisjunctSubRegs)
|
2016-12-15 22:36:06 +08:00
|
|
|
return LaneBitmask::getAll();
|
2015-12-04 09:51:19 +08:00
|
|
|
|
|
|
|
unsigned SubReg = MO.getSubReg();
|
|
|
|
if (SubReg == 0)
|
|
|
|
return RC.getLaneMask();
|
|
|
|
return TRI->getSubRegIndexLaneMask(SubReg);
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Adds register output and data dependencies from this SUnit to instructions
|
|
|
|
/// that occur later in the same scheduling region if they read from or write to
|
|
|
|
/// the virtual register defined at OperIdx.
|
2012-01-14 10:17:18 +08:00
|
|
|
///
|
|
|
|
/// TODO: Hoist loop induction variable increments. This has to be
|
|
|
|
/// reevaluated. Generally, IV scheduling should be done before coalescing.
|
|
|
|
void ScheduleDAGInstrs::addVRegDefDeps(SUnit *SU, unsigned OperIdx) {
|
2015-12-04 09:51:19 +08:00
|
|
|
MachineInstr *MI = SU->getInstr();
|
|
|
|
MachineOperand &MO = MI->getOperand(OperIdx);
|
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
|
|
|
|
LaneBitmask DefLaneMask;
|
|
|
|
LaneBitmask KillLaneMask;
|
|
|
|
if (TrackLaneMasks) {
|
|
|
|
bool IsKill = MO.getSubReg() == 0 || MO.isUndef();
|
|
|
|
DefLaneMask = getLaneMaskForMO(MO);
|
|
|
|
// If we have a <read-undef> flag, none of the lane values comes from an
|
|
|
|
// earlier instruction.
|
2016-12-15 22:36:06 +08:00
|
|
|
KillLaneMask = IsKill ? LaneBitmask::getAll() : DefLaneMask;
|
2015-12-04 09:51:19 +08:00
|
|
|
|
|
|
|
// Clear undef flag, we'll re-add it later once we know which subregister
|
|
|
|
// Def is first.
|
|
|
|
MO.setIsUndef(false);
|
|
|
|
} else {
|
2016-12-15 22:36:06 +08:00
|
|
|
DefLaneMask = LaneBitmask::getAll();
|
|
|
|
KillLaneMask = LaneBitmask::getAll();
|
2015-12-04 09:51:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (MO.isDead()) {
|
|
|
|
assert(CurrentVRegUses.find(Reg) == CurrentVRegUses.end() &&
|
|
|
|
"Dead defs should have no uses");
|
|
|
|
} else {
|
|
|
|
// Add data dependence to all uses we found so far.
|
|
|
|
const TargetSubtargetInfo &ST = MF.getSubtarget();
|
|
|
|
for (VReg2SUnitOperIdxMultiMap::iterator I = CurrentVRegUses.find(Reg),
|
|
|
|
E = CurrentVRegUses.end(); I != E; /*empty*/) {
|
|
|
|
LaneBitmask LaneMask = I->LaneMask;
|
|
|
|
// Ignore uses of other lanes.
|
2016-12-15 22:36:06 +08:00
|
|
|
if ((LaneMask & KillLaneMask).none()) {
|
2015-12-04 09:51:19 +08:00
|
|
|
++I;
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-14 10:17:18 +08:00
|
|
|
|
2016-12-17 03:11:56 +08:00
|
|
|
if ((LaneMask & DefLaneMask).any()) {
|
2015-12-04 09:51:19 +08:00
|
|
|
SUnit *UseSU = I->SU;
|
|
|
|
MachineInstr *Use = UseSU->getInstr();
|
|
|
|
SDep Dep(SU, SDep::Data, Reg);
|
|
|
|
Dep.setLatency(SchedModel.computeOperandLatency(MI, OperIdx, Use,
|
|
|
|
I->OperandIndex));
|
|
|
|
ST.adjustSchedDependency(SU, UseSU, Dep);
|
|
|
|
UseSU->addPred(Dep);
|
|
|
|
}
|
|
|
|
|
|
|
|
LaneMask &= ~KillLaneMask;
|
|
|
|
// If we found a Def for all lanes of this use, remove it from the list.
|
2016-12-17 03:11:56 +08:00
|
|
|
if (LaneMask.any()) {
|
2015-12-04 09:51:19 +08:00
|
|
|
I->LaneMask = LaneMask;
|
|
|
|
++I;
|
|
|
|
} else
|
|
|
|
I = CurrentVRegUses.erase(I);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shortcut: Singly defined vregs do not have output/anti dependencies.
|
2012-07-31 07:48:17 +08:00
|
|
|
if (MRI.hasOneDef(Reg))
|
2012-07-28 09:48:15 +08:00
|
|
|
return;
|
2012-02-22 14:08:13 +08:00
|
|
|
|
2015-12-04 09:51:19 +08:00
|
|
|
// Add output dependence to the next nearest defs of this vreg.
|
2012-01-14 10:17:18 +08:00
|
|
|
//
|
|
|
|
// Unless this definition is dead, the output dependence should be
|
|
|
|
// transitively redundant with antidependencies from this definition's
|
|
|
|
// uses. We're conservative for now until we have a way to guarantee the uses
|
|
|
|
// are not eliminated sometime during scheduling. The output dependence edge
|
|
|
|
// is also useful if output latency exceeds def-use latency.
|
2015-12-04 09:51:19 +08:00
|
|
|
LaneBitmask LaneMask = DefLaneMask;
|
|
|
|
for (VReg2SUnit &V2SU : make_range(CurrentVRegDefs.find(Reg),
|
|
|
|
CurrentVRegDefs.end())) {
|
|
|
|
// Ignore defs for other lanes.
|
2016-12-15 22:36:06 +08:00
|
|
|
if ((V2SU.LaneMask & LaneMask).none())
|
2015-12-04 09:51:19 +08:00
|
|
|
continue;
|
|
|
|
// Add an output dependence.
|
|
|
|
SUnit *DefSU = V2SU.SU;
|
|
|
|
// Ignore additional defs of the same lanes in one instruction. This can
|
|
|
|
// happen because lanemasks are shared for targets with too many
|
|
|
|
// subregisters. We also use some representration tricks/hacks where we
|
|
|
|
// add super-register defs/uses, to imply that although we only access parts
|
|
|
|
// of the reg we care about the full one.
|
|
|
|
if (DefSU == SU)
|
|
|
|
continue;
|
|
|
|
SDep Dep(SU, SDep::Output, Reg);
|
|
|
|
Dep.setLatency(
|
|
|
|
SchedModel.computeOutputLatency(MI, OperIdx, DefSU->getInstr()));
|
|
|
|
DefSU->addPred(Dep);
|
|
|
|
|
|
|
|
// Update current definition. This can get tricky if the def was about a
|
|
|
|
// bigger lanemask before. We then have to shrink it and create a new
|
|
|
|
// VReg2SUnit for the non-overlapping part.
|
|
|
|
LaneBitmask OverlapMask = V2SU.LaneMask & LaneMask;
|
|
|
|
LaneBitmask NonOverlapMask = V2SU.LaneMask & ~LaneMask;
|
|
|
|
V2SU.SU = SU;
|
|
|
|
V2SU.LaneMask = OverlapMask;
|
2016-12-17 03:11:56 +08:00
|
|
|
if (NonOverlapMask.any())
|
2016-05-25 09:18:00 +08:00
|
|
|
CurrentVRegDefs.insert(VReg2SUnit(Reg, NonOverlapMask, DefSU));
|
2012-01-14 10:17:18 +08:00
|
|
|
}
|
2015-12-04 09:51:19 +08:00
|
|
|
// If there was no CurrentVRegDefs entry for some lanes yet, create one.
|
2016-12-17 03:11:56 +08:00
|
|
|
if (LaneMask.any())
|
2015-12-04 09:51:19 +08:00
|
|
|
CurrentVRegDefs.insert(VReg2SUnit(Reg, LaneMask, SU));
|
2012-02-22 14:08:11 +08:00
|
|
|
}
|
2012-01-14 10:17:18 +08:00
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// \brief Adds a register data dependency if the instruction that defines the
|
|
|
|
/// virtual register used at OperIdx is mapped to an SUnit. Add a register
|
|
|
|
/// antidependency from this SUnit to instructions that occur later in the same
|
|
|
|
/// scheduling region if they write the virtual register.
|
2012-02-22 14:08:11 +08:00
|
|
|
///
|
|
|
|
/// TODO: Handle ExitSU "uses" properly.
|
|
|
|
void ScheduleDAGInstrs::addVRegUseDeps(SUnit *SU, unsigned OperIdx) {
|
2015-12-04 09:51:19 +08:00
|
|
|
const MachineInstr *MI = SU->getInstr();
|
|
|
|
const MachineOperand &MO = MI->getOperand(OperIdx);
|
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
|
|
|
|
// Remember the use. Data dependencies will be added when we find the def.
|
2016-12-15 22:36:06 +08:00
|
|
|
LaneBitmask LaneMask = TrackLaneMasks ? getLaneMaskForMO(MO)
|
|
|
|
: LaneBitmask::getAll();
|
2015-12-04 09:51:19 +08:00
|
|
|
CurrentVRegUses.insert(VReg2SUnitOperIdx(Reg, LaneMask, OperIdx, SU));
|
|
|
|
|
|
|
|
// Add antidependences to the following defs of the vreg.
|
|
|
|
for (VReg2SUnit &V2SU : make_range(CurrentVRegDefs.find(Reg),
|
|
|
|
CurrentVRegDefs.end())) {
|
|
|
|
// Ignore defs for unrelated lanes.
|
|
|
|
LaneBitmask PrevDefLaneMask = V2SU.LaneMask;
|
2016-12-15 22:36:06 +08:00
|
|
|
if ((PrevDefLaneMask & LaneMask).none())
|
2015-12-04 09:51:19 +08:00
|
|
|
continue;
|
|
|
|
if (V2SU.SU == SU)
|
|
|
|
continue;
|
2012-02-22 14:08:11 +08:00
|
|
|
|
2015-12-04 09:51:19 +08:00
|
|
|
V2SU.SU->addPred(SDep(SU, SDep::Anti, Reg));
|
2015-12-03 11:01:10 +08:00
|
|
|
}
|
2012-01-14 10:17:18 +08:00
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Returns true if MI is an instruction we are unable to reason about
|
2012-05-16 02:59:41 +08:00
|
|
|
/// (like a call or something with unmodeled side effects).
|
|
|
|
static inline bool isGlobalMemoryObject(AliasAnalysis *AA, MachineInstr *MI) {
|
2015-10-25 07:11:13 +08:00
|
|
|
return MI->isCall() || MI->hasUnmodeledSideEffects() ||
|
2016-09-10 09:03:20 +08:00
|
|
|
(MI->hasOrderedMemoryRef() && !MI->isDereferenceableInvariantLoad(AA));
|
2012-05-16 02:59:41 +08:00
|
|
|
}
|
|
|
|
|
2016-02-04 01:52:29 +08:00
|
|
|
void ScheduleDAGInstrs::addChainDependency (SUnit *SUa, SUnit *SUb,
|
|
|
|
unsigned Latency) {
|
2017-03-10 07:33:36 +08:00
|
|
|
if (SUa->getInstr()->mayAlias(AAForDep, *SUb->getInstr(), UseTBAA)) {
|
2016-02-04 01:52:29 +08:00
|
|
|
SDep Dep(SUa, SDep::MayAliasMem);
|
|
|
|
Dep.setLatency(Latency);
|
2012-11-06 11:13:46 +08:00
|
|
|
SUb->addPred(Dep);
|
|
|
|
}
|
2012-05-16 02:59:41 +08:00
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// \brief Creates an SUnit for each real instruction, numbered in top-down
|
|
|
|
/// topological order. The instruction order A < B, implies that no edge exists
|
|
|
|
/// from B to A.
|
2012-02-22 14:08:11 +08:00
|
|
|
///
|
|
|
|
/// Map each real instruction to its SUnit.
|
|
|
|
///
|
2012-03-14 12:00:41 +08:00
|
|
|
/// After initSUnits, the SUnits vector cannot be resized and the scheduler may
|
|
|
|
/// hang onto SUnit pointers. We may relax this in the future by using SUnit IDs
|
|
|
|
/// instead of pointers.
|
|
|
|
///
|
|
|
|
/// MachineScheduler relies on initSUnits numbering the nodes by their order in
|
|
|
|
/// the original instruction list.
|
2012-02-22 14:08:11 +08:00
|
|
|
void ScheduleDAGInstrs::initSUnits() {
|
|
|
|
// We'll be allocating one SUnit for each real instruction in the region,
|
|
|
|
// which is contained within a basic block.
|
2013-08-24 01:48:33 +08:00
|
|
|
SUnits.reserve(NumRegionInstrs);
|
2012-01-14 10:17:18 +08:00
|
|
|
|
2016-07-02 00:21:48 +08:00
|
|
|
for (MachineInstr &MI : llvm::make_range(RegionBegin, RegionEnd)) {
|
|
|
|
if (MI.isDebugValue())
|
2012-02-22 14:08:11 +08:00
|
|
|
continue;
|
2012-01-14 10:17:18 +08:00
|
|
|
|
2016-07-02 00:21:48 +08:00
|
|
|
SUnit *SU = newSUnit(&MI);
|
|
|
|
MISUnitMap[&MI] = SU;
|
2012-02-22 14:08:11 +08:00
|
|
|
|
2016-07-02 00:21:48 +08:00
|
|
|
SU->isCall = MI.isCall();
|
|
|
|
SU->isCommutable = MI.isCommutable();
|
2012-02-22 14:08:11 +08:00
|
|
|
|
|
|
|
// Assign the Latency field of SU using target-provided information.
|
2012-10-10 13:43:09 +08:00
|
|
|
SU->Latency = SchedModel.computeInstrLatency(SU->getInstr());
|
2013-12-06 01:55:58 +08:00
|
|
|
|
2014-04-19 01:35:08 +08:00
|
|
|
// If this SUnit uses a reserved or unbuffered resource, mark it as such.
|
|
|
|
//
|
2014-05-15 09:52:21 +08:00
|
|
|
// Reserved resources block an instruction from issuing and stall the
|
2014-04-19 01:35:08 +08:00
|
|
|
// entire pipeline. These are identified by BufferSize=0.
|
|
|
|
//
|
2014-05-15 09:52:21 +08:00
|
|
|
// Unbuffered resources prevent execution of subsequent instructions that
|
2014-04-19 01:35:08 +08:00
|
|
|
// require the same resources. This is used for in-order execution pipelines
|
|
|
|
// within an out-of-order core. These are identified by BufferSize=1.
|
2013-12-06 01:55:58 +08:00
|
|
|
if (SchedModel.hasInstrSchedModel()) {
|
|
|
|
const MCSchedClassDesc *SC = getSchedClass(SU);
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const MCWriteProcResEntry &PRE :
|
|
|
|
make_range(SchedModel.getWriteProcResBegin(SC),
|
|
|
|
SchedModel.getWriteProcResEnd(SC))) {
|
|
|
|
switch (SchedModel.getProcResource(PRE.ProcResourceIdx)->BufferSize) {
|
2013-12-06 01:56:02 +08:00
|
|
|
case 0:
|
|
|
|
SU->hasReservedResource = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
2013-12-06 01:55:58 +08:00
|
|
|
SU->isUnbuffered = true;
|
|
|
|
break;
|
2013-12-06 01:56:02 +08:00
|
|
|
default:
|
|
|
|
break;
|
2013-12-06 01:55:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-22 14:08:11 +08:00
|
|
|
}
|
2012-01-14 10:17:15 +08:00
|
|
|
}
|
|
|
|
|
2016-02-04 01:52:29 +08:00
|
|
|
class ScheduleDAGInstrs::Value2SUsMap : public MapVector<ValueType, SUList> {
|
|
|
|
/// Current total number of SUs in map.
|
|
|
|
unsigned NumNodes;
|
|
|
|
|
|
|
|
/// 1 for loads, 0 for stores. (see comment in SUList)
|
|
|
|
unsigned TrueMemOrderLatency;
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
public:
|
2016-02-04 01:52:29 +08:00
|
|
|
Value2SUsMap(unsigned lat = 0) : NumNodes(0), TrueMemOrderLatency(lat) {}
|
|
|
|
|
|
|
|
/// To keep NumNodes up to date, insert() is used instead of
|
|
|
|
/// this operator w/ push_back().
|
|
|
|
ValueType &operator[](const SUList &Key) {
|
|
|
|
llvm_unreachable("Don't use. Use insert() instead."); };
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Adds SU to the SUList of V. If Map grows huge, reduce its size by calling
|
|
|
|
/// reduce().
|
2016-02-04 01:52:29 +08:00
|
|
|
void inline insert(SUnit *SU, ValueType V) {
|
|
|
|
MapVector::operator[](V).push_back(SU);
|
|
|
|
NumNodes++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Clears the list of SUs mapped to V.
|
|
|
|
void inline clearList(ValueType V) {
|
|
|
|
iterator Itr = find(V);
|
|
|
|
if (Itr != end()) {
|
|
|
|
assert (NumNodes >= Itr->second.size());
|
|
|
|
NumNodes -= Itr->second.size();
|
|
|
|
|
|
|
|
Itr->second.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Clears map from all contents.
|
|
|
|
void clear() {
|
|
|
|
MapVector<ValueType, SUList>::clear();
|
|
|
|
NumNodes = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned inline size() const { return NumNodes; }
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Counts the number of SUs in this map after a reduction.
|
2016-02-04 01:52:29 +08:00
|
|
|
void reComputeSize(void) {
|
|
|
|
NumNodes = 0;
|
|
|
|
for (auto &I : *this)
|
|
|
|
NumNodes += I.second.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned inline getTrueMemOrderLatency() const {
|
|
|
|
return TrueMemOrderLatency;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dump();
|
|
|
|
};
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::addChainDependencies(SUnit *SU,
|
|
|
|
Value2SUsMap &Val2SUsMap) {
|
|
|
|
for (auto &I : Val2SUsMap)
|
|
|
|
addChainDependencies(SU, I.second,
|
|
|
|
Val2SUsMap.getTrueMemOrderLatency());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::addChainDependencies(SUnit *SU,
|
|
|
|
Value2SUsMap &Val2SUsMap,
|
|
|
|
ValueType V) {
|
|
|
|
Value2SUsMap::iterator Itr = Val2SUsMap.find(V);
|
|
|
|
if (Itr != Val2SUsMap.end())
|
|
|
|
addChainDependencies(SU, Itr->second,
|
|
|
|
Val2SUsMap.getTrueMemOrderLatency());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::addBarrierChain(Value2SUsMap &map) {
|
|
|
|
assert (BarrierChain != nullptr);
|
|
|
|
|
|
|
|
for (auto &I : map) {
|
|
|
|
SUList &sus = I.second;
|
|
|
|
for (auto *SU : sus)
|
|
|
|
SU->addPredBarrier(BarrierChain);
|
|
|
|
}
|
|
|
|
map.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::insertBarrierChain(Value2SUsMap &map) {
|
|
|
|
assert (BarrierChain != nullptr);
|
|
|
|
|
|
|
|
// Go through all lists of SUs.
|
|
|
|
for (Value2SUsMap::iterator I = map.begin(), EE = map.end(); I != EE;) {
|
|
|
|
Value2SUsMap::iterator CurrItr = I++;
|
|
|
|
SUList &sus = CurrItr->second;
|
|
|
|
SUList::iterator SUItr = sus.begin(), SUEE = sus.end();
|
|
|
|
for (; SUItr != SUEE; ++SUItr) {
|
|
|
|
// Stop on BarrierChain or any instruction above it.
|
|
|
|
if ((*SUItr)->NodeNum <= BarrierChain->NodeNum)
|
|
|
|
break;
|
|
|
|
|
|
|
|
(*SUItr)->addPredBarrier(BarrierChain);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove also the BarrierChain from list if present.
|
2016-05-03 01:29:55 +08:00
|
|
|
if (SUItr != SUEE && *SUItr == BarrierChain)
|
2016-02-04 01:52:29 +08:00
|
|
|
SUItr++;
|
|
|
|
|
|
|
|
// Remove all SUs that are now successors of BarrierChain.
|
|
|
|
if (SUItr != sus.begin())
|
|
|
|
sus.erase(sus.begin(), SUItr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove all entries with empty su lists.
|
|
|
|
map.remove_if([&](std::pair<ValueType, SUList> &mapEntry) {
|
|
|
|
return (mapEntry.second.empty()); });
|
|
|
|
|
|
|
|
// Recompute the size of the map (NumNodes).
|
|
|
|
map.reComputeSize();
|
|
|
|
}
|
|
|
|
|
2012-04-25 01:56:43 +08:00
|
|
|
void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
2013-08-30 11:49:48 +08:00
|
|
|
RegPressureTracker *RPTracker,
|
2015-12-04 09:51:19 +08:00
|
|
|
PressureDiffs *PDiffs,
|
2016-01-20 08:23:32 +08:00
|
|
|
LiveIntervals *LIS,
|
2015-12-04 09:51:19 +08:00
|
|
|
bool TrackLaneMasks) {
|
2015-01-27 15:54:39 +08:00
|
|
|
const TargetSubtargetInfo &ST = MF.getSubtarget();
|
2013-08-29 11:25:05 +08:00
|
|
|
bool UseAA = EnableAASchedMI.getNumOccurrences() > 0 ? EnableAASchedMI
|
|
|
|
: ST.useAA();
|
2016-02-04 01:52:29 +08:00
|
|
|
AAForDep = UseAA ? AA : nullptr;
|
|
|
|
|
|
|
|
BarrierChain = nullptr;
|
2013-08-29 11:25:05 +08:00
|
|
|
|
2015-12-04 09:51:19 +08:00
|
|
|
this->TrackLaneMasks = TrackLaneMasks;
|
2013-09-05 05:00:02 +08:00
|
|
|
MISUnitMap.clear();
|
|
|
|
ScheduleDAG::clearDAG();
|
|
|
|
|
2012-02-22 14:08:11 +08:00
|
|
|
// Create an SUnit for each real instruction.
|
|
|
|
initSUnits();
|
2008-11-20 07:18:57 +08:00
|
|
|
|
2013-08-30 11:49:48 +08:00
|
|
|
if (PDiffs)
|
|
|
|
PDiffs->init(SUnits.size());
|
|
|
|
|
2016-02-04 01:52:29 +08:00
|
|
|
// We build scheduling units by walking a block's instruction list
|
|
|
|
// from bottom to top.
|
|
|
|
|
|
|
|
// Each MIs' memory operand(s) is analyzed to a list of underlying
|
2016-02-04 21:08:48 +08:00
|
|
|
// objects. The SU is then inserted in the SUList(s) mapped from the
|
|
|
|
// Value(s). Each Value thus gets mapped to lists of SUs depending
|
|
|
|
// on it, stores and loads kept separately. Two SUs are trivially
|
|
|
|
// non-aliasing if they both depend on only identified Values and do
|
|
|
|
// not share any common Value.
|
2016-02-04 01:52:29 +08:00
|
|
|
Value2SUsMap Stores, Loads(1 /*TrueMemOrderLatency*/);
|
|
|
|
|
|
|
|
// Certain memory accesses are known to not alias any SU in Stores
|
|
|
|
// or Loads, and have therefore their own 'NonAlias'
|
|
|
|
// domain. E.g. spill / reload instructions never alias LLVM I/R
|
2016-02-04 21:08:48 +08:00
|
|
|
// Values. It would be nice to assume that this type of memory
|
|
|
|
// accesses always have a proper memory operand modelling, and are
|
|
|
|
// therefore never unanalyzable, but this is conservatively not
|
|
|
|
// done.
|
2016-02-04 01:52:29 +08:00
|
|
|
Value2SUsMap NonAliasStores, NonAliasLoads(1 /*TrueMemOrderLatency*/);
|
|
|
|
|
2010-03-11 06:13:47 +08:00
|
|
|
// Remove any stale debug info; sometimes BuildSchedGraph is called again
|
|
|
|
// without emitting the info from the previous call.
|
2011-06-03 04:07:12 +08:00
|
|
|
DbgValues.clear();
|
2014-04-14 08:51:57 +08:00
|
|
|
FirstDbgValue = nullptr;
|
2010-03-11 06:13:47 +08:00
|
|
|
|
2012-02-23 09:52:38 +08:00
|
|
|
assert(Defs.empty() && Uses.empty() &&
|
|
|
|
"Only BuildGraph should update Defs/Uses");
|
2013-01-22 02:18:53 +08:00
|
|
|
Defs.setUniverse(TRI->getNumRegs());
|
|
|
|
Uses.setUniverse(TRI->getNumRegs());
|
2011-05-07 05:52:52 +08:00
|
|
|
|
2015-12-04 09:51:19 +08:00
|
|
|
assert(CurrentVRegDefs.empty() && "nobody else should use CurrentVRegDefs");
|
|
|
|
assert(CurrentVRegUses.empty() && "nobody else should use CurrentVRegUses");
|
|
|
|
unsigned NumVirtRegs = MRI.getNumVirtRegs();
|
|
|
|
CurrentVRegDefs.setUniverse(NumVirtRegs);
|
|
|
|
CurrentVRegUses.setUniverse(NumVirtRegs);
|
|
|
|
|
2012-02-23 09:52:38 +08:00
|
|
|
// Model data dependencies between instructions being scheduled and the
|
|
|
|
// ExitSU.
|
2012-03-08 07:00:49 +08:00
|
|
|
addSchedBarrierDeps();
|
2012-02-23 09:52:38 +08:00
|
|
|
|
2009-02-11 07:27:53 +08:00
|
|
|
// Walk the list of instructions, from bottom moving up.
|
2014-04-14 08:51:57 +08:00
|
|
|
MachineInstr *DbgMI = nullptr;
|
2012-03-09 12:29:02 +08:00
|
|
|
for (MachineBasicBlock::iterator MII = RegionEnd, MIE = RegionBegin;
|
2008-11-20 07:18:57 +08:00
|
|
|
MII != MIE; --MII) {
|
2016-07-02 00:21:48 +08:00
|
|
|
MachineInstr &MI = *std::prev(MII);
|
|
|
|
if (DbgMI) {
|
|
|
|
DbgValues.push_back(std::make_pair(DbgMI, &MI));
|
2014-04-14 08:51:57 +08:00
|
|
|
DbgMI = nullptr;
|
2011-06-03 04:07:12 +08:00
|
|
|
}
|
|
|
|
|
2016-07-02 00:21:48 +08:00
|
|
|
if (MI.isDebugValue()) {
|
|
|
|
DbgMI = &MI;
|
2010-03-11 06:13:47 +08:00
|
|
|
continue;
|
|
|
|
}
|
2016-07-02 00:21:48 +08:00
|
|
|
SUnit *SU = MISUnitMap[&MI];
|
2013-08-30 11:49:48 +08:00
|
|
|
assert(SU && "No SUnit mapped to this MI");
|
|
|
|
|
2012-04-25 01:56:43 +08:00
|
|
|
if (RPTracker) {
|
2016-01-13 06:57:35 +08:00
|
|
|
RegisterOperands RegOpers;
|
2016-07-02 00:21:48 +08:00
|
|
|
RegOpers.collect(MI, *TRI, MRI, TrackLaneMasks, false);
|
2016-01-20 08:23:32 +08:00
|
|
|
if (TrackLaneMasks) {
|
2016-07-02 00:21:48 +08:00
|
|
|
SlotIndex SlotIdx = LIS->getInstructionIndex(MI);
|
2016-01-20 08:23:32 +08:00
|
|
|
RegOpers.adjustLaneLiveness(*LIS, MRI, SlotIdx);
|
|
|
|
}
|
2016-01-13 06:57:35 +08:00
|
|
|
if (PDiffs != nullptr)
|
|
|
|
PDiffs->addInstruction(SU->NodeNum, RegOpers, MRI);
|
|
|
|
|
|
|
|
RPTracker->recedeSkipDebugValues();
|
2016-07-02 00:21:48 +08:00
|
|
|
assert(&*RPTracker->getPos() == &MI && "RPTracker in sync");
|
2016-01-13 06:57:35 +08:00
|
|
|
RPTracker->recede(RegOpers);
|
2012-04-25 01:56:43 +08:00
|
|
|
}
|
2011-06-03 04:07:12 +08:00
|
|
|
|
2014-03-07 14:08:31 +08:00
|
|
|
assert(
|
2016-07-02 00:21:48 +08:00
|
|
|
(CanHandleTerminators || (!MI.isTerminator() && !MI.isPosition())) &&
|
2014-03-07 14:08:31 +08:00
|
|
|
"Cannot schedule terminators or labels!");
|
2008-11-20 07:18:57 +08:00
|
|
|
|
2008-12-04 09:35:46 +08:00
|
|
|
// Add register-based dependencies (data, anti, and output).
|
2016-05-11 00:50:30 +08:00
|
|
|
// For some instructions (calls, returns, inline-asm, etc.) there can
|
|
|
|
// be explicit uses and implicit defs, in which case the use will appear
|
|
|
|
// on the operand list before the def. Do two passes over the operand
|
|
|
|
// list to make sure that defs are processed before any uses.
|
2012-12-19 04:53:01 +08:00
|
|
|
bool HasVRegDef = false;
|
2016-07-02 00:21:48 +08:00
|
|
|
for (unsigned j = 0, n = MI.getNumOperands(); j != n; ++j) {
|
|
|
|
const MachineOperand &MO = MI.getOperand(j);
|
2016-05-11 00:50:30 +08:00
|
|
|
if (!MO.isReg() || !MO.isDef())
|
|
|
|
continue;
|
2008-11-20 07:18:57 +08:00
|
|
|
unsigned Reg = MO.getReg();
|
2016-11-11 06:11:00 +08:00
|
|
|
if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
2012-01-14 10:17:15 +08:00
|
|
|
addPhysRegDeps(SU, j);
|
2016-11-11 06:11:00 +08:00
|
|
|
} else if (TargetRegisterInfo::isVirtualRegister(Reg)) {
|
2016-05-11 00:50:30 +08:00
|
|
|
HasVRegDef = true;
|
|
|
|
addVRegDefDeps(SU, j);
|
2008-11-20 07:18:57 +08:00
|
|
|
}
|
|
|
|
}
|
2016-05-11 00:50:30 +08:00
|
|
|
// Now process all uses.
|
2016-07-02 00:21:48 +08:00
|
|
|
for (unsigned j = 0, n = MI.getNumOperands(); j != n; ++j) {
|
|
|
|
const MachineOperand &MO = MI.getOperand(j);
|
2016-05-11 04:11:58 +08:00
|
|
|
// Only look at use operands.
|
|
|
|
// We do not need to check for MO.readsReg() here because subsequent
|
|
|
|
// subregister defs will get output dependence edges and need no
|
|
|
|
// additional use dependencies.
|
2016-05-11 00:50:30 +08:00
|
|
|
if (!MO.isReg() || !MO.isUse())
|
|
|
|
continue;
|
|
|
|
unsigned Reg = MO.getReg();
|
2016-11-11 06:11:00 +08:00
|
|
|
if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
2016-05-11 00:50:30 +08:00
|
|
|
addPhysRegDeps(SU, j);
|
2016-11-11 06:11:00 +08:00
|
|
|
} else if (TargetRegisterInfo::isVirtualRegister(Reg) && MO.readsReg()) {
|
2016-05-11 00:50:30 +08:00
|
|
|
addVRegUseDeps(SU, j);
|
2016-11-11 06:11:00 +08:00
|
|
|
}
|
2016-05-11 00:50:30 +08:00
|
|
|
}
|
|
|
|
|
2012-12-19 04:53:01 +08:00
|
|
|
// If we haven't seen any uses in this scheduling region, create a
|
|
|
|
// dependence edge to ExitSU to model the live-out latency. This is required
|
|
|
|
// for vreg defs with no in-region use, and prefetches with no vreg def.
|
|
|
|
//
|
|
|
|
// FIXME: NumDataSuccs would be more precise than NumSuccs here. This
|
|
|
|
// check currently relies on being called before adding chain deps.
|
2016-07-02 00:21:48 +08:00
|
|
|
if (SU->NumSuccs == 0 && SU->Latency > 1 && (HasVRegDef || MI.mayLoad())) {
|
2012-12-19 04:53:01 +08:00
|
|
|
SDep Dep(SU, SDep::Artificial);
|
|
|
|
Dep.setLatency(SU->Latency - 1);
|
|
|
|
ExitSU.addPred(Dep);
|
|
|
|
}
|
2008-12-04 09:35:46 +08:00
|
|
|
|
2016-02-04 01:52:29 +08:00
|
|
|
// Add memory dependencies (Note: isStoreToStackSlot and
|
|
|
|
// isLoadFromStackSLot are not usable after stack slots are lowered to
|
|
|
|
// actual addresses).
|
|
|
|
|
|
|
|
// This is a barrier event that acts as a pivotal node in the DAG.
|
2016-07-02 00:21:48 +08:00
|
|
|
if (isGlobalMemoryObject(AA, &MI)) {
|
2016-02-04 01:52:29 +08:00
|
|
|
|
|
|
|
// Become the barrier chain.
|
2009-11-10 03:22:17 +08:00
|
|
|
if (BarrierChain)
|
2016-02-04 01:52:29 +08:00
|
|
|
BarrierChain->addPredBarrier(SU);
|
2009-11-10 03:22:17 +08:00
|
|
|
BarrierChain = SU;
|
2014-12-09 07:36:48 +08:00
|
|
|
|
2016-02-04 01:52:29 +08:00
|
|
|
DEBUG(dbgs() << "Global memory object and new barrier chain: SU("
|
|
|
|
<< BarrierChain->NodeNum << ").\n";);
|
[ScheduleDAGInstrs::buildSchedGraph()] Handling of memory dependecies rewritten.
The buildSchedGraph() was in need of reworking as the AA features had been
added on top of earlier code. It was very difficult to understand, and buggy.
There had been found cases where scheduling dependencies had actually been
missed (see r228686).
AliasChain, RejectMemNodes, adjustChainDeps() and iterateChainSucc() have
been removed. There are instead now just the four maps from Value to SUs, which
have been renamed to Stores, Loads, NonAliasStores and NonAliasLoads.
An unknown store used to become the AliasChain, but now becomes a store mapped
to 'unknownValue' (in Stores). What used to be PendingLoads is instead the
list of SUs mapped to 'unknownValue' in Loads.
RejectMemNodes and adjustChainDeps() used to be a safety-net for everything.
The SU maps were sometimes cleared and SUs were put in RejectMemNodes, where
adjustChainDeps() would look. Instead of this, a more straight forward approach
is used in maintaining the SU maps without clearing them and simply letting
them grow over time. Instead of the cutt-off in adjustChainDeps() search, a
reduction of maps will be done if needed (see below).
Each SUnit either becomes the BarrierChain, or is put into one of the maps. For
each SUnit encountered, all the information about previous ones are still
available until a new BarrierChain is set, at which point the maps are cleared.
For huge regions, the algorithm becomes slow, therefore the maps will get
reduced at a threshold (current default is 1000 nodes), by a fraction (default 1/2).
These values can be tuned by use of CL options in case some test case shows that
they need to be changed (-dag-maps-huge-region and -dag-maps-reduction-size).
There has not been any considerable change observed in output quality or compile
time. There may now be more DAG edges inserted than before (i.e. if A->B->C,
then A->C is not needed). However, in a comparison run there were fewer total
calls to AA, and a somewhat improved compile time, which means this seems to
be not a problem.
http://reviews.llvm.org/D8705
Reviewers: Hal Finkel, Andy Trick.
llvm-svn: 259201
2016-01-30 00:11:18 +08:00
|
|
|
|
2016-02-04 01:52:29 +08:00
|
|
|
// Add dependencies against everything below it and clear maps.
|
|
|
|
addBarrierChain(Stores);
|
|
|
|
addBarrierChain(Loads);
|
|
|
|
addBarrierChain(NonAliasStores);
|
|
|
|
addBarrierChain(NonAliasLoads);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If it's not a store or a variant load, we're done.
|
2016-09-10 09:03:20 +08:00
|
|
|
if (!MI.mayStore() &&
|
|
|
|
!(MI.mayLoad() && !MI.isDereferenceableInvariantLoad(AA)))
|
2016-02-04 01:52:29 +08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Always add dependecy edge to BarrierChain if present.
|
|
|
|
if (BarrierChain)
|
|
|
|
BarrierChain->addPredBarrier(SU);
|
|
|
|
|
|
|
|
// Find the underlying objects for MI. The Objs vector is either
|
|
|
|
// empty, or filled with the Values of memory locations which this
|
|
|
|
// SU depends on. An empty vector means the memory location is
|
2016-02-16 00:43:15 +08:00
|
|
|
// unknown, and may alias anything.
|
2016-02-04 01:52:29 +08:00
|
|
|
UnderlyingObjectsVector Objs;
|
2016-07-02 00:21:48 +08:00
|
|
|
getUnderlyingObjectsForInstr(&MI, MFI, Objs, MF.getDataLayout());
|
2016-02-04 01:52:29 +08:00
|
|
|
|
2016-07-02 00:21:48 +08:00
|
|
|
if (MI.mayStore()) {
|
2012-12-11 02:49:16 +08:00
|
|
|
if (Objs.empty()) {
|
2016-02-04 01:52:29 +08:00
|
|
|
// An unknown store depends on all stores and loads.
|
|
|
|
addChainDependencies(SU, Stores);
|
|
|
|
addChainDependencies(SU, NonAliasStores);
|
|
|
|
addChainDependencies(SU, Loads);
|
|
|
|
addChainDependencies(SU, NonAliasLoads);
|
|
|
|
|
|
|
|
// Map this store to 'UnknownValue'.
|
|
|
|
Stores.insert(SU, UnknownValue);
|
2016-04-01 05:55:58 +08:00
|
|
|
} else {
|
|
|
|
// Add precise dependencies against all previously seen memory
|
|
|
|
// accesses mapped to the same Value(s).
|
2016-04-15 05:31:07 +08:00
|
|
|
for (const UnderlyingObject &UnderlObj : Objs) {
|
|
|
|
ValueType V = UnderlObj.getValue();
|
|
|
|
bool ThisMayAlias = UnderlObj.mayAlias();
|
2016-02-04 01:52:29 +08:00
|
|
|
|
2016-04-01 05:55:58 +08:00
|
|
|
// Add dependencies to previous stores and loads mapped to V.
|
2016-04-15 05:31:07 +08:00
|
|
|
addChainDependencies(SU, (ThisMayAlias ? Stores : NonAliasStores), V);
|
2016-04-01 05:55:58 +08:00
|
|
|
addChainDependencies(SU, (ThisMayAlias ? Loads : NonAliasLoads), V);
|
2016-04-12 23:50:19 +08:00
|
|
|
}
|
|
|
|
// Update the store map after all chains have been added to avoid adding
|
|
|
|
// self-loop edge if multiple underlying objects are present.
|
2016-04-15 05:31:07 +08:00
|
|
|
for (const UnderlyingObject &UnderlObj : Objs) {
|
|
|
|
ValueType V = UnderlObj.getValue();
|
|
|
|
bool ThisMayAlias = UnderlObj.mayAlias();
|
2016-02-04 01:52:29 +08:00
|
|
|
|
2016-04-01 05:55:58 +08:00
|
|
|
// Map this store to V.
|
2016-04-15 05:31:07 +08:00
|
|
|
(ThisMayAlias ? Stores : NonAliasStores).insert(SU, V);
|
2016-04-01 05:55:58 +08:00
|
|
|
}
|
|
|
|
// The store may have dependencies to unanalyzable loads and
|
|
|
|
// stores.
|
|
|
|
addChainDependencies(SU, Loads, UnknownValue);
|
|
|
|
addChainDependencies(SU, Stores, UnknownValue);
|
2009-11-03 01:06:28 +08:00
|
|
|
}
|
2016-04-01 05:55:58 +08:00
|
|
|
} else { // SU is a load.
|
2016-02-04 01:52:29 +08:00
|
|
|
if (Objs.empty()) {
|
|
|
|
// An unknown load depends on all stores.
|
|
|
|
addChainDependencies(SU, Stores);
|
|
|
|
addChainDependencies(SU, NonAliasStores);
|
|
|
|
|
|
|
|
Loads.insert(SU, UnknownValue);
|
2016-04-01 05:55:58 +08:00
|
|
|
} else {
|
2016-04-15 05:31:07 +08:00
|
|
|
for (const UnderlyingObject &UnderlObj : Objs) {
|
|
|
|
ValueType V = UnderlObj.getValue();
|
|
|
|
bool ThisMayAlias = UnderlObj.mayAlias();
|
2012-12-11 02:49:16 +08:00
|
|
|
|
2016-04-01 05:55:58 +08:00
|
|
|
// Add precise dependencies against all previously seen stores
|
|
|
|
// mapping to the same Value(s).
|
|
|
|
addChainDependencies(SU, (ThisMayAlias ? Stores : NonAliasStores), V);
|
2016-02-04 01:52:29 +08:00
|
|
|
|
2016-04-01 05:55:58 +08:00
|
|
|
// Map this load to V.
|
|
|
|
(ThisMayAlias ? Loads : NonAliasLoads).insert(SU, V);
|
|
|
|
}
|
|
|
|
// The load may have dependencies to unanalyzable stores.
|
|
|
|
addChainDependencies(SU, Stores, UnknownValue);
|
2011-05-06 03:24:06 +08:00
|
|
|
}
|
2016-02-04 01:52:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reduce maps if they grow huge.
|
|
|
|
if (Stores.size() + Loads.size() >= HugeRegion) {
|
|
|
|
DEBUG(dbgs() << "Reducing Stores and Loads maps.\n";);
|
2016-04-16 12:58:30 +08:00
|
|
|
reduceHugeMemNodeMaps(Stores, Loads, getReductionSize());
|
2016-02-04 01:52:29 +08:00
|
|
|
}
|
|
|
|
if (NonAliasStores.size() + NonAliasLoads.size() >= HugeRegion) {
|
|
|
|
DEBUG(dbgs() << "Reducing NonAliasStores and NonAliasLoads maps.\n";);
|
2016-04-16 12:58:30 +08:00
|
|
|
reduceHugeMemNodeMaps(NonAliasStores, NonAliasLoads, getReductionSize());
|
2008-11-20 07:18:57 +08:00
|
|
|
}
|
|
|
|
}
|
2016-02-04 01:52:29 +08:00
|
|
|
|
2012-12-01 09:22:49 +08:00
|
|
|
if (DbgMI)
|
|
|
|
FirstDbgValue = DbgMI;
|
2009-01-16 03:20:50 +08:00
|
|
|
|
2012-02-23 09:52:38 +08:00
|
|
|
Defs.clear();
|
|
|
|
Uses.clear();
|
2015-12-04 09:51:19 +08:00
|
|
|
CurrentVRegDefs.clear();
|
|
|
|
CurrentVRegUses.clear();
|
2016-02-04 01:52:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
raw_ostream &llvm::operator<<(raw_ostream &OS, const PseudoSourceValue* PSV) {
|
|
|
|
PSV->printCustom(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::Value2SUsMap::dump() {
|
|
|
|
for (auto &Itr : *this) {
|
|
|
|
if (Itr.first.is<const Value*>()) {
|
|
|
|
const Value *V = Itr.first.get<const Value*>();
|
|
|
|
if (isa<UndefValue>(V))
|
|
|
|
dbgs() << "Unknown";
|
|
|
|
else
|
|
|
|
V->printAsOperand(dbgs());
|
|
|
|
}
|
|
|
|
else if (Itr.first.is<const PseudoSourceValue*>())
|
|
|
|
dbgs() << Itr.first.get<const PseudoSourceValue*>();
|
|
|
|
else
|
|
|
|
llvm_unreachable("Unknown Value type.");
|
|
|
|
|
|
|
|
dbgs() << " : ";
|
|
|
|
dumpSUList(Itr.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::reduceHugeMemNodeMaps(Value2SUsMap &stores,
|
|
|
|
Value2SUsMap &loads, unsigned N) {
|
|
|
|
DEBUG(dbgs() << "Before reduction:\nStoring SUnits:\n";
|
|
|
|
stores.dump();
|
|
|
|
dbgs() << "Loading SUnits:\n";
|
|
|
|
loads.dump());
|
|
|
|
|
|
|
|
// Insert all SU's NodeNums into a vector and sort it.
|
|
|
|
std::vector<unsigned> NodeNums;
|
|
|
|
NodeNums.reserve(stores.size() + loads.size());
|
|
|
|
for (auto &I : stores)
|
|
|
|
for (auto *SU : I.second)
|
|
|
|
NodeNums.push_back(SU->NodeNum);
|
|
|
|
for (auto &I : loads)
|
|
|
|
for (auto *SU : I.second)
|
|
|
|
NodeNums.push_back(SU->NodeNum);
|
|
|
|
std::sort(NodeNums.begin(), NodeNums.end());
|
|
|
|
|
|
|
|
// The N last elements in NodeNums will be removed, and the SU with
|
|
|
|
// the lowest NodeNum of them will become the new BarrierChain to
|
|
|
|
// let the not yet seen SUs have a dependency to the removed SUs.
|
|
|
|
assert (N <= NodeNums.size());
|
|
|
|
SUnit *newBarrierChain = &SUnits[*(NodeNums.end() - N)];
|
|
|
|
if (BarrierChain) {
|
|
|
|
// The aliasing and non-aliasing maps reduce independently of each
|
|
|
|
// other, but share a common BarrierChain. Check if the
|
|
|
|
// newBarrierChain is above the former one. If it is not, it may
|
|
|
|
// introduce a loop to use newBarrierChain, so keep the old one.
|
|
|
|
if (newBarrierChain->NodeNum < BarrierChain->NodeNum) {
|
|
|
|
BarrierChain->addPredBarrier(newBarrierChain);
|
|
|
|
BarrierChain = newBarrierChain;
|
|
|
|
DEBUG(dbgs() << "Inserting new barrier chain: SU("
|
|
|
|
<< BarrierChain->NodeNum << ").\n";);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DEBUG(dbgs() << "Keeping old barrier chain: SU("
|
|
|
|
<< BarrierChain->NodeNum << ").\n";);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
BarrierChain = newBarrierChain;
|
|
|
|
|
|
|
|
insertBarrierChain(stores);
|
|
|
|
insertBarrierChain(loads);
|
|
|
|
|
|
|
|
DEBUG(dbgs() << "After reduction:\nStoring SUnits:\n";
|
|
|
|
stores.dump();
|
|
|
|
dbgs() << "Loading SUnits:\n";
|
|
|
|
loads.dump());
|
2008-11-20 07:18:57 +08:00
|
|
|
}
|
|
|
|
|
2013-12-29 05:56:55 +08:00
|
|
|
void ScheduleDAGInstrs::startBlockForKills(MachineBasicBlock *BB) {
|
|
|
|
// Start with no live registers.
|
|
|
|
LiveRegs.reset();
|
|
|
|
|
|
|
|
// Examine the live-in regs of all successors.
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const MachineBasicBlock *Succ : BB->successors()) {
|
|
|
|
for (const auto &LI : Succ->liveins()) {
|
2013-12-29 05:56:55 +08:00
|
|
|
// Repeat, for reg and all subregs.
|
2015-09-10 02:08:03 +08:00
|
|
|
for (MCSubRegIterator SubRegs(LI.PhysReg, TRI, /*IncludeSelf=*/true);
|
2013-12-29 05:56:55 +08:00
|
|
|
SubRegs.isValid(); ++SubRegs)
|
|
|
|
LiveRegs.set(*SubRegs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ScheduleDAGInstrs should toggle kill flags on bundled instrs.
ScheduleDAGInstrs wasn't setting or clearing the kill flags on instructions inside bundles. This led to code such as this
%R3<def> = t2ANDrr %R0
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use,kill>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
being transformed to
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
%R3<def> = t2ANDrr %R0<kill>
where the kill flag was removed from the BUNDLE instruction, but not the t2ORRrr inside it. The verifier then thought that
R0 was undefined when read by the AND.
This change make the toggleKillFlags method also check for bundles and toggle flags on bundled instructions.
Setting the kill flag is special cased as we only want to set the kill flag on the last instruction in the bundle.
llvm-svn: 236428
2015-05-05 00:52:06 +08:00
|
|
|
/// \brief If we change a kill flag on the bundle instruction implicit register
|
|
|
|
/// operands, then we also need to propagate that to any instructions inside
|
|
|
|
/// the bundle which had the same kill state.
|
|
|
|
static void toggleBundleKillFlag(MachineInstr *MI, unsigned Reg,
|
2016-05-11 01:57:27 +08:00
|
|
|
bool NewKillState,
|
|
|
|
const TargetRegisterInfo *TRI) {
|
ScheduleDAGInstrs should toggle kill flags on bundled instrs.
ScheduleDAGInstrs wasn't setting or clearing the kill flags on instructions inside bundles. This led to code such as this
%R3<def> = t2ANDrr %R0
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use,kill>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
being transformed to
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
%R3<def> = t2ANDrr %R0<kill>
where the kill flag was removed from the BUNDLE instruction, but not the t2ORRrr inside it. The verifier then thought that
R0 was undefined when read by the AND.
This change make the toggleKillFlags method also check for bundles and toggle flags on bundled instructions.
Setting the kill flag is special cased as we only want to set the kill flag on the last instruction in the bundle.
llvm-svn: 236428
2015-05-05 00:52:06 +08:00
|
|
|
if (MI->getOpcode() != TargetOpcode::BUNDLE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Walk backwards from the last instruction in the bundle to the first.
|
|
|
|
// Once we set a kill flag on an instruction, we bail out, as otherwise we
|
|
|
|
// might set it on too many operands. We will clear as many flags as we
|
|
|
|
// can though.
|
2016-02-23 04:49:58 +08:00
|
|
|
MachineBasicBlock::instr_iterator Begin = MI->getIterator();
|
2016-10-25 10:55:17 +08:00
|
|
|
MachineBasicBlock::instr_iterator End = getBundleEnd(Begin);
|
ScheduleDAGInstrs should toggle kill flags on bundled instrs.
ScheduleDAGInstrs wasn't setting or clearing the kill flags on instructions inside bundles. This led to code such as this
%R3<def> = t2ANDrr %R0
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use,kill>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
being transformed to
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
%R3<def> = t2ANDrr %R0<kill>
where the kill flag was removed from the BUNDLE instruction, but not the t2ORRrr inside it. The verifier then thought that
R0 was undefined when read by the AND.
This change make the toggleKillFlags method also check for bundles and toggle flags on bundled instructions.
Setting the kill flag is special cased as we only want to set the kill flag on the last instruction in the bundle.
llvm-svn: 236428
2015-05-05 00:52:06 +08:00
|
|
|
while (Begin != End) {
|
2016-05-11 01:57:27 +08:00
|
|
|
if (NewKillState) {
|
|
|
|
if ((--End)->addRegisterKilled(Reg, TRI, /* addIfNotFound= */ false))
|
|
|
|
return;
|
|
|
|
} else
|
2017-01-28 02:53:05 +08:00
|
|
|
(--End)->clearRegisterKills(Reg, TRI);
|
ScheduleDAGInstrs should toggle kill flags on bundled instrs.
ScheduleDAGInstrs wasn't setting or clearing the kill flags on instructions inside bundles. This led to code such as this
%R3<def> = t2ANDrr %R0
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use,kill>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
being transformed to
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
%R3<def> = t2ANDrr %R0<kill>
where the kill flag was removed from the BUNDLE instruction, but not the t2ORRrr inside it. The verifier then thought that
R0 was undefined when read by the AND.
This change make the toggleKillFlags method also check for bundles and toggle flags on bundled instructions.
Setting the kill flag is special cased as we only want to set the kill flag on the last instruction in the bundle.
llvm-svn: 236428
2015-05-05 00:52:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:05 +08:00
|
|
|
void ScheduleDAGInstrs::toggleKillFlag(MachineInstr &MI, MachineOperand &MO) {
|
2017-01-28 02:53:07 +08:00
|
|
|
if (MO.isDebug())
|
|
|
|
return;
|
|
|
|
|
2013-12-29 05:56:55 +08:00
|
|
|
// Setting kill flag...
|
|
|
|
if (!MO.isKill()) {
|
|
|
|
MO.setIsKill(true);
|
2017-01-28 02:53:05 +08:00
|
|
|
toggleBundleKillFlag(&MI, MO.getReg(), true, TRI);
|
|
|
|
return;
|
2013-12-29 05:56:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// If MO itself is live, clear the kill flag...
|
|
|
|
if (LiveRegs.test(MO.getReg())) {
|
|
|
|
MO.setIsKill(false);
|
2017-01-28 02:53:05 +08:00
|
|
|
toggleBundleKillFlag(&MI, MO.getReg(), false, TRI);
|
|
|
|
return;
|
2013-12-29 05:56:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// If any subreg of MO is live, then create an imp-def for that
|
|
|
|
// subreg and keep MO marked as killed.
|
|
|
|
MO.setIsKill(false);
|
2017-01-28 02:53:05 +08:00
|
|
|
toggleBundleKillFlag(&MI, MO.getReg(), false, TRI);
|
2013-12-29 05:56:55 +08:00
|
|
|
bool AllDead = true;
|
|
|
|
const unsigned SuperReg = MO.getReg();
|
2017-01-28 02:53:05 +08:00
|
|
|
MachineInstrBuilder MIB(MF, &MI);
|
2013-12-29 05:56:55 +08:00
|
|
|
for (MCSubRegIterator SubRegs(SuperReg, TRI); SubRegs.isValid(); ++SubRegs) {
|
|
|
|
if (LiveRegs.test(*SubRegs)) {
|
|
|
|
MIB.addReg(*SubRegs, RegState::ImplicitDefine);
|
|
|
|
AllDead = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ScheduleDAGInstrs should toggle kill flags on bundled instrs.
ScheduleDAGInstrs wasn't setting or clearing the kill flags on instructions inside bundles. This led to code such as this
%R3<def> = t2ANDrr %R0
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use,kill>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
being transformed to
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
%R3<def> = t2ANDrr %R0<kill>
where the kill flag was removed from the BUNDLE instruction, but not the t2ORRrr inside it. The verifier then thought that
R0 was undefined when read by the AND.
This change make the toggleKillFlags method also check for bundles and toggle flags on bundled instructions.
Setting the kill flag is special cased as we only want to set the kill flag on the last instruction in the bundle.
llvm-svn: 236428
2015-05-05 00:52:06 +08:00
|
|
|
if(AllDead) {
|
2013-12-29 05:56:55 +08:00
|
|
|
MO.setIsKill(true);
|
2017-01-28 02:53:05 +08:00
|
|
|
toggleBundleKillFlag(&MI, MO.getReg(), true, TRI);
|
ScheduleDAGInstrs should toggle kill flags on bundled instrs.
ScheduleDAGInstrs wasn't setting or clearing the kill flags on instructions inside bundles. This led to code such as this
%R3<def> = t2ANDrr %R0
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use,kill>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
being transformed to
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
%R3<def> = t2ANDrr %R0<kill>
where the kill flag was removed from the BUNDLE instruction, but not the t2ORRrr inside it. The verifier then thought that
R0 was undefined when read by the AND.
This change make the toggleKillFlags method also check for bundles and toggle flags on bundled instructions.
Setting the kill flag is special cased as we only want to set the kill flag on the last instruction in the bundle.
llvm-svn: 236428
2015-05-05 00:52:06 +08:00
|
|
|
}
|
2013-12-29 05:56:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScheduleDAGInstrs::fixupKills(MachineBasicBlock *MBB) {
|
2017-01-28 02:53:00 +08:00
|
|
|
// FIXME: Reuse the LivePhysRegs utility for this.
|
2013-12-29 05:56:55 +08:00
|
|
|
DEBUG(dbgs() << "Fixup kills for BB#" << MBB->getNumber() << '\n');
|
|
|
|
|
|
|
|
LiveRegs.resize(TRI->getNumRegs());
|
|
|
|
BitVector killedRegs(TRI->getNumRegs());
|
|
|
|
|
|
|
|
startBlockForKills(MBB);
|
|
|
|
|
|
|
|
// Examine block from end to start...
|
|
|
|
unsigned Count = MBB->size();
|
|
|
|
for (MachineBasicBlock::iterator I = MBB->end(), E = MBB->begin();
|
|
|
|
I != E; --Count) {
|
2016-07-02 00:21:48 +08:00
|
|
|
MachineInstr &MI = *--I;
|
|
|
|
if (MI.isDebugValue())
|
2013-12-29 05:56:55 +08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Update liveness. Registers that are defed but not used in this
|
|
|
|
// instruction are now dead. Mark register and all subregs as they
|
|
|
|
// are completely defined.
|
2016-07-02 00:21:48 +08:00
|
|
|
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
|
|
|
MachineOperand &MO = MI.getOperand(i);
|
2013-12-29 05:56:55 +08:00
|
|
|
if (MO.isRegMask())
|
|
|
|
LiveRegs.clearBitsNotInMask(MO.getRegMask());
|
|
|
|
if (!MO.isReg()) continue;
|
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
if (Reg == 0) continue;
|
|
|
|
if (!MO.isDef()) continue;
|
|
|
|
// Ignore two-addr defs.
|
2016-07-02 00:21:48 +08:00
|
|
|
if (MI.isRegTiedToUseOperand(i)) continue;
|
2013-12-29 05:56:55 +08:00
|
|
|
|
|
|
|
// Repeat for reg and all subregs.
|
|
|
|
for (MCSubRegIterator SubRegs(Reg, TRI, /*IncludeSelf=*/true);
|
|
|
|
SubRegs.isValid(); ++SubRegs)
|
|
|
|
LiveRegs.reset(*SubRegs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Examine all used registers and set/clear kill flag. When a
|
|
|
|
// register is used multiple times we only set the kill flag on
|
|
|
|
// the first use. Don't set kill flags on undef operands.
|
|
|
|
killedRegs.reset();
|
2016-10-05 21:15:06 +08:00
|
|
|
|
|
|
|
// toggleKillFlag can append new operands (implicit defs), so using
|
|
|
|
// a range-based loop is not safe. The new operands will be appended
|
|
|
|
// at the end of the operand list and they don't need to be visited,
|
|
|
|
// so iterating until the currently last operand is ok.
|
|
|
|
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
|
|
|
MachineOperand &MO = MI.getOperand(i);
|
2013-12-29 05:56:55 +08:00
|
|
|
if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue;
|
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
if ((Reg == 0) || MRI.isReserved(Reg)) continue;
|
|
|
|
|
|
|
|
bool kill = false;
|
|
|
|
if (!killedRegs.test(Reg)) {
|
|
|
|
kill = true;
|
|
|
|
// A register is not killed if any subregs are live...
|
|
|
|
for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
|
|
|
|
if (LiveRegs.test(*SubRegs)) {
|
|
|
|
kill = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If subreg is not live, then register is killed if it became
|
|
|
|
// live in this instruction
|
|
|
|
if (kill)
|
|
|
|
kill = !LiveRegs.test(Reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MO.isKill() != kill) {
|
|
|
|
DEBUG(dbgs() << "Fixing " << MO << " in ");
|
2017-01-28 02:53:05 +08:00
|
|
|
toggleKillFlag(MI, MO);
|
2016-07-02 00:21:48 +08:00
|
|
|
DEBUG(MI.dump());
|
|
|
|
DEBUG({
|
|
|
|
if (MI.getOpcode() == TargetOpcode::BUNDLE) {
|
|
|
|
MachineBasicBlock::instr_iterator Begin = MI.getIterator();
|
2016-10-25 10:55:17 +08:00
|
|
|
MachineBasicBlock::instr_iterator End = getBundleEnd(Begin);
|
2016-07-02 00:21:48 +08:00
|
|
|
while (++Begin != End)
|
|
|
|
DEBUG(Begin->dump());
|
|
|
|
}
|
ScheduleDAGInstrs should toggle kill flags on bundled instrs.
ScheduleDAGInstrs wasn't setting or clearing the kill flags on instructions inside bundles. This led to code such as this
%R3<def> = t2ANDrr %R0
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use,kill>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
being transformed to
BUNDLE %ITSTATE<imp-def,dead>, %R0<imp-use>
t2IT 1, 24, %ITSTATE<imp-def>
R6<def,tied6> = t2ORRrr %R0<kill>, ...
%R3<def> = t2ANDrr %R0<kill>
where the kill flag was removed from the BUNDLE instruction, but not the t2ORRrr inside it. The verifier then thought that
R0 was undefined when read by the AND.
This change make the toggleKillFlags method also check for bundles and toggle flags on bundled instructions.
Setting the kill flag is special cased as we only want to set the kill flag on the last instruction in the bundle.
llvm-svn: 236428
2015-05-05 00:52:06 +08:00
|
|
|
});
|
2013-12-29 05:56:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
killedRegs.set(Reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark any used register (that is not using undef) and subregs as
|
|
|
|
// now live...
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const MachineOperand &MO : MI.operands()) {
|
2013-12-29 05:56:55 +08:00
|
|
|
if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue;
|
|
|
|
unsigned Reg = MO.getReg();
|
|
|
|
if ((Reg == 0) || MRI.isReserved(Reg)) continue;
|
|
|
|
|
|
|
|
for (MCSubRegIterator SubRegs(Reg, TRI, /*IncludeSelf=*/true);
|
|
|
|
SubRegs.isValid(); ++SubRegs)
|
|
|
|
LiveRegs.set(*SubRegs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-20 07:18:57 +08:00
|
|
|
void ScheduleDAGInstrs::dumpNode(const SUnit *SU) const {
|
2017-01-28 10:02:38 +08:00
|
|
|
// Cannot completely remove virtual function even in release mode.
|
2012-09-12 06:23:19 +08:00
|
|
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
2008-11-20 07:18:57 +08:00
|
|
|
SU->getInstr()->dump();
|
2012-09-07 03:06:06 +08:00
|
|
|
#endif
|
2008-11-20 07:18:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const {
|
2014-06-27 06:52:05 +08:00
|
|
|
std::string s;
|
|
|
|
raw_string_ostream oss(s);
|
2009-02-11 07:27:53 +08:00
|
|
|
if (SU == &EntrySU)
|
|
|
|
oss << "<entry>";
|
|
|
|
else if (SU == &ExitSU)
|
|
|
|
oss << "<exit>";
|
|
|
|
else
|
2015-02-27 08:11:34 +08:00
|
|
|
SU->getInstr()->print(oss, /*SkipOpers=*/true);
|
2008-11-20 07:18:57 +08:00
|
|
|
return oss.str();
|
|
|
|
}
|
|
|
|
|
2012-03-07 08:18:22 +08:00
|
|
|
/// Return the basic block label. It is not necessarilly unique because a block
|
|
|
|
/// contains multiple scheduling regions. But it is fine for visualization.
|
|
|
|
std::string ScheduleDAGInstrs::getDAGName() const {
|
|
|
|
return "dag." + BB->getFullName();
|
|
|
|
}
|
2012-10-16 02:02:27 +08:00
|
|
|
|
2012-11-28 13:13:28 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// SchedDFSResult Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace llvm {
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Internal state used to compute SchedDFSResult.
|
2012-11-28 13:13:28 +08:00
|
|
|
class SchedDFSImpl {
|
|
|
|
SchedDFSResult &R;
|
|
|
|
|
|
|
|
/// Join DAG nodes into equivalence classes by their subtree.
|
|
|
|
IntEqClasses SubtreeClasses;
|
|
|
|
/// List PredSU, SuccSU pairs that represent data edges between subtrees.
|
|
|
|
std::vector<std::pair<const SUnit*, const SUnit*> > ConnectionPairs;
|
|
|
|
|
2013-01-25 14:52:27 +08:00
|
|
|
struct RootData {
|
|
|
|
unsigned NodeID;
|
2017-01-28 02:53:00 +08:00
|
|
|
unsigned ParentNodeID; ///< Parent node (member of the parent subtree).
|
|
|
|
unsigned SubInstrCount; ///< Instr count in this tree only, not children.
|
2013-01-25 14:52:27 +08:00
|
|
|
|
|
|
|
RootData(unsigned id): NodeID(id),
|
|
|
|
ParentNodeID(SchedDFSResult::InvalidSubtreeID),
|
|
|
|
SubInstrCount(0) {}
|
|
|
|
|
|
|
|
unsigned getSparseSetIndex() const { return NodeID; }
|
|
|
|
};
|
|
|
|
|
|
|
|
SparseSet<RootData> RootSet;
|
|
|
|
|
2012-11-28 13:13:28 +08:00
|
|
|
public:
|
2013-01-25 14:52:27 +08:00
|
|
|
SchedDFSImpl(SchedDFSResult &r): R(r), SubtreeClasses(R.DFSNodeData.size()) {
|
|
|
|
RootSet.setUniverse(R.DFSNodeData.size());
|
|
|
|
}
|
2012-11-28 13:13:28 +08:00
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Returns true if this node been visited by the DFS traversal.
|
2013-01-25 14:02:44 +08:00
|
|
|
///
|
|
|
|
/// During visitPostorderNode the Node's SubtreeID is assigned to the Node
|
|
|
|
/// ID. Later, SubtreeID is updated but remains valid.
|
2012-11-28 13:13:28 +08:00
|
|
|
bool isVisited(const SUnit *SU) const {
|
2013-01-25 14:52:27 +08:00
|
|
|
return R.DFSNodeData[SU->NodeNum].SubtreeID
|
|
|
|
!= SchedDFSResult::InvalidSubtreeID;
|
2012-11-28 13:13:28 +08:00
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Initializes this node's instruction count. We don't need to flag the node
|
2012-11-28 13:13:28 +08:00
|
|
|
/// visited until visitPostorder because the DAG cannot have cycles.
|
|
|
|
void visitPreorder(const SUnit *SU) {
|
2013-01-25 14:52:27 +08:00
|
|
|
R.DFSNodeData[SU->NodeNum].InstrCount =
|
|
|
|
SU->getInstr()->isTransient() ? 0 : 1;
|
2013-01-25 14:02:44 +08:00
|
|
|
}
|
2012-11-28 13:13:28 +08:00
|
|
|
|
2013-01-25 14:02:44 +08:00
|
|
|
/// Called once for each node after all predecessors are visited. Revisit this
|
|
|
|
/// node's predecessors and potentially join them now that we know the ILP of
|
|
|
|
/// the other predecessors.
|
|
|
|
void visitPostorderNode(const SUnit *SU) {
|
|
|
|
// Mark this node as the root of a subtree. It may be joined with its
|
|
|
|
// successors later.
|
2013-01-25 14:52:27 +08:00
|
|
|
R.DFSNodeData[SU->NodeNum].SubtreeID = SU->NodeNum;
|
|
|
|
RootData RData(SU->NodeNum);
|
|
|
|
RData.SubInstrCount = SU->getInstr()->isTransient() ? 0 : 1;
|
2012-11-28 13:13:28 +08:00
|
|
|
|
2013-01-25 14:02:44 +08:00
|
|
|
// If any predecessors are still in their own subtree, they either cannot be
|
|
|
|
// joined or are large enough to remain separate. If this parent node's
|
|
|
|
// total instruction count is not greater than a child subtree by at least
|
|
|
|
// the subtree limit, then try to join it now since splitting subtrees is
|
|
|
|
// only useful if multiple high-pressure paths are possible.
|
2013-01-25 14:52:27 +08:00
|
|
|
unsigned InstrCount = R.DFSNodeData[SU->NodeNum].InstrCount;
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const SDep &PredDep : SU->Preds) {
|
|
|
|
if (PredDep.getKind() != SDep::Data)
|
2013-01-25 14:02:44 +08:00
|
|
|
continue;
|
2016-10-01 07:08:07 +08:00
|
|
|
unsigned PredNum = PredDep.getSUnit()->NodeNum;
|
2013-01-25 14:52:27 +08:00
|
|
|
if ((InstrCount - R.DFSNodeData[PredNum].InstrCount) < R.SubtreeLimit)
|
2016-10-01 07:08:07 +08:00
|
|
|
joinPredSubtree(PredDep, SU, /*CheckLimit=*/false);
|
2013-01-25 14:52:27 +08:00
|
|
|
|
|
|
|
// Either link or merge the TreeData entry from the child to the parent.
|
2013-01-25 14:52:30 +08:00
|
|
|
if (R.DFSNodeData[PredNum].SubtreeID == PredNum) {
|
|
|
|
// If the predecessor's parent is invalid, this is a tree edge and the
|
|
|
|
// current node is the parent.
|
|
|
|
if (RootSet[PredNum].ParentNodeID == SchedDFSResult::InvalidSubtreeID)
|
|
|
|
RootSet[PredNum].ParentNodeID = SU->NodeNum;
|
|
|
|
}
|
|
|
|
else if (RootSet.count(PredNum)) {
|
|
|
|
// The predecessor is not a root, but is still in the root set. This
|
|
|
|
// must be the new parent that it was just joined to. Note that
|
|
|
|
// RootSet[PredNum].ParentNodeID may either be invalid or may still be
|
|
|
|
// set to the original parent.
|
2013-01-25 14:52:27 +08:00
|
|
|
RData.SubInstrCount += RootSet[PredNum].SubInstrCount;
|
|
|
|
RootSet.erase(PredNum);
|
|
|
|
}
|
2013-01-25 14:02:44 +08:00
|
|
|
}
|
2013-01-25 14:52:27 +08:00
|
|
|
RootSet[SU->NodeNum] = RData;
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// \brief Called once for each tree edge after calling visitPostOrderNode on
|
|
|
|
/// the predecessor. Increment the parent node's instruction count and
|
2013-01-25 14:52:27 +08:00
|
|
|
/// preemptively join this subtree to its parent's if it is small enough.
|
|
|
|
void visitPostorderEdge(const SDep &PredDep, const SUnit *Succ) {
|
|
|
|
R.DFSNodeData[Succ->NodeNum].InstrCount
|
|
|
|
+= R.DFSNodeData[PredDep.getSUnit()->NodeNum].InstrCount;
|
|
|
|
joinPredSubtree(PredDep, Succ);
|
2012-11-28 13:13:28 +08:00
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Adds a connection for cross edges.
|
2013-01-25 14:02:44 +08:00
|
|
|
void visitCrossEdge(const SDep &PredDep, const SUnit *Succ) {
|
2012-11-28 13:13:28 +08:00
|
|
|
ConnectionPairs.push_back(std::make_pair(PredDep.getSUnit(), Succ));
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Sets each node's subtree ID to the representative ID and record
|
|
|
|
/// connections between trees.
|
2012-11-28 13:13:28 +08:00
|
|
|
void finalize() {
|
|
|
|
SubtreeClasses.compress();
|
2013-01-25 14:52:27 +08:00
|
|
|
R.DFSTreeData.resize(SubtreeClasses.getNumClasses());
|
|
|
|
assert(SubtreeClasses.getNumClasses() == RootSet.size()
|
|
|
|
&& "number of roots should match trees");
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const RootData &Root : RootSet) {
|
|
|
|
unsigned TreeID = SubtreeClasses[Root.NodeID];
|
|
|
|
if (Root.ParentNodeID != SchedDFSResult::InvalidSubtreeID)
|
|
|
|
R.DFSTreeData[TreeID].ParentTreeID = SubtreeClasses[Root.ParentNodeID];
|
|
|
|
R.DFSTreeData[TreeID].SubInstrCount = Root.SubInstrCount;
|
2013-01-25 14:52:30 +08:00
|
|
|
// Note that SubInstrCount may be greater than InstrCount if we joined
|
|
|
|
// subtrees across a cross edge. InstrCount will be attributed to the
|
|
|
|
// original parent, while SubInstrCount will be attributed to the joined
|
|
|
|
// parent.
|
2013-01-25 14:52:27 +08:00
|
|
|
}
|
2012-11-28 13:13:28 +08:00
|
|
|
R.SubtreeConnections.resize(SubtreeClasses.getNumClasses());
|
|
|
|
R.SubtreeConnectLevels.resize(SubtreeClasses.getNumClasses());
|
|
|
|
DEBUG(dbgs() << R.getNumSubtrees() << " subtrees:\n");
|
2013-01-25 14:52:27 +08:00
|
|
|
for (unsigned Idx = 0, End = R.DFSNodeData.size(); Idx != End; ++Idx) {
|
|
|
|
R.DFSNodeData[Idx].SubtreeID = SubtreeClasses[Idx];
|
2012-11-28 13:13:28 +08:00
|
|
|
DEBUG(dbgs() << " SU(" << Idx << ") in tree "
|
2013-01-25 14:52:27 +08:00
|
|
|
<< R.DFSNodeData[Idx].SubtreeID << '\n');
|
2012-11-28 13:13:28 +08:00
|
|
|
}
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const std::pair<const SUnit*, const SUnit*> &P : ConnectionPairs) {
|
|
|
|
unsigned PredTree = SubtreeClasses[P.first->NodeNum];
|
|
|
|
unsigned SuccTree = SubtreeClasses[P.second->NodeNum];
|
2012-11-28 13:13:28 +08:00
|
|
|
if (PredTree == SuccTree)
|
|
|
|
continue;
|
2016-10-01 07:08:07 +08:00
|
|
|
unsigned Depth = P.first->getDepth();
|
2012-11-28 13:13:28 +08:00
|
|
|
addConnection(PredTree, SuccTree, Depth);
|
|
|
|
addConnection(SuccTree, PredTree, Depth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Joins the predecessor subtree with the successor that is its DFS parent.
|
|
|
|
/// Applies some heuristics before joining.
|
2013-01-25 14:02:44 +08:00
|
|
|
bool joinPredSubtree(const SDep &PredDep, const SUnit *Succ,
|
|
|
|
bool CheckLimit = true) {
|
|
|
|
assert(PredDep.getKind() == SDep::Data && "Subtrees are for data edges");
|
|
|
|
|
|
|
|
// Check if the predecessor is already joined.
|
|
|
|
const SUnit *PredSU = PredDep.getSUnit();
|
|
|
|
unsigned PredNum = PredSU->NodeNum;
|
2013-01-25 14:52:27 +08:00
|
|
|
if (R.DFSNodeData[PredNum].SubtreeID != PredNum)
|
2013-01-25 14:02:44 +08:00
|
|
|
return false;
|
2013-01-25 08:12:57 +08:00
|
|
|
|
|
|
|
// Four is the magic number of successors before a node is considered a
|
|
|
|
// pinch point.
|
|
|
|
unsigned NumDataSucs = 0;
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const SDep &SuccDep : PredSU->Succs) {
|
|
|
|
if (SuccDep.getKind() == SDep::Data) {
|
2013-01-25 08:12:57 +08:00
|
|
|
if (++NumDataSucs >= 4)
|
2013-01-25 14:02:44 +08:00
|
|
|
return false;
|
2013-01-25 08:12:57 +08:00
|
|
|
}
|
|
|
|
}
|
2013-01-25 14:52:27 +08:00
|
|
|
if (CheckLimit && R.DFSNodeData[PredNum].InstrCount > R.SubtreeLimit)
|
2013-01-25 14:02:44 +08:00
|
|
|
return false;
|
2013-01-25 14:52:27 +08:00
|
|
|
R.DFSNodeData[PredNum].SubtreeID = Succ->NodeNum;
|
2013-01-25 14:02:44 +08:00
|
|
|
SubtreeClasses.join(Succ->NodeNum, PredNum);
|
|
|
|
return true;
|
2013-01-25 08:12:57 +08:00
|
|
|
}
|
|
|
|
|
2012-11-28 13:13:28 +08:00
|
|
|
/// Called by finalize() to record a connection between trees.
|
|
|
|
void addConnection(unsigned FromTree, unsigned ToTree, unsigned Depth) {
|
|
|
|
if (!Depth)
|
|
|
|
return;
|
|
|
|
|
2013-01-25 14:52:27 +08:00
|
|
|
do {
|
|
|
|
SmallVectorImpl<SchedDFSResult::Connection> &Connections =
|
|
|
|
R.SubtreeConnections[FromTree];
|
2016-10-01 07:08:07 +08:00
|
|
|
for (SchedDFSResult::Connection &C : Connections) {
|
|
|
|
if (C.TreeID == ToTree) {
|
|
|
|
C.Level = std::max(C.Level, Depth);
|
2013-01-25 14:52:27 +08:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 13:13:28 +08:00
|
|
|
}
|
2013-01-25 14:52:27 +08:00
|
|
|
Connections.push_back(SchedDFSResult::Connection(ToTree, Depth));
|
|
|
|
FromTree = R.DFSTreeData[FromTree].ParentTreeID;
|
|
|
|
} while (FromTree != SchedDFSResult::InvalidSubtreeID);
|
2012-11-28 13:13:28 +08:00
|
|
|
}
|
|
|
|
};
|
2017-01-28 02:53:00 +08:00
|
|
|
} // end namespace llvm
|
2012-11-28 13:13:28 +08:00
|
|
|
|
2012-10-16 02:02:27 +08:00
|
|
|
namespace {
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Manage the stack used by a reverse depth-first search over the DAG.
|
2012-10-16 02:02:27 +08:00
|
|
|
class SchedDAGReverseDFS {
|
|
|
|
std::vector<std::pair<const SUnit*, SUnit::const_pred_iterator> > DFSStack;
|
|
|
|
public:
|
|
|
|
bool isComplete() const { return DFSStack.empty(); }
|
|
|
|
|
|
|
|
void follow(const SUnit *SU) {
|
|
|
|
DFSStack.push_back(std::make_pair(SU, SU->Preds.begin()));
|
|
|
|
}
|
|
|
|
void advance() { ++DFSStack.back().second; }
|
|
|
|
|
2012-11-28 13:13:28 +08:00
|
|
|
const SDep *backtrack() {
|
|
|
|
DFSStack.pop_back();
|
2014-04-14 08:51:57 +08:00
|
|
|
return DFSStack.empty() ? nullptr : std::prev(DFSStack.back().second);
|
2012-11-28 13:13:28 +08:00
|
|
|
}
|
2012-10-16 02:02:27 +08:00
|
|
|
|
|
|
|
const SUnit *getCurr() const { return DFSStack.back().first; }
|
|
|
|
|
|
|
|
SUnit::const_pred_iterator getPred() const { return DFSStack.back().second; }
|
|
|
|
|
|
|
|
SUnit::const_pred_iterator getPredEnd() const {
|
|
|
|
return getCurr()->Preds.end();
|
|
|
|
}
|
|
|
|
};
|
2015-06-23 17:49:53 +08:00
|
|
|
} // anonymous
|
2012-10-16 02:02:27 +08:00
|
|
|
|
2013-01-25 14:02:44 +08:00
|
|
|
static bool hasDataSucc(const SUnit *SU) {
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const SDep &SuccDep : SU->Succs) {
|
|
|
|
if (SuccDep.getKind() == SDep::Data &&
|
|
|
|
!SuccDep.getSUnit()->isBoundaryNode())
|
2013-01-25 14:02:44 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
/// Computes an ILP metric for all nodes in the subDAG reachable via depth-first
|
2012-10-16 02:02:27 +08:00
|
|
|
/// search from this root.
|
2013-01-25 14:33:57 +08:00
|
|
|
void SchedDFSResult::compute(ArrayRef<SUnit> SUnits) {
|
2012-10-16 02:02:27 +08:00
|
|
|
if (!IsBottomUp)
|
|
|
|
llvm_unreachable("Top-down ILP metric is unimplemnted");
|
|
|
|
|
2012-11-28 13:13:28 +08:00
|
|
|
SchedDFSImpl Impl(*this);
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const SUnit &SU : SUnits) {
|
|
|
|
if (Impl.isVisited(&SU) || hasDataSucc(&SU))
|
2013-01-25 14:33:57 +08:00
|
|
|
continue;
|
|
|
|
|
2012-11-28 13:13:28 +08:00
|
|
|
SchedDAGReverseDFS DFS;
|
2016-10-01 07:08:07 +08:00
|
|
|
Impl.visitPreorder(&SU);
|
|
|
|
DFS.follow(&SU);
|
2012-11-28 13:13:28 +08:00
|
|
|
for (;;) {
|
|
|
|
// Traverse the leftmost path as far as possible.
|
|
|
|
while (DFS.getPred() != DFS.getPredEnd()) {
|
|
|
|
const SDep &PredDep = *DFS.getPred();
|
|
|
|
DFS.advance();
|
2013-01-25 14:02:44 +08:00
|
|
|
// Ignore non-data edges.
|
2013-01-25 14:52:30 +08:00
|
|
|
if (PredDep.getKind() != SDep::Data
|
|
|
|
|| PredDep.getSUnit()->isBoundaryNode()) {
|
2013-01-25 14:02:44 +08:00
|
|
|
continue;
|
2013-01-25 14:52:30 +08:00
|
|
|
}
|
2013-01-25 14:02:44 +08:00
|
|
|
// An already visited edge is a cross edge, assuming an acyclic DAG.
|
2012-11-28 13:13:28 +08:00
|
|
|
if (Impl.isVisited(PredDep.getSUnit())) {
|
2013-01-25 14:02:44 +08:00
|
|
|
Impl.visitCrossEdge(PredDep, DFS.getCurr());
|
2012-11-28 13:13:28 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Impl.visitPreorder(PredDep.getSUnit());
|
|
|
|
DFS.follow(PredDep.getSUnit());
|
|
|
|
}
|
|
|
|
// Visit the top of the stack in postorder and backtrack.
|
|
|
|
const SUnit *Child = DFS.getCurr();
|
|
|
|
const SDep *PredDep = DFS.backtrack();
|
2013-01-25 14:02:44 +08:00
|
|
|
Impl.visitPostorderNode(Child);
|
|
|
|
if (PredDep)
|
|
|
|
Impl.visitPostorderEdge(*PredDep, DFS.getCurr());
|
2012-11-28 13:13:28 +08:00
|
|
|
if (DFS.isComplete())
|
|
|
|
break;
|
2012-10-16 02:02:27 +08:00
|
|
|
}
|
2012-11-28 13:13:28 +08:00
|
|
|
}
|
|
|
|
Impl.finalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// The root of the given SubtreeID was just scheduled. For all subtrees
|
|
|
|
/// connected to this tree, record the depth of the connection so that the
|
|
|
|
/// nearest connected subtrees can be prioritized.
|
|
|
|
void SchedDFSResult::scheduleTree(unsigned SubtreeID) {
|
2016-10-01 07:08:07 +08:00
|
|
|
for (const Connection &C : SubtreeConnections[SubtreeID]) {
|
|
|
|
SubtreeConnectLevels[C.TreeID] =
|
|
|
|
std::max(SubtreeConnectLevels[C.TreeID], C.Level);
|
|
|
|
DEBUG(dbgs() << " Tree: " << C.TreeID
|
|
|
|
<< " @" << SubtreeConnectLevels[C.TreeID] << '\n');
|
2012-10-16 02:02:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-28 10:02:38 +08:00
|
|
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
|
|
|
LLVM_DUMP_METHOD void ILPValue::print(raw_ostream &OS) const {
|
2012-11-28 13:13:28 +08:00
|
|
|
OS << InstrCount << " / " << Length << " = ";
|
|
|
|
if (!Length)
|
2012-10-16 02:02:27 +08:00
|
|
|
OS << "BADILP";
|
2012-11-28 13:13:28 +08:00
|
|
|
else
|
|
|
|
OS << format("%g", ((double)InstrCount / Length));
|
2012-10-16 02:02:27 +08:00
|
|
|
}
|
|
|
|
|
2017-01-28 10:02:38 +08:00
|
|
|
LLVM_DUMP_METHOD void ILPValue::dump() const {
|
2012-10-16 02:02:27 +08:00
|
|
|
dbgs() << *this << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-07-02 05:19:13 +08:00
|
|
|
LLVM_DUMP_METHOD
|
2012-10-16 02:02:27 +08:00
|
|
|
raw_ostream &operator<<(raw_ostream &OS, const ILPValue &Val) {
|
|
|
|
Val.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
2017-01-28 02:53:00 +08:00
|
|
|
} // end namespace llvm
|
2017-01-28 10:02:38 +08:00
|
|
|
#endif
|