Skip to content

Commit 7d5b44f

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW51)
LLVM: llvm/llvm-project@c73876d SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@441aa40
2 parents 08be083 + 37f0b87 commit 7d5b44f

File tree

7,202 files changed

+186729
-73120
lines changed

Some content is hidden

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

7,202 files changed

+186729
-73120
lines changed

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class BinaryContext {
152152
std::string Filename;
153153

154154
/// Unique build ID if available for the binary.
155-
Optional<std::string> FileBuildID;
155+
std::optional<std::string> FileBuildID;
156156

157157
/// Set of all sections.
158158
struct CompareSections {
@@ -259,7 +259,7 @@ class BinaryContext {
259259
void clearFragmentsToSkip() { FragmentsToSkip.clear(); }
260260

261261
/// Given DWOId returns CU if it exists in DWOCUs.
262-
Optional<DWARFUnit *> getDWOCU(uint64_t DWOId);
262+
std::optional<DWARFUnit *> getDWOCU(uint64_t DWOId);
263263

264264
/// Returns DWOContext if it exists.
265265
DWARFContext *getDWOContext() const;
@@ -283,9 +283,9 @@ class BinaryContext {
283283

284284
Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName,
285285
unsigned FileNumber,
286-
Optional<MD5::MD5Result> Checksum,
287-
Optional<StringRef> Source, unsigned CUID,
288-
unsigned DWARFVersion);
286+
std::optional<MD5::MD5Result> Checksum,
287+
std::optional<StringRef> Source,
288+
unsigned CUID, unsigned DWARFVersion);
289289

290290
/// [start memory address] -> [segment info] mapping.
291291
std::map<uint64_t, SegmentInfo> SegmentMapInfo;
@@ -319,7 +319,7 @@ class BinaryContext {
319319
StringRef getFilename() const { return Filename; }
320320
void setFilename(StringRef Name) { Filename = std::string(Name); }
321321

322-
Optional<StringRef> getFileBuildID() const {
322+
std::optional<StringRef> getFileBuildID() const {
323323
if (FileBuildID)
324324
return StringRef(*FileBuildID);
325325

@@ -1063,9 +1063,9 @@ class BinaryContext {
10631063
/// segments was mapped. \p FileOffset is the offset in the file of the
10641064
/// mapping. Note that \p FileOffset should be page-aligned and could be
10651065
/// different from the file offset of the segment which could be unaligned.
1066-
/// If no segment is found that matches \p FileOffset, return NoneType().
1067-
Optional<uint64_t> getBaseAddressForMapping(uint64_t MMapAddress,
1068-
uint64_t FileOffset) const;
1066+
/// If no segment is found that matches \p FileOffset, return std::nullopt.
1067+
std::optional<uint64_t> getBaseAddressForMapping(uint64_t MMapAddress,
1068+
uint64_t FileOffset) const;
10691069

10701070
/// Check if the address belongs to this binary's static allocation space.
10711071
bool containsAddress(uint64_t Address) const {

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,8 @@ class BinaryFunction {
894894
BinaryBasicBlock *getLandingPadBBFor(const BinaryBasicBlock &BB,
895895
const MCInst &InvokeInst) const {
896896
assert(BC.MIB->isInvoke(InvokeInst) && "must be invoke instruction");
897-
const Optional<MCPlus::MCLandingPad> LP = BC.MIB->getEHInfo(InvokeInst);
897+
const std::optional<MCPlus::MCLandingPad> LP =
898+
BC.MIB->getEHInfo(InvokeInst);
898899
if (LP && LP->first) {
899900
BinaryBasicBlock *LBB = BB.getLandingPad(LP->first);
900901
assert(LBB && "Landing pad should be defined");
@@ -971,7 +972,7 @@ class BinaryFunction {
971972
/// returns false. Stop if Callback returns true or all names have been used.
972973
/// Return the name for which the Callback returned true if any.
973974
template <typename FType>
974-
Optional<StringRef> forEachName(FType Callback) const {
975+
std::optional<StringRef> forEachName(FType Callback) const {
975976
for (MCSymbol *Symbol : Symbols)
976977
if (Callback(Symbol->getName()))
977978
return Symbol->getName();
@@ -992,11 +993,12 @@ class BinaryFunction {
992993
}
993994

994995
/// Check if any of function names matches the given regex.
995-
Optional<StringRef> hasNameRegex(const StringRef NameRegex) const;
996+
std::optional<StringRef> hasNameRegex(const StringRef NameRegex) const;
996997

997998
/// Check if any of restored function names matches the given regex.
998999
/// Restored name means stripping BOLT-added suffixes like "/1",
999-
Optional<StringRef> hasRestoredNameRegex(const StringRef NameRegex) const;
1000+
std::optional<StringRef>
1001+
hasRestoredNameRegex(const StringRef NameRegex) const;
10001002

10011003
/// Return a vector of all possible names for the function.
10021004
std::vector<StringRef> getNames() const {
@@ -1316,7 +1318,7 @@ class BinaryFunction {
13161318
}
13171319

13181320
/// Return the name of the section this function originated from.
1319-
Optional<StringRef> getOriginSectionName() const {
1321+
std::optional<StringRef> getOriginSectionName() const {
13201322
if (!OriginSection)
13211323
return std::nullopt;
13221324
return OriginSection->getName();

bolt/include/bolt/Core/DebugData.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct AttrInfo {
4646
/// \param DIE die to look up in.
4747
/// \param AbbrevDecl abbrev declaration for the die.
4848
/// \param Index an index in Abbrev declaration entry.
49-
Optional<AttrInfo>
49+
std::optional<AttrInfo>
5050
findAttributeInfo(const DWARFDie DIE,
5151
const DWARFAbbreviationDeclaration *AbbrevDecl,
5252
uint32_t Index);
@@ -56,7 +56,8 @@ findAttributeInfo(const DWARFDie DIE,
5656
/// \param DIE die to look up in.
5757
/// \param Attr the attribute to extract.
5858
/// \return an optional AttrInfo with DWARFFormValue and Offset.
59-
Optional<AttrInfo> findAttributeInfo(const DWARFDie DIE, dwarf::Attribute Attr);
59+
std::optional<AttrInfo> findAttributeInfo(const DWARFDie DIE,
60+
dwarf::Attribute Attr);
6061

6162
// DWARF5 Header in order of encoding.
6263
// Types represent encodnig sizes.
@@ -424,13 +425,13 @@ class DebugStrOffsetsWriter {
424425

425426
/// Initializes Buffer and Stream.
426427
void initialize(const DWARFSection &StrOffsetsSection,
427-
const Optional<StrOffsetsContributionDescriptor> Contr);
428+
const std::optional<StrOffsetsContributionDescriptor> Contr);
428429

429430
/// Update Str offset in .debug_str in .debug_str_offsets.
430431
void updateAddressMap(uint32_t Index, uint32_t Address);
431432

432433
/// Writes out current sections entry into .debug_str_offsets.
433-
void finalizeSection();
434+
void finalizeSection(DWARFUnit &Unit);
434435

435436
/// Returns False if no strings were added to .debug_str.
436437
bool isFinalized() const { return !StrOffsetsBuffer->empty(); }
@@ -444,8 +445,10 @@ class DebugStrOffsetsWriter {
444445
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
445446
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
446447
std::map<uint32_t, uint32_t> IndexToAddressMap;
448+
DenseSet<uint64_t> ProcessedBaseOffsets;
447449
// Section size not including header.
448450
uint32_t CurrentSectionSize{0};
451+
bool StrOffsetSectionWasModified = false;
449452
};
450453

451454
using DebugStrBufferVector = SmallVector<char, 16>;
@@ -1130,11 +1133,11 @@ class DwarfLineTable {
11301133

11311134
/// Emit the Dwarf file and the line tables for a given CU.
11321135
void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params,
1133-
Optional<MCDwarfLineStr> &LineStr, BinaryContext &BC) const;
1136+
std::optional<MCDwarfLineStr> &LineStr, BinaryContext &BC) const;
11341137

11351138
Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
1136-
Optional<MD5::MD5Result> Checksum,
1137-
Optional<StringRef> Source,
1139+
std::optional<MD5::MD5Result> Checksum,
1140+
std::optional<StringRef> Source,
11381141
uint16_t DwarfVersion,
11391142
unsigned FileNumber = 0) {
11401143
assert(RawData.empty() && "cannot use with raw data");
@@ -1150,8 +1153,8 @@ class DwarfLineTable {
11501153
/// Sets the root file \p Directory, \p FileName, optional \p CheckSum, and
11511154
/// optional \p Source.
11521155
void setRootFile(StringRef Directory, StringRef FileName,
1153-
Optional<MD5::MD5Result> Checksum,
1154-
Optional<StringRef> Source) {
1156+
std::optional<MD5::MD5Result> Checksum,
1157+
std::optional<StringRef> Source) {
11551158
Header.setRootFile(Directory, FileName, Checksum, Source);
11561159
}
11571160

bolt/include/bolt/Core/FunctionLayout.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,8 @@ class FunctionFragment {
7171
using FragmentListType = SmallVector<unsigned, 0>;
7272

7373
public:
74-
using iterator = raw_pointer_iterator<BasicBlockListType::const_iterator,
75-
BinaryBasicBlock>;
76-
using const_iterator =
77-
raw_pointer_iterator<BasicBlockListType::const_iterator,
78-
const BinaryBasicBlock>;
74+
using iterator = BasicBlockListType::iterator;
75+
using const_iterator = BasicBlockListType::const_iterator;
7976

8077
private:
8178
FunctionLayout *Layout;
@@ -150,9 +147,7 @@ class FunctionLayout {
150147
pointee_iterator<FragmentListType::const_iterator,
151148
const FunctionFragment>;
152149
using block_iterator = BasicBlockListType::iterator;
153-
using block_const_iterator =
154-
raw_pointer_iterator<BasicBlockListType::const_iterator,
155-
const BinaryBasicBlock>;
150+
using block_const_iterator = BasicBlockListType::const_iterator;
156151
using block_reverse_iterator = std::reverse_iterator<block_iterator>;
157152
using block_const_reverse_iterator =
158153
std::reverse_iterator<block_const_iterator>;
@@ -303,16 +298,18 @@ class FunctionLayout {
303298
return {block_begin(), block_end()};
304299
}
305300
block_reverse_iterator block_rbegin() {
306-
return block_reverse_iterator(block_end());
301+
return block_reverse_iterator(Blocks.rbegin());
307302
}
308303
block_const_reverse_iterator block_rbegin() const {
309-
return block_const_reverse_iterator(block_end());
304+
return block_const_reverse_iterator(
305+
std::make_reverse_iterator(block_end()));
310306
}
311307
block_reverse_iterator block_rend() {
312-
return block_reverse_iterator(block_begin());
308+
return block_reverse_iterator(Blocks.rend());
313309
}
314310
block_const_reverse_iterator block_rend() const {
315-
return block_const_reverse_iterator(block_begin());
311+
return block_const_reverse_iterator(
312+
std::make_reverse_iterator(block_begin()));
316313
}
317314
iterator_range<block_const_reverse_iterator> rblocks() const {
318315
return {block_rbegin(), block_rend()};

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "bolt/Core/Relocation.h"
1919
#include "llvm/ADT/ArrayRef.h"
2020
#include "llvm/ADT/BitVector.h"
21-
#include "llvm/ADT/Optional.h"
2221
#include "llvm/ADT/StringMap.h"
2322
#include "llvm/MC/MCAsmBackend.h"
2423
#include "llvm/MC/MCDisassembler/MCSymbolizer.h"
@@ -33,6 +32,7 @@
3332
#include <cassert>
3433
#include <cstdint>
3534
#include <map>
35+
#include <optional>
3636
#include <system_error>
3737
#include <unordered_map>
3838
#include <unordered_set>
@@ -132,8 +132,8 @@ class MCPlusBuilder {
132132
AnnotationInst->addOperand(MCOperand::createImm(AnnotationValue));
133133
}
134134

135-
Optional<int64_t> getAnnotationOpValue(const MCInst &Inst,
136-
unsigned Index) const {
135+
std::optional<int64_t> getAnnotationOpValue(const MCInst &Inst,
136+
unsigned Index) const {
137137
const MCInst *AnnotationInst = getAnnotationInst(Inst);
138138
if (!AnnotationInst)
139139
return std::nullopt;
@@ -1049,7 +1049,7 @@ class MCPlusBuilder {
10491049
}
10501050

10511051
/// Return handler and action info for invoke instruction if present.
1052-
Optional<MCPlus::MCLandingPad> getEHInfo(const MCInst &Inst) const;
1052+
std::optional<MCPlus::MCLandingPad> getEHInfo(const MCInst &Inst) const;
10531053

10541054
/// Add handler and action info for call instruction.
10551055
void addEHInfo(MCInst &Inst, const MCPlus::MCLandingPad &LP);
@@ -1081,7 +1081,7 @@ class MCPlusBuilder {
10811081
bool unsetJumpTable(MCInst &Inst);
10821082

10831083
/// Return destination of conditional tail call instruction if \p Inst is one.
1084-
Optional<uint64_t> getConditionalTailCall(const MCInst &Inst) const;
1084+
std::optional<uint64_t> getConditionalTailCall(const MCInst &Inst) const;
10851085

10861086
/// Mark the \p Instruction as a conditional tail call, and set its
10871087
/// destination address if it is known. If \p Instruction was already marked,
@@ -1093,7 +1093,7 @@ class MCPlusBuilder {
10931093
bool unsetConditionalTailCall(MCInst &Inst);
10941094

10951095
/// Return offset of \p Inst in the original function, if available.
1096-
Optional<uint32_t> getOffset(const MCInst &Inst) const;
1096+
std::optional<uint32_t> getOffset(const MCInst &Inst) const;
10971097

10981098
/// Return the offset if the annotation is present, or \p Default otherwise.
10991099
uint32_t getOffsetWithDefault(const MCInst &Inst, uint32_t Default) const;
@@ -1591,8 +1591,8 @@ class MCPlusBuilder {
15911591

15921592
/// Create a target-specific relocation out of the \p Fixup.
15931593
/// Note that not every fixup could be converted into a relocation.
1594-
virtual Optional<Relocation> createRelocation(const MCFixup &Fixup,
1595-
const MCAsmBackend &MAB) const {
1594+
virtual std::optional<Relocation>
1595+
createRelocation(const MCFixup &Fixup, const MCAsmBackend &MAB) const {
15961596
llvm_unreachable("not implemented");
15971597
return Relocation();
15981598
}
@@ -1666,7 +1666,7 @@ class MCPlusBuilder {
16661666
}
16671667

16681668
/// Return annotation index matching the \p Name.
1669-
Optional<unsigned> getAnnotationIndex(StringRef Name) const {
1669+
std::optional<unsigned> getAnnotationIndex(StringRef Name) const {
16701670
auto AI = AnnotationNameIndexMap.find(Name);
16711671
if (AI != AnnotationNameIndexMap.end())
16721672
return AI->second;
@@ -1744,7 +1744,7 @@ class MCPlusBuilder {
17441744
/// Use hasAnnotation() if the annotation may not exist.
17451745
template <typename ValueType>
17461746
ValueType &getAnnotationAs(const MCInst &Inst, unsigned Index) const {
1747-
Optional<int64_t> Value = getAnnotationOpValue(Inst, Index);
1747+
std::optional<int64_t> Value = getAnnotationOpValue(Inst, Index);
17481748
assert(Value && "annotation should exist");
17491749
return reinterpret_cast<MCPlus::MCSimpleAnnotation<ValueType> *>(*Value)
17501750
->getValue();

bolt/include/bolt/Passes/ShrinkWrapping.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class CalleeSavedAnalysis {
2727
DataflowInfoManager &Info;
2828
MCPlusBuilder::AllocatorIdTy AllocatorId;
2929

30-
Optional<unsigned> SaveTagIndex;
31-
Optional<unsigned> RestoreTagIndex;
30+
std::optional<unsigned> SaveTagIndex;
31+
std::optional<unsigned> RestoreTagIndex;
3232

3333
/// Compute all stores of callee-saved regs. Those are the ones that stores a
3434
/// register whose definition is not local.
@@ -140,9 +140,9 @@ class StackLayoutModifier {
140140

141141
bool IsInitialized{false};
142142

143-
Optional<unsigned> TodoTagIndex;
144-
Optional<unsigned> SlotTagIndex;
145-
Optional<unsigned> OffsetCFIRegTagIndex;
143+
std::optional<unsigned> TodoTagIndex;
144+
std::optional<unsigned> SlotTagIndex;
145+
std::optional<unsigned> OffsetCFIRegTagIndex;
146146

147147
public:
148148
// Keep a worklist of operations to perform on the function to perform
@@ -315,7 +315,7 @@ class ShrinkWrapping {
315315
static std::atomic<std::uint64_t> InstrDynamicCount;
316316
static std::atomic<std::uint64_t> StoreDynamicCount;
317317

318-
Optional<unsigned> AnnotationIndex;
318+
std::optional<unsigned> AnnotationIndex;
319319

320320
/// Allow our custom worklist-sensitive analysis
321321
/// PredictiveStackPointerTracking to access WorklistItem

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#ifndef BOLT_PROFILE_BOLTADDRESSTRANSLATION_H
1010
#define BOLT_PROFILE_BOLTADDRESSTRANSLATION_H
1111

12-
#include "llvm/ADT/Optional.h"
1312
#include "llvm/ADT/SmallVector.h"
1413
#include "llvm/ADT/StringRef.h"
1514
#include <cstdint>
1615
#include <map>
16+
#include <optional>
1717
#include <system_error>
1818

1919
namespace llvm {
@@ -96,11 +96,11 @@ class BoltAddressTranslation {
9696

9797
/// Use the map keys containing basic block addresses to infer fall-throughs
9898
/// taken in the path started at FirstLBR.To and ending at SecondLBR.From.
99-
/// Return NoneType if trace is invalid or the list of fall-throughs
99+
/// Return std::nullopt if trace is invalid or the list of fall-throughs
100100
/// otherwise.
101-
Optional<FallthroughListTy> getFallthroughsInTrace(uint64_t FuncAddress,
102-
uint64_t From,
103-
uint64_t To) const;
101+
std::optional<FallthroughListTy> getFallthroughsInTrace(uint64_t FuncAddress,
102+
uint64_t From,
103+
uint64_t To) const;
104104

105105
/// If available, fetch the address of the hot part linked to the cold part
106106
/// at \p Address. Return 0 otherwise.

0 commit comments

Comments
 (0)