Skip to content

Commit

Permalink
SWDEV-179954 - OpenCL/LC - Merge branch amd-master into amd-common
Browse files Browse the repository at this point in the history
Change-Id: Ib04365f28ee7aa856eba066142adaeadfa17f86f
  • Loading branch information
Jenkins committed Jun 12, 2019
2 parents 648441a + 48a8989 commit 742a194
Show file tree
Hide file tree
Showing 56 changed files with 2,346 additions and 62 deletions.
22 changes: 18 additions & 4 deletions docs/CommandGuide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,38 @@ Basic Commands
llc
lli
llvm-link
llvm-ar
llvm-lib
llvm-lipo
llvm-nm
llvm-objdump
llvm-config
llvm-cxxmap
llvm-diff
llvm-cov
llvm-profdata
llvm-stress
llvm-symbolizer
llvm-addr2line
llvm-dwarfdump
dsymutil
llvm-mca
llvm-readobj

GNU binutils replacements
~~~~~~~~~~~~~~~~~~~~~~~~~

.. toctree::
:maxdepth: 1

llvm-addr2line
llvm-ar
llvm-cxxfilt
llvm-nm
llvm-objcopy
llvm-objdump
llvm-ranlib
llvm-readelf
llvm-size
llvm-strings
llvm-strip

Debugging Tools
~~~~~~~~~~~~~~~

Expand Down
10 changes: 10 additions & 0 deletions docs/CommandGuide/llvm-cxxfilt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# llvm-cxxfilt - a symbol demangler

## SYNOPSIS

**llvm-cxxfilt** [*options*]

## DESCRIPTION

**llvm-cxxfilt** is symbol demangler that can be used as a replacement for the
GNU **c++filt** tool.
16 changes: 16 additions & 0 deletions docs/CommandGuide/llvm-objcopy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# llvm-objcopy - object copying tool

## SYNOPSIS

**llvm-objcopy** [*options*]

## DESCRIPTION

**llvm-objcopy** is a tool to copy and manipulate objects.

The tool is still in active development, but in most scenarios it works as a
drop-in replacement for GNU's **objcopy**.

## SEE ALSO

[llvm-strip](llvm-strip.html)
17 changes: 17 additions & 0 deletions docs/CommandGuide/llvm-ranlib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# llvm-ranlib - generates an archive index

## SYNOPSIS

**llvm-ranlib** [*options*]

## DESCRIPTION

**llvm-ranlib** is an alias for the [llvm-ar](llvm-ar.html) tool that generates
an index for an archive. It can be used as a replacement for GNU's **ranlib**
tool.

Running **llvm-ranlib** is equivalent to running **llvm-ar s**.

## SEE ALSO

Refer to [llvm-ar](llvm-ar.html) for additional information.
28 changes: 28 additions & 0 deletions docs/CommandGuide/llvm-readelf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# llvm-readelf - a drop-in replacement for readelf

## SYNOPSIS

**llvm-readelf** [*options*]

## DESCRIPTION

**llvm-readelf** is an alias for the [llvm-readobj](llvm-readobj.html) tool with
a command-line interface and output style more closely resembling GNU
**readelf**.

Here are some of those differences:

* Uses `--elf-output-style=GNU` by default.

* Allows single-letter grouped flags (e.g. `llvm-readelf -SW` is the same as
`llvm-readelf -S -W`).

* Allows use of `-s` as an alias for `--symbols` (versus `--section-headers` in
**llvm-readobj**) for GNU **readelf** compatibility.

* Prevents use of `-sr`, `-sd`, `-st` and `-dt` **llvm-readobj** aliases, to
avoid conflicting with standard GNU **readelf** grouped flags.

## SEE ALSO

Refer to [llvm-readobj](llvm-readobj.html) for additional information.
10 changes: 10 additions & 0 deletions docs/CommandGuide/llvm-size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# llvm-size - print segment sizes

## SYNOPSIS

**llvm-size** [*options*]

## DESCRIPTION

**llvm-size** is a tool that prints segment sizes in object files. The goal is
to make it a drop-in replacement for GNU's **size**.
10 changes: 10 additions & 0 deletions docs/CommandGuide/llvm-strings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# llvm-strings - print strings

## SYNOPSIS

**llvm-strings** [*options*]

## DESCRIPTION

**llvm-strings** is a tool that prints strings in object files. The goal is to
make it a drop-in replacement for GNU's **size**.
16 changes: 16 additions & 0 deletions docs/CommandGuide/llvm-strip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# llvm-strip - object stripping tool

## SYNOPSIS

**llvm-strip** [*options*]

## DESCRIPTION

**llvm-strip** is a tool to strip sections and symbols from object files.

The tool is still in active development, but in most scenarios it works as a
drop-in replacement for GNU's **strip**.

## SEE ALSO

[llvm-objcopy](llvm-objcopy.html)
6 changes: 6 additions & 0 deletions include/llvm/Analysis/VectorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ Value *findScalarElement(Value *V, unsigned EltNo);
/// a sequence of instructions that broadcast a single value into a vector.
const Value *getSplatValue(const Value *V);

/// Return true if the input value is known to be a vector with all identical
/// elements (potentially including undefined elements).
/// This may be more powerful than the related getSplatValue() because it is
/// not limited by finding a scalar source value to a splatted vector.
bool isSplatValue(const Value *V, unsigned Depth = 0);

/// Compute a map of integer instructions to their minimum legal type
/// size.
///
Expand Down
8 changes: 8 additions & 0 deletions include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,14 @@ class MachineIRBuilder {
return buildInstr(TargetOpcode::G_UMAX, {Dst}, {Src0, Src1});
}

/// Build and insert \p Res = G_JUMP_TABLE \p JTI
///
/// G_JUMP_TABLE sets \p Res to the address of the jump table specified by
/// the jump table index \p JTI.
///
/// \return a MachineInstrBuilder for the newly created instruction.
MachineInstrBuilder buildJumpTable(const LLT PtrTy, unsigned JTI);

virtual MachineInstrBuilder buildInstr(unsigned Opc, ArrayRef<DstOp> DstOps,
ArrayRef<SrcOp> SrcOps,
Optional<unsigned> Flags = None);
Expand Down
6 changes: 3 additions & 3 deletions include/llvm/CodeGen/MachinePipeliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ class SwingSchedulerDAG : public ScheduleDAGInstrs {
MBBVectorTy &EpilogBBs);
void splitLifetimes(MachineBasicBlock *KernelBB, MBBVectorTy &EpilogBBs,
SMSchedule &Schedule);
void addBranches(MBBVectorTy &PrologBBs, MachineBasicBlock *KernelBB,
MBBVectorTy &EpilogBBs, SMSchedule &Schedule,
ValueMapTy *VRMap);
void addBranches(MachineBasicBlock &PreheaderBB, MBBVectorTy &PrologBBs,
MachineBasicBlock *KernelBB, MBBVectorTy &EpilogBBs,
SMSchedule &Schedule, ValueMapTy *VRMap);
bool computeDelta(MachineInstr &MI, unsigned &Delta);
void updateMemOperands(MachineInstr &NewMI, MachineInstr &OldMI,
unsigned Num);
Expand Down
5 changes: 3 additions & 2 deletions include/llvm/CodeGen/TargetInstrInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,9 @@ class TargetInstrInfo : public MCInstrInfo {
/// is finished. Return the value/register of the new loop count. We need
/// this function when peeling off one or more iterations of a loop. This
/// function assumes the nth iteration is peeled first.
virtual unsigned reduceLoopCount(MachineBasicBlock &MBB, MachineInstr *IndVar,
MachineInstr &Cmp,
virtual unsigned reduceLoopCount(MachineBasicBlock &MBB,
MachineBasicBlock &PreHeader,
MachineInstr *IndVar, MachineInstr &Cmp,
SmallVectorImpl<MachineOperand> &Cond,
SmallVectorImpl<MachineInstr *> &PrevInsts,
unsigned Iter, unsigned MaxIter) const {
Expand Down
3 changes: 3 additions & 0 deletions include/llvm/CodeGen/TargetSubtargetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ class TargetSubtargetInfo : public MCSubtargetInfo {
/// for preRA scheduling with the source level scheduler.
virtual bool enableMachineSchedDefaultSched() const { return true; }

/// True if the subtarget should run MachinePipeliner
virtual bool enableMachinePipeliner() const { return true; };

/// True if the subtarget should enable joining global copies.
///
/// By default this is enabled if the machine scheduler is enabled, but
Expand Down
5 changes: 4 additions & 1 deletion include/llvm/Support/TargetOpcodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,15 @@ HANDLE_TARGET_OPCODE(G_ADDRSPACE_CAST)
/// Generic block address
HANDLE_TARGET_OPCODE(G_BLOCK_ADDR)

/// Generic jump table address
HANDLE_TARGET_OPCODE(G_JUMP_TABLE)

// TODO: Add more generic opcodes as we move along.

/// Marker for the end of the generic opcode.
/// This is used to check if an opcode is in the range of the
/// generic opcodes.
HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_END, G_BLOCK_ADDR)
HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_END, G_JUMP_TABLE)

/// BUILTIN_OP_END - This must be the last enum value in this list.
/// The target-specific post-isel opcode values start here.
Expand Down
6 changes: 6 additions & 0 deletions include/llvm/Target/GenericOpcodes.td
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ def G_BLOCK_ADDR : GenericInstruction {
let hasSideEffects = 0;
}

def G_JUMP_TABLE : GenericInstruction {
let OutOperandList = (outs type0:$dst);
let InOperandList = (ins unknown:$jti);
let hasSideEffects = 0;
}

//------------------------------------------------------------------------------
// Binary ops.
//------------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions lib/Analysis/LoopAnalysisManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ PreservedAnalyses llvm::getLoopPassPreservedAnalyses() {
PA.preserve<LoopAnalysis>();
PA.preserve<LoopAnalysisManagerFunctionProxy>();
PA.preserve<ScalarEvolutionAnalysis>();
if (EnableMSSALoopDependency)
PA.preserve<MemorySSAAnalysis>();
// FIXME: What we really want to do here is preserve an AA category, but that
// concept doesn't exist yet.
PA.preserve<AAManager>();
Expand Down
5 changes: 4 additions & 1 deletion lib/Analysis/MemorySSAUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,13 +860,14 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates,

SmallVector<BasicBlock *, 8> BlocksToProcess;
SmallVector<BasicBlock *, 16> BlocksWithDefsToReplace;
SmallVector<WeakVH, 8> InsertedPhis;

// First create MemoryPhis in all blocks that don't have one. Create in the
// order found in Updates, not in PredMap, to get deterministic numbering.
for (auto &Edge : Updates) {
BasicBlock *BB = Edge.getTo();
if (PredMap.count(BB) && !MSSA->getMemoryAccess(BB))
MSSA->createMemoryPhi(BB);
InsertedPhis.push_back(MSSA->createMemoryPhi(BB));
}

// Now we'll fill in the MemoryPhis with the right incoming values.
Expand Down Expand Up @@ -967,6 +968,7 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates,
IDFPhi->setIncomingValue(I, GetLastDef(IDFPhi->getIncomingBlock(I)));
} else {
IDFPhi = MSSA->createMemoryPhi(BBIDF);
InsertedPhis.push_back(IDFPhi);
for (auto &Pair : children<GraphDiffInvBBPair>({GD, BBIDF})) {
BasicBlock *Pi = Pair.second;
IDFPhi->addIncoming(GetLastDef(Pi), Pi);
Expand Down Expand Up @@ -1009,6 +1011,7 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates,
}
}
}
tryRemoveTrivialPhis(InsertedPhis);
}

// Move What before Where in the MemorySSA IR.
Expand Down
4 changes: 2 additions & 2 deletions lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8126,9 +8126,9 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
break;
}
}
if (!MultipleInitValues && InitValue)
return getSCEV(InitValue);
}
if (!MultipleInitValues && InitValue)
return getSCEV(InitValue);
}
// Okay, we know how many times the containing loop executes. If
// this is a constant evolving PHI node, get the final value at
Expand Down
39 changes: 39 additions & 0 deletions lib/Analysis/VectorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,45 @@ const llvm::Value *llvm::getSplatValue(const Value *V) {
return nullptr;
}

// This setting is based on its counterpart in value tracking, but it could be
// adjusted if needed.
const unsigned MaxDepth = 6;

bool llvm::isSplatValue(const Value *V, unsigned Depth) {
assert(Depth <= MaxDepth && "Limit Search Depth");

if (isa<VectorType>(V->getType())) {
if (isa<UndefValue>(V))
return true;
// FIXME: Constant splat analysis does not allow undef elements.
if (auto *C = dyn_cast<Constant>(V))
return C->getSplatValue() != nullptr;
}

// FIXME: Constant splat analysis does not allow undef elements.
Constant *Mask;
if (match(V, m_ShuffleVector(m_Value(), m_Value(), m_Constant(Mask))))
return Mask->getSplatValue() != nullptr;

// The remaining tests are all recursive, so bail out if we hit the limit.
if (Depth++ == MaxDepth)
return false;

// If both operands of a binop are splats, the result is a splat.
Value *X, *Y, *Z;
if (match(V, m_BinOp(m_Value(X), m_Value(Y))))
return isSplatValue(X, Depth) && isSplatValue(Y, Depth);

// If all operands of a select are splats, the result is a splat.
if (match(V, m_Select(m_Value(X), m_Value(Y), m_Value(Z))))
return isSplatValue(X, Depth) && isSplatValue(Y, Depth) &&
isSplatValue(Z, Depth);

// TODO: Add support for unary ops (fneg), casts, intrinsics (overflow ops).

return false;
}

MapVector<Instruction *, uint64_t>
llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
const TargetTransformInfo *TTI) {
Expand Down
6 changes: 6 additions & 0 deletions lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ MachineInstrBuilder MachineIRBuilder::buildGlobalValue(unsigned Res,
.addGlobalAddress(GV);
}

MachineInstrBuilder MachineIRBuilder::buildJumpTable(const LLT PtrTy,
unsigned JTI) {
return buildInstr(TargetOpcode::G_JUMP_TABLE, {PtrTy}, {})
.addJumpTableIndex(JTI);
}

void MachineIRBuilder::validateBinaryOp(const LLT &Res, const LLT &Op0,
const LLT &Op1) {
assert((Res.isScalar() || Res.isVector()) && "invalid operand type");
Expand Down
Loading

0 comments on commit 742a194

Please sign in to comment.