Skip to content

Commit 090b984

Browse files
AutomergerAutomerger
authored andcommitted
Propagating prior merge from 'llvm.org/master'.
apple-llvm-split-commit: a13b70864790bef7c5090447e061ec1a711847f5 apple-llvm-split-dir: llvm/
2 parents a7578f8 + f7a6fb9 commit 090b984

File tree

214 files changed

+6982
-860
lines changed

Some content is hidden

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

214 files changed

+6982
-860
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include "llvm/Pass.h"
2828
#include "llvm/Support/AtomicOrdering.h"
2929
#include "llvm/Support/DataTypes.h"
30+
#include "llvm/Analysis/LoopInfo.h"
31+
#include "llvm/Analysis/ScalarEvolution.h"
32+
#include "llvm/IR/Dominators.h"
3033
#include <functional>
3134

3235
namespace llvm {
@@ -75,6 +78,26 @@ struct MemIntrinsicInfo {
7578
}
7679
};
7780

81+
/// Attributes of a target dependent hardware loop.
82+
struct HardwareLoopInfo {
83+
HardwareLoopInfo() = delete;
84+
HardwareLoopInfo(Loop *L) : L(L) {}
85+
Loop *L = nullptr;
86+
BasicBlock *ExitBlock = nullptr;
87+
BranchInst *ExitBranch = nullptr;
88+
const SCEV *ExitCount = nullptr;
89+
IntegerType *CountType = nullptr;
90+
Value *LoopDecrement = nullptr; // Decrement the loop counter by this
91+
// value in every iteration.
92+
bool IsNestingLegal = false; // Can a hardware loop be a parent to
93+
// another hardware loop?
94+
bool CounterInReg = false; // Should loop counter be updated in
95+
// the loop via a phi?
96+
bool isHardwareLoopCandidate(ScalarEvolution &SE, LoopInfo &LI,
97+
DominatorTree &DT, bool ForceNestedLoop = false,
98+
bool ForceHardwareLoopPHI = false);
99+
};
100+
78101
/// This pass provides access to the codegen interfaces that are needed
79102
/// for IR-level transformations.
80103
class TargetTransformInfo {
@@ -448,23 +471,6 @@ class TargetTransformInfo {
448471
void getUnrollingPreferences(Loop *L, ScalarEvolution &,
449472
UnrollingPreferences &UP) const;
450473

451-
/// Attributes of a target dependent hardware loop.
452-
struct HardwareLoopInfo {
453-
HardwareLoopInfo() = delete;
454-
HardwareLoopInfo(Loop *L) : L(L) { }
455-
Loop *L = nullptr;
456-
BasicBlock *ExitBlock = nullptr;
457-
BranchInst *ExitBranch = nullptr;
458-
const SCEV *ExitCount = nullptr;
459-
IntegerType *CountType = nullptr;
460-
Value *LoopDecrement = nullptr; // Decrement the loop counter by this
461-
// value in every iteration.
462-
bool IsNestingLegal = false; // Can a hardware loop be a parent to
463-
// another hardware loop?
464-
bool CounterInReg = false; // Should loop counter be updated in
465-
// the loop via a phi?
466-
};
467-
468474
/// Query the target whether it would be profitable to convert the given loop
469475
/// into a hardware loop.
470476
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class TargetTransformInfoImplBase {
193193
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
194194
AssumptionCache &AC,
195195
TargetLibraryInfo *LibInfo,
196-
TTI::HardwareLoopInfo &HWLoopInfo) {
196+
HardwareLoopInfo &HWLoopInfo) {
197197
return false;
198198
}
199199

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
495495
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
496496
AssumptionCache &AC,
497497
TargetLibraryInfo *LibInfo,
498-
TTI::HardwareLoopInfo &HWLoopInfo) {
498+
HardwareLoopInfo &HWLoopInfo) {
499499
return BaseT::isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
500500
}
501501

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,9 @@ namespace llvm {
345345
/// pointer or stack pointer index addressing.
346346
extern char &LocalStackSlotAllocationID;
347347

348-
/// ExpandISelPseudos - This pass expands pseudo-instructions.
349-
extern char &ExpandISelPseudosID;
348+
/// This pass expands pseudo-instructions, reserves registers and adjusts
349+
/// machine frame information.
350+
extern char &FinalizeISelID;
350351

351352
/// UnpackMachineBundles - This pass unpack machine instruction bundles.
352353
extern char &UnpackMachineBundlesID;

llvm/include/llvm/DebugInfo/CodeView/CodeView.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ enum class ModifierOptions : uint16_t {
304304
};
305305
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions)
306306

307+
// If the subsection kind has this bit set, then the linker should ignore it.
308+
enum : uint32_t { SubsectionIgnoreFlag = 0x80000000 };
309+
307310
enum class DebugSubsectionKind : uint32_t {
308311
None = 0,
309312
Symbols = 0xf1,

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
X(InitListExpr) \
9090
X(FoldExpr) \
9191
X(ThrowExpr) \
92+
X(UUIDOfExpr) \
9293
X(BoolExpr) \
9394
X(IntegerCastExpr) \
9495
X(IntegerLiteral) \
@@ -1873,6 +1874,21 @@ class ThrowExpr : public Node {
18731874
}
18741875
};
18751876

1877+
// MSVC __uuidof extension, generated by clang in -fms-extensions mode.
1878+
class UUIDOfExpr : public Node {
1879+
Node *Operand;
1880+
public:
1881+
UUIDOfExpr(Node *Operand_) : Node(KUUIDOfExpr), Operand(Operand_) {}
1882+
1883+
template<typename Fn> void match(Fn F) const { F(Operand); }
1884+
1885+
void printLeft(OutputStream &S) const override {
1886+
S << "__uuidof(";
1887+
Operand->print(S);
1888+
S << ")";
1889+
}
1890+
};
1891+
18761892
class BoolExpr : public Node {
18771893
bool Value;
18781894

@@ -4649,6 +4665,21 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
46494665
case '9':
46504666
return getDerived().parseUnresolvedName();
46514667
}
4668+
4669+
if (consumeIf("u8__uuidoft")) {
4670+
Node *Ty = getDerived().parseType();
4671+
if (!Ty)
4672+
return nullptr;
4673+
return make<UUIDOfExpr>(Ty);
4674+
}
4675+
4676+
if (consumeIf("u8__uuidofz")) {
4677+
Node *Ex = getDerived().parseExpr();
4678+
if (!Ex)
4679+
return nullptr;
4680+
return make<UUIDOfExpr>(Ex);
4681+
}
4682+
46524683
return nullptr;
46534684
}
46544685

llvm/include/llvm/IR/IntrinsicsX86.td

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,17 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
277277
// Control register.
278278
let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
279279
def int_x86_sse_stmxcsr :
280-
Intrinsic<[], [llvm_ptr_ty], []>;
280+
Intrinsic<[], [llvm_ptr_ty],
281+
[IntrWriteMem, IntrArgMemOnly,
282+
// This prevents reordering with ldmxcsr
283+
IntrHasSideEffects]>;
281284
def int_x86_sse_ldmxcsr :
282-
Intrinsic<[], [llvm_ptr_ty], []>;
285+
Intrinsic<[], [llvm_ptr_ty],
286+
[IntrReadMem, IntrArgMemOnly, IntrHasSideEffects,
287+
// FIXME: LDMXCSR does not actualy write to memory,
288+
// but Fast and DAG Isel both use writing to memory
289+
// as a proxy for having side effects.
290+
IntrWriteMem]>;
283291
}
284292

285293
// Misc.

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ void initializeEarlyTailDuplicatePass(PassRegistry&);
137137
void initializeEdgeBundlesPass(PassRegistry&);
138138
void initializeEliminateAvailableExternallyLegacyPassPass(PassRegistry&);
139139
void initializeEntryExitInstrumenterPass(PassRegistry&);
140-
void initializeExpandISelPseudosPass(PassRegistry&);
141140
void initializeExpandMemCmpPassPass(PassRegistry&);
142141
void initializeExpandPostRAPass(PassRegistry&);
143142
void initializeExpandReductionsPass(PassRegistry&);
144143
void initializeMakeGuardsExplicitLegacyPassPass(PassRegistry&);
145144
void initializeExternalAAWrapperPassPass(PassRegistry&);
146145
void initializeFEntryInserterPass(PassRegistry&);
146+
void initializeFinalizeISelPass(PassRegistry&);
147147
void initializeFinalizeMachineBundlesPass(PassRegistry&);
148148
void initializeFlattenCFGPassPass(PassRegistry&);
149149
void initializeFloat2IntLegacyPassPass(PassRegistry&);

llvm/include/llvm/ObjectYAML/ELFYAML.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct DynamicSection : Section {
153153
struct RawContentSection : Section {
154154
Optional<yaml::BinaryRef> Content;
155155
Optional<llvm::yaml::Hex64> Size;
156-
llvm::yaml::Hex64 Info;
156+
Optional<llvm::yaml::Hex64> Info;
157157

158158
RawContentSection() : Section(SectionKind::RawContent) {}
159159

llvm/include/llvm/Target/Target.td

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,49 @@ include "llvm/Target/TargetSchedule.td"
398398

399399
class Predicate; // Forward def
400400

401+
class InstructionEncoding {
402+
// Size of encoded instruction.
403+
int Size;
404+
405+
// The "namespace" in which this instruction exists, on targets like ARM
406+
// which multiple ISA namespaces exist.
407+
string DecoderNamespace = "";
408+
409+
// List of predicates which will be turned into isel matching code.
410+
list<Predicate> Predicates = [];
411+
412+
string DecoderMethod = "";
413+
414+
// Is the instruction decoder method able to completely determine if the
415+
// given instruction is valid or not. If the TableGen definition of the
416+
// instruction specifies bitpattern A??B where A and B are static bits, the
417+
// hasCompleteDecoder flag says whether the decoder method fully handles the
418+
// ?? space, i.e. if it is a final arbiter for the instruction validity.
419+
// If not then the decoder attempts to continue decoding when the decoder
420+
// method fails.
421+
//
422+
// This allows to handle situations where the encoding is not fully
423+
// orthogonal. Example:
424+
// * InstA with bitpattern 0b0000????,
425+
// * InstB with bitpattern 0b000000?? but the associated decoder method
426+
// DecodeInstB() returns Fail when ?? is 0b00 or 0b11.
427+
//
428+
// The decoder tries to decode a bitpattern that matches both InstA and
429+
// InstB bitpatterns first as InstB (because it is the most specific
430+
// encoding). In the default case (hasCompleteDecoder = 1), when
431+
// DecodeInstB() returns Fail the bitpattern gets rejected. By setting
432+
// hasCompleteDecoder = 0 in InstB, the decoder is informed that
433+
// DecodeInstB() is not able to determine if all possible values of ?? are
434+
// valid or not. If DecodeInstB() returns Fail the decoder will attempt to
435+
// decode the bitpattern as InstA too.
436+
bit hasCompleteDecoder = 1;
437+
}
438+
401439
//===----------------------------------------------------------------------===//
402440
// Instruction set description - These classes correspond to the C++ classes in
403441
// the Target/TargetInstrInfo.h file.
404442
//
405-
class Instruction {
443+
class Instruction : InstructionEncoding {
406444
string Namespace = "";
407445

408446
dag OutOperandList; // An dag containing the MI def operand list.
@@ -427,10 +465,6 @@ class Instruction {
427465
// from the opcode.
428466
int Size = 0;
429467

430-
// DecoderNamespace - The "namespace" in which this instruction exists, on
431-
// targets like ARM which multiple ISA namespaces exist.
432-
string DecoderNamespace = "";
433-
434468
// Code size, for instruction selection.
435469
// FIXME: What does this actually mean?
436470
int CodeSize = 0;
@@ -532,31 +566,6 @@ class Instruction {
532566
string DisableEncoding = "";
533567

534568
string PostEncoderMethod = "";
535-
string DecoderMethod = "";
536-
537-
// Is the instruction decoder method able to completely determine if the
538-
// given instruction is valid or not. If the TableGen definition of the
539-
// instruction specifies bitpattern A??B where A and B are static bits, the
540-
// hasCompleteDecoder flag says whether the decoder method fully handles the
541-
// ?? space, i.e. if it is a final arbiter for the instruction validity.
542-
// If not then the decoder attempts to continue decoding when the decoder
543-
// method fails.
544-
//
545-
// This allows to handle situations where the encoding is not fully
546-
// orthogonal. Example:
547-
// * InstA with bitpattern 0b0000????,
548-
// * InstB with bitpattern 0b000000?? but the associated decoder method
549-
// DecodeInstB() returns Fail when ?? is 0b00 or 0b11.
550-
//
551-
// The decoder tries to decode a bitpattern that matches both InstA and
552-
// InstB bitpatterns first as InstB (because it is the most specific
553-
// encoding). In the default case (hasCompleteDecoder = 1), when
554-
// DecodeInstB() returns Fail the bitpattern gets rejected. By setting
555-
// hasCompleteDecoder = 0 in InstB, the decoder is informed that
556-
// DecodeInstB() is not able to determine if all possible values of ?? are
557-
// valid or not. If DecodeInstB() returns Fail the decoder will attempt to
558-
// decode the bitpattern as InstA too.
559-
bit hasCompleteDecoder = 1;
560569

561570
/// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
562571
bits<64> TSFlags = 0;
@@ -593,6 +602,13 @@ class Instruction {
593602
bit FastISelShouldIgnore = 0;
594603
}
595604

605+
/// Defines an additional encoding that disassembles to the given instruction
606+
/// Like Instruction, the Inst and SoftFail fields are omitted to allow targets
607+
// to specify their size.
608+
class AdditionalEncoding<Instruction I> : InstructionEncoding {
609+
Instruction AliasOf = I;
610+
}
611+
596612
/// PseudoInstExpansion - Expansion information for a pseudo-instruction.
597613
/// Which instruction it expands to and how the operands map from the
598614
/// pseudo.

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,91 @@ struct NoTTIImpl : TargetTransformInfoImplCRTPBase<NoTTIImpl> {
4040
};
4141
}
4242

43+
bool HardwareLoopInfo::isHardwareLoopCandidate(ScalarEvolution &SE,
44+
LoopInfo &LI, DominatorTree &DT,
45+
bool ForceNestedLoop,
46+
bool ForceHardwareLoopPHI) {
47+
SmallVector<BasicBlock *, 4> ExitingBlocks;
48+
L->getExitingBlocks(ExitingBlocks);
49+
50+
for (SmallVectorImpl<BasicBlock *>::iterator I = ExitingBlocks.begin(),
51+
IE = ExitingBlocks.end();
52+
I != IE; ++I) {
53+
BasicBlock *BB = *I;
54+
55+
// If we pass the updated counter back through a phi, we need to know
56+
// which latch the updated value will be coming from.
57+
if (!L->isLoopLatch(BB)) {
58+
if (ForceHardwareLoopPHI || CounterInReg)
59+
continue;
60+
}
61+
62+
const SCEV *EC = SE.getExitCount(L, BB);
63+
if (isa<SCEVCouldNotCompute>(EC))
64+
continue;
65+
if (const SCEVConstant *ConstEC = dyn_cast<SCEVConstant>(EC)) {
66+
if (ConstEC->getValue()->isZero())
67+
continue;
68+
} else if (!SE.isLoopInvariant(EC, L))
69+
continue;
70+
71+
if (SE.getTypeSizeInBits(EC->getType()) > CountType->getBitWidth())
72+
continue;
73+
74+
// If this exiting block is contained in a nested loop, it is not eligible
75+
// for insertion of the branch-and-decrement since the inner loop would
76+
// end up messing up the value in the CTR.
77+
if (!IsNestingLegal && LI.getLoopFor(BB) != L && !ForceNestedLoop)
78+
continue;
79+
80+
// We now have a loop-invariant count of loop iterations (which is not the
81+
// constant zero) for which we know that this loop will not exit via this
82+
// existing block.
83+
84+
// We need to make sure that this block will run on every loop iteration.
85+
// For this to be true, we must dominate all blocks with backedges. Such
86+
// blocks are in-loop predecessors to the header block.
87+
bool NotAlways = false;
88+
for (pred_iterator PI = pred_begin(L->getHeader()),
89+
PIE = pred_end(L->getHeader());
90+
PI != PIE; ++PI) {
91+
if (!L->contains(*PI))
92+
continue;
93+
94+
if (!DT.dominates(*I, *PI)) {
95+
NotAlways = true;
96+
break;
97+
}
98+
}
99+
100+
if (NotAlways)
101+
continue;
102+
103+
// Make sure this blocks ends with a conditional branch.
104+
Instruction *TI = BB->getTerminator();
105+
if (!TI)
106+
continue;
107+
108+
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
109+
if (!BI->isConditional())
110+
continue;
111+
112+
ExitBranch = BI;
113+
} else
114+
continue;
115+
116+
// Note that this block may not be the loop latch block, even if the loop
117+
// has a latch block.
118+
ExitBlock = *I;
119+
ExitCount = EC;
120+
break;
121+
}
122+
123+
if (!ExitBlock)
124+
return false;
125+
return true;
126+
}
127+
43128
TargetTransformInfo::TargetTransformInfo(const DataLayout &DL)
44129
: TTIImpl(new Model<NoTTIImpl>(NoTTIImpl(DL))) {}
45130

0 commit comments

Comments
 (0)