aboutsummaryrefslogtreecommitdiff
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ADT/BitmaskEnum.h4
-rw-r--r--llvm/include/llvm/ADT/FoldingSet.h32
-rw-r--r--llvm/include/llvm/ADT/IndexedMap.h17
-rw-r--r--llvm/include/llvm/ADT/SmallVector.h20
-rw-r--r--llvm/include/llvm/ADT/identity.h31
-rw-r--r--llvm/include/llvm/Analysis/ScalarEvolution.h8
-rw-r--r--llvm/include/llvm/Analysis/TargetTransformInfo.h3
-rw-r--r--llvm/include/llvm/AsmParser/AsmParserContext.h70
-rw-r--r--llvm/include/llvm/AsmParser/FileLoc.h56
-rw-r--r--llvm/include/llvm/AsmParser/LLLexer.h24
-rw-r--r--llvm/include/llvm/AsmParser/LLParser.h11
-rw-r--r--llvm/include/llvm/AsmParser/Parser.h16
-rw-r--r--llvm/include/llvm/BinaryFormat/ELF.h1
-rw-r--r--llvm/include/llvm/CodeGen/AtomicExpand.h2
-rw-r--r--llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h2
-rw-r--r--llvm/include/llvm/CodeGen/BasicTTIImpl.h24
-rw-r--r--llvm/include/llvm/CodeGen/CodeGenPrepare.h2
-rw-r--r--llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h2
-rw-r--r--llvm/include/llvm/CodeGen/CommandFlags.h2
-rw-r--r--llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h4
-rw-r--r--llvm/include/llvm/CodeGen/DebugHandlerBase.h2
-rw-r--r--llvm/include/llvm/CodeGen/DroppedVariableStatsMIR.h9
-rw-r--r--llvm/include/llvm/CodeGen/DwarfEHPrepare.h2
-rw-r--r--llvm/include/llvm/CodeGen/ExpandFp.h2
-rw-r--r--llvm/include/llvm/CodeGen/ExpandLargeDivRem.h2
-rw-r--r--llvm/include/llvm/CodeGen/ExpandMemCmp.h2
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h6
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/Combiner.h2
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h2
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h2
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h2
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h17
-rw-r--r--llvm/include/llvm/CodeGen/IndirectBrExpand.h2
-rw-r--r--llvm/include/llvm/CodeGen/InterleavedAccess.h2
-rw-r--r--llvm/include/llvm/CodeGen/InterleavedLoadCombine.h2
-rw-r--r--llvm/include/llvm/CodeGen/MIR2Vec.h227
-rw-r--r--llvm/include/llvm/CodeGen/MachineBlockHashInfo.h114
-rw-r--r--llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h2
-rw-r--r--llvm/include/llvm/CodeGen/MachineModuleSlotTracker.h2
-rw-r--r--llvm/include/llvm/CodeGen/MachineOutliner.h2
-rw-r--r--llvm/include/llvm/CodeGen/Passes.h3
-rw-r--r--llvm/include/llvm/CodeGen/ResourcePriorityQueue.h2
-rw-r--r--llvm/include/llvm/CodeGen/SDPatternMatch.h5
-rw-r--r--llvm/include/llvm/CodeGen/SafeStack.h2
-rw-r--r--llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h1
-rw-r--r--llvm/include/llvm/CodeGen/SelectOptimize.h2
-rw-r--r--llvm/include/llvm/CodeGen/SelectionDAGNodes.h15
-rw-r--r--llvm/include/llvm/CodeGen/StackProtector.h2
-rw-r--r--llvm/include/llvm/CodeGen/TargetRegisterInfo.h2
-rw-r--r--llvm/include/llvm/CodeGen/TypePromotion.h2
-rw-r--r--llvm/include/llvm/CodeGen/VLIWMachineScheduler.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/Core.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/Layer.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/LinkGraphLinkingLayer.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h1
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorDylibManager.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/TaskDispatch.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h4
-rw-r--r--llvm/include/llvm/IR/Attributes.td2
-rw-r--r--llvm/include/llvm/IR/AutoUpgrade.h10
-rw-r--r--llvm/include/llvm/IR/Intrinsics.td12
-rw-r--r--llvm/include/llvm/IR/IntrinsicsAMDGPU.td14
-rw-r--r--llvm/include/llvm/IR/IntrinsicsNVVM.td100
-rw-r--r--llvm/include/llvm/IR/ModuleSummaryIndex.h54
-rw-r--r--llvm/include/llvm/IR/RuntimeLibcalls.td4
-rw-r--r--llvm/include/llvm/IRReader/IRReader.h17
-rw-r--r--llvm/include/llvm/InitializePasses.h1
-rw-r--r--llvm/include/llvm/LTO/LTO.h3
-rw-r--r--llvm/include/llvm/MC/MCContext.h2
-rw-r--r--llvm/include/llvm/Passes/CodeGenPassBuilder.h18
-rw-r--r--llvm/include/llvm/Support/AllocToken.h68
-rw-r--r--llvm/include/llvm/Support/GlobPattern.h21
-rw-r--r--llvm/include/llvm/Target/TargetOptions.h12
-rw-r--r--llvm/include/llvm/Transforms/Instrumentation/AllocToken.h2
-rw-r--r--llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h5
83 files changed, 879 insertions, 269 deletions
diff --git a/llvm/include/llvm/ADT/BitmaskEnum.h b/llvm/include/llvm/ADT/BitmaskEnum.h
index d464cbc..9555fad 100644
--- a/llvm/include/llvm/ADT/BitmaskEnum.h
+++ b/llvm/include/llvm/ADT/BitmaskEnum.h
@@ -106,7 +106,7 @@ struct is_bitmask_enum : std::false_type {};
template <typename E>
struct is_bitmask_enum<
- E, std::enable_if_t<sizeof(E::LLVM_BITMASK_LARGEST_ENUMERATOR) >= 0>>
+ E, std::void_t<decltype(E::LLVM_BITMASK_LARGEST_ENUMERATOR)>>
: std::true_type {};
/// Trait class to determine bitmask enumeration largest bit.
@@ -114,7 +114,7 @@ template <typename E, typename Enable = void> struct largest_bitmask_enum_bit;
template <typename E>
struct largest_bitmask_enum_bit<
- E, std::enable_if_t<sizeof(E::LLVM_BITMASK_LARGEST_ENUMERATOR) >= 0>> {
+ E, std::void_t<decltype(E::LLVM_BITMASK_LARGEST_ENUMERATOR)>> {
using UnderlyingTy = std::underlying_type_t<E>;
static constexpr UnderlyingTy value =
static_cast<UnderlyingTy>(E::LLVM_BITMASK_LARGEST_ENUMERATOR);
diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h
index 82a88c4..675b5c6 100644
--- a/llvm/include/llvm/ADT/FoldingSet.h
+++ b/llvm/include/llvm/ADT/FoldingSet.h
@@ -332,6 +332,14 @@ class FoldingSetNodeID {
/// Use a SmallVector to avoid a heap allocation in the common case.
SmallVector<unsigned, 32> Bits;
+ template <typename T> void AddIntegerImpl(T I) {
+ static_assert(std::is_integral_v<T> && sizeof(T) <= sizeof(unsigned) * 2,
+ "T must be an integer type no wider than 64 bits");
+ Bits.push_back(static_cast<unsigned>(I));
+ if constexpr (sizeof(unsigned) < sizeof(T))
+ Bits.push_back(static_cast<unsigned long long>(I) >> 32);
+ }
+
public:
FoldingSetNodeID() = default;
@@ -348,24 +356,12 @@ public:
"unexpected pointer size");
AddInteger(reinterpret_cast<uintptr_t>(Ptr));
}
- void AddInteger(signed I) { Bits.push_back(I); }
- void AddInteger(unsigned I) { Bits.push_back(I); }
- void AddInteger(long I) { AddInteger((unsigned long)I); }
- void AddInteger(unsigned long I) {
- if (sizeof(long) == sizeof(int))
- AddInteger(unsigned(I));
- else if (sizeof(long) == sizeof(long long)) {
- AddInteger((unsigned long long)I);
- } else {
- llvm_unreachable("unexpected sizeof(long)");
- }
- }
- void AddInteger(long long I) { AddInteger((unsigned long long)I); }
- void AddInteger(unsigned long long I) {
- AddInteger(unsigned(I));
- AddInteger(unsigned(I >> 32));
- }
-
+ void AddInteger(signed I) { AddIntegerImpl(I); }
+ void AddInteger(unsigned I) { AddIntegerImpl(I); }
+ void AddInteger(long I) { AddIntegerImpl(I); }
+ void AddInteger(unsigned long I) { AddIntegerImpl(I); }
+ void AddInteger(long long I) { AddIntegerImpl(I); }
+ void AddInteger(unsigned long long I) { AddIntegerImpl(I); }
void AddBoolean(bool B) { AddInteger(B ? 1U : 0U); }
LLVM_ABI void AddString(StringRef String);
LLVM_ABI void AddNodeID(const FoldingSetNodeID &ID);
diff --git a/llvm/include/llvm/ADT/IndexedMap.h b/llvm/include/llvm/ADT/IndexedMap.h
index cda0316..55935a7 100644
--- a/llvm/include/llvm/ADT/IndexedMap.h
+++ b/llvm/include/llvm/ADT/IndexedMap.h
@@ -22,12 +22,21 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/identity.h"
#include <cassert>
namespace llvm {
-template <typename T, typename ToIndexT = identity<unsigned>> class IndexedMap {
+namespace detail {
+template <class Ty> struct IdentityIndex {
+ using argument_type = Ty;
+
+ Ty &operator()(Ty &self) const { return self; }
+ const Ty &operator()(const Ty &self) const { return self; }
+};
+} // namespace detail
+
+template <typename T, typename ToIndexT = detail::IdentityIndex<unsigned>>
+class IndexedMap {
using IndexT = typename ToIndexT::argument_type;
// Prefer SmallVector with zero inline storage over std::vector. IndexedMaps
// can grow very large and SmallVector grows more efficiently as long as T
@@ -35,11 +44,11 @@ template <typename T, typename ToIndexT = identity<unsigned>> class IndexedMap {
using StorageT = SmallVector<T, 0>;
StorageT storage_;
- T nullVal_;
+ T nullVal_ = T();
ToIndexT toIndex_;
public:
- IndexedMap() : nullVal_(T()) {}
+ IndexedMap() = default;
explicit IndexedMap(const T &val) : nullVal_(val) {}
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index efae6f3..51109d1 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -14,6 +14,7 @@
#ifndef LLVM_ADT_SMALLVECTOR_H
#define LLVM_ADT_SMALLVECTOR_H
+#include "llvm/ADT/ADL.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/Compiler.h"
#include <algorithm>
@@ -734,6 +735,12 @@ public:
void assign(const SmallVectorImpl &RHS) { assign(RHS.begin(), RHS.end()); }
+ template <typename U,
+ typename = std::enable_if_t<std::is_convertible_v<U, T>>>
+ void assign(ArrayRef<U> AR) {
+ assign(AR.begin(), AR.end());
+ }
+
iterator erase(const_iterator CI) {
// Just cast away constness because this is a non-const member function.
iterator I = const_cast<iterator>(CI);
@@ -1228,7 +1235,7 @@ public:
}
template <typename U,
- typename = std::enable_if_t<std::is_convertible<U, T>::value>>
+ typename = std::enable_if_t<std::is_convertible_v<U, T>>>
explicit SmallVector(ArrayRef<U> A) : SmallVectorImpl<T>(N) {
this->append(A.begin(), A.end());
}
@@ -1289,28 +1296,27 @@ inline size_t capacity_in_bytes(const SmallVector<T, N> &X) {
template <typename RangeType>
using ValueTypeFromRangeType =
- std::remove_const_t<std::remove_reference_t<decltype(*std::begin(
- std::declval<RangeType &>()))>>;
+ std::remove_const_t<detail::ValueOfRange<RangeType>>;
/// Given a range of type R, iterate the entire range and return a
/// SmallVector with elements of the vector. This is useful, for example,
/// when you want to iterate a range and then sort the results.
template <unsigned Size, typename R>
SmallVector<ValueTypeFromRangeType<R>, Size> to_vector(R &&Range) {
- return {std::begin(Range), std::end(Range)};
+ return {adl_begin(Range), adl_end(Range)};
}
template <typename R>
SmallVector<ValueTypeFromRangeType<R>> to_vector(R &&Range) {
- return {std::begin(Range), std::end(Range)};
+ return {adl_begin(Range), adl_end(Range)};
}
template <typename Out, unsigned Size, typename R>
SmallVector<Out, Size> to_vector_of(R &&Range) {
- return {std::begin(Range), std::end(Range)};
+ return {adl_begin(Range), adl_end(Range)};
}
template <typename Out, typename R> SmallVector<Out> to_vector_of(R &&Range) {
- return {std::begin(Range), std::end(Range)};
+ return {adl_begin(Range), adl_end(Range)};
}
// Explicit instantiations
diff --git a/llvm/include/llvm/ADT/identity.h b/llvm/include/llvm/ADT/identity.h
deleted file mode 100644
index 88d033f..0000000
--- a/llvm/include/llvm/ADT/identity.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===- llvm/ADT/Identity.h - Provide std::identity from C++20 ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides an implementation of std::identity from C++20.
-//
-// No library is required when using these functions.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ADT_IDENTITY_H
-#define LLVM_ADT_IDENTITY_H
-
-namespace llvm {
-
-// Similar to `std::identity` from C++20.
-template <class Ty> struct identity {
- using is_transparent = void;
- using argument_type = Ty;
-
- Ty &operator()(Ty &self) const { return self; }
- const Ty &operator()(const Ty &self) const { return self; }
-};
-
-} // namespace llvm
-
-#endif // LLVM_ADT_IDENTITY_H
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 3d3ec14..04ea769 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -638,8 +638,12 @@ public:
/// \p GEP The GEP. The indices contained in the GEP itself are ignored,
/// instead we use IndexExprs.
/// \p IndexExprs The expressions for the indices.
- LLVM_ABI const SCEV *
- getGEPExpr(GEPOperator *GEP, const SmallVectorImpl<const SCEV *> &IndexExprs);
+ LLVM_ABI const SCEV *getGEPExpr(GEPOperator *GEP,
+ ArrayRef<const SCEV *> IndexExprs);
+ LLVM_ABI const SCEV *getGEPExpr(const SCEV *BaseExpr,
+ ArrayRef<const SCEV *> IndexExprs,
+ Type *SrcElementTy,
+ GEPNoWrapFlags NW = GEPNoWrapFlags::none());
LLVM_ABI const SCEV *getAbsExpr(const SCEV *Op, bool IsNSW);
LLVM_ABI const SCEV *getMinMaxExpr(SCEVTypes Kind,
SmallVectorImpl<const SCEV *> &Operands);
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 5d3b233..7b7dc1b 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -227,6 +227,9 @@ public:
/// Get the kind of extension that an instruction represents.
LLVM_ABI static PartialReductionExtendKind
getPartialReductionExtendKind(Instruction *I);
+ /// Get the kind of extension that a cast opcode represents.
+ LLVM_ABI static PartialReductionExtendKind
+ getPartialReductionExtendKind(Instruction::CastOps CastOpc);
/// Construct a TTI object using a type implementing the \c Concept
/// API below.
diff --git a/llvm/include/llvm/AsmParser/AsmParserContext.h b/llvm/include/llvm/AsmParser/AsmParserContext.h
new file mode 100644
index 0000000..1a397486
--- /dev/null
+++ b/llvm/include/llvm/AsmParser/AsmParserContext.h
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ASMPARSER_ASMPARSERCONTEXT_H
+#define LLVM_ASMPARSER_ASMPARSERCONTEXT_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/AsmParser/FileLoc.h"
+#include "llvm/IR/Value.h"
+#include <optional>
+
+namespace llvm {
+
+/// Registry of file location information for LLVM IR constructs.
+///
+/// This class provides access to the file location information
+/// for various LLVM IR constructs. Currently, it supports Function,
+/// BasicBlock and Instruction locations.
+///
+/// When available, it can answer queries about what is at a given
+/// file location, as well as where in a file a given IR construct
+/// is.
+///
+/// This information is optionally emitted by the LLParser while
+/// it reads LLVM textual IR.
+class AsmParserContext {
+ DenseMap<Function *, FileLocRange> Functions;
+ DenseMap<BasicBlock *, FileLocRange> Blocks;
+ DenseMap<Instruction *, FileLocRange> Instructions;
+
+public:
+ std::optional<FileLocRange> getFunctionLocation(const Function *) const;
+ std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const;
+ std::optional<FileLocRange> getInstructionLocation(const Instruction *) const;
+ /// Get the function at the requested location range.
+ /// If no single function occupies the queried range, or the record is
+ /// missing, a nullptr is returned.
+ Function *getFunctionAtLocation(const FileLocRange &) const;
+ /// Get the function at the requested location.
+ /// If no function occupies the queried location, or the record is missing, a
+ /// nullptr is returned.
+ Function *getFunctionAtLocation(const FileLoc &) const;
+ /// Get the block at the requested location range.
+ /// If no single block occupies the queried range, or the record is missing, a
+ /// nullptr is returned.
+ BasicBlock *getBlockAtLocation(const FileLocRange &) const;
+ /// Get the block at the requested location.
+ /// If no block occupies the queried location, or the record is missing, a
+ /// nullptr is returned.
+ BasicBlock *getBlockAtLocation(const FileLoc &) const;
+ /// Get the instruction at the requested location range.
+ /// If no single instruction occupies the queried range, or the record is
+ /// missing, a nullptr is returned.
+ Instruction *getInstructionAtLocation(const FileLocRange &) const;
+ /// Get the instruction at the requested location.
+ /// If no instruction occupies the queried location, or the record is missing,
+ /// a nullptr is returned.
+ Instruction *getInstructionAtLocation(const FileLoc &) const;
+ bool addFunctionLocation(Function *, const FileLocRange &);
+ bool addBlockLocation(BasicBlock *, const FileLocRange &);
+ bool addInstructionLocation(Instruction *, const FileLocRange &);
+};
+} // namespace llvm
+
+#endif
diff --git a/llvm/include/llvm/AsmParser/FileLoc.h b/llvm/include/llvm/AsmParser/FileLoc.h
new file mode 100644
index 0000000..02c1849
--- /dev/null
+++ b/llvm/include/llvm/AsmParser/FileLoc.h
@@ -0,0 +1,56 @@
+//===-- FileLoc.h ---------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ASMPARSER_FILELOC_H
+#define LLVM_ASMPARSER_FILELOC_H
+
+#include <cassert>
+#include <utility>
+
+namespace llvm {
+
+/// Struct holding Line:Column location
+struct FileLoc {
+ /// 0-based line number
+ unsigned Line;
+ /// 0-based column number
+ unsigned Col;
+
+ bool operator<=(const FileLoc &RHS) const {
+ return Line < RHS.Line || (Line == RHS.Line && Col <= RHS.Col);
+ }
+
+ bool operator<(const FileLoc &RHS) const {
+ return Line < RHS.Line || (Line == RHS.Line && Col < RHS.Col);
+ }
+
+ FileLoc(unsigned L, unsigned C) : Line(L), Col(C) {}
+ FileLoc(std::pair<unsigned, unsigned> LC) : Line(LC.first), Col(LC.second) {}
+};
+
+/// Struct holding a semiopen range [Start; End)
+struct FileLocRange {
+ FileLoc Start;
+ FileLoc End;
+
+ FileLocRange() : Start(0, 0), End(0, 0) {}
+
+ FileLocRange(FileLoc S, FileLoc E) : Start(S), End(E) {
+ assert(Start <= End);
+ }
+
+ bool contains(FileLoc L) const { return Start <= L && L < End; }
+
+ bool contains(FileLocRange LR) const {
+ return Start <= LR.Start && LR.End <= End;
+ }
+};
+
+} // namespace llvm
+
+#endif
diff --git a/llvm/include/llvm/AsmParser/LLLexer.h b/llvm/include/llvm/AsmParser/LLLexer.h
index 501a7ae..0e379e5 100644
--- a/llvm/include/llvm/AsmParser/LLLexer.h
+++ b/llvm/include/llvm/AsmParser/LLLexer.h
@@ -13,22 +13,25 @@
#ifndef LLVM_ASMPARSER_LLLEXER_H
#define LLVM_ASMPARSER_LLLEXER_H
-#include "LLToken.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APSInt.h"
+#include "llvm/AsmParser/LLToken.h"
#include "llvm/Support/SMLoc.h"
+#include "llvm/Support/SourceMgr.h"
#include <string>
namespace llvm {
class Type;
class SMDiagnostic;
- class SourceMgr;
class LLVMContext;
class LLLexer {
const char *CurPtr;
StringRef CurBuf;
+ /// The end (exclusive) of the previous token.
+ const char *PrevTokEnd = nullptr;
+
enum class ErrorPriority {
None, // No error message present.
Parser, // Errors issued by parser.
@@ -62,9 +65,7 @@ namespace llvm {
explicit LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &,
LLVMContext &C);
- lltok::Kind Lex() {
- return CurKind = LexToken();
- }
+ lltok::Kind Lex() { return CurKind = LexToken(); }
typedef SMLoc LocTy;
LocTy getLoc() const { return SMLoc::getFromPointer(TokStart); }
@@ -79,6 +80,19 @@ namespace llvm {
IgnoreColonInIdentifiers = val;
}
+ /// Get the line, column position of the start of the current token,
+ /// zero-indexed
+ std::pair<unsigned, unsigned> getTokLineColumnPos() {
+ auto LC = SM.getLineAndColumn(SMLoc::getFromPointer(TokStart));
+ return {LC.first - 1, LC.second - 1};
+ }
+ /// Get the line, column position of the end of the previous token,
+ /// zero-indexed exclusive
+ std::pair<unsigned, unsigned> getPrevTokEndLineColumnPos() {
+ auto LC = SM.getLineAndColumn(SMLoc::getFromPointer(PrevTokEnd));
+ return {LC.first - 1, LC.second - 1};
+ }
+
// This returns true as a convenience for the parser functions that return
// true on error.
bool ParseError(LocTy ErrorLoc, const Twine &Msg) {
diff --git a/llvm/include/llvm/AsmParser/LLParser.h b/llvm/include/llvm/AsmParser/LLParser.h
index c01de4a..9eb31d7 100644
--- a/llvm/include/llvm/AsmParser/LLParser.h
+++ b/llvm/include/llvm/AsmParser/LLParser.h
@@ -13,8 +13,9 @@
#ifndef LLVM_ASMPARSER_LLPARSER_H
#define LLVM_ASMPARSER_LLPARSER_H
-#include "LLLexer.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/AsmParser/AsmParserContext.h"
+#include "llvm/AsmParser/LLLexer.h"
#include "llvm/AsmParser/NumberedValues.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Attributes.h"
@@ -177,6 +178,9 @@ namespace llvm {
// Map of module ID to path.
std::map<unsigned, StringRef> ModuleIdMap;
+ /// Keeps track of source locations for Values, BasicBlocks, and Functions.
+ AsmParserContext *ParserContext;
+
/// Only the llvm-as tool may set this to false to bypass
/// UpgradeDebuginfo so it can generate broken bitcode.
bool UpgradeDebugInfo;
@@ -189,10 +193,11 @@ namespace llvm {
public:
LLParser(StringRef F, SourceMgr &SM, SMDiagnostic &Err, Module *M,
ModuleSummaryIndex *Index, LLVMContext &Context,
- SlotMapping *Slots = nullptr)
+ SlotMapping *Slots = nullptr,
+ AsmParserContext *ParserContext = nullptr)
: Context(Context), OPLex(F, SM, Err, Context),
Lex(F, SM, Err, Context), M(M), Index(Index), Slots(Slots),
- BlockAddressPFS(nullptr) {}
+ BlockAddressPFS(nullptr), ParserContext(ParserContext) {}
bool Run(
bool UpgradeDebugInfo,
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
diff --git a/llvm/include/llvm/AsmParser/Parser.h b/llvm/include/llvm/AsmParser/Parser.h
index c900b79..22b0881 100644
--- a/llvm/include/llvm/AsmParser/Parser.h
+++ b/llvm/include/llvm/AsmParser/Parser.h
@@ -15,6 +15,7 @@
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/AsmParser/AsmParserContext.h"
#include "llvm/Support/Compiler.h"
#include <memory>
#include <optional>
@@ -62,7 +63,8 @@ parseAssemblyFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
/// parsing.
LLVM_ABI std::unique_ptr<Module>
parseAssemblyString(StringRef AsmString, SMDiagnostic &Err,
- LLVMContext &Context, SlotMapping *Slots = nullptr);
+ LLVMContext &Context, SlotMapping *Slots = nullptr,
+ AsmParserContext *ParserContext = nullptr);
/// Holds the Module and ModuleSummaryIndex returned by the interfaces
/// that parse both.
@@ -128,9 +130,9 @@ parseSummaryIndexAssemblyString(StringRef AsmString, SMDiagnostic &Err);
LLVM_ABI std::unique_ptr<Module> parseAssembly(
MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context,
SlotMapping *Slots = nullptr,
- DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
- return std::nullopt;
- });
+ DataLayoutCallbackTy DataLayoutCallback =
+ [](StringRef, StringRef) { return std::nullopt; },
+ AsmParserContext *ParserContext = nullptr);
/// Parse LLVM Assembly including the summary index from a MemoryBuffer.
///
@@ -169,9 +171,9 @@ parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);
LLVM_ABI bool parseAssemblyInto(
MemoryBufferRef F, Module *M, ModuleSummaryIndex *Index, SMDiagnostic &Err,
SlotMapping *Slots = nullptr,
- DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
- return std::nullopt;
- });
+ DataLayoutCallbackTy DataLayoutCallback =
+ [](StringRef, StringRef) { return std::nullopt; },
+ AsmParserContext *ParserContext = nullptr);
/// Parse a type and a constant value in the given string.
///
diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h
index 8d0dc64..6ee6b666 100644
--- a/llvm/include/llvm/BinaryFormat/ELF.h
+++ b/llvm/include/llvm/BinaryFormat/ELF.h
@@ -1185,6 +1185,7 @@ enum : unsigned {
SHT_LLVM_LTO = 0x6fff4c0c, // .llvm.lto for fat LTO.
SHT_LLVM_JT_SIZES = 0x6fff4c0d, // LLVM jump tables sizes.
SHT_LLVM_CFI_JUMP_TABLE = 0x6fff4c0e, // LLVM CFI jump table.
+ SHT_LLVM_CALL_GRAPH = 0x6fff4c0f, // LLVM Call Graph Section.
// Android's experimental support for SHT_RELR sections.
// https://android.googlesource.com/platform/bionic/+/b7feec74547f84559a1467aca02708ff61346d2a/libc/include/elf.h#512
SHT_ANDROID_RELR = 0x6fffff00, // Relocation entries; only offsets.
diff --git a/llvm/include/llvm/CodeGen/AtomicExpand.h b/llvm/include/llvm/CodeGen/AtomicExpand.h
index 1b8a988..34f520f 100644
--- a/llvm/include/llvm/CodeGen/AtomicExpand.h
+++ b/llvm/include/llvm/CodeGen/AtomicExpand.h
@@ -21,7 +21,7 @@ private:
const TargetMachine *TM;
public:
- AtomicExpandPass(const TargetMachine *TM) : TM(TM) {}
+ AtomicExpandPass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
diff --git a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
index 82dd5fe..48650a6 100644
--- a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
+++ b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
@@ -155,7 +155,7 @@ class BasicBlockSectionsProfileReaderAnalysis
public:
static AnalysisKey Key;
typedef BasicBlockSectionsProfileReader Result;
- BasicBlockSectionsProfileReaderAnalysis(const TargetMachine *TM) : TM(TM) {}
+ BasicBlockSectionsProfileReaderAnalysis(const TargetMachine &TM) : TM(&TM) {}
Result run(Function &F, FunctionAnalysisManager &AM);
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 4f27d9f1..76b6c8e 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -366,7 +366,7 @@ private:
protected:
explicit BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
: BaseT(DL) {}
- virtual ~BasicTTIImplBase() = default;
+ ~BasicTTIImplBase() override = default;
using TargetTransformInfoImplBase::DL;
@@ -821,13 +821,13 @@ public:
SimplifyAndSetOp);
}
- virtual std::optional<unsigned>
+ std::optional<unsigned>
getCacheSize(TargetTransformInfo::CacheLevel Level) const override {
return std::optional<unsigned>(
getST()->getCacheSize(static_cast<unsigned>(Level)));
}
- virtual std::optional<unsigned>
+ std::optional<unsigned>
getCacheAssociativity(TargetTransformInfo::CacheLevel Level) const override {
std::optional<unsigned> TargetResult =
getST()->getCacheAssociativity(static_cast<unsigned>(Level));
@@ -838,31 +838,31 @@ public:
return BaseT::getCacheAssociativity(Level);
}
- virtual unsigned getCacheLineSize() const override {
+ unsigned getCacheLineSize() const override {
return getST()->getCacheLineSize();
}
- virtual unsigned getPrefetchDistance() const override {
+ unsigned getPrefetchDistance() const override {
return getST()->getPrefetchDistance();
}
- virtual unsigned getMinPrefetchStride(unsigned NumMemAccesses,
- unsigned NumStridedMemAccesses,
- unsigned NumPrefetches,
- bool HasCall) const override {
+ unsigned getMinPrefetchStride(unsigned NumMemAccesses,
+ unsigned NumStridedMemAccesses,
+ unsigned NumPrefetches,
+ bool HasCall) const override {
return getST()->getMinPrefetchStride(NumMemAccesses, NumStridedMemAccesses,
NumPrefetches, HasCall);
}
- virtual unsigned getMaxPrefetchIterationsAhead() const override {
+ unsigned getMaxPrefetchIterationsAhead() const override {
return getST()->getMaxPrefetchIterationsAhead();
}
- virtual bool enableWritePrefetching() const override {
+ bool enableWritePrefetching() const override {
return getST()->enableWritePrefetching();
}
- virtual bool shouldPrefetchAddressSpace(unsigned AS) const override {
+ bool shouldPrefetchAddressSpace(unsigned AS) const override {
return getST()->shouldPrefetchAddressSpace(AS);
}
diff --git a/llvm/include/llvm/CodeGen/CodeGenPrepare.h b/llvm/include/llvm/CodeGen/CodeGenPrepare.h
index dee3a9e..e673d0f 100644
--- a/llvm/include/llvm/CodeGen/CodeGenPrepare.h
+++ b/llvm/include/llvm/CodeGen/CodeGenPrepare.h
@@ -26,7 +26,7 @@ private:
const TargetMachine *TM;
public:
- CodeGenPreparePass(const TargetMachine *TM) : TM(TM) {}
+ CodeGenPreparePass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
diff --git a/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h b/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h
index 3950b95..7a6feda 100644
--- a/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h
+++ b/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h
@@ -42,7 +42,7 @@ public:
/// Create a pass configuration object to be used by addPassToEmitX methods
/// for generating a pipeline of CodeGen passes.
- virtual TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
+ TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
/// Add passes to the specified pass manager to get the specified file
/// emitted. Typically this will involve several steps of code generation.
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h
index 39c5a8d..af66f2d 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -58,8 +58,6 @@ LLVM_ABI CodeGenFileType getFileType();
LLVM_ABI FramePointerKind getFramePointerUsage();
-LLVM_ABI bool getEnableUnsafeFPMath();
-
LLVM_ABI bool getEnableNoInfsFPMath();
LLVM_ABI bool getEnableNoNaNsFPMath();
diff --git a/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h b/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h
index 4383249..7b74f2a 100644
--- a/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h
+++ b/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h
@@ -24,10 +24,10 @@ class TargetMachine;
struct ComplexDeinterleavingPass
: public PassInfoMixin<ComplexDeinterleavingPass> {
private:
- TargetMachine *TM;
+ const TargetMachine *TM;
public:
- ComplexDeinterleavingPass(TargetMachine *TM) : TM(TM) {}
+ ComplexDeinterleavingPass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
diff --git a/llvm/include/llvm/CodeGen/DebugHandlerBase.h b/llvm/include/llvm/CodeGen/DebugHandlerBase.h
index fee4bb1..e72801b 100644
--- a/llvm/include/llvm/CodeGen/DebugHandlerBase.h
+++ b/llvm/include/llvm/CodeGen/DebugHandlerBase.h
@@ -118,7 +118,7 @@ private:
// AsmPrinterHandler overrides.
public:
- virtual ~DebugHandlerBase() override;
+ ~DebugHandlerBase() override;
void beginModule(Module *M) override;
diff --git a/llvm/include/llvm/CodeGen/DroppedVariableStatsMIR.h b/llvm/include/llvm/CodeGen/DroppedVariableStatsMIR.h
index bc8dc1b..6da10d8 100644
--- a/llvm/include/llvm/CodeGen/DroppedVariableStatsMIR.h
+++ b/llvm/include/llvm/CodeGen/DroppedVariableStatsMIR.h
@@ -44,12 +44,11 @@ private:
StringRef FuncOrModName);
/// Override base class method to run on an llvm::MachineFunction
/// specifically.
- virtual void
- visitEveryInstruction(unsigned &DroppedCount,
- DenseMap<VarID, DILocation *> &InlinedAtsMap,
- VarID Var) override;
+ void visitEveryInstruction(unsigned &DroppedCount,
+ DenseMap<VarID, DILocation *> &InlinedAtsMap,
+ VarID Var) override;
/// Override base class method to run on DBG_VALUEs specifically.
- virtual void visitEveryDebugRecord(
+ void visitEveryDebugRecord(
DenseSet<VarID> &VarIDSet,
DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
StringRef FuncName, bool Before) override;
diff --git a/llvm/include/llvm/CodeGen/DwarfEHPrepare.h b/llvm/include/llvm/CodeGen/DwarfEHPrepare.h
index 3f625cd..5b68b8c 100644
--- a/llvm/include/llvm/CodeGen/DwarfEHPrepare.h
+++ b/llvm/include/llvm/CodeGen/DwarfEHPrepare.h
@@ -24,7 +24,7 @@ class DwarfEHPreparePass : public PassInfoMixin<DwarfEHPreparePass> {
const TargetMachine *TM;
public:
- explicit DwarfEHPreparePass(const TargetMachine *TM_) : TM(TM_) {}
+ explicit DwarfEHPreparePass(const TargetMachine &TM_) : TM(&TM_) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/ExpandFp.h b/llvm/include/llvm/CodeGen/ExpandFp.h
index f1f441b..28e6aec 100644
--- a/llvm/include/llvm/CodeGen/ExpandFp.h
+++ b/llvm/include/llvm/CodeGen/ExpandFp.h
@@ -22,7 +22,7 @@ private:
CodeGenOptLevel OptLevel;
public:
- explicit ExpandFpPass(const TargetMachine *TM, CodeGenOptLevel OptLevel);
+ explicit ExpandFpPass(const TargetMachine &TM, CodeGenOptLevel OptLevel);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
diff --git a/llvm/include/llvm/CodeGen/ExpandLargeDivRem.h b/llvm/include/llvm/CodeGen/ExpandLargeDivRem.h
index 6fc4409..b73a382 100644
--- a/llvm/include/llvm/CodeGen/ExpandLargeDivRem.h
+++ b/llvm/include/llvm/CodeGen/ExpandLargeDivRem.h
@@ -20,7 +20,7 @@ private:
const TargetMachine *TM;
public:
- explicit ExpandLargeDivRemPass(const TargetMachine *TM_) : TM(TM_) {}
+ explicit ExpandLargeDivRemPass(const TargetMachine &TM_) : TM(&TM_) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
diff --git a/llvm/include/llvm/CodeGen/ExpandMemCmp.h b/llvm/include/llvm/CodeGen/ExpandMemCmp.h
index 94a8778..0b845e4 100644
--- a/llvm/include/llvm/CodeGen/ExpandMemCmp.h
+++ b/llvm/include/llvm/CodeGen/ExpandMemCmp.h
@@ -19,7 +19,7 @@ class ExpandMemCmpPass : public PassInfoMixin<ExpandMemCmpPass> {
const TargetMachine *TM;
public:
- explicit ExpandMemCmpPass(const TargetMachine *TM_) : TM(TM_) {}
+ explicit ExpandMemCmpPass(const TargetMachine &TM_) : TM(&TM_) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h
index ea3f1a8..6701ae0 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h
@@ -40,14 +40,14 @@ public:
// A CSE config for fully optimized builds.
class LLVM_ABI CSEConfigFull : public CSEConfigBase {
public:
- virtual ~CSEConfigFull() = default;
+ ~CSEConfigFull() override = default;
bool shouldCSEOpc(unsigned Opc) override;
};
// Commonly used for O0 config.
class LLVM_ABI CSEConfigConstantOnly : public CSEConfigBase {
public:
- virtual ~CSEConfigConstantOnly() = default;
+ ~CSEConfigConstantOnly() override = default;
bool shouldCSEOpc(unsigned Opc) override;
};
@@ -118,7 +118,7 @@ class LLVM_ABI GISelCSEInfo : public GISelChangeObserver {
public:
GISelCSEInfo() = default;
- virtual ~GISelCSEInfo();
+ ~GISelCSEInfo() override;
void setMF(MachineFunction &MF);
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Combiner.h b/llvm/include/llvm/CodeGen/GlobalISel/Combiner.h
index 39ff90c..7a313f4 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/Combiner.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/Combiner.h
@@ -60,7 +60,7 @@ public:
Combiner(MachineFunction &MF, CombinerInfo &CInfo,
const TargetPassConfig *TPC, GISelValueTracking *VT,
GISelCSEInfo *CSEInfo = nullptr);
- virtual ~Combiner();
+ ~Combiner() override;
virtual bool tryCombineAll(MachineInstr &I) const = 0;
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h b/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h
index 2db66ba..17d656a 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h
@@ -58,7 +58,7 @@ class LLVM_ABI GISelValueTracking : public GISelChangeObserver {
public:
GISelValueTracking(MachineFunction &MF, unsigned MaxDepth = 6);
- ~GISelValueTracking() = default;
+ ~GISelValueTracking() override = default;
const MachineFunction &getMachineFunction() const { return MF; }
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
index 3d7ccd5..268025e7 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
@@ -656,7 +656,7 @@ private:
IRT->addSuccessorWithProb(Src, Dst, Prob);
}
- virtual ~GISelSwitchLowering() = default;
+ ~GISelSwitchLowering() override = default;
private:
IRTranslator *IRT;
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
index cf65f34..5694079 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
@@ -21,7 +21,7 @@ class GISelObserverWrapper;
class LLVM_ABI InstructionSelector : public GIMatchTableExecutor {
public:
- virtual ~InstructionSelector();
+ ~InstructionSelector() override;
/// Select the (possibly generic) instruction \p I to only use target-specific
/// opcodes. It is OK to insert multiple instructions, but they cannot be
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
index b7ccfbb..8db99ba 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
@@ -210,8 +210,8 @@ struct SpecificConstantMatch {
};
/// Matches a constant equal to \p RequestedValue.
-inline SpecificConstantMatch m_SpecificICst(APInt RequestedValue) {
- return SpecificConstantMatch(std::move(RequestedValue));
+inline SpecificConstantMatch m_SpecificICst(const APInt &RequestedValue) {
+ return SpecificConstantMatch(RequestedValue);
}
inline SpecificConstantMatch m_SpecificICst(int64_t RequestedValue) {
@@ -221,7 +221,7 @@ inline SpecificConstantMatch m_SpecificICst(int64_t RequestedValue) {
/// Matcher for a specific constant splat.
struct SpecificConstantSplatMatch {
APInt RequestedVal;
- SpecificConstantSplatMatch(const APInt RequestedVal)
+ SpecificConstantSplatMatch(const APInt &RequestedVal)
: RequestedVal(RequestedVal) {}
bool match(const MachineRegisterInfo &MRI, Register Reg) {
return isBuildVectorConstantSplat(Reg, MRI, RequestedVal,
@@ -230,8 +230,9 @@ struct SpecificConstantSplatMatch {
};
/// Matches a constant splat of \p RequestedValue.
-inline SpecificConstantSplatMatch m_SpecificICstSplat(APInt RequestedValue) {
- return SpecificConstantSplatMatch(std::move(RequestedValue));
+inline SpecificConstantSplatMatch
+m_SpecificICstSplat(const APInt &RequestedValue) {
+ return SpecificConstantSplatMatch(RequestedValue);
}
inline SpecificConstantSplatMatch m_SpecificICstSplat(int64_t RequestedValue) {
@@ -242,7 +243,7 @@ inline SpecificConstantSplatMatch m_SpecificICstSplat(int64_t RequestedValue) {
/// Matcher for a specific constant or constant splat.
struct SpecificConstantOrSplatMatch {
APInt RequestedVal;
- SpecificConstantOrSplatMatch(const APInt RequestedVal)
+ SpecificConstantOrSplatMatch(const APInt &RequestedVal)
: RequestedVal(RequestedVal) {}
bool match(const MachineRegisterInfo &MRI, Register Reg) {
APInt MatchedVal;
@@ -263,8 +264,8 @@ struct SpecificConstantOrSplatMatch {
/// Matches a \p RequestedValue constant or a constant splat of \p
/// RequestedValue.
inline SpecificConstantOrSplatMatch
-m_SpecificICstOrSplat(APInt RequestedValue) {
- return SpecificConstantOrSplatMatch(std::move(RequestedValue));
+m_SpecificICstOrSplat(const APInt &RequestedValue) {
+ return SpecificConstantOrSplatMatch(RequestedValue);
}
inline SpecificConstantOrSplatMatch
diff --git a/llvm/include/llvm/CodeGen/IndirectBrExpand.h b/llvm/include/llvm/CodeGen/IndirectBrExpand.h
index f7d9d5d..572a712 100644
--- a/llvm/include/llvm/CodeGen/IndirectBrExpand.h
+++ b/llvm/include/llvm/CodeGen/IndirectBrExpand.h
@@ -19,7 +19,7 @@ class IndirectBrExpandPass : public PassInfoMixin<IndirectBrExpandPass> {
const TargetMachine *TM;
public:
- IndirectBrExpandPass(const TargetMachine *TM) : TM(TM) {}
+ IndirectBrExpandPass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/InterleavedAccess.h b/llvm/include/llvm/CodeGen/InterleavedAccess.h
index 31bd19a..42bfa84 100644
--- a/llvm/include/llvm/CodeGen/InterleavedAccess.h
+++ b/llvm/include/llvm/CodeGen/InterleavedAccess.h
@@ -25,7 +25,7 @@ class InterleavedAccessPass : public PassInfoMixin<InterleavedAccessPass> {
const TargetMachine *TM;
public:
- explicit InterleavedAccessPass(const TargetMachine *TM) : TM(TM) {}
+ explicit InterleavedAccessPass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h b/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h
index fa99aa3..2750fd4 100644
--- a/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h
+++ b/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h
@@ -20,7 +20,7 @@ class InterleavedLoadCombinePass
const TargetMachine *TM;
public:
- explicit InterleavedLoadCombinePass(const TargetMachine *TM) : TM(TM) {}
+ explicit InterleavedLoadCombinePass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/MIR2Vec.h b/llvm/include/llvm/CodeGen/MIR2Vec.h
index f6b0571..44f009c 100644
--- a/llvm/include/llvm/CodeGen/MIR2Vec.h
+++ b/llvm/include/llvm/CodeGen/MIR2Vec.h
@@ -7,9 +7,20 @@
//===----------------------------------------------------------------------===//
///
/// \file
-/// This file defines the MIR2Vec vocabulary
-/// analysis(MIR2VecVocabLegacyAnalysis), the core mir2vec::MIREmbedder
-/// interface for generating Machine IR embeddings, and related utilities.
+/// This file defines the MIR2Vec framework for generating Machine IR
+/// embeddings.
+///
+/// Design Overview:
+/// ----------------------
+/// 1. MIR2VecVocabProvider - Core vocabulary loading logic (no PM dependency)
+/// - Can be used standalone or wrapped by the pass manager
+/// - Requires MachineModuleInfo with parsed machine functions
+///
+/// 2. MIR2VecVocabLegacyAnalysis - Pass manager wrapper (ImmutablePass)
+/// - Integrated and used by llc -print-mir2vec
+///
+/// 3. MIREmbedder - Generates embeddings from vocabulary
+/// - SymbolicMIREmbedder: MIR2Vec embedding implementation
///
/// MIR2Vec extends IR2Vec to support Machine IR embeddings. It represents the
/// LLVM Machine IR as embeddings which can be used as input to machine learning
@@ -35,6 +46,8 @@
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
+#include "llvm/CodeGen/MachineOperand.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
@@ -61,7 +74,7 @@ class MIREmbedder;
class SymbolicMIREmbedder;
extern llvm::cl::OptionCategory MIR2VecCategory;
-extern cl::opt<float> OpcWeight;
+extern cl::opt<float> OpcWeight, CommonOperandWeight, RegOperandWeight;
using Embedding = ir2vec::Embedding;
using MachineInstEmbeddingsMap = DenseMap<const MachineInstr *, Embedding>;
@@ -74,43 +87,172 @@ class MIRVocabulary {
friend class llvm::MIR2VecVocabLegacyAnalysis;
using VocabMap = std::map<std::string, ir2vec::Embedding>;
-private:
- // Define vocabulary layout - adapted for MIR
+ // MIRVocabulary Layout:
+ // +-------------------+-----------------------------------------------------+
+ // | Entity Type | Description |
+ // +-------------------+-----------------------------------------------------+
+ // | 1. Opcodes | Target specific opcodes derived from TII, grouped |
+ // | | by instruction semantics. |
+ // | 2. Common Operands| All common operand types, except register operands, |
+ // | | defined by MachineOperand::MachineOperandType enum. |
+ // | 3. Physical | Register classes defined by the target, specialized |
+ // | Reg classes | by physical registers. |
+ // | 4. Virtual | Register classes defined by the target, specialized |
+ // | Reg classes | by virtual and physical registers. |
+ // +-------------------+-----------------------------------------------------+
+
+ /// Layout information for the MIR vocabulary. Defines the starting index
+ /// and size of each section in the vocabulary.
struct {
size_t OpcodeBase = 0;
- size_t OperandBase = 0;
+ size_t CommonOperandBase = 0;
+ size_t PhyRegBase = 0;
+ size_t VirtRegBase = 0;
size_t TotalEntries = 0;
} Layout;
- enum class Section : unsigned { Opcodes = 0, MaxSections };
+ // TODO: See if we can have only one reg classes section instead of physical
+ // and virtual separate sections in the vocabulary. This would reduce the
+ // number of vocabulary entities significantly.
+ // We can potentially distinguish physical and virtual registers by
+ // considering them as a separate feature.
+ enum class Section : unsigned {
+ Opcodes = 0,
+ CommonOperands = 1,
+ PhyRegisters = 2,
+ VirtRegisters = 3,
+ MaxSections
+ };
ir2vec::VocabStorage Storage;
- mutable std::set<std::string> UniqueBaseOpcodeNames;
+ std::set<std::string> UniqueBaseOpcodeNames;
+ SmallVector<std::string, 24> RegisterOperandNames;
+
+ // Some instructions have optional register operands that may be NoRegister.
+ // We return a zero vector in such cases.
+ Embedding ZeroEmbedding;
+
+ // We have specialized MO_Register handling in the Register operand section,
+ // so we don't include it here. Also, no MO_DbgInstrRef for now.
+ static constexpr StringLiteral CommonOperandNames[] = {
+ "Immediate", "CImmediate", "FPImmediate", "MBB",
+ "FrameIndex", "ConstantPoolIndex", "TargetIndex", "JumpTableIndex",
+ "ExternalSymbol", "GlobalAddress", "BlockAddress", "RegisterMask",
+ "RegisterLiveOut", "Metadata", "MCSymbol", "CFIIndex",
+ "IntrinsicID", "Predicate", "ShuffleMask"};
+ static_assert(std::size(CommonOperandNames) == MachineOperand::MO_Last - 1 &&
+ "Common operand names size changed, update accordingly");
+
const TargetInstrInfo &TII;
- void generateStorage(const VocabMap &OpcodeMap);
+ const TargetRegisterInfo &TRI;
+ const MachineRegisterInfo &MRI;
+
+ void generateStorage(const VocabMap &OpcodeMap,
+ const VocabMap &CommonOperandMap,
+ const VocabMap &PhyRegMap, const VocabMap &VirtRegMap);
void buildCanonicalOpcodeMapping();
+ void buildRegisterOperandMapping();
/// Get canonical index for a machine opcode
unsigned getCanonicalOpcodeIndex(unsigned Opcode) const;
+ /// Get index for a common (non-register) machine operand
+ unsigned
+ getCommonOperandIndex(MachineOperand::MachineOperandType OperandType) const;
+
+ /// Get index for a register machine operand
+ unsigned getRegisterOperandIndex(Register Reg) const;
+
+ // Accessors for operand types
+ const Embedding &
+ operator[](MachineOperand::MachineOperandType OperandType) const {
+ unsigned LocalIndex = getCommonOperandIndex(OperandType);
+ return Storage[static_cast<unsigned>(Section::CommonOperands)][LocalIndex];
+ }
+
+ const Embedding &operator[](Register Reg) const {
+ // Reg is sometimes NoRegister (0) for optional operands. We return a zero
+ // vector in this case.
+ if (!Reg.isValid())
+ return ZeroEmbedding;
+ // TODO: Implement proper stack slot handling for MIR2Vec embeddings.
+ // Stack slots represent frame indices and should have their own
+ // embedding strategy rather than defaulting to register class 0.
+ // Consider: 1) Separate vocabulary section for stack slots
+ // 2) Stack slot size/alignment based embeddings
+ // 3) Frame index based categorization
+ if (Reg.isStack())
+ return ZeroEmbedding;
+
+ unsigned LocalIndex = getRegisterOperandIndex(Reg);
+ auto SectionID =
+ Reg.isPhysical() ? Section::PhyRegisters : Section::VirtRegisters;
+ return Storage[static_cast<unsigned>(SectionID)][LocalIndex];
+ }
+
+ /// Get entity ID (flat index) for a common operand type
+ /// This is used for triplet generation
+ unsigned getEntityIDForCommonOperand(
+ MachineOperand::MachineOperandType OperandType) const {
+ return Layout.CommonOperandBase + getCommonOperandIndex(OperandType);
+ }
+
+ /// Get entity ID (flat index) for a register
+ /// This is used for triplet generation
+ unsigned getEntityIDForRegister(Register Reg) const {
+ if (!Reg.isValid() || Reg.isStack())
+ return Layout
+ .VirtRegBase; // Return VirtRegBase for invalid/stack registers
+ unsigned LocalIndex = getRegisterOperandIndex(Reg);
+ size_t BaseOffset =
+ Reg.isPhysical() ? Layout.PhyRegBase : Layout.VirtRegBase;
+ return BaseOffset + LocalIndex;
+ }
+
public:
/// Static method for extracting base opcode names (public for testing)
static std::string extractBaseOpcodeName(StringRef InstrName);
- /// Get canonical index for base name (public for testing)
+ /// Get indices from opcode or operand names. These are public for testing.
+ /// String based lookups are inefficient and should be avoided in general.
unsigned getCanonicalIndexForBaseName(StringRef BaseName) const;
+ unsigned getCanonicalIndexForOperandName(StringRef OperandName) const;
+ unsigned getCanonicalIndexForRegisterClass(StringRef RegName,
+ bool IsPhysical = true) const;
/// Get the string key for a vocabulary entry at the given position
std::string getStringKey(unsigned Pos) const;
unsigned getDimension() const { return Storage.getDimension(); }
+ /// Get entity ID (flat index) for an opcode
+ /// This is used for triplet generation
+ unsigned getEntityIDForOpcode(unsigned Opcode) const {
+ return Layout.OpcodeBase + getCanonicalOpcodeIndex(Opcode);
+ }
+
+ /// Get entity ID (flat index) for a machine operand
+ /// This is used for triplet generation
+ unsigned getEntityIDForMachineOperand(const MachineOperand &MO) const {
+ if (MO.getType() == MachineOperand::MO_Register)
+ return getEntityIDForRegister(MO.getReg());
+ return getEntityIDForCommonOperand(MO.getType());
+ }
+
// Accessor methods
const Embedding &operator[](unsigned Opcode) const {
unsigned LocalIndex = getCanonicalOpcodeIndex(Opcode);
return Storage[static_cast<unsigned>(Section::Opcodes)][LocalIndex];
}
+ const Embedding &operator[](MachineOperand Operand) const {
+ auto OperandType = Operand.getType();
+ if (OperandType == MachineOperand::MO_Register)
+ return operator[](Operand.getReg());
+ else
+ return operator[](OperandType);
+ }
+
// Iterator access
using const_iterator = ir2vec::VocabStorage::const_iterator;
const_iterator begin() const { return Storage.begin(); }
@@ -120,18 +262,25 @@ public:
MIRVocabulary() = delete;
/// Factory method to create MIRVocabulary from vocabulary map
- static Expected<MIRVocabulary> create(VocabMap &&Entries,
- const TargetInstrInfo &TII);
+ static Expected<MIRVocabulary>
+ create(VocabMap &&OpcMap, VocabMap &&CommonOperandsMap, VocabMap &&PhyRegMap,
+ VocabMap &&VirtRegMap, const TargetInstrInfo &TII,
+ const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI);
/// Create a dummy vocabulary for testing purposes.
static Expected<MIRVocabulary>
- createDummyVocabForTest(const TargetInstrInfo &TII, unsigned Dim = 1);
+ createDummyVocabForTest(const TargetInstrInfo &TII,
+ const TargetRegisterInfo &TRI,
+ const MachineRegisterInfo &MRI, unsigned Dim = 1);
/// Total number of entries in the vocabulary
size_t getCanonicalSize() const { return Storage.size(); }
private:
- MIRVocabulary(VocabMap &&Entries, const TargetInstrInfo &TII);
+ MIRVocabulary(VocabMap &&OpcMap, VocabMap &&CommonOperandsMap,
+ VocabMap &&PhyRegMap, VocabMap &&VirtRegMap,
+ const TargetInstrInfo &TII, const TargetRegisterInfo &TRI,
+ const MachineRegisterInfo &MRI);
};
/// Base class for MIR embedders
@@ -144,11 +293,13 @@ protected:
const unsigned Dimension;
/// Weight for opcode embeddings
- const float OpcWeight;
+ const float OpcWeight, CommonOperandWeight, RegOperandWeight;
MIREmbedder(const MachineFunction &MF, const MIRVocabulary &Vocab)
: MF(MF), Vocab(Vocab), Dimension(Vocab.getDimension()),
- OpcWeight(mir2vec::OpcWeight) {}
+ OpcWeight(mir2vec::OpcWeight),
+ CommonOperandWeight(mir2vec::CommonOperandWeight),
+ RegOperandWeight(mir2vec::RegOperandWeight) {}
/// Function to compute embeddings.
Embedding computeEmbeddings() const;
@@ -204,26 +355,58 @@ public:
} // namespace mir2vec
+/// MIR2Vec vocabulary provider used by pass managers and standalone tools.
+/// This class encapsulates the core vocabulary loading logic and can be used
+/// independently of the pass manager infrastructure. For pass-based usage,
+/// see MIR2VecVocabLegacyAnalysis.
+///
+/// Note: This provider pattern makes new PM migration straightforward when
+/// needed. A new PM analysis wrapper can be added that delegates to this
+/// provider, similar to how MIR2VecVocabLegacyAnalysis currently wraps it.
+class MIR2VecVocabProvider {
+ using VocabMap = std::map<std::string, mir2vec::Embedding>;
+
+public:
+ MIR2VecVocabProvider(const MachineModuleInfo &MMI) : MMI(MMI) {}
+
+ Expected<mir2vec::MIRVocabulary> getVocabulary(const Module &M);
+
+private:
+ Error readVocabulary(VocabMap &OpcVocab, VocabMap &CommonOperandVocab,
+ VocabMap &PhyRegVocabMap, VocabMap &VirtRegVocabMap);
+ const MachineModuleInfo &MMI;
+};
+
/// Pass to analyze and populate MIR2Vec vocabulary from a module
class MIR2VecVocabLegacyAnalysis : public ImmutablePass {
using VocabVector = std::vector<mir2vec::Embedding>;
using VocabMap = std::map<std::string, mir2vec::Embedding>;
- VocabMap StrVocabMap;
- VocabVector Vocab;
StringRef getPassName() const override;
- Error readVocabulary();
protected:
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<MachineModuleInfoWrapperPass>();
AU.setPreservesAll();
}
+ std::unique_ptr<MIR2VecVocabProvider> Provider;
public:
static char ID;
MIR2VecVocabLegacyAnalysis() : ImmutablePass(ID) {}
- Expected<mir2vec::MIRVocabulary> getMIR2VecVocabulary(const Module &M);
+
+ Expected<mir2vec::MIRVocabulary> getMIR2VecVocabulary(const Module &M) {
+ MachineModuleInfo &MMI =
+ getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
+ if (!Provider)
+ Provider = std::make_unique<MIR2VecVocabProvider>(MMI);
+ return Provider->getVocabulary(M);
+ }
+
+ MIR2VecVocabProvider &getProvider() {
+ assert(Provider && "Provider not initialized");
+ return *Provider;
+ }
};
/// This pass prints the embeddings in the MIR2Vec vocabulary
@@ -275,4 +458,4 @@ MachineFunctionPass *createMIR2VecPrinterLegacyPass(raw_ostream &OS);
} // namespace llvm
-#endif // LLVM_CODEGEN_MIR2VEC_H \ No newline at end of file
+#endif // LLVM_CODEGEN_MIR2VEC_H
diff --git a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
new file mode 100644
index 0000000..d044d5f
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
@@ -0,0 +1,114 @@
+//===- llvm/CodeGen/MachineBlockHashInfo.h ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Compute the hashes of basic blocks.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_MACHINEBLOCKHASHINFO_H
+#define LLVM_CODEGEN_MACHINEBLOCKHASHINFO_H
+
+#include "llvm/CodeGen/MachineFunctionPass.h"
+
+namespace llvm {
+
+/// An object wrapping several components of a basic block hash. The combined
+/// (blended) hash is represented and stored as one uint64_t, while individual
+/// components are of smaller size (e.g., uint16_t or uint8_t).
+struct BlendedBlockHash {
+public:
+ explicit BlendedBlockHash(uint16_t Offset, uint16_t OpcodeHash,
+ uint16_t InstrHash, uint16_t NeighborHash)
+ : Offset(Offset), OpcodeHash(OpcodeHash), InstrHash(InstrHash),
+ NeighborHash(NeighborHash) {}
+
+ explicit BlendedBlockHash(uint64_t CombinedHash) {
+ Offset = CombinedHash & 0xffff;
+ CombinedHash >>= 16;
+ OpcodeHash = CombinedHash & 0xffff;
+ CombinedHash >>= 16;
+ InstrHash = CombinedHash & 0xffff;
+ CombinedHash >>= 16;
+ NeighborHash = CombinedHash & 0xffff;
+ }
+
+ /// Combine the blended hash into uint64_t.
+ uint64_t combine() const {
+ uint64_t Hash = 0;
+ Hash |= uint64_t(NeighborHash);
+ Hash <<= 16;
+ Hash |= uint64_t(InstrHash);
+ Hash <<= 16;
+ Hash |= uint64_t(OpcodeHash);
+ Hash <<= 16;
+ Hash |= uint64_t(Offset);
+ return Hash;
+ }
+
+ /// Compute a distance between two given blended hashes. The smaller the
+ /// distance, the more similar two blocks are. For identical basic blocks,
+ /// the distance is zero.
+ /// Since OpcodeHash is highly stable, we consider a match good only if
+ /// the OpcodeHashes are identical. Mismatched OpcodeHashes lead to low
+ /// matching accuracy, and poor matches undermine the quality of final
+ /// inference. Notably, during inference, we also consider the matching
+ /// ratio of basic blocks. For MachineFunctions with a low matching
+ /// ratio, we directly skip optimization to reduce the impact of
+ /// mismatches. This ensures even very poor profiles won’t cause negative
+ /// optimization.
+ /// In the context of matching, we consider NeighborHash to be more
+ /// important. This is especially true when accounting for inlining
+ /// scenarios, where the position of a basic block in the control
+ /// flow graph is more critical.
+ uint64_t distance(const BlendedBlockHash &BBH) const {
+ assert(OpcodeHash == BBH.OpcodeHash &&
+ "incorrect blended hash distance computation");
+ uint64_t Dist = 0;
+ // Account for NeighborHash
+ Dist += NeighborHash == BBH.NeighborHash ? 0 : 1;
+ Dist <<= 16;
+ // Account for InstrHash
+ Dist += InstrHash == BBH.InstrHash ? 0 : 1;
+ Dist <<= 16;
+ // Account for Offset
+ Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset);
+ return Dist;
+ }
+
+private:
+ /// The offset of the basic block from the function start.
+ uint16_t Offset{0};
+ /// Hash of the basic block instructions, excluding operands.
+ uint16_t OpcodeHash{0};
+ /// Hash of the basic block instructions, including opcodes and
+ /// operands.
+ uint16_t InstrHash{0};
+ /// OpcodeHash of the basic block together with OpcodeHashes of its
+ /// successors and predecessors.
+ uint16_t NeighborHash{0};
+};
+
+class MachineBlockHashInfo : public MachineFunctionPass {
+ DenseMap<const MachineBasicBlock *, uint64_t> MBBHashInfo;
+
+public:
+ static char ID;
+ MachineBlockHashInfo();
+
+ StringRef getPassName() const override { return "Basic Block Hash Compute"; }
+
+ void getAnalysisUsage(AnalysisUsage &AU) const override;
+
+ bool runOnMachineFunction(MachineFunction &F) override;
+
+ uint64_t getMBBHash(const MachineBasicBlock &MBB);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_CODEGEN_MACHINEBLOCKHASHINFO_H
diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
index cd00e5f..bea1c78 100644
--- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -42,7 +42,7 @@ public:
FunctionAnalysisManager::Invalidator &);
};
- MachineFunctionAnalysis(const TargetMachine *TM) : TM(TM) {};
+ MachineFunctionAnalysis(const TargetMachine &TM) : TM(&TM) {};
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/MachineModuleSlotTracker.h b/llvm/include/llvm/CodeGen/MachineModuleSlotTracker.h
index 770f1b3..5504896 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleSlotTracker.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleSlotTracker.h
@@ -37,7 +37,7 @@ public:
MachineModuleSlotTracker(const MachineModuleInfo &MMI,
const MachineFunction *MF,
bool ShouldInitializeAllMetadata = true);
- ~MachineModuleSlotTracker();
+ ~MachineModuleSlotTracker() override;
void collectMachineMDNodes(MachineMDNodeListType &L) const;
};
diff --git a/llvm/include/llvm/CodeGen/MachineOutliner.h b/llvm/include/llvm/CodeGen/MachineOutliner.h
index fbb958cc..66cab3d 100644
--- a/llvm/include/llvm/CodeGen/MachineOutliner.h
+++ b/llvm/include/llvm/CodeGen/MachineOutliner.h
@@ -306,7 +306,7 @@ struct GlobalOutlinedFunction : public OutlinedFunction {
}
GlobalOutlinedFunction() = delete;
- ~GlobalOutlinedFunction() = default;
+ ~GlobalOutlinedFunction() override = default;
};
} // namespace outliner
diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h
index 7fae550..9fddd47 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -69,6 +69,9 @@ LLVM_ABI MachineFunctionPass *createBasicBlockSectionsPass();
LLVM_ABI MachineFunctionPass *createBasicBlockPathCloningPass();
+/// createMachineBlockHashInfoPass - This pass computes basic block hashes.
+LLVM_ABI MachineFunctionPass *createMachineBlockHashInfoPass();
+
/// createMachineFunctionSplitterPass - This pass splits machine functions
/// using profile information.
LLVM_ABI MachineFunctionPass *createMachineFunctionSplitterPass();
diff --git a/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h b/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
index c15bc67..0af4f47 100644
--- a/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
+++ b/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
@@ -75,7 +75,7 @@ namespace llvm {
public:
ResourcePriorityQueue(SelectionDAGISel *IS);
- ~ResourcePriorityQueue();
+ ~ResourcePriorityQueue() override;
bool isBottomUp() const override { return false; }
diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h
index 201dc68..0dcf400 100644
--- a/llvm/include/llvm/CodeGen/SDPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h
@@ -559,6 +559,11 @@ m_VSelect(const T0_P &Cond, const T1_P &T, const T2_P &F) {
}
template <typename T0_P, typename T1_P, typename T2_P>
+inline auto m_SelectLike(const T0_P &Cond, const T1_P &T, const T2_P &F) {
+ return m_AnyOf(m_Select(Cond, T, F), m_VSelect(Cond, T, F));
+}
+
+template <typename T0_P, typename T1_P, typename T2_P>
inline Result_match<0, TernaryOpc_match<T0_P, T1_P, T2_P>>
m_Load(const T0_P &Ch, const T1_P &Ptr, const T2_P &Offset) {
return m_Result<0>(
diff --git a/llvm/include/llvm/CodeGen/SafeStack.h b/llvm/include/llvm/CodeGen/SafeStack.h
index e8f0d14..05ad40e 100644
--- a/llvm/include/llvm/CodeGen/SafeStack.h
+++ b/llvm/include/llvm/CodeGen/SafeStack.h
@@ -19,7 +19,7 @@ class SafeStackPass : public PassInfoMixin<SafeStackPass> {
const TargetMachine *TM;
public:
- explicit SafeStackPass(const TargetMachine *TM_) : TM(TM_) {}
+ explicit SafeStackPass(const TargetMachine &TM_) : TM(&TM_) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
index 4eacbdc..26d7080 100644
--- a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
+++ b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
@@ -18,7 +18,6 @@
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SparseMultiSet.h"
-#include "llvm/ADT/identity.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/LiveRegUnits.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
diff --git a/llvm/include/llvm/CodeGen/SelectOptimize.h b/llvm/include/llvm/CodeGen/SelectOptimize.h
index 37024a15..33f66bb 100644
--- a/llvm/include/llvm/CodeGen/SelectOptimize.h
+++ b/llvm/include/llvm/CodeGen/SelectOptimize.h
@@ -25,7 +25,7 @@ class SelectOptimizePass : public PassInfoMixin<SelectOptimizePass> {
const TargetMachine *TM;
public:
- explicit SelectOptimizePass(const TargetMachine *TM) : TM(TM) {}
+ explicit SelectOptimizePass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 69713d0..1759463 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -418,12 +418,21 @@ public:
Unpredictable = 1 << 13,
// Compare instructions which may carry the samesign flag.
SameSign = 1 << 14,
+ // ISD::PTRADD operations that remain in bounds, i.e., the left operand is
+ // an address in a memory object in which the result of the operation also
+ // lies. WARNING: Since SDAG generally uses integers instead of pointer
+ // types, a PTRADD's pointer operand is effectively the result of an
+ // implicit inttoptr cast. Therefore, when an inbounds PTRADD uses a
+ // pointer P, transformations cannot assume that P has the provenance
+ // implied by its producer as, e.g, operations between producer and PTRADD
+ // that affect the provenance may have been optimized away.
+ InBounds = 1 << 15,
// NOTE: Please update LargestValue in LLVM_DECLARE_ENUM_AS_BITMASK below
// the class definition when adding new flags.
PoisonGeneratingFlags = NoUnsignedWrap | NoSignedWrap | Exact | Disjoint |
- NonNeg | NoNaNs | NoInfs | SameSign,
+ NonNeg | NoNaNs | NoInfs | SameSign | InBounds,
FastMathFlags = NoNaNs | NoInfs | NoSignedZeros | AllowReciprocal |
AllowContract | ApproximateFuncs | AllowReassociation,
};
@@ -458,6 +467,7 @@ public:
void setAllowReassociation(bool b) { setFlag<AllowReassociation>(b); }
void setNoFPExcept(bool b) { setFlag<NoFPExcept>(b); }
void setUnpredictable(bool b) { setFlag<Unpredictable>(b); }
+ void setInBounds(bool b) { setFlag<InBounds>(b); }
// These are accessors for each flag.
bool hasNoUnsignedWrap() const { return Flags & NoUnsignedWrap; }
@@ -475,6 +485,7 @@ public:
bool hasAllowReassociation() const { return Flags & AllowReassociation; }
bool hasNoFPExcept() const { return Flags & NoFPExcept; }
bool hasUnpredictable() const { return Flags & Unpredictable; }
+ bool hasInBounds() const { return Flags & InBounds; }
bool operator==(const SDNodeFlags &Other) const {
return Flags == Other.Flags;
@@ -484,7 +495,7 @@ public:
};
LLVM_DECLARE_ENUM_AS_BITMASK(decltype(SDNodeFlags::None),
- SDNodeFlags::SameSign);
+ SDNodeFlags::InBounds);
inline SDNodeFlags operator|(SDNodeFlags LHS, SDNodeFlags RHS) {
LHS |= RHS;
diff --git a/llvm/include/llvm/CodeGen/StackProtector.h b/llvm/include/llvm/CodeGen/StackProtector.h
index dfafc78..fbe7935 100644
--- a/llvm/include/llvm/CodeGen/StackProtector.h
+++ b/llvm/include/llvm/CodeGen/StackProtector.h
@@ -86,7 +86,7 @@ class StackProtectorPass : public PassInfoMixin<StackProtectorPass> {
const TargetMachine *TM;
public:
- explicit StackProtectorPass(const TargetMachine *TM) : TM(TM) {}
+ explicit StackProtectorPass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
index 822245f..f031353 100644
--- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
@@ -280,7 +280,7 @@ protected:
unsigned Mode = 0);
public:
- virtual ~TargetRegisterInfo();
+ ~TargetRegisterInfo() override;
/// Return the number of registers for the function. (may overestimate)
virtual unsigned getNumSupportedRegs(const MachineFunction &) const {
diff --git a/llvm/include/llvm/CodeGen/TypePromotion.h b/llvm/include/llvm/CodeGen/TypePromotion.h
index efe5823..ba32a21 100644
--- a/llvm/include/llvm/CodeGen/TypePromotion.h
+++ b/llvm/include/llvm/CodeGen/TypePromotion.h
@@ -26,7 +26,7 @@ private:
const TargetMachine *TM;
public:
- TypePromotionPass(const TargetMachine *TM): TM(TM) { }
+ TypePromotionPass(const TargetMachine &TM) : TM(&TM) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
diff --git a/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h b/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h
index 112ff6d..65ff1eb 100644
--- a/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h
+++ b/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h
@@ -223,7 +223,7 @@ public:
enum { TopQID = 1, BotQID = 2, LogMaxQID = 2 };
ConvergingVLIWScheduler() : Top(TopQID, "TopQ"), Bot(BotQID, "BotQ") {}
- virtual ~ConvergingVLIWScheduler() = default;
+ ~ConvergingVLIWScheduler() override = default;
void initialize(ScheduleDAGMI *dag) override;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
index 8613ddd..f05febf 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -448,7 +448,7 @@ public:
FailedToMaterialize(std::shared_ptr<SymbolStringPool> SSP,
std::shared_ptr<SymbolDependenceMap> Symbols);
- ~FailedToMaterialize();
+ ~FailedToMaterialize() override;
std::error_code convertToErrorCode() const override;
void log(raw_ostream &OS) const override;
const SymbolDependenceMap &getSymbols() const { return *Symbols; }
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h b/llvm/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h
index 254b897..e84eb4b 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h
@@ -70,7 +70,7 @@ public:
DebugObjectManagerPlugin(ExecutionSession &ES,
std::unique_ptr<DebugObjectRegistrar> Target,
bool RequireDebugSections, bool AutoRegisterCode);
- ~DebugObjectManagerPlugin();
+ ~DebugObjectManagerPlugin() override;
void notifyMaterializing(MaterializationResponsibility &MR,
jitlink::LinkGraph &G, jitlink::JITLinkContext &Ctx,
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.h b/llvm/include/llvm/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.h
index 179fedc..f9b1d2c 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.h
@@ -32,7 +32,7 @@ public:
ExecutorAddr RegisterPerfEndAddr,
ExecutorAddr RegisterPerfImplAddr, bool EmitDebugInfo,
bool EmitUnwindInfo);
- ~PerfSupportPlugin();
+ ~PerfSupportPlugin() override;
void modifyPassConfig(MaterializationResponsibility &MR,
jitlink::LinkGraph &G,
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.h
index fa48480..031bb27 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.h
@@ -52,7 +52,7 @@ public:
EPCGenericRTDyldMemoryManager(EPCGenericRTDyldMemoryManager &&) = delete;
EPCGenericRTDyldMemoryManager &
operator=(EPCGenericRTDyldMemoryManager &&) = delete;
- ~EPCGenericRTDyldMemoryManager();
+ ~EPCGenericRTDyldMemoryManager() override;
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
unsigned SectionID,
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
index fecffc2..fa4bb9d 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
@@ -285,7 +285,7 @@ public:
/// Map type for initializing the manager. See init.
using StubInitsMap = StringMap<std::pair<ExecutorAddr, JITSymbolFlags>>;
- virtual ~IndirectStubsManager() = default;
+ ~IndirectStubsManager() override = default;
/// Create a single stub with the given name, target address and flags.
virtual Error createStub(StringRef StubName, ExecutorAddr StubAddr,
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Layer.h b/llvm/include/llvm/ExecutionEngine/Orc/Layer.h
index 8dfc12e..25df380 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Layer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Layer.h
@@ -136,7 +136,7 @@ public:
static char ID;
ObjectLayer(ExecutionSession &ES);
- virtual ~ObjectLayer();
+ ~ObjectLayer() override;
/// Returns the execution session for this layer.
ExecutionSession &getExecutionSession() { return ES; }
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LinkGraphLinkingLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/LinkGraphLinkingLayer.h
index d3643f9..2079a35 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LinkGraphLinkingLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LinkGraphLinkingLayer.h
@@ -88,7 +88,7 @@ public:
std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr);
/// Destroy the LinkGraphLinkingLayer.
- ~LinkGraphLinkingLayer();
+ ~LinkGraphLinkingLayer() override;
/// Add a plugin.
LinkGraphLinkingLayer &addPlugin(std::shared_ptr<Plugin> P) {
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h b/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
index 9c34bf1..b23093d 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
@@ -286,7 +286,6 @@ private:
// FIXME: ObjCImageInfos and HeaderAddrs need to be cleared when
// JITDylibs are removed.
DenseMap<JITDylib *, ObjCImageInfo> ObjCImageInfos;
- DenseMap<JITDylib *, ExecutorAddr> HeaderAddrs;
};
using GetJITDylibHeaderSendResultFn =
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
index 1fb472a1..8c6a8f5 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
@@ -58,7 +58,7 @@ public:
RTDyldObjectLinkingLayer(ExecutionSession &ES,
GetMemoryManagerFunction GetMemoryManager);
- ~RTDyldObjectLinkingLayer();
+ ~RTDyldObjectLinkingLayer() override;
/// Emit the object.
void emit(std::unique_ptr<MaterializationResponsibility> R,
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
index 7acb6a4..8176183 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
@@ -69,7 +69,7 @@ public:
SimpleRemoteEPC &operator=(const SimpleRemoteEPC &) = delete;
SimpleRemoteEPC(SimpleRemoteEPC &&) = delete;
SimpleRemoteEPC &operator=(SimpleRemoteEPC &&) = delete;
- ~SimpleRemoteEPC();
+ ~SimpleRemoteEPC() override;
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) override;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h
index 85c2d65..2c385de 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h
@@ -29,7 +29,7 @@ namespace rt_bootstrap {
class LLVM_ABI ExecutorSharedMemoryMapperService final
: public ExecutorBootstrapService {
public:
- ~ExecutorSharedMemoryMapperService(){};
+ ~ExecutorSharedMemoryMapperService() override {};
Expected<std::pair<ExecutorAddr, std::string>> reserve(uint64_t Size);
Expected<ExecutorAddr> initialize(ExecutorAddr Reservation,
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorDylibManager.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorDylibManager.h
index 7526a29d..7ca2ff2 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorDylibManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorDylibManager.h
@@ -37,7 +37,7 @@ namespace rt_bootstrap {
/// Simple page-based allocator.
class LLVM_ABI SimpleExecutorDylibManager : public ExecutorBootstrapService {
public:
- virtual ~SimpleExecutorDylibManager();
+ ~SimpleExecutorDylibManager() override;
Expected<tpctypes::DylibHandle> open(const std::string &Path, uint64_t Mode);
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h
index 6224e92..45256ec 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h
@@ -32,7 +32,7 @@ namespace rt_bootstrap {
/// Simple page-based allocator.
class LLVM_ABI SimpleExecutorMemoryManager : public ExecutorBootstrapService {
public:
- virtual ~SimpleExecutorMemoryManager();
+ ~SimpleExecutorMemoryManager() override;
Expected<ExecutorAddr> reserve(uint64_t Size);
Expected<ExecutorAddr> initialize(tpctypes::FinalizeRequest &FR);
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TaskDispatch.h b/llvm/include/llvm/ExecutionEngine/Orc/TaskDispatch.h
index 9cf6e00..b73da19 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TaskDispatch.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TaskDispatch.h
@@ -37,7 +37,7 @@ class LLVM_ABI Task : public RTTIExtends<Task, RTTIRoot> {
public:
static char ID;
- virtual ~Task() = default;
+ ~Task() override = default;
/// Description of the task to be performed. Used for logging.
virtual void printDescription(raw_ostream &OS) = 0;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h b/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
index 45834f1..d8506ce 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/WaitingOnGraph.h
@@ -186,9 +186,7 @@ private:
SmallVector<ElementId> SortedElems(ContainerElems.begin(),
ContainerElems.end());
llvm::sort(SortedElems);
- Hash = hash_combine(
- Hash, Container,
- hash_combine_range(SortedElems.begin(), SortedElems.end()));
+ Hash = hash_combine(Hash, Container, hash_combine_range(SortedElems));
}
return Hash;
}
diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td
index 8e7d9dc..8ce2b1b 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -410,7 +410,6 @@ def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
def NoSignedZerosFPMath : StrBoolAttr<"no-signed-zeros-fp-math">;
-def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
def NoJumpTables : StrBoolAttr<"no-jump-tables">;
def NoInlineLineTables : StrBoolAttr<"no-inline-line-tables">;
def ProfileSampleAccurate : StrBoolAttr<"profile-sample-accurate">;
@@ -474,7 +473,6 @@ def : MergeRule<"setAND<LessPreciseFPMADAttr>">;
def : MergeRule<"setAND<NoInfsFPMathAttr>">;
def : MergeRule<"setAND<NoNansFPMathAttr>">;
def : MergeRule<"setAND<NoSignedZerosFPMathAttr>">;
-def : MergeRule<"setAND<UnsafeFPMathAttr>">;
def : MergeRule<"setOR<NoImplicitFloatAttr>">;
def : MergeRule<"setOR<NoJumpTablesAttr>">;
def : MergeRule<"setOR<ProfileSampleAccurateAttr>">;
diff --git a/llvm/include/llvm/IR/AutoUpgrade.h b/llvm/include/llvm/IR/AutoUpgrade.h
index 31096e8..540d60a 100644
--- a/llvm/include/llvm/IR/AutoUpgrade.h
+++ b/llvm/include/llvm/IR/AutoUpgrade.h
@@ -96,6 +96,16 @@ namespace llvm {
/// info. Return true if module is modified.
LLVM_ABI bool UpgradeDebugInfo(Module &M);
+ /// Copies module attributes to the functions in the module.
+ /// Currently only effects ARM, Thumb and AArch64 targets.
+ /// Supported attributes:
+ /// - branch-target-enforcement
+ /// - branch-protection-pauth-lr
+ /// - guarded-control-stack
+ /// - sign-return-address
+ /// - sign-return-address-with-bkey
+ void copyModuleAttrToFunctions(Module &M);
+
/// Check whether a string looks like an old loop attachment tag.
inline bool mayBeOldLoopAttachmentTag(StringRef Name) {
return Name.starts_with("llvm.vectorizer.");
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index e6cce9a4..4d59ee8 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1487,24 +1487,23 @@ def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>;
//
def int_var_annotation : DefaultAttrsIntrinsic<
[], [llvm_anyptr_ty, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
- [IntrInaccessibleMemOnly], "llvm.var.annotation">;
+ [IntrInaccessibleMemOnly]>;
def int_ptr_annotation : DefaultAttrsIntrinsic<
[llvm_anyptr_ty],
[LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
- [IntrInaccessibleMemOnly], "llvm.ptr.annotation">;
+ [IntrInaccessibleMemOnly]>;
def int_annotation : DefaultAttrsIntrinsic<
[llvm_anyint_ty],
[LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty],
- [IntrInaccessibleMemOnly], "llvm.annotation">;
+ [IntrInaccessibleMemOnly]>;
// Annotates the current program point with metadata strings which are emitted
// as CodeView debug info records. This is expensive, as it disables inlining
// and is modelled as having side effects.
def int_codeview_annotation : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
- [IntrInaccessibleMemOnly, IntrNoDuplicate],
- "llvm.codeview.annotation">;
+ [IntrInaccessibleMemOnly, IntrNoDuplicate]>;
//===------------------------ Trampoline Intrinsics -----------------------===//
//
@@ -1881,8 +1880,7 @@ def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
// Intrinsic to detect whether its argument is a constant.
def int_is_constant : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty],
- [IntrNoMem, IntrConvergent],
- "llvm.is.constant">;
+ [IntrNoMem, IntrConvergent]>;
// Introduce a use of the argument without generating any code.
def int_fake_use : DefaultAttrsIntrinsic<[], [llvm_vararg_ty],
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 9e334d4..8e35109 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -3789,6 +3789,20 @@ def int_amdgcn_perm_pk16_b8_u4 : ClangBuiltin<"__builtin_amdgcn_perm_pk16_b8_u4"
DefaultAttrsIntrinsic<[llvm_v4i32_ty], [llvm_i64_ty, llvm_i64_ty, llvm_v2i32_ty],
[IntrNoMem, IntrSpeculatable]>;
+class AMDGPUAddMinMax<LLVMType Ty, string Name> : ClangBuiltin<"__builtin_amdgcn_"#Name>,
+ DefaultAttrsIntrinsic<[Ty], [Ty, Ty, Ty, llvm_i1_ty /* clamp */],
+ [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<3>>]>;
+
+def int_amdgcn_add_max_i32 : AMDGPUAddMinMax<llvm_i32_ty, "add_max_i32">;
+def int_amdgcn_add_max_u32 : AMDGPUAddMinMax<llvm_i32_ty, "add_max_u32">;
+def int_amdgcn_add_min_i32 : AMDGPUAddMinMax<llvm_i32_ty, "add_min_i32">;
+def int_amdgcn_add_min_u32 : AMDGPUAddMinMax<llvm_i32_ty, "add_min_u32">;
+
+def int_amdgcn_pk_add_max_i16 : AMDGPUAddMinMax<llvm_v2i16_ty, "pk_add_max_i16">;
+def int_amdgcn_pk_add_max_u16 : AMDGPUAddMinMax<llvm_v2i16_ty, "pk_add_max_u16">;
+def int_amdgcn_pk_add_min_i16 : AMDGPUAddMinMax<llvm_v2i16_ty, "pk_add_min_i16">;
+def int_amdgcn_pk_add_min_u16 : AMDGPUAddMinMax<llvm_v2i16_ty, "pk_add_min_u16">;
+
class AMDGPUCooperativeAtomicStore<LLVMType Ty> : Intrinsic <
[],
[llvm_anyptr_ty, // pointer to store to
diff --git a/llvm/include/llvm/IR/IntrinsicsNVVM.td b/llvm/include/llvm/IR/IntrinsicsNVVM.td
index 3af1750..c9df6c4 100644
--- a/llvm/include/llvm/IR/IntrinsicsNVVM.td
+++ b/llvm/include/llvm/IR/IntrinsicsNVVM.td
@@ -456,7 +456,7 @@ class WMMA_REGS<string Geom, string Frag, string PtxEltType, bit IsSparse = fals
}
class WMMA_NAME_LDST<string Op, WMMA_REGS Frag, string Layout, int WithStride> {
- string intr = "llvm.nvvm.wmma."
+ string intr_name = "llvm.nvvm.wmma."
# Frag.geom
# "." # Op
# "." # Frag.frag
@@ -467,7 +467,7 @@ class WMMA_NAME_LDST<string Op, WMMA_REGS Frag, string Layout, int WithStride> {
// TODO(tra): record name should ideally use the same field order as the intrinsic.
// E.g. string record = !subst("llvm", "int",
// !subst(".", "_", llvm));
- string record = "int_nvvm_wmma_"
+ string record_name = "int_nvvm_wmma_"
# Frag.geom
# "_" # Op
# "_" # Frag.frag
@@ -496,7 +496,7 @@ class MMA_SIGNATURE<WMMA_REGS A, WMMA_REGS B, WMMA_REGS C, WMMA_REGS D> {
class WMMA_NAME<string ALayout, string BLayout, int Satfinite, string Rnd, string b1op,
WMMA_REGS A, WMMA_REGS B, WMMA_REGS C, WMMA_REGS D> {
string signature = MMA_SIGNATURE<A, B, C, D>.ret;
- string record = "int_nvvm_wmma_"
+ string record_name = "int_nvvm_wmma_"
# A.geom
# "_mma"
# !subst(".", "_", b1op)
@@ -510,7 +510,7 @@ class WMMA_NAME<string ALayout, string BLayout, int Satfinite, string Rnd, strin
class MMA_NAME<string ALayout, string BLayout, int Satfinite, string b1op, string Kind,
WMMA_REGS A, WMMA_REGS B, WMMA_REGS C, WMMA_REGS D> {
string signature = MMA_SIGNATURE<A, B, C, D>.ret;
- string record = "int_nvvm_mma"
+ string record_name = "int_nvvm_mma"
# !subst(".", "_", b1op)
# "_" # A.geom
# "_" # ALayout
@@ -524,7 +524,7 @@ class MMA_SP_NAME<string Metadata, string Kind, int Satfinite,
WMMA_REGS A, WMMA_REGS B,
WMMA_REGS C, WMMA_REGS D> {
string signature = MMA_SIGNATURE<A, B, C, D>.ret;
- string record = "int_nvvm_mma"
+ string record_name = "int_nvvm_mma"
# "_" # !subst("::", "_", Metadata)
# "_" # A.geom
# "_row_col"
@@ -533,26 +533,37 @@ class MMA_SP_NAME<string Metadata, string Kind, int Satfinite,
# signature;
}
+// Helper class that takes an intrinsic name and construct a record name.
+// Additionally, sets `intr_name` to be non-empty if the default name assigned
+// to this intrinsic will not match the name given.
+class IntrinsicName<string name> {
+ string record_name = !subst(".", "_",
+ !subst("llvm.", "int_", name));
+ // Use explicit intrinsic name if it has an _ in it, else rely on LLVM
+ // assigned default name.
+ string intr_name = !if(!ne(!find(name, "_"), -1), name, "");
+}
+
class LDMATRIX_NAME<WMMA_REGS Frag, int Trans> {
- string intr = "llvm.nvvm.ldmatrix.sync.aligned"
+ defvar name = "llvm.nvvm.ldmatrix.sync.aligned"
# "." # Frag.geom
# "." # Frag.frag
# !if(Trans, ".trans", "")
# "." # Frag.ptx_elt_type
;
- string record = !subst(".", "_",
- !subst("llvm.", "int_", intr));
+ string intr_name = IntrinsicName<name>.intr_name;
+ string record_name = IntrinsicName<name>.record_name;
}
class STMATRIX_NAME<WMMA_REGS Frag, int Trans> {
- string intr = "llvm.nvvm.stmatrix.sync.aligned"
+ defvar name = "llvm.nvvm.stmatrix.sync.aligned"
# "." # Frag.geom
# "." # Frag.frag
# !if(Trans, ".trans", "")
# "." # Frag.ptx_elt_type
;
- string record = !subst(".", "_",
- !subst("llvm.", "int_", intr));
+ string intr_name = IntrinsicName<name>.intr_name;
+ string record_name = IntrinsicName<name>.record_name;
}
// Generates list of 4-tuples of WMMA_REGS representing a valid MMA op.
@@ -1042,45 +1053,49 @@ class NVVM_TCGEN05_MMA_BASE<string Space, bit Sp> {
class NVVM_TCGEN05_MMA<bit Sp, string Space,
bit AShift, bit ScaleInputD>:
NVVM_TCGEN05_MMA_BASE<Space, Sp> {
- string intr = "llvm.nvvm.tcgen05.mma"
+ string name = "llvm.nvvm.tcgen05.mma"
# !if(!eq(Sp, 1), ".sp", "")
# "." # Space
# !if(!eq(ScaleInputD, 1), ".scale_d", "")
# !if(!eq(AShift, 1), ".ashift", "");
- string record = !subst(".", "_", !subst("llvm.", "int_", intr));
+ string intr_name = IntrinsicName<name>.intr_name;
+ string record_name = IntrinsicName<name>.record_name;
}
class NVVM_TCGEN05_MMA_BLOCKSCALE<bit Sp, string Space,
string Kind, string ScaleVecSize>:
NVVM_TCGEN05_MMA_BASE<Space, Sp> {
- string intr = "llvm.nvvm.tcgen05.mma"
+ string name = "llvm.nvvm.tcgen05.mma"
# !if(!eq(Sp, 1), ".sp", "")
# "." # Space
# "." # Kind
# ".block_scale" # ScaleVecSize;
- string record = !subst(".", "_", !subst("llvm.", "int_", intr));
+ string intr_name = IntrinsicName<name>.intr_name;
+ string record_name = IntrinsicName<name>.record_name;
}
class NVVM_TCGEN05_MMA_WS<bit Sp, string Space, bit ZeroColMask>:
NVVM_TCGEN05_MMA_BASE<Space, Sp> {
- string intr = "llvm.nvvm.tcgen05.mma.ws"
+ string name = "llvm.nvvm.tcgen05.mma.ws"
# !if(!eq(Sp, 1), ".sp", "")
# "." # Space
# !if(!eq(ZeroColMask, 1), ".zero_col_mask", "");
- string record = !subst(".", "_", !subst("llvm.", "int_", intr));
+ string intr_name = IntrinsicName<name>.intr_name;
+ string record_name = IntrinsicName<name>.record_name;
}
class NVVM_TCGEN05_MMA_DISABLE_OUTPUT_LANE<bit Sp, string Space,
int CtaGroup, bit AShift,
bit ScaleInputD>:
NVVM_TCGEN05_MMA_BASE<Space, Sp> {
- string intr = "llvm.nvvm.tcgen05.mma"
+ string name = "llvm.nvvm.tcgen05.mma"
# !if(!eq(Sp, 1), ".sp", "")
# "." # Space
# !if(!eq(ScaleInputD, 1), ".scale_d", "")
# ".disable_output_lane.cg" # CtaGroup
# !if(!eq(AShift, 1), ".ashift", "");
- string record = !subst(".", "_", !subst("llvm.", "int_", intr));
+ string intr_name = IntrinsicName<name>.intr_name;
+ string record_name = IntrinsicName<name>.record_name;
}
class NVVM_TCGEN05_MMA_BLOCKSCALE_SUPPORTED<string Kind, string ScaleVecSize> {
@@ -2273,7 +2288,7 @@ class NVVM_WMMA_LD<WMMA_REGS Frag, string Layout, int WithStride>
: Intrinsic<Frag.regs,
!if(WithStride, [llvm_anyptr_ty, llvm_i32_ty], [llvm_anyptr_ty]),
[IntrWillReturn, IntrReadMem, IntrArgMemOnly, IntrNoCallback, ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>],
- WMMA_NAME_LDST<"load", Frag, Layout, WithStride>.intr>;
+ WMMA_NAME_LDST<"load", Frag, Layout, WithStride>.intr_name>;
// WMMA.STORE.D
class NVVM_WMMA_ST<WMMA_REGS Frag, string Layout, int WithStride>
@@ -2283,18 +2298,18 @@ class NVVM_WMMA_ST<WMMA_REGS Frag, string Layout, int WithStride>
Frag.regs,
!if(WithStride, [llvm_i32_ty], [])),
[IntrWriteMem, IntrArgMemOnly, IntrNoCallback, WriteOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>],
- WMMA_NAME_LDST<"store", Frag, Layout, WithStride>.intr>;
+ WMMA_NAME_LDST<"store", Frag, Layout, WithStride>.intr_name>;
// Create all load/store variants
foreach layout = ["row", "col"] in {
foreach stride = [0, 1] in {
foreach frag = NVVM_MMA_OPS.all_ld_ops in
if NVVM_WMMA_LDST_SUPPORTED<frag, layout>.ret then
- def WMMA_NAME_LDST<"load", frag, layout, stride>.record
+ def WMMA_NAME_LDST<"load", frag, layout, stride>.record_name
: NVVM_WMMA_LD<frag, layout, stride>;
foreach frag = NVVM_MMA_OPS.all_st_ops in
if NVVM_WMMA_LDST_SUPPORTED<frag, layout>.ret then
- def WMMA_NAME_LDST<"store", frag, layout, stride>.record
+ def WMMA_NAME_LDST<"store", frag, layout, stride>.record_name
: NVVM_WMMA_ST<frag, layout, stride>;
}
}
@@ -2313,7 +2328,7 @@ foreach layout_a = ["row", "col"] in {
foreach b1op = NVVM_MMA_B1OPS<op>.ret in {
if NVVM_WMMA_SUPPORTED<op, layout_a, layout_b, satf, rnd>.ret then {
def WMMA_NAME<layout_a, layout_b, satf, rnd, b1op,
- op[0], op[1], op[2], op[3]>.record
+ op[0], op[1], op[2], op[3]>.record_name
: NVVM_MMA<op[0], op[1], op[2], op[3]>;
}
} // b1op
@@ -2330,7 +2345,7 @@ foreach layout_a = ["row", "col"] in {
foreach b1op = NVVM_MMA_B1OPS<op>.ret in {
foreach kind = ["", "kind::f8f6f4"] in {
if NVVM_MMA_SUPPORTED<op, layout_a, layout_b, kind, satf>.ret then {
- def MMA_NAME<layout_a, layout_b, satf, b1op, kind, op[0], op[1], op[2], op[3]>.record
+ def MMA_NAME<layout_a, layout_b, satf, b1op, kind, op[0], op[1], op[2], op[3]>.record_name
: NVVM_MMA<op[0], op[1], op[2], op[3]>;
}
} // kind
@@ -2379,7 +2394,7 @@ foreach metadata = ["sp", "sp::ordered_metadata"] in {
foreach op = NVVM_MMA_OPS.all_mma_sp_ops in {
if NVVM_MMA_SP_SUPPORTED<op, metadata, kind, satf>.ret then {
def MMA_SP_NAME<metadata, kind, satf,
- op[0], op[1], op[2], op[3]>.record
+ op[0], op[1], op[2], op[3]>.record_name
: NVVM_MMA_SP<op[0], op[1], op[2], op[3]>;
}
} // op
@@ -2392,12 +2407,12 @@ class NVVM_LDMATRIX<WMMA_REGS Frag, int Transposed>
: Intrinsic<Frag.regs, [llvm_anyptr_ty],
[IntrReadMem, IntrArgMemOnly, IntrNoCallback, ReadOnly<ArgIndex<0>>,
NoCapture<ArgIndex<0>>],
- LDMATRIX_NAME<Frag, Transposed>.intr>;
+ LDMATRIX_NAME<Frag, Transposed>.intr_name>;
foreach transposed = [0, 1] in {
foreach frag = NVVM_MMA_OPS.all_ldmatrix_ops in {
if NVVM_LDMATRIX_SUPPORTED<frag, transposed>.ret then {
- def LDMATRIX_NAME<frag, transposed>.record
+ def LDMATRIX_NAME<frag, transposed>.record_name
: NVVM_LDMATRIX<frag, transposed>;
}
}
@@ -2409,12 +2424,12 @@ class NVVM_STMATRIX<WMMA_REGS Frag, int Transposed>
!listconcat([llvm_anyptr_ty], Frag.regs),
[IntrWriteMem, IntrArgMemOnly, IntrNoCallback,
WriteOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>],
- STMATRIX_NAME<Frag, Transposed>.intr>;
+ STMATRIX_NAME<Frag, Transposed>.intr_name>;
foreach transposed = [0, 1] in {
foreach frag = NVVM_MMA_OPS.all_stmatrix_ops in {
if NVVM_STMATRIX_SUPPORTED<frag, transposed>.ret then {
- def STMATRIX_NAME<frag, transposed>.record
+ def STMATRIX_NAME<frag, transposed>.record_name
: NVVM_STMATRIX<frag, transposed>;
}
}
@@ -2767,14 +2782,15 @@ foreach cta_group = ["cg1", "cg2"] in {
"64x128b_warpx2_02_13",
"64x128b_warpx2_01_23",
"32x128b_warpx4"] in {
- defvar intr_suffix = StrJoin<"_", [shape, src_fmt, cta_group]>.ret;
- defvar name_suffix = StrJoin<".", [shape, src_fmt, cta_group]>.ret;
+ defvar name = "llvm.nvvm.tcgen05.cp." #
+ StrJoin<".", [shape, src_fmt, cta_group]>.ret;
- def int_nvvm_tcgen05_cp_ # intr_suffix : Intrinsic<[],
+ defvar intrinsic_name = IntrinsicName<name>;
+ def intrinsic_name.record_name : Intrinsic<[],
[llvm_tmem_ptr_ty, // tmem_addr
llvm_i64_ty], // smem descriptor
[IntrConvergent, IntrInaccessibleMemOrArgMemOnly, NoCapture<ArgIndex<0>>],
- "llvm.nvvm.tcgen05.cp." # name_suffix>;
+ intrinsic_name.intr_name>;
}
}
}
@@ -2881,9 +2897,9 @@ foreach sp = [0, 1] in {
]
);
- def mma.record:
+ def mma.record_name:
DefaultAttrsIntrinsicFlags<[], args, flags, intrinsic_properties,
- mma.intr>;
+ mma.intr_name>;
}
}
}
@@ -2918,8 +2934,8 @@ foreach sp = [0, 1] in {
Range<ArgIndex<!add(nargs, 1)>, 0, !if(!eq(ashift, 1), 2, 4)>]
);
- def mma.record: DefaultAttrsIntrinsicFlags<[], args, flags, intrinsic_properties,
- mma.intr>;
+ def mma.record_name : DefaultAttrsIntrinsicFlags<[], args, flags,
+ intrinsic_properties, mma.intr_name>;
} // ashift
} // scale_d
} // cta_group
@@ -2944,11 +2960,11 @@ foreach sp = [0, 1] in {
defvar collector_usage = ArgIndex<!add(nargs, 1)>;
if NVVM_TCGEN05_MMA_BLOCKSCALE_SUPPORTED<kind, scale_vec_size>.ret then {
- def mma.record: DefaultAttrsIntrinsicFlags<[], args, flags,
+ def mma.record_name : DefaultAttrsIntrinsicFlags<[], args, flags,
!listconcat(mma.common_intr_props,
[Range<cta_group, 1, 3>,
Range<collector_usage, 0, 4>]),
- mma.intr>;
+ mma.intr_name>;
}
}
}
@@ -2977,9 +2993,9 @@ foreach sp = [0, 1] in {
Range<ArgIndex<!add(nargs, 2)>, 0, 4>]
);
- def mma.record:
+ def mma.record_name:
DefaultAttrsIntrinsicFlags<[], args, flags, intrinsic_properties,
- mma.intr>;
+ mma.intr_name>;
}
}
}
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 0062cec..eb60bee 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -172,9 +172,13 @@ struct alignas(8) GlobalValueSummaryInfo {
/// Add a summary corresponding to a global value definition in a module with
/// the corresponding GUID.
- void addSummary(std::unique_ptr<GlobalValueSummary> Summary) {
- return SummaryList.push_back(std::move(Summary));
- }
+ inline void addSummary(std::unique_ptr<GlobalValueSummary> Summary);
+
+ /// Verify that the HasLocal flag is consistent with the SummaryList. Should
+ /// only be called prior to index-based internalization and promotion.
+ inline void verifyLocal() const;
+
+ bool hasLocal() const { return HasLocal; }
private:
/// List of global value summary structures for a particular value held
@@ -183,6 +187,22 @@ private:
/// compiling without sufficient distinguishing path, or (theoretically) hash
/// collisions. Each summary is from a different module.
GlobalValueSummaryList SummaryList;
+
+ /// True if the SummaryList contains at least one summary with local linkage.
+ /// In most cases there should be only one, unless translation units with
+ /// same-named locals were compiled without distinguishing path. And generally
+ /// there should not be a mix of local and non-local summaries, because the
+ /// GUID for a local is computed with the path prepended and a ';' delimiter.
+ /// In extremely rare cases there could be a GUID hash collision. Having the
+ /// flag saves having to walk through all summaries to prove the existence or
+ /// not of any locals.
+ /// NOTE: this flag is set when the index is built. It does not reflect
+ /// index-based internalization and promotion decisions. Generally most
+ /// index-based analysis occurs before then, but any users should assert that
+ /// the withInternalizeAndPromote() flag is not set on the index.
+ /// TODO: Replace checks in various ThinLTO analyses that loop through all
+ /// summaries to handle the local case with a check of the flag.
+ bool HasLocal : 1;
};
/// Map from global value GUID to corresponding summary structures. Use a
@@ -219,6 +239,10 @@ struct ValueInfo {
return getRef()->second.getSummaryList();
}
+ void verifyLocal() const { getRef()->second.verifyLocal(); }
+
+ bool hasLocal() const { return getRef()->second.hasLocal(); }
+
// Even if the index is built with GVs available, we may not have one for
// summary entries synthesized for profiled indirect call targets.
bool hasName() const { return !haveGVs() || getValue(); }
@@ -649,7 +673,23 @@ public:
friend class ModuleSummaryIndex;
};
-GlobalValueSummaryInfo::GlobalValueSummaryInfo(bool HaveGVs) : U(HaveGVs) {}
+GlobalValueSummaryInfo::GlobalValueSummaryInfo(bool HaveGVs)
+ : U(HaveGVs), HasLocal(false) {}
+
+void GlobalValueSummaryInfo::addSummary(
+ std::unique_ptr<GlobalValueSummary> Summary) {
+ if (GlobalValue::isLocalLinkage(Summary->linkage()))
+ HasLocal = true;
+ return SummaryList.push_back(std::move(Summary));
+}
+
+void GlobalValueSummaryInfo::verifyLocal() const {
+ assert(HasLocal ==
+ llvm::any_of(SummaryList,
+ [](const std::unique_ptr<GlobalValueSummary> &Summary) {
+ return GlobalValue::isLocalLinkage(Summary->linkage());
+ }));
+}
/// Alias summary information.
class AliasSummary : public GlobalValueSummary {
@@ -1449,6 +1489,9 @@ private:
/// every summary of a GV is synchronized.
bool WithDSOLocalPropagation = false;
+ /// Indicates that summary-based internalization and promotion has run.
+ bool WithInternalizeAndPromote = false;
+
/// Indicates that we have whole program visibility.
bool WithWholeProgramVisibility = false;
@@ -1653,6 +1696,9 @@ public:
bool withDSOLocalPropagation() const { return WithDSOLocalPropagation; }
void setWithDSOLocalPropagation() { WithDSOLocalPropagation = true; }
+ bool withInternalizeAndPromote() const { return WithInternalizeAndPromote; }
+ void setWithInternalizeAndPromote() { WithInternalizeAndPromote = true; }
+
bool withWholeProgramVisibility() const { return WithWholeProgramVisibility; }
void setWithWholeProgramVisibility() { WithWholeProgramVisibility = true; }
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index a8b647c..3dc9055 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -2117,7 +2117,9 @@ defvar MSP430DefaultOptOut = [
__fixdfdi, __fixunsdfsi, __modsi3, __floatunsisf,
__fixunsdfdi, __ltsf2, __floatdisf, __floatdidf,
__lshrsi3, __subsf3, __umodhi3, __floatunsidf,
- __floatundidf
+ __floatundidf, __gtdf2, __eqdf2, __gedf2, __ltdf2, __ledf2,
+ __adddf3, __divdf3, __divdi3, __moddi3,
+ __muldf3, __subdf3, __udivdi3, __umoddi3
];
// EABI Libcalls - EABI Section 6.2
diff --git a/llvm/include/llvm/IRReader/IRReader.h b/llvm/include/llvm/IRReader/IRReader.h
index 790140f..00cf12d 100644
--- a/llvm/include/llvm/IRReader/IRReader.h
+++ b/llvm/include/llvm/IRReader/IRReader.h
@@ -15,6 +15,7 @@
#define LLVM_IRREADER_IRREADER_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/AsmParser/AsmParserContext.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Support/Compiler.h"
#include <memory>
@@ -50,19 +51,19 @@ getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
/// for it. Otherwise, attempt to parse it as LLVM Assembly and return
/// a Module for it.
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
-LLVM_ABI std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer,
- SMDiagnostic &Err,
- LLVMContext &Context,
- ParserCallbacks Callbacks = {});
+LLVM_ABI std::unique_ptr<Module>
+parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, LLVMContext &Context,
+ ParserCallbacks Callbacks = {},
+ AsmParserContext *ParserContext = nullptr);
/// If the given file holds a bitcode image, return a Module for it.
/// Otherwise, attempt to parse it as LLVM Assembly and return a Module
/// for it.
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
-LLVM_ABI std::unique_ptr<Module> parseIRFile(StringRef Filename,
- SMDiagnostic &Err,
- LLVMContext &Context,
- ParserCallbacks Callbacks = {});
+LLVM_ABI std::unique_ptr<Module>
+parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
+ ParserCallbacks Callbacks = {},
+ AsmParserContext *ParserContext = nullptr);
}
#endif
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index d507ba2..581b4ad 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -62,6 +62,7 @@ LLVM_ABI void initializeBasicBlockSectionsPass(PassRegistry &);
LLVM_ABI void initializeBarrierNoopPass(PassRegistry &);
LLVM_ABI void initializeBasicAAWrapperPassPass(PassRegistry &);
LLVM_ABI void initializeBlockFrequencyInfoWrapperPassPass(PassRegistry &);
+LLVM_ABI void initializeMachineBlockHashInfoPass(PassRegistry &);
LLVM_ABI void initializeBranchFolderLegacyPass(PassRegistry &);
LLVM_ABI void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry &);
LLVM_ABI void initializeBranchRelaxationLegacyPass(PassRegistry &);
diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h
index 000472f..a837cdd 100644
--- a/llvm/include/llvm/LTO/LTO.h
+++ b/llvm/include/llvm/LTO/LTO.h
@@ -317,6 +317,8 @@ LLVM_ABI ThinBackend createInProcessThinBackend(
/// distributor.
/// RemoteCompiler specifies the path to a Clang executable to be invoked for
/// the backend jobs.
+/// RemoteCompilerPrependArgs specifies a list of prepend arguments to be
+/// applied to the backend compilations.
/// RemoteCompilerArgs specifies a list of arguments to be applied to the
/// backend compilations.
/// SaveTemps is a debugging tool that prevents temporary files created by this
@@ -326,6 +328,7 @@ LLVM_ABI ThinBackend createOutOfProcessThinBackend(
bool ShouldEmitIndexFiles, bool ShouldEmitImportsFiles,
StringRef LinkerOutputFile, StringRef Distributor,
ArrayRef<StringRef> DistributorArgs, StringRef RemoteCompiler,
+ ArrayRef<StringRef> RemoteCompilerPrependArgs,
ArrayRef<StringRef> RemoteCompilerArgs, bool SaveTemps);
/// This ThinBackend writes individual module indexes to files, instead of
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index 4a528ee..74abe34 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -175,7 +175,7 @@ private:
unsigned GetInstance(unsigned LocalLabelVal);
/// SHT_LLVM_BB_ADDR_MAP version to emit.
- uint8_t BBAddrMapVersion = 3;
+ uint8_t BBAddrMapVersion = 4;
/// The file name of the log file from the environment variable
/// AS_SECURE_LOG_FILE. Which must be set before the .secure_log_unique
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 6a235c0..2f207925 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -736,8 +736,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPasses(
addPass(LowerEmuTLSPass());
addPass(PreISelIntrinsicLoweringPass(&TM));
- addPass(ExpandLargeDivRemPass(&TM));
- addPass(ExpandFpPass(&TM, getOptLevel()));
+ addPass(ExpandLargeDivRemPass(TM));
+ addPass(ExpandFpPass(TM, getOptLevel()));
derived().addIRPasses(addPass);
derived().addCodeGenPrepare(addPass);
@@ -773,7 +773,7 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(
// target lowering hook.
if (!Opt.DisableMergeICmps)
addPass(MergeICmpsPass());
- addPass(ExpandMemCmpPass(&TM));
+ addPass(ExpandMemCmpPass(TM));
}
// Run GC lowering passes for builtin collectors
@@ -812,7 +812,7 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(
// Convert conditional moves to conditional jumps when profitable.
if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
- addPass(SelectOptimizePass(&TM));
+ addPass(SelectOptimizePass(TM));
if (Opt.EnableGlobalMergeFunc)
addPass(GlobalMergeFuncPass());
@@ -839,14 +839,14 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addPassesToHandleExceptions(
case ExceptionHandling::ARM:
case ExceptionHandling::AIX:
case ExceptionHandling::ZOS:
- addPass(DwarfEHPreparePass(&TM));
+ addPass(DwarfEHPreparePass(TM));
break;
case ExceptionHandling::WinEH:
// We support using both GCC-style and MSVC-style exceptions on Windows, so
// add both preparation passes. Each pass will only actually run if it
// recognizes the personality function.
addPass(WinEHPreparePass());
- addPass(DwarfEHPreparePass(&TM));
+ addPass(DwarfEHPreparePass(TM));
break;
case ExceptionHandling::Wasm:
// Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
@@ -871,7 +871,7 @@ template <typename Derived, typename TargetMachineT>
void CodeGenPassBuilder<Derived, TargetMachineT>::addCodeGenPrepare(
AddIRPass &addPass) const {
if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
- addPass(CodeGenPreparePass(&TM));
+ addPass(CodeGenPreparePass(TM));
// TODO: Default ctor'd RewriteSymbolPass is no-op.
// addPass(RewriteSymbolPass());
}
@@ -892,8 +892,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare(
addPass(CallBrPreparePass());
// Add both the safe stack and the stack protection passes: each of them will
// only protect functions that have corresponding attributes.
- addPass(SafeStackPass(&TM));
- addPass(StackProtectorPass(&TM));
+ addPass(SafeStackPass(TM));
+ addPass(StackProtectorPass(TM));
if (Opt.PrintISelInput)
addPass(PrintFunctionPass(dbgs(),
diff --git a/llvm/include/llvm/Support/AllocToken.h b/llvm/include/llvm/Support/AllocToken.h
new file mode 100644
index 0000000..e40d816
--- /dev/null
+++ b/llvm/include/llvm/Support/AllocToken.h
@@ -0,0 +1,68 @@
+//===- llvm/Support/AllocToken.h - Allocation Token Calculation -----*- C++ -*//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Definition of AllocToken modes and shared calculation of stateless token IDs.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_ALLOCTOKEN_H
+#define LLVM_SUPPORT_ALLOCTOKEN_H
+
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include <cstdint>
+#include <optional>
+
+namespace llvm {
+
+/// Modes for generating allocation token IDs.
+enum class AllocTokenMode {
+ /// Incrementally increasing token ID.
+ Increment,
+
+ /// Simple mode that returns a statically-assigned random token ID.
+ Random,
+
+ /// Token ID based on allocated type hash.
+ TypeHash,
+
+ /// Token ID based on allocated type hash, where the top half ID-space is
+ /// reserved for types that contain pointers and the bottom half for types
+ /// that do not contain pointers.
+ TypeHashPointerSplit,
+};
+
+/// The default allocation token mode.
+inline constexpr AllocTokenMode DefaultAllocTokenMode =
+ AllocTokenMode::TypeHashPointerSplit;
+
+/// Returns the AllocTokenMode from its canonical string name; if an invalid
+/// name was provided returns nullopt.
+LLVM_ABI std::optional<AllocTokenMode>
+getAllocTokenModeFromString(StringRef Name);
+
+/// Metadata about an allocation used to generate a token ID.
+struct AllocTokenMetadata {
+ SmallString<64> TypeName;
+ bool ContainsPointer;
+};
+
+/// Calculates stable allocation token ID. Returns std::nullopt for stateful
+/// modes that are only available in the AllocToken pass.
+///
+/// \param Mode The token generation mode.
+/// \param Metadata The metadata about the allocation.
+/// \param MaxTokens The maximum number of tokens (must not be 0)
+/// \return The calculated allocation token ID, or std::nullopt.
+LLVM_ABI std::optional<uint64_t>
+getAllocToken(AllocTokenMode Mode, const AllocTokenMetadata &Metadata,
+ uint64_t MaxTokens);
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_ALLOCTOKEN_H
diff --git a/llvm/include/llvm/Support/GlobPattern.h b/llvm/include/llvm/Support/GlobPattern.h
index c1b4484..8cae6a3 100644
--- a/llvm/include/llvm/Support/GlobPattern.h
+++ b/llvm/include/llvm/Support/GlobPattern.h
@@ -63,21 +63,30 @@ public:
// Returns true for glob pattern "*". Can be used to avoid expensive
// preparation/acquisition of the input for match().
bool isTrivialMatchAll() const {
- if (!Prefix.empty())
+ if (PrefixSize)
return false;
- if (!Suffix.empty())
+ if (SuffixSize)
return false;
if (SubGlobs.size() != 1)
return false;
return SubGlobs[0].getPat() == "*";
}
- StringRef prefix() const { return Prefix; }
- StringRef suffix() const { return Suffix; }
+ // The following functions are just shortcuts for faster matching. They are
+ // conservative to simplify implementations.
+
+ // Returns plain prefix of the pattern.
+ StringRef prefix() const { return Pattern.take_front(PrefixSize); }
+ // Returns plain suffix of the pattern.
+ StringRef suffix() const { return Pattern.take_back(SuffixSize); }
+ // Returns the longest plain substring of the pattern between prefix and
+ // suffix.
+ StringRef longest_substr() const;
private:
- StringRef Prefix;
- StringRef Suffix;
+ StringRef Pattern;
+ size_t PrefixSize = 0;
+ size_t SuffixSize = 0;
struct SubGlobPattern {
/// \param Pat the pattern to match against
diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
index 2c2122a..bfd2817 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -118,9 +118,8 @@ enum CodeObjectVersionKind {
class TargetOptions {
public:
TargetOptions()
- : UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
- NoTrappingFPMath(true), NoSignedZerosFPMath(false),
- EnableAIXExtendedAltivecABI(false),
+ : NoInfsFPMath(false), NoNaNsFPMath(false), NoTrappingFPMath(true),
+ NoSignedZerosFPMath(false), EnableAIXExtendedAltivecABI(false),
HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
@@ -156,13 +155,6 @@ public:
/// MCAsmInfo::BinutilsVersion.
std::pair<int, int> BinutilsVersion{0, 0};
- /// UnsafeFPMath - This flag is enabled when the
- /// -enable-unsafe-fp-math flag is specified on the command line. When
- /// this flag is off (the default), the code generator is not allowed to
- /// produce results that are "less precise" than IEEE allows. This includes
- /// use of X86 instructions like FSIN and FCOS instead of libcalls.
- unsigned UnsafeFPMath : 1;
-
/// NoInfsFPMath - This flag is enabled when the
/// -enable-no-infs-fp-math flag is specified on the command line. When
/// this flag is off (the default), the code generator is not allowed to
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h b/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
index b1391cb0..077703c 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
@@ -16,6 +16,7 @@
#include "llvm/IR/Analysis.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/Support/AllocToken.h"
#include <optional>
namespace llvm {
@@ -23,6 +24,7 @@ namespace llvm {
class Module;
struct AllocTokenOptions {
+ AllocTokenMode Mode = DefaultAllocTokenMode;
std::optional<uint64_t> MaxTokens;
bool FastABI = false;
bool Extended = false;
diff --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index 979f3b3e..e677cbf 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -21,6 +21,7 @@
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Dominators.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Printable.h"
#include <cassert>
namespace llvm {
@@ -611,6 +612,10 @@ LLVM_ABI void InvertBranch(BranchInst *PBI, IRBuilderBase &Builder);
// br/brcond/unreachable/ret
LLVM_ABI bool hasOnlySimpleTerminator(const Function &F);
+/// Print BasicBlock \p BB as an operand or print "<nullptr>" if \p BB is a
+/// nullptr.
+LLVM_ABI Printable printBasicBlock(const BasicBlock *BB);
+
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H