diff --git a/clang/include/clang/AST/DeclarationName.h b/clang/include/clang/AST/DeclarationName.h index 3cb0a02ff49b..b7334bf3d3a2 100644 --- a/clang/include/clang/AST/DeclarationName.h +++ b/clang/include/clang/AST/DeclarationName.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace clang { @@ -194,6 +195,14 @@ class DeclarationName { "The various classes that DeclarationName::Ptr can point to" " must be at least aligned to 8 bytes!"); + static_assert(std::is_same< + std::underlying_type_t, + std::underlying_type_t + >::value, + "The various enums used to compute values for NameKind should " + "all have the same underlying type" + ); + public: /// The kind of the name stored in this DeclarationName. /// The first 7 enumeration values are stored inline and correspond @@ -207,15 +216,18 @@ class DeclarationName { CXXDestructorName = StoredCXXDestructorName, CXXConversionFunctionName = StoredCXXConversionFunctionName, CXXOperatorName = StoredCXXOperatorName, - CXXDeductionGuideName = UncommonNameKindOffset + - detail::DeclarationNameExtra::CXXDeductionGuideName, + CXXDeductionGuideName = + static_cast>(UncommonNameKindOffset) + + static_cast>(detail::DeclarationNameExtra::CXXDeductionGuideName), CXXLiteralOperatorName = - UncommonNameKindOffset + - detail::DeclarationNameExtra::CXXLiteralOperatorName, - CXXUsingDirective = UncommonNameKindOffset + - detail::DeclarationNameExtra::CXXUsingDirective, - ObjCMultiArgSelector = UncommonNameKindOffset + - detail::DeclarationNameExtra::ObjCMultiArgSelector + static_cast>(UncommonNameKindOffset) + + static_cast>(detail::DeclarationNameExtra::CXXLiteralOperatorName), + CXXUsingDirective = + static_cast>(UncommonNameKindOffset) + + static_cast>(detail::DeclarationNameExtra::CXXUsingDirective), + ObjCMultiArgSelector = + static_cast>(UncommonNameKindOffset) + + static_cast>(detail::DeclarationNameExtra::ObjCMultiArgSelector), }; private: diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h index 98c120fe2d2e..1f44aaff7b4f 100644 --- a/llvm/include/llvm/ADT/StringRef.h +++ b/llvm/include/llvm/ADT/StringRef.h @@ -76,6 +76,7 @@ namespace llvm { return ::memcmp(Lhs,Rhs,Length); } + protected: // Constexpr version of std::strlen. static constexpr size_t strLen(const char *Str) { #if __cplusplus > 201402L @@ -91,6 +92,13 @@ namespace llvm { #endif } +#if __cpp_char8_t + // Constexpr version of std::strlen for char8_t + static constexpr size_t strLen(const char8_t *Str) { + return std::char_traits::length(Str); + } +#endif + public: /// @name Constructors /// @{ @@ -106,10 +114,22 @@ namespace llvm { /*implicit*/ constexpr StringRef(const char *Str) : Data(Str), Length(Str ? strLen(Str) : 0) {} +#if __cpp_char8_t + /// Construct a string ref from a cstring. + /*implicit*/ StringRef(const char8_t *Str) + : StringRef(reinterpret_cast(Str)) {} +#endif + /// Construct a string ref from a pointer and length. /*implicit*/ constexpr StringRef(const char *data, size_t length) : Data(data), Length(length) {} +#if __cpp_char8_t + /// Construct a string ref from a pointer and length. + /*implicit*/ StringRef(const char8_t *data, size_t length) + : StringRef(reinterpret_cast(data), length) {} +#endif + /// Construct a string ref from an std::string. /*implicit*/ StringRef(const std::string &Str) : Data(Str.data()), Length(Str.length()) {} @@ -874,19 +894,38 @@ namespace llvm { constexpr StringLiteral(const char *Str, size_t N) : StringRef(Str, N) { } +#if __cpp_char8_t + StringLiteral(const char8_t *Str, size_t N) : StringRef(Str, N) { + } +#endif + public: template constexpr StringLiteral(const char (&Str)[N]) #if defined(__clang__) && __has_attribute(enable_if) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wgcc-compat" - __attribute((enable_if(__builtin_strlen(Str) == N - 1, + __attribute((enable_if(strLen(Str) == N - 1, "invalid string literal"))) #pragma clang diagnostic pop #endif : StringRef(Str, N - 1) { } +#if __cpp_char8_t + template + StringLiteral(const char8_t (&Str)[N]) +#if defined(__clang__) && __has_attribute(enable_if) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgcc-compat" + __attribute((enable_if(strLen(Str) == N - 1, + "invalid string literal"))) +#pragma clang diagnostic pop +#endif + : StringRef(Str, N - 1) { + } +#endif + // Explicit construction for strings like "foo\0bar". template static constexpr StringLiteral withInnerNUL(const char (&Str)[N]) { diff --git a/llvm/include/llvm/Analysis/IteratedDominanceFrontier.h b/llvm/include/llvm/Analysis/IteratedDominanceFrontier.h index 8166b52aa226..41ae1a572140 100644 --- a/llvm/include/llvm/Analysis/IteratedDominanceFrontier.h +++ b/llvm/include/llvm/Analysis/IteratedDominanceFrontier.h @@ -73,7 +73,7 @@ ChildrenGetterTy::get(const NodeRef &N) { return {Children.begin(), Children.end()}; } - return GD->template getChildren(N); + return GD->template getChildren(N); } } // end of namespace IDFCalculatorDetail diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index a5717bae12c3..b0130611bad7 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -62,7 +62,16 @@ class MDNode; class MemorySSAUpdater; class ScalarEvolution; class raw_ostream; -template class DominatorTreeBase; + +template +using DTIdentityView = X; + +template class View> +class DominatorTreeOnView; + +template +using DominatorTreeBase = DominatorTreeOnView; + template class LoopInfoBase; template class LoopBase; diff --git a/llvm/include/llvm/CodeGen/LiveIntervalCalc.h b/llvm/include/llvm/CodeGen/LiveIntervalCalc.h index 76005e835595..ee2bf65a3657 100644 --- a/llvm/include/llvm/CodeGen/LiveIntervalCalc.h +++ b/llvm/include/llvm/CodeGen/LiveIntervalCalc.h @@ -21,7 +21,14 @@ namespace llvm { -template class DomTreeNodeBase; +template +using DTIdentityView = X; + +template class View> +class DomTreeNodeOnView; + +template +using DomTreeNodeBase = DomTreeNodeOnView; using MachineDomTreeNode = DomTreeNodeBase; diff --git a/llvm/include/llvm/CodeGen/LiveRangeCalc.h b/llvm/include/llvm/CodeGen/LiveRangeCalc.h index bbb6f2ddd233..f0cf1fad723b 100644 --- a/llvm/include/llvm/CodeGen/LiveRangeCalc.h +++ b/llvm/include/llvm/CodeGen/LiveRangeCalc.h @@ -36,13 +36,21 @@ namespace llvm { -template class DomTreeNodeBase; +template +using DTIdentityView = X; + +template class View> +class DomTreeNodeOnView; + +template +using DomTreeNodeBase = DomTreeNodeOnView; + +using MachineDomTreeNode = DomTreeNodeBase; + class MachineDominatorTree; class MachineFunction; class MachineRegisterInfo; -using MachineDomTreeNode = DomTreeNodeBase; - class LiveRangeCalc { const MachineFunction *MF = nullptr; const MachineRegisterInfo *MRI = nullptr; diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h index 46bf73cdd7b6..a96dea5985c0 100644 --- a/llvm/include/llvm/CodeGen/MachineDominators.h +++ b/llvm/include/llvm/CodeGen/MachineDominators.h @@ -32,9 +32,9 @@ inline void DominatorTreeBase::addRoot( this->Roots.push_back(MBB); } -extern template class DomTreeNodeBase; -extern template class DominatorTreeBase; // DomTree -extern template class DominatorTreeBase; // PostDomTree +extern template class DomTreeNodeOnView; +extern template class DominatorTreeOnView; // DomTree +extern template class DominatorTreeOnView; // PostDomTree using MachineDomTreeNode = DomTreeNodeBase; diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h index 08dbccaf2c01..de5a5306669d 100644 --- a/llvm/include/llvm/IR/Dominators.h +++ b/llvm/include/llvm/IR/Dominators.h @@ -32,50 +32,57 @@ class Instruction; class Module; class raw_ostream; -extern template class DomTreeNodeBase; -extern template class DominatorTreeBase; // DomTree -extern template class DominatorTreeBase; // PostDomTree +extern template class DomTreeNodeOnView; +extern template class DominatorTreeOnView; // DomTree +extern template class DominatorTreeOnView; // PostDomTree extern template class cfg::Update; namespace DomTreeBuilder { -using BBDomTree = DomTreeBase; -using BBPostDomTree = PostDomTreeBase; +template class View> +using BBDomTreeOnView = DomTreeOnView; + +using BBDomTree = DomTreeOnView; + +template class View> +using BBPostDomTreeOnView = PostDomTreeOnView; + +using BBPostDomTree = PostDomTreeOnView; using BBUpdates = ArrayRef>; -using BBDomTreeGraphDiff = GraphDiff; -using BBPostDomTreeGraphDiff = GraphDiff; - -extern template void Calculate(BBDomTree &DT); -extern template void CalculateWithUpdates(BBDomTree &DT, - BBUpdates U); - -extern template void Calculate(BBPostDomTree &DT); - -extern template void InsertEdge(BBDomTree &DT, BasicBlock *From, - BasicBlock *To); -extern template void InsertEdge(BBPostDomTree &DT, - BasicBlock *From, - BasicBlock *To); - -extern template void DeleteEdge(BBDomTree &DT, BasicBlock *From, - BasicBlock *To); -extern template void DeleteEdge(BBPostDomTree &DT, - BasicBlock *From, - BasicBlock *To); - -extern template void ApplyUpdates(BBDomTree &DT, - BBDomTreeGraphDiff &, - BBDomTreeGraphDiff *); -extern template void ApplyUpdates(BBPostDomTree &DT, - BBPostDomTreeGraphDiff &, - BBPostDomTreeGraphDiff *); - -extern template bool Verify(const BBDomTree &DT, - BBDomTree::VerificationLevel VL); -extern template bool Verify(const BBPostDomTree &DT, - BBPostDomTree::VerificationLevel VL); +using BBDomTreeGraphDiff = GraphDiff; +using BBPostDomTreeGraphDiff = GraphDiff; + +extern template void Calculate(BBDomTree &DT); +extern template void +CalculateWithUpdates(BBDomTree &DT, BBUpdates U); + +extern template void Calculate(BBPostDomTree &DT); + +extern template void +InsertEdge(BBDomTree &DT, BasicBlock *From, BasicBlock *To); +extern template void +InsertEdge(BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); + +extern template void +DeleteEdge(BBDomTree &DT, BasicBlock *From, BasicBlock *To); +extern template void +DeleteEdge(BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); + +extern template void +ApplyUpdates(BBDomTree &DT, + BBDomTreeGraphDiff &, + BBDomTreeGraphDiff *); +extern template void +ApplyUpdates(BBPostDomTree &DT, + BBPostDomTreeGraphDiff &, + BBPostDomTreeGraphDiff *); + +extern template bool +Verify(const BBDomTree &DT, BBDomTree::VerificationLevel VL); +extern template bool +Verify(const BBPostDomTree &DT, BBPostDomTree::VerificationLevel VL); } // namespace DomTreeBuilder using DomTreeNode = DomTreeNodeBase; diff --git a/llvm/include/llvm/Support/CFGDiff.h b/llvm/include/llvm/Support/CFGDiff.h index c90b9aca78b5..b0a50690d228 100644 --- a/llvm/include/llvm/Support/CFGDiff.h +++ b/llvm/include/llvm/Support/CFGDiff.h @@ -132,11 +132,12 @@ template class GraphDiff { } using VectRet = SmallVector; - template VectRet getChildren(NodePtr N) const { + template class View> VectRet getChildren(NodePtr N) const { using DirectedNodeT = - std::conditional_t, NodePtr>; - auto R = children(N); - VectRet Res = VectRet(detail::reverse_if(R)); + std::conditional_t>, View>; + VectRet Res = VectRet(children(N)); + if (not InverseEdge) + std::reverse(Res.begin(), Res.end()); // Remove nullptr children for clang. llvm::erase_value(Res, nullptr); diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index 18e08dbcd175..0bb6c5749a56 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -41,44 +41,51 @@ namespace llvm { +template +using DTIdentityView = X; + +template class View> +class DominatorTreeOnView; + template -class DominatorTreeBase; +using DominatorTreeBase = DominatorTreeOnView; namespace DomTreeBuilder { -template -struct SemiNCAInfo; +template class View> +struct SemiNCAInfoOnView; } // namespace DomTreeBuilder /// Base class for the actual dominator tree node. -template class DomTreeNodeBase { +template class View> +class DomTreeNodeOnView { friend class PostDominatorTree; - friend class DominatorTreeBase; - friend class DominatorTreeBase; - friend struct DomTreeBuilder::SemiNCAInfo>; - friend struct DomTreeBuilder::SemiNCAInfo>; + friend class DominatorTreeOnView; + friend class DominatorTreeOnView; + friend struct DomTreeBuilder::SemiNCAInfoOnView; + friend struct DomTreeBuilder::SemiNCAInfoOnView; NodeT *TheBB; - DomTreeNodeBase *IDom; + DomTreeNodeOnView *IDom; unsigned Level; - SmallVector Children; + SmallVector Children; mutable unsigned DFSNumIn = ~0; mutable unsigned DFSNumOut = ~0; public: - DomTreeNodeBase(NodeT *BB, DomTreeNodeBase *iDom) + DomTreeNodeOnView(NodeT *BB, DomTreeNodeOnView *iDom) : TheBB(BB), IDom(iDom), Level(IDom ? IDom->Level + 1 : 0) {} - using iterator = typename SmallVector::iterator; + using iterator = typename SmallVector::iterator; using const_iterator = - typename SmallVector::const_iterator; + typename SmallVector::const_iterator; iterator begin() { return Children.begin(); } iterator end() { return Children.end(); } const_iterator begin() const { return Children.begin(); } const_iterator end() const { return Children.end(); } - DomTreeNodeBase *const &back() const { return Children.back(); } - DomTreeNodeBase *&back() { return Children.back(); } + DomTreeNodeOnView *const &back() const { return Children.back(); } + DomTreeNodeOnView *&back() { return Children.back(); } iterator_range children() { return make_range(begin(), end()); } iterator_range children() const { @@ -86,11 +93,11 @@ template class DomTreeNodeBase { } NodeT *getBlock() const { return TheBB; } - DomTreeNodeBase *getIDom() const { return IDom; } + DomTreeNodeOnView *getIDom() const { return IDom; } unsigned getLevel() const { return Level; } - std::unique_ptr addChild( - std::unique_ptr C) { + std::unique_ptr addChild( + std::unique_ptr C) { Children.push_back(C.get()); return C; } @@ -100,19 +107,19 @@ template class DomTreeNodeBase { void clearAllChildren() { Children.clear(); } - bool compare(const DomTreeNodeBase *Other) const { + bool compare(const DomTreeNodeOnView *Other) const { if (getNumChildren() != Other->getNumChildren()) return true; if (Level != Other->Level) return true; SmallPtrSet OtherChildren; - for (const DomTreeNodeBase *I : *Other) { + for (const DomTreeNodeOnView *I : *Other) { const NodeT *Nd = I->getBlock(); OtherChildren.insert(Nd); } - for (const DomTreeNodeBase *I : *this) { + for (const DomTreeNodeOnView *I : *this) { const NodeT *N = I->getBlock(); if (OtherChildren.count(N) == 0) return true; @@ -120,7 +127,7 @@ template class DomTreeNodeBase { return false; } - void setIDom(DomTreeNodeBase *NewIDom) { + void setIDom(DomTreeNodeOnView *NewIDom) { assert(IDom && "No immediate dominator?"); if (IDom == NewIDom) return; @@ -146,7 +153,7 @@ template class DomTreeNodeBase { private: // Return true if this node is dominated by other. Use this only if DFS info // is valid. - bool DominatedBy(const DomTreeNodeBase *other) const { + bool DominatedBy(const DomTreeNodeOnView *other) const { return this->DFSNumIn >= other->DFSNumIn && this->DFSNumOut <= other->DFSNumOut; } @@ -155,13 +162,13 @@ template class DomTreeNodeBase { assert(IDom); if (Level == IDom->Level + 1) return; - SmallVector WorkStack = {this}; + SmallVector WorkStack = {this}; while (!WorkStack.empty()) { - DomTreeNodeBase *Current = WorkStack.pop_back_val(); + DomTreeNodeOnView *Current = WorkStack.pop_back_val(); Current->Level = Current->IDom->Level + 1; - for (DomTreeNodeBase *C : *Current) { + for (DomTreeNodeOnView *C : *Current) { assert(C->IDom); if (C->Level != C->IDom->Level + 1) WorkStack.push_back(C); } @@ -170,7 +177,10 @@ template class DomTreeNodeBase { }; template -raw_ostream &operator<<(raw_ostream &O, const DomTreeNodeBase *Node) { +using DomTreeNodeBase = DomTreeNodeOnView; + +template class View> +raw_ostream &operator<<(raw_ostream &O, const DomTreeNodeOnView *Node) { if (Node->getBlock()) Node->getBlock()->printAsOperand(O, false); else @@ -182,11 +192,11 @@ raw_ostream &operator<<(raw_ostream &O, const DomTreeNodeBase *Node) { return O; } -template -void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &O, +template class View> +void PrintDomTree(const DomTreeNodeOnView *N, raw_ostream &O, unsigned Lev) { O.indent(2 * Lev) << "[" << Lev << "] " << N; - for (typename DomTreeNodeBase::const_iterator I = N->begin(), + for (typename DomTreeNodeOnView::const_iterator I = N->begin(), E = N->end(); I != E; ++I) PrintDomTree(*I, O, Lev + 1); @@ -194,41 +204,42 @@ void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &O, namespace DomTreeBuilder { // The routines below are provided in a separate header but referenced here. -template -void Calculate(DomTreeT &DT); - -template -void CalculateWithUpdates(DomTreeT &DT, - ArrayRef Updates); - -template -void InsertEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, - typename DomTreeT::NodePtr To); - -template -void DeleteEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, - typename DomTreeT::NodePtr To); - -template -void ApplyUpdates(DomTreeT &DT, - GraphDiff &PreViewCFG, - GraphDiff *PostViewCFG); - -template -bool Verify(const DomTreeT &DT, typename DomTreeT::VerificationLevel VL); +template class View> +void Calculate(DominatorTreeOnView &DT); + +template class View> +void CalculateWithUpdates(DominatorTreeOnView &DT, + ArrayRef::UpdateType> Updates); + +template class View> +void InsertEdge(DominatorTreeOnView &DT, + typename DominatorTreeOnView::NodePtr From, + typename DominatorTreeOnView::NodePtr To); + +template class View> +void DeleteEdge(DominatorTreeOnView &DT, + typename DominatorTreeOnView::NodePtr From, + typename DominatorTreeOnView::NodePtr To); + +template class View> +void ApplyUpdates(DominatorTreeOnView &DT, + GraphDiff::NodePtr, IsPostDom> &PreViewCFG, + GraphDiff::NodePtr, IsPostDom> *PostViewCFG); + +template class View> +bool Verify(const DominatorTreeOnView &DT, + typename DominatorTreeOnView::VerificationLevel VL); } // namespace DomTreeBuilder /// Core dominator tree base class. /// /// This class is a generic template over graph nodes. It is instantiated for /// various graphs in the LLVM IR or in the code generator. -template -class DominatorTreeBase { +template class View> +class DominatorTreeOnView { public: static_assert(std::is_pointer::NodeRef>::value, - "Currently DominatorTreeBase supports only pointer nodes"); + "Currently DominatorTreeOnView supports only pointer nodes"); using NodeType = NodeT; using NodePtr = NodeT *; using ParentPtr = decltype(std::declval()->getParent()); @@ -249,20 +260,21 @@ class DominatorTreeBase { SmallVector Roots; using DomTreeNodeMapType = - DenseMap>>; + DenseMap>>; DomTreeNodeMapType DomTreeNodes; - DomTreeNodeBase *RootNode = nullptr; + DomTreeNodeOnView *RootNode = nullptr; ParentPtr Parent = nullptr; mutable bool DFSInfoValid = false; mutable unsigned int SlowQueries = 0; - friend struct DomTreeBuilder::SemiNCAInfo; + friend struct DomTreeBuilder::SemiNCAInfoOnView; + friend struct DomTreeBuilder::SemiNCAInfoOnView; public: - DominatorTreeBase() {} + DominatorTreeOnView() {} - DominatorTreeBase(DominatorTreeBase &&Arg) + DominatorTreeOnView(DominatorTreeOnView &&Arg) : Roots(std::move(Arg.Roots)), DomTreeNodes(std::move(Arg.DomTreeNodes)), RootNode(Arg.RootNode), @@ -272,7 +284,7 @@ class DominatorTreeBase { Arg.wipe(); } - DominatorTreeBase &operator=(DominatorTreeBase &&RHS) { + DominatorTreeOnView &operator=(DominatorTreeOnView &&RHS) { Roots = std::move(RHS.Roots); DomTreeNodes = std::move(RHS.DomTreeNodes); RootNode = RHS.RootNode; @@ -283,8 +295,8 @@ class DominatorTreeBase { return *this; } - DominatorTreeBase(const DominatorTreeBase &) = delete; - DominatorTreeBase &operator=(const DominatorTreeBase &) = delete; + DominatorTreeOnView(const DominatorTreeOnView &) = delete; + DominatorTreeOnView &operator=(const DominatorTreeOnView &) = delete; /// Iteration over roots. /// @@ -314,7 +326,7 @@ class DominatorTreeBase { /// compare - Return false if the other dominator tree base matches this /// dominator tree base. Otherwise return true. - bool compare(const DominatorTreeBase &Other) const { + bool compare(const DominatorTreeOnView &Other) const { if (Parent != Other.Parent) return true; if (Roots.size() != Other.Roots.size()) @@ -334,8 +346,8 @@ class DominatorTreeBase { if (OI == OtherDomTreeNodes.end()) return true; - DomTreeNodeBase &MyNd = *DomTreeNode.second; - DomTreeNodeBase &OtherNd = *OI->second; + DomTreeNodeOnView &MyNd = *DomTreeNode.second; + DomTreeNodeOnView &OtherNd = *OI->second; if (MyNd.compare(&OtherNd)) return true; @@ -348,7 +360,7 @@ class DominatorTreeBase { /// block. This is the same as using operator[] on this class. The result /// may (but is not required to) be null for a forward (backwards) /// statically unreachable block. - DomTreeNodeBase *getNode(const NodeT *BB) const { + DomTreeNodeOnView *getNode(const NodeT *BB) const { auto I = DomTreeNodes.find(BB); if (I != DomTreeNodes.end()) return I->second.get(); @@ -356,7 +368,7 @@ class DominatorTreeBase { } /// See getNode. - DomTreeNodeBase *operator[](const NodeT *BB) const { + DomTreeNodeOnView *operator[](const NodeT *BB) const { return getNode(BB); } @@ -367,20 +379,20 @@ class DominatorTreeBase { /// post-dominance information must be capable of dealing with this /// possibility. /// - DomTreeNodeBase *getRootNode() { return RootNode; } - const DomTreeNodeBase *getRootNode() const { return RootNode; } + DomTreeNodeOnView *getRootNode() { return RootNode; } + const DomTreeNodeOnView *getRootNode() const { return RootNode; } /// Get all nodes dominated by R, including R itself. void getDescendants(NodeT *R, SmallVectorImpl &Result) const { Result.clear(); - const DomTreeNodeBase *RN = getNode(R); + const DomTreeNodeOnView *RN = getNode(R); if (!RN) return; // If R is unreachable, it will not be present in the DOM tree. - SmallVector *, 8> WL; + SmallVector *, 8> WL; WL.push_back(RN); while (!WL.empty()) { - const DomTreeNodeBase *N = WL.pop_back_val(); + const DomTreeNodeOnView *N = WL.pop_back_val(); Result.push_back(N->getBlock()); WL.append(N->begin(), N->end()); } @@ -389,8 +401,8 @@ class DominatorTreeBase { /// properlyDominates - Returns true iff A dominates B and A != B. /// Note that this is not a constant time operation! /// - bool properlyDominates(const DomTreeNodeBase *A, - const DomTreeNodeBase *B) const { + bool properlyDominates(const DomTreeNodeOnView *A, + const DomTreeNodeOnView *B) const { if (!A || !B) return false; if (A == B) @@ -408,13 +420,13 @@ class DominatorTreeBase { return isReachableFromEntry(getNode(const_cast(A))); } - bool isReachableFromEntry(const DomTreeNodeBase *A) const { return A; } + bool isReachableFromEntry(const DomTreeNodeOnView *A) const { return A; } /// dominates - Returns true iff A dominates B. Note that this is not a /// constant time operation! /// - bool dominates(const DomTreeNodeBase *A, - const DomTreeNodeBase *B) const { + bool dominates(const DomTreeNodeOnView *A, + const DomTreeNodeOnView *B) const { // A node trivially dominates itself. if (B == A) return true; @@ -478,8 +490,8 @@ class DominatorTreeBase { return &Entry; } - DomTreeNodeBase *NodeA = getNode(A); - DomTreeNodeBase *NodeB = getNode(B); + DomTreeNodeOnView *NodeA = getNode(A); + DomTreeNodeOnView *NodeB = getNode(B); assert(NodeA && "A must be in the tree"); assert(NodeB && "B must be in the tree"); @@ -502,7 +514,7 @@ class DominatorTreeBase { const_cast(B)); } - bool isVirtualRoot(const DomTreeNodeBase *A) const { + bool isVirtualRoot(const DomTreeNodeOnView *A) const { return isPostDominator() && !A->getBlock(); } @@ -544,7 +556,7 @@ class DominatorTreeBase { void applyUpdates(ArrayRef Updates) { GraphDiff PreViewCFG( Updates, /*ReverseApplyUpdates=*/true); - DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, nullptr); + DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, nullptr); } /// \param Updates An unordered sequence of updates to perform. The current @@ -556,7 +568,7 @@ class DominatorTreeBase { ArrayRef PostViewUpdates) { if (Updates.empty()) { GraphDiff PostViewCFG(PostViewUpdates); - DomTreeBuilder::ApplyUpdates(*this, PostViewCFG, &PostViewCFG); + DomTreeBuilder::ApplyUpdates(*this, PostViewCFG, &PostViewCFG); } else { // PreViewCFG needs to merge Updates and PostViewCFG. The updates in // Updates need to be reversed, and match the direction in PostViewCFG. @@ -569,7 +581,7 @@ class DominatorTreeBase { GraphDiff PreViewCFG(AllUpdates, /*ReverseApplyUpdates=*/true); GraphDiff PostViewCFG(PostViewUpdates); - DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, &PostViewCFG); + DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, &PostViewCFG); } } @@ -617,9 +629,9 @@ class DominatorTreeBase { /// \param DomBB CFG node that is dominator for BB. /// \returns New dominator tree node that represents new CFG node. /// - DomTreeNodeBase *addNewBlock(NodeT *BB, NodeT *DomBB) { + DomTreeNodeOnView *addNewBlock(NodeT *BB, NodeT *DomBB) { assert(getNode(BB) == nullptr && "Block already in dominator tree!"); - DomTreeNodeBase *IDomNode = getNode(DomBB); + DomTreeNodeOnView *IDomNode = getNode(DomBB); assert(IDomNode && "Not immediate dominator specified for block!"); DFSInfoValid = false; return createChild(BB, IDomNode); @@ -630,12 +642,12 @@ class DominatorTreeBase { /// \param BB New node in CFG. /// \returns New dominator tree node that represents new CFG node. /// - DomTreeNodeBase *setNewRoot(NodeT *BB) { + DomTreeNodeOnView *setNewRoot(NodeT *BB) { assert(getNode(BB) == nullptr && "Block already in dominator tree!"); assert(!this->isPostDominator() && "Cannot change root of post-dominator tree"); DFSInfoValid = false; - DomTreeNodeBase *NewNode = createNode(BB); + DomTreeNodeOnView *NewNode = createNode(BB); if (Roots.empty()) { addRoot(BB); } else { @@ -653,8 +665,8 @@ class DominatorTreeBase { /// changeImmediateDominator - This method is used to update the dominator /// tree information when a node's immediate dominator changes. /// - void changeImmediateDominator(DomTreeNodeBase *N, - DomTreeNodeBase *NewIDom) { + void changeImmediateDominator(DomTreeNodeOnView *N, + DomTreeNodeOnView *NewIDom) { assert(N && NewIDom && "Cannot change null node pointers!"); DFSInfoValid = false; N->setIDom(NewIDom); @@ -668,14 +680,14 @@ class DominatorTreeBase { /// dominate any other blocks. Removes node from its immediate dominator's /// children list. Deletes dominator node associated with basic block BB. void eraseNode(NodeT *BB) { - DomTreeNodeBase *Node = getNode(BB); + DomTreeNodeOnView *Node = getNode(BB); assert(Node && "Removing node that isn't in dominator tree."); assert(Node->isLeaf() && "Node is not a leaf node."); DFSInfoValid = false; // Remove node from immediate dominator's children list. - DomTreeNodeBase *IDom = Node->getIDom(); + DomTreeNodeOnView *IDom = Node->getIDom(); if (IDom) { const auto I = find(IDom->Children, Node); assert(I != IDom->Children.end() && @@ -700,9 +712,9 @@ class DominatorTreeBase { /// tree to reflect this change. void splitBlock(NodeT *NewBB) { if (IsPostDominator) - Split>(NewBB); + Split>>(NewBB); else - Split(NewBB); + Split>(NewBB); } /// print - Convert to human readable form @@ -736,11 +748,11 @@ class DominatorTreeBase { return; } - SmallVector *, - typename DomTreeNodeBase::const_iterator>, + SmallVector *, + typename DomTreeNodeOnView::const_iterator>, 32> WorkStack; - const DomTreeNodeBase *ThisRoot = getRootNode(); + const DomTreeNodeOnView *ThisRoot = getRootNode(); assert((!Parent || ThisRoot) && "Empty constructed DomTree"); if (!ThisRoot) return; @@ -753,7 +765,7 @@ class DominatorTreeBase { ThisRoot->DFSNumIn = DFSNum++; while (!WorkStack.empty()) { - const DomTreeNodeBase *Node = WorkStack.back().first; + const DomTreeNodeOnView *Node = WorkStack.back().first; const auto ChildIt = WorkStack.back().second; // If we visited all of the children of this node, "recurse" back up the @@ -763,7 +775,7 @@ class DominatorTreeBase { WorkStack.pop_back(); } else { // Otherwise, recursively visit this child. - const DomTreeNodeBase *Child = *ChildIt; + const DomTreeNodeOnView *Child = *ChildIt; ++WorkStack.back().second; WorkStack.push_back({Child, Child->begin()}); @@ -816,15 +828,16 @@ class DominatorTreeBase { protected: void addRoot(NodeT *BB) { this->Roots.push_back(BB); } - DomTreeNodeBase *createChild(NodeT *BB, DomTreeNodeBase *IDom) { + DomTreeNodeOnView * + createChild(NodeT *BB, DomTreeNodeOnView *IDom) { return (DomTreeNodes[BB] = IDom->addChild( - std::make_unique>(BB, IDom))) + std::make_unique>(BB, IDom))) .get(); } - DomTreeNodeBase *createNode(NodeT *BB) { + DomTreeNodeOnView *createNode(NodeT *BB) { return (DomTreeNodes[BB] = - std::make_unique>(BB, nullptr)) + std::make_unique>(BB, nullptr)) .get(); } @@ -873,25 +886,25 @@ class DominatorTreeBase { } // Create the new dominator tree node... and set the idom of NewBB. - DomTreeNodeBase *NewBBNode = addNewBlock(NewBB, NewBBIDom); + DomTreeNodeOnView *NewBBNode = addNewBlock(NewBB, NewBBIDom); // If NewBB strictly dominates other blocks, then it is now the immediate // dominator of NewBBSucc. Update the dominator tree as appropriate. if (NewBBDominatesNewBBSucc) { - DomTreeNodeBase *NewBBSuccNode = getNode(NewBBSucc); + DomTreeNodeOnView *NewBBSuccNode = getNode(NewBBSucc); changeImmediateDominator(NewBBSuccNode, NewBBNode); } } private: - bool dominatedBySlowTreeWalk(const DomTreeNodeBase *A, - const DomTreeNodeBase *B) const { + bool dominatedBySlowTreeWalk(const DomTreeNodeOnView *A, + const DomTreeNodeOnView *B) const { assert(A != B); assert(isReachableFromEntry(B)); assert(isReachableFromEntry(A)); const unsigned ALevel = A->getLevel(); - const DomTreeNodeBase *IDom; + const DomTreeNodeOnView *IDom; // Don't walk nodes above A's subtree. When we reach A's level, we must // either find A or be in some other subtree not dominated by A. @@ -912,16 +925,22 @@ class DominatorTreeBase { } }; +template class View> +using DomTreeOnView = DominatorTreeOnView; + template -using DomTreeBase = DominatorTreeBase; +using DomTreeBase = DomTreeOnView; + +template class View> +using PostDomTreeOnView = DominatorTreeOnView; template -using PostDomTreeBase = DominatorTreeBase; +using PostDomTreeBase = PostDomTreeOnView; // These two functions are declared out of line as a workaround for building // with old (< r147295) versions of clang because of pr11642. -template -bool DominatorTreeBase::dominates(const NodeT *A, +template class View> +bool DominatorTreeOnView::dominates(const NodeT *A, const NodeT *B) const { if (A == B) return true; @@ -932,8 +951,8 @@ bool DominatorTreeBase::dominates(const NodeT *A, return dominates(getNode(const_cast(A)), getNode(const_cast(B))); } -template -bool DominatorTreeBase::properlyDominates( +template class View> +bool DominatorTreeOnView::properlyDominates( const NodeT *A, const NodeT *B) const { if (A == B) return false; diff --git a/llvm/include/llvm/Support/GenericDomTreeConstruction.h b/llvm/include/llvm/Support/GenericDomTreeConstruction.h index 4b59ad1f017f..8f20da1991ec 100644 --- a/llvm/include/llvm/Support/GenericDomTreeConstruction.h +++ b/llvm/include/llvm/Support/GenericDomTreeConstruction.h @@ -51,13 +51,13 @@ namespace llvm { namespace DomTreeBuilder { -template -struct SemiNCAInfo { +template class View> +struct SemiNCAInfoOnView { + using DomTreeT = DominatorTreeOnView; using NodePtr = typename DomTreeT::NodePtr; - using NodeT = typename DomTreeT::NodeType; - using TreeNodePtr = DomTreeNodeBase *; + using TreeNode = DomTreeNodeOnView; + using TreeNodePtr = TreeNode*; using RootsT = decltype(DomTreeT::Roots); - static constexpr bool IsPostDom = DomTreeT::IsPostDominator; using GraphDiffT = GraphDiff; // Information record used by Semi-NCA during tree construction. @@ -95,7 +95,7 @@ struct SemiNCAInfo { using BatchUpdatePtr = BatchUpdateInfo *; // If BUI is a nullptr, then there's no batch update in progress. - SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {} + SemiNCAInfoOnView(BatchUpdatePtr BUI) : BatchUpdates(BUI) {} void clear() { NumToNode = {nullptr}; // Restore to initial state with a dummy start node. @@ -107,16 +107,18 @@ struct SemiNCAInfo { template static SmallVector getChildren(NodePtr N, BatchUpdatePtr BUI) { if (BUI) - return BUI->PreViewCFG.template getChildren(N); + return BUI->PreViewCFG.template getChildren(N); return getChildren(N); } template static SmallVector getChildren(NodePtr N) { using DirectedNodeT = - std::conditional_t, NodePtr>; - auto R = children(N); - SmallVector Res(detail::reverse_if(R)); + std::conditional_t>, View>; + using VectRet = SmallVector; + VectRet Res = VectRet(children(N)); + if (not Inversed) + std::reverse(Res.begin(), Res.end()); // Remove nullptr children for clang. llvm::erase_value(Res, nullptr); @@ -357,7 +359,7 @@ struct SemiNCAInfo { return Roots; } - SemiNCAInfo SNCA(BUI); + SemiNCAInfoOnView SNCA(BUI); // PostDominatorTree always has a virtual root. SNCA.addVirtualRoot(); @@ -510,7 +512,7 @@ struct SemiNCAInfo { assert(IsPostDom && "This function is for postdominators only"); LLVM_DEBUG(dbgs() << "Removing redundant roots\n"); - SemiNCAInfo SNCA(BUI); + SemiNCAInfoOnView SNCA(BUI); for (unsigned i = 0; i < Roots.size(); ++i) { auto &Root = Roots[i]; @@ -571,7 +573,7 @@ struct SemiNCAInfo { } // This is rebuilding the whole tree, not incrementally, but PostViewBUI is // used in case the caller needs a DT update with a CFGView. - SemiNCAInfo SNCA(PostViewBUI); + SemiNCAInfoOnView SNCA(PostViewBUI); // Step #0: Number blocks in depth-first order and initialize variables used // in later stages of the algorithm. @@ -904,7 +906,7 @@ struct SemiNCAInfo { return false; }; - SemiNCAInfo SNCA(BUI); + SemiNCAInfoOnView SNCA(BUI); SNCA.runDFS(Root, 0, UnreachableDescender, 0); SNCA.runSemiNCA(DT); SNCA.attachNewSubtree(DT, Incoming); @@ -997,7 +999,7 @@ struct SemiNCAInfo { LLVM_DEBUG(dbgs() << "\tTop of subtree: " << BlockNamePrinter(ToIDomTN) << "\n"); - SemiNCAInfo SNCA(BUI); + SemiNCAInfoOnView SNCA(BUI); SNCA.runDFS(ToIDom, 0, DescendBelow, 0); LLVM_DEBUG(dbgs() << "\tRunning Semi-NCA\n"); SNCA.runSemiNCA(DT, Level); @@ -1064,7 +1066,7 @@ struct SemiNCAInfo { return false; }; - SemiNCAInfo SNCA(BUI); + SemiNCAInfoOnView SNCA(BUI); unsigned LastDFSNum = SNCA.runDFS(ToTN->getBlock(), 0, DescendAndCollect, 0); @@ -1558,48 +1560,46 @@ struct SemiNCAInfo { } }; -template -void Calculate(DomTreeT &DT) { - SemiNCAInfo::CalculateFromScratch(DT, nullptr); +template class View> +void Calculate(DominatorTreeOnView &DT) { + SemiNCAInfoOnView::CalculateFromScratch(DT, nullptr); } -template -void CalculateWithUpdates(DomTreeT &DT, - ArrayRef Updates) { +template class View> +void CalculateWithUpdates(DominatorTreeOnView &DT, + ArrayRef::UpdateType> Updates) { // FIXME: Updated to use the PreViewCFG and behave the same as until now. // This behavior is however incorrect; this actually needs the PostViewCFG. - GraphDiff PreViewCFG( + GraphDiff::NodePtr, IsPostDom> PreViewCFG( Updates, /*ReverseApplyUpdates=*/true); - typename SemiNCAInfo::BatchUpdateInfo BUI(PreViewCFG); - SemiNCAInfo::CalculateFromScratch(DT, &BUI); + typename SemiNCAInfoOnView::BatchUpdateInfo BUI(PreViewCFG); + SemiNCAInfoOnView::CalculateFromScratch(DT, &BUI); } -template -void InsertEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, - typename DomTreeT::NodePtr To) { +template class View> +void InsertEdge(DominatorTreeOnView &DT, typename DominatorTreeOnView::NodePtr From, + typename DominatorTreeOnView::NodePtr To) { if (DT.isPostDominator()) std::swap(From, To); - SemiNCAInfo::InsertEdge(DT, nullptr, From, To); + SemiNCAInfoOnView::InsertEdge(DT, nullptr, From, To); } -template -void DeleteEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, - typename DomTreeT::NodePtr To) { +template class View> +void DeleteEdge(DominatorTreeOnView &DT, typename DominatorTreeOnView::NodePtr From, + typename DominatorTreeOnView::NodePtr To) { if (DT.isPostDominator()) std::swap(From, To); - SemiNCAInfo::DeleteEdge(DT, nullptr, From, To); + SemiNCAInfoOnView::DeleteEdge(DT, nullptr, From, To); } -template -void ApplyUpdates(DomTreeT &DT, - GraphDiff &PreViewCFG, - GraphDiff *PostViewCFG) { - SemiNCAInfo::ApplyUpdates(DT, PreViewCFG, PostViewCFG); +template class View> +void ApplyUpdates(DominatorTreeOnView &DT, + GraphDiff::NodePtr, IsPostDom> &PreViewCFG, + GraphDiff::NodePtr, IsPostDom> *PostViewCFG) { + SemiNCAInfoOnView::ApplyUpdates(DT, PreViewCFG, PostViewCFG); } -template -bool Verify(const DomTreeT &DT, typename DomTreeT::VerificationLevel VL) { - SemiNCAInfo SNCA(nullptr); +template class View> +bool Verify(const DominatorTreeOnView &DT, typename DominatorTreeOnView::VerificationLevel VL) { + SemiNCAInfoOnView SNCA(nullptr); // Simplist check is to compare against a new tree. This will also // usefully print the old and new trees, if they are different. @@ -1611,12 +1611,12 @@ bool Verify(const DomTreeT &DT, typename DomTreeT::VerificationLevel VL) { !SNCA.VerifyLevels(DT) || !SNCA.VerifyDFSNumbers(DT)) return false; - // Extra checks depending on VerificationLevel. Up to O(N^3). - if (VL == DomTreeT::VerificationLevel::Basic || - VL == DomTreeT::VerificationLevel::Full) + // Extra checks depending on VerificationLevel. Up to O(N^3) + if (VL == DominatorTreeOnView::VerificationLevel::Basic || + VL == DominatorTreeOnView::VerificationLevel::Full) if (!SNCA.verifyParentProperty(DT)) return false; - if (VL == DomTreeT::VerificationLevel::Full) + if (VL == DominatorTreeOnView::VerificationLevel::Full) if (!SNCA.verifySiblingProperty(DT)) return false; diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h index 7d572fe06f6f..2ff398d691f7 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -221,6 +221,15 @@ class raw_ostream { return this->operator<<(StringRef(Str)); } +#if __cpp_char8_t + raw_ostream &operator<<(const char8_t *Str) { + // Inline fast path, particularly for constant strings where a sufficiently + // smart compiler will simplify strlen. + + return this->operator<<(StringRef(Str)); + } +#endif + raw_ostream &operator<<(const std::string &Str) { // Avoid the fast path, it would only increase code size for a marginal win. return write(Str.data(), Str.length()); diff --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h index 951660bbab28..e2df311cb60e 100644 --- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h +++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h @@ -20,8 +20,17 @@ namespace llvm { -template class DomTreeNodeBase; +template +using DTIdentityView = X; + +template class View> +class DomTreeNodeOnView; + +template +using DomTreeNodeBase = DomTreeNodeOnView; + using DomTreeNode = DomTreeNodeBase; + class AAResults; class AliasSet; class AliasSetTracker; diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index 99fa58b8872a..4737c40948f3 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -876,7 +876,7 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef Updates, // Check number of predecessors, we only care if there's more than one. unsigned Count = 0; BasicBlock *Pred = nullptr; - for (auto *Pi : GD->template getChildren(BB)) { + for (auto *Pi : GD->template getChildren(BB)) { Pred = Pi; Count++; if (Count == 2) @@ -970,7 +970,7 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef Updates, auto *BB = BBPredPair.first; const auto &AddedBlockSet = BBPredPair.second.Added; auto &PrevBlockSet = BBPredPair.second.Prev; - for (auto *Pi : GD->template getChildren(BB)) { + for (auto *Pi : GD->template getChildren(BB)) { if (!AddedBlockSet.count(Pi)) PrevBlockSet.insert(Pi); EdgeCountMap[{Pi, BB}]++; @@ -1121,7 +1121,7 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef Updates, for (unsigned I = 0, E = IDFPhi->getNumIncomingValues(); I < E; ++I) IDFPhi->setIncomingValue(I, GetLastDef(IDFPhi->getIncomingBlock(I))); } else { - for (auto *Pi : GD->template getChildren(BBIDF)) + for (auto *Pi : GD->template getChildren(BBIDF)) IDFPhi->addIncoming(GetLastDef(Pi), Pi); } } diff --git a/llvm/lib/CodeGen/MachineDominators.cpp b/llvm/lib/CodeGen/MachineDominators.cpp index c8845d838282..3c8d79644001 100644 --- a/llvm/lib/CodeGen/MachineDominators.cpp +++ b/llvm/lib/CodeGen/MachineDominators.cpp @@ -33,8 +33,8 @@ static cl::opt VerifyMachineDomInfoX( cl::desc("Verify machine dominator info (time consuming)")); namespace llvm { -template class DomTreeNodeBase; -template class DominatorTreeBase; // DomTreeBase +template class DomTreeNodeOnView; +template class DominatorTreeOnView; // DomTreeBase } char MachineDominatorTree::ID = 0; diff --git a/llvm/lib/CodeGen/MachinePostDominators.cpp b/llvm/lib/CodeGen/MachinePostDominators.cpp index fb96d0efa4d4..c13fdbbc1815 100644 --- a/llvm/lib/CodeGen/MachinePostDominators.cpp +++ b/llvm/lib/CodeGen/MachinePostDominators.cpp @@ -17,7 +17,7 @@ using namespace llvm; namespace llvm { -template class DominatorTreeBase; // PostDomTreeBase +template class DominatorTreeOnView; // PostDomTreeBase extern bool VerifyMachineDomInfo; } // namespace llvm diff --git a/llvm/lib/IR/Dominators.cpp b/llvm/lib/IR/Dominators.cpp index fbc28c202aec..86326fdea3cc 100644 --- a/llvm/lib/IR/Dominators.cpp +++ b/llvm/lib/IR/Dominators.cpp @@ -63,43 +63,59 @@ bool BasicBlockEdge::isSingleEdge() const { // //===----------------------------------------------------------------------===// -template class llvm::DomTreeNodeBase; -template class llvm::DominatorTreeBase; // DomTreeBase -template class llvm::DominatorTreeBase; // PostDomTreeBase + +namespace llvm { + +template class View> +class DominatorTreeOnView; + +template +using DominatorTreeBase = DominatorTreeOnView; + +template class View> +class DomTreeNodeOnView; + +template +using DomTreeNodeBase = DomTreeNodeOnView; + +template class DomTreeNodeOnView; +template class DominatorTreeOnView; // DomTree +template class DominatorTreeOnView; // PostDomTree +} // end namespace template class llvm::cfg::Update; -template void llvm::DomTreeBuilder::Calculate( +template void llvm::DomTreeBuilder::Calculate( DomTreeBuilder::BBDomTree &DT); template void -llvm::DomTreeBuilder::CalculateWithUpdates( +llvm::DomTreeBuilder::CalculateWithUpdates( DomTreeBuilder::BBDomTree &DT, BBUpdates U); -template void llvm::DomTreeBuilder::Calculate( +template void llvm::DomTreeBuilder::Calculate( DomTreeBuilder::BBPostDomTree &DT); // No CalculateWithUpdates instantiation, unless a usecase arises. -template void llvm::DomTreeBuilder::InsertEdge( +template void llvm::DomTreeBuilder::InsertEdge( DomTreeBuilder::BBDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::InsertEdge( +template void llvm::DomTreeBuilder::InsertEdge( DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::DeleteEdge( +template void llvm::DomTreeBuilder::DeleteEdge( DomTreeBuilder::BBDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::DeleteEdge( +template void llvm::DomTreeBuilder::DeleteEdge( DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::ApplyUpdates( - DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &, - DomTreeBuilder::BBDomTreeGraphDiff *); -template void llvm::DomTreeBuilder::ApplyUpdates( - DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBPostDomTreeGraphDiff &, - DomTreeBuilder::BBPostDomTreeGraphDiff *); +template void +llvm::DomTreeBuilder::ApplyUpdates( + BBDomTree &DT, BBDomTreeGraphDiff &, BBDomTreeGraphDiff *); +template void +llvm::DomTreeBuilder::ApplyUpdates( + BBPostDomTree &DT, BBPostDomTreeGraphDiff &, BBPostDomTreeGraphDiff *); -template bool llvm::DomTreeBuilder::Verify( +template bool llvm::DomTreeBuilder::Verify( const DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTree::VerificationLevel VL); -template bool llvm::DomTreeBuilder::Verify( +template bool llvm::DomTreeBuilder::Verify( const DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBPostDomTree::VerificationLevel VL); diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp index a16a458168d4..d719a288981e 100644 --- a/llvm/lib/Object/XCOFFObjectFile.cpp +++ b/llvm/lib/Object/XCOFFObjectFile.cpp @@ -166,7 +166,7 @@ XCOFFObjectFile::getStringTableEntry(uint32_t Offset) const { // field; as a soft-error recovery mechanism, we treat such cases as having an // offset of 0. if (Offset < 4) - return StringRef(nullptr, 0); + return StringRef(); if (StringTable.Data != nullptr && StringTable.Size > Offset) return (StringTable.Data + Offset); diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index b26399e0ae58..709ddd291505 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -1018,7 +1018,7 @@ void VPWidenCanonicalIVRecipe::print(raw_ostream &O, const Twine &Indent, O << " = WIDEN-CANONICAL-INDUCTION"; } -template void DomTreeBuilder::Calculate(VPDominatorTree &DT); +template void DomTreeBuilder::Calculate(VPDominatorTree &DT); void VPValue::replaceAllUsesWith(VPValue *New) { for (unsigned J = 0; J < getNumUsers();) { diff --git a/llvm/test/tools/llvm-ar/error-opening-permission.test b/llvm/test/tools/llvm-ar/error-opening-permission.test deleted file mode 100644 index d8d0cbfd3556..000000000000 --- a/llvm/test/tools/llvm-ar/error-opening-permission.test +++ /dev/null @@ -1,14 +0,0 @@ -## Unsupported on windows as marking files "unreadable" -## is non-trivial on windows. -# UNSUPPORTED: system-windows - -# RUN: rm -rf %t && mkdir -p %t -# RUN: echo file1 > %t/1.txt - -## No Permission: -# RUN: llvm-ar rc %t/permission.b %t/1.txt -# RUN: chmod 100 %t/permission.b -# RUN: not llvm-ar p %t/permission.b 2>&1 | \ -# RUN: FileCheck %s --check-prefix=NO-PERMISSION -DARCHIVE=%t/permission.b - -# NO-PERMISSION: error: unable to open '[[ARCHIVE]]': {{.*}}{{[pP]}}ermission denied diff --git a/llvm/test/tools/llvm-elfabi/fail-file-write.test b/llvm/test/tools/llvm-elfabi/fail-file-write.test deleted file mode 100644 index c3c479e73887..000000000000 --- a/llvm/test/tools/llvm-elfabi/fail-file-write.test +++ /dev/null @@ -1,18 +0,0 @@ -## Test failing to write output file on non-windows platforms. - -# UNSUPPORTED: system-windows -# RUN: rm -rf %t.TestDir -# RUN: mkdir %t.TestDir -# RUN: touch %t.TestDir/Output.TestFile -# RUN: chmod 400 %t.TestDir -# RUN: not llvm-elfabi %s --output-target=elf64-little %t.TestDir/Output.TestFile 2>&1 | FileCheck %s --check-prefix=ERR -# RUN: chmod 777 %t.TestDir -# RUN: rm -rf %t.TestDir - ---- !tapi-tbe -TbeVersion: 1.0 -Arch: AArch64 -Symbols: {} -... - -# ERR: {{.*}}Permission denied{{.*}} when trying to open `{{.*}}.TestDir/Output.TestFile` for writing diff --git a/llvm/unittests/ADT/APFixedPointTest.cpp b/llvm/unittests/ADT/APFixedPointTest.cpp index 53fa1cd8b503..8891889c62ee 100644 --- a/llvm/unittests/ADT/APFixedPointTest.cpp +++ b/llvm/unittests/ADT/APFixedPointTest.cpp @@ -223,7 +223,7 @@ void CheckIntPartMin(const FixedPointSemantics &Sema, int64_t Expected) { ASSERT_EQ(APFixedPoint::getMin(Sema).getIntPart(), Expected); } -void CheckIntPartMax(const FixedPointSemantics &Sema, uint64_t Expected) { +void CheckIntPartMax(const FixedPointSemantics &Sema, int64_t Expected) { ASSERT_EQ(APFixedPoint::getMax(Sema).getIntPart(), Expected); } diff --git a/llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp b/llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp index a2d5805a9874..5e1a8f28527b 100644 --- a/llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp +++ b/llvm/unittests/IR/DominatorTreeBatchUpdatesTest.cpp @@ -26,8 +26,8 @@ using DomUpdate = DominatorTree::UpdateType; static_assert( std::is_same::value, "Trees differing only in IsPostDom should have the same update types"); -using DomSNCA = DomTreeBuilder::SemiNCAInfo; -using PostDomSNCA = DomTreeBuilder::SemiNCAInfo; +using DomSNCA = DomTreeBuilder::SemiNCAInfoOnView; +using PostDomSNCA = DomTreeBuilder::SemiNCAInfoOnView; const auto Insert = DominatorTree::Insert; const auto Delete = DominatorTree::Delete; diff --git a/llvm/unittests/Support/DJBTest.cpp b/llvm/unittests/Support/DJBTest.cpp index c01bbe1eaa67..c9d1d9fc5dd2 100644 --- a/llvm/unittests/Support/DJBTest.cpp +++ b/llvm/unittests/Support/DJBTest.cpp @@ -18,7 +18,7 @@ TEST(DJBTest, caseFolding) { StringLiteral Two; }; - static constexpr TestCase Tests[] = { + static TestCase Tests[] = { {{"ASDF"}, {"asdf"}}, {{"qWeR"}, {"QwEr"}}, {{"qqqqqqqqqqqqqqqqqqqq"}, {"QQQQQQQQQQQQQQQQQQQQ"}}, diff --git a/llvm/unittests/Support/JSONTest.cpp b/llvm/unittests/Support/JSONTest.cpp index ed9a72d36b06..2168f170f8f3 100644 --- a/llvm/unittests/Support/JSONTest.cpp +++ b/llvm/unittests/Support/JSONTest.cpp @@ -174,12 +174,12 @@ TEST(JSONTest, Parse) { Compare(R"("\"\\\b\f\n\r\t")", "\"\\\b\f\n\r\t"); Compare(R"("\u0000")", llvm::StringRef("\0", 1)); Compare("\"\x7f\"", "\x7f"); - Compare(R"("\ud801\udc37")", u8"\U00010437"); // UTF16 surrogate pair escape. - Compare("\"\xE2\x82\xAC\xF0\x9D\x84\x9E\"", u8"\u20ac\U0001d11e"); // UTF8 + Compare(R"("\ud801\udc37")", reinterpret_cast(u8"\U00010437")); // UTF16 surrogate pair escape. + Compare("\"\xE2\x82\xAC\xF0\x9D\x84\x9E\"", reinterpret_cast(u8"\u20ac\U0001d11e")); // UTF8 Compare( R"("LoneLeading=\ud801, LoneTrailing=\udc01, LeadingLeadingTrailing=\ud801\ud801\udc37")", - u8"LoneLeading=\ufffd, LoneTrailing=\ufffd, " - u8"LeadingLeadingTrailing=\ufffd\U00010437"); // Invalid unicode. + reinterpret_cast(u8"LoneLeading=\ufffd, LoneTrailing=\ufffd, " + u8"LeadingLeadingTrailing=\ufffd\U00010437")); // Invalid unicode. Compare(R"({"":0,"":0})", Object{{"", 0}}); Compare(R"({"obj":{},"arr":[]})", Object{{"obj", Object{}}, {"arr", {}}});