Skip to content

Commit 4daf980

Browse files
author
Jenkins
committed
merge main into amd-stg-open
Change-Id: Ibffd0754d65edb4812d5bae7ff6193fda2822bb7
2 parents c2fa665 + 9cdba33 commit 4daf980

Some content is hidden

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

47 files changed

+1190
-160
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3982,7 +3982,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
39823982
// All MSVC dtors other than the base dtor are linkonce_odr and delegate to
39833983
// each other bottoming out with the base dtor. Therefore we emit non-base
39843984
// dtors on usage, even if there is no dtor definition in the TU.
3985-
if (D && isa<CXXDestructorDecl>(D) &&
3985+
if (isa_and_nonnull<CXXDestructorDecl>(D) &&
39863986
getCXXABI().useThunkForDtorVariant(cast<CXXDestructorDecl>(D),
39873987
GD.getDtorType()))
39883988
addDeferredDeclToEmit(GD);

lld/Common/Args.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ int64_t lld::args::getHex(opt::InputArgList &args, unsigned key,
5454
return ::getInteger(args, key, Default, 16);
5555
}
5656

57-
std::vector<StringRef> lld::args::getStrings(opt::InputArgList &args, int id) {
58-
std::vector<StringRef> v;
57+
SmallVector<StringRef, 0> lld::args::getStrings(opt::InputArgList &args,
58+
int id) {
59+
SmallVector<StringRef, 0> v;
5960
for (auto *arg : args.filtered(id))
6061
v.push_back(arg->getValue());
6162
return v;

lld/Common/Strings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ bool StringMatcher::match(StringRef s) const {
4646
}
4747

4848
// Converts a hex string (e.g. "deadbeef") to a vector.
49-
std::vector<uint8_t> lld::parseHex(StringRef s) {
50-
std::vector<uint8_t> hex;
49+
SmallVector<uint8_t, 0> lld::parseHex(StringRef s) {
50+
SmallVector<uint8_t, 0> hex;
5151
while (!s.empty()) {
5252
StringRef b = s.substr(0, 2);
5353
s = s.substr(2);

lld/ELF/Config.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ struct Configuration {
142142
std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;
143143
std::pair<llvm::StringRef, llvm::StringRef> thinLTOPrefixReplace;
144144
std::string rpath;
145-
std::vector<VersionDefinition> versionDefinitions;
146-
std::vector<llvm::StringRef> auxiliaryList;
147-
std::vector<llvm::StringRef> filterList;
148-
std::vector<llvm::StringRef> passPlugins;
149-
std::vector<llvm::StringRef> searchPaths;
150-
std::vector<llvm::StringRef> symbolOrderingFile;
151-
std::vector<llvm::StringRef> thinLTOModulesToCompile;
152-
std::vector<llvm::StringRef> undefined;
153-
std::vector<SymbolVersion> dynamicList;
154-
std::vector<uint8_t> buildIdVector;
145+
llvm::SmallVector<VersionDefinition, 0> versionDefinitions;
146+
llvm::SmallVector<llvm::StringRef, 0> auxiliaryList;
147+
llvm::SmallVector<llvm::StringRef, 0> filterList;
148+
llvm::SmallVector<llvm::StringRef, 0> passPlugins;
149+
llvm::SmallVector<llvm::StringRef, 0> searchPaths;
150+
llvm::SmallVector<llvm::StringRef, 0> symbolOrderingFile;
151+
llvm::SmallVector<llvm::StringRef, 0> thinLTOModulesToCompile;
152+
llvm::SmallVector<llvm::StringRef, 0> undefined;
153+
llvm::SmallVector<SymbolVersion, 0> dynamicList;
154+
llvm::SmallVector<uint8_t, 0> buildIdVector;
155155
llvm::MapVector<std::pair<const InputSectionBase *, const InputSectionBase *>,
156156
uint64_t>
157157
callGraphProfile;
@@ -167,7 +167,8 @@ struct Configuration {
167167
bool checkDynamicRelocs;
168168
bool compressDebugSections;
169169
bool cref;
170-
std::vector<std::pair<llvm::GlobPattern, uint64_t>> deadRelocInNonAlloc;
170+
llvm::SmallVector<std::pair<llvm::GlobPattern, uint64_t>, 0>
171+
deadRelocInNonAlloc;
171172
bool demangle = true;
172173
bool dependentLibraries;
173174
bool disableVerify;
@@ -217,7 +218,7 @@ struct Configuration {
217218
bool relrGlibc = false;
218219
bool relrPackDynRelocs = false;
219220
llvm::DenseSet<llvm::StringRef> saveTempsArgs;
220-
std::vector<std::pair<llvm::GlobPattern, uint32_t>> shuffleSections;
221+
llvm::SmallVector<std::pair<llvm::GlobPattern, uint32_t>, 0> shuffleSections;
221222
bool singleRoRx;
222223
bool shared;
223224
bool symbolic;
@@ -235,7 +236,7 @@ struct Configuration {
235236
bool unique;
236237
bool useAndroidRelrTags = false;
237238
bool warnBackrefs;
238-
std::vector<llvm::GlobPattern> warnBackrefsExclude;
239+
llvm::SmallVector<llvm::GlobPattern, 0> warnBackrefsExclude;
239240
bool warnCommon;
240241
bool warnMissingEntry;
241242
bool warnSymbolOrdering;

lld/ELF/Driver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
606606
}
607607

608608
static std::string getRpath(opt::InputArgList &args) {
609-
std::vector<StringRef> v = args::getStrings(args, OPT_rpath);
609+
SmallVector<StringRef, 0> v = args::getStrings(args, OPT_rpath);
610610
return llvm::join(v.begin(), v.end(), ":");
611611
}
612612

@@ -807,7 +807,7 @@ static OrphanHandlingPolicy getOrphanHandling(opt::InputArgList &args) {
807807
// Parse --build-id or --build-id=<style>. We handle "tree" as a
808808
// synonym for "sha1" because all our hash functions including
809809
// --build-id=sha1 are actually tree hashes for performance reasons.
810-
static std::pair<BuildIdKind, std::vector<uint8_t>>
810+
static std::pair<BuildIdKind, SmallVector<uint8_t, 0>>
811811
getBuildId(opt::InputArgList &args) {
812812
auto *arg = args.getLastArg(OPT_build_id);
813813
if (!arg)
@@ -982,8 +982,8 @@ static std::pair<StringRef, StringRef> getOldNewOptions(opt::InputArgList &args,
982982
}
983983

984984
// Parse the symbol ordering file and warn for any duplicate entries.
985-
static std::vector<StringRef> getSymbolOrderingFile(MemoryBufferRef mb) {
986-
SetVector<StringRef> names;
985+
static SmallVector<StringRef, 0> getSymbolOrderingFile(MemoryBufferRef mb) {
986+
SetVector<StringRef, SmallVector<StringRef, 0>> names;
987987
for (StringRef s : args::getLines(mb))
988988
if (!names.insert(s) && config->warnSymbolOrdering)
989989
warn(mb.getBufferIdentifier() + ": duplicate ordered symbol: " + s);

lld/ELF/InputSection.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,10 +1343,6 @@ static size_t findNull(StringRef s, size_t entSize) {
13431343
llvm_unreachable("");
13441344
}
13451345

1346-
SyntheticSection *MergeInputSection::getParent() const {
1347-
return cast_or_null<SyntheticSection>(parent);
1348-
}
1349-
13501346
// Split SHF_STRINGS section. Such section is a sequence of
13511347
// null-terminated strings.
13521348
void MergeInputSection::splitStrings(StringRef s, size_t entSize) {

lld/ELF/InputSection.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ class MergeInputSection : public InputSectionBase {
296296
return const_cast<MergeInputSection *>(this)->getSectionPiece(offset);
297297
}
298298

299-
SyntheticSection *getParent() const;
299+
SyntheticSection *getParent() const {
300+
return cast_or_null<SyntheticSection>(parent);
301+
}
300302

301303
private:
302304
void splitStrings(StringRef s, size_t size);
@@ -394,6 +396,27 @@ class InputSection : public InputSectionBase {
394396

395397
static_assert(sizeof(InputSection) <= 160, "InputSection is too big");
396398

399+
class SyntheticSection : public InputSection {
400+
public:
401+
SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment,
402+
StringRef name)
403+
: InputSection(nullptr, flags, type, alignment, {}, name,
404+
InputSectionBase::Synthetic) {}
405+
406+
virtual ~SyntheticSection() = default;
407+
virtual size_t getSize() const = 0;
408+
virtual bool updateAllocSize() { return false; }
409+
// If the section has the SHF_ALLOC flag and the size may be changed if
410+
// thunks are added, update the section size.
411+
virtual bool isNeeded() const { return true; }
412+
virtual void finalizeContents() {}
413+
virtual void writeTo(uint8_t *buf) = 0;
414+
415+
static bool classof(const SectionBase *sec) {
416+
return sec->kind() == InputSectionBase::Synthetic;
417+
}
418+
};
419+
397420
inline bool isDebugSection(const InputSectionBase &sec) {
398421
return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 &&
399422
sec.name.startswith(".debug");

lld/ELF/SyntheticSections.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,6 @@ class Defined;
3434
struct PhdrEntry;
3535
class SymbolTableBaseSection;
3636

37-
class SyntheticSection : public InputSection {
38-
public:
39-
SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment,
40-
StringRef name)
41-
: InputSection(nullptr, flags, type, alignment, {}, name,
42-
InputSectionBase::Synthetic) {}
43-
44-
virtual ~SyntheticSection() = default;
45-
virtual void writeTo(uint8_t *buf) = 0;
46-
virtual size_t getSize() const = 0;
47-
virtual void finalizeContents() {}
48-
// If the section has the SHF_ALLOC flag and the size may be changed if
49-
// thunks are added, update the section size.
50-
virtual bool updateAllocSize() { return false; }
51-
virtual bool isNeeded() const { return true; }
52-
53-
static bool classof(const SectionBase *d) {
54-
return d->kind() == InputSectionBase::Synthetic;
55-
}
56-
};
57-
5837
struct CieRecord {
5938
EhSectionPiece *cie = nullptr;
6039
SmallVector<EhSectionPiece *, 0> fdes;

lld/ELF/Writer.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,14 +1102,10 @@ template <class ELFT> void Writer<ELFT>::setReservedSymbolSections() {
11021102
// The more branches in getSectionRank that match, the more similar they are.
11031103
// Since each branch corresponds to a bit flag, we can just use
11041104
// countLeadingZeros.
1105-
static int getRankProximityAux(const OutputSection &a, const OutputSection &b) {
1106-
return countLeadingZeros(a.sortRank ^ b.sortRank);
1107-
}
1108-
11091105
static int getRankProximity(OutputSection *a, SectionCommand *b) {
11101106
auto *osd = dyn_cast<OutputDesc>(b);
11111107
return (osd && osd->osec.hasInputSections)
1112-
? getRankProximityAux(*a, osd->osec)
1108+
? countLeadingZeros(a->sortRank ^ osd->osec.sortRank)
11131109
: -1;
11141110
}
11151111

lld/MachO/Config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "llvm/ADT/DenseMap.h"
1414
#include "llvm/ADT/DenseSet.h"
1515
#include "llvm/ADT/MapVector.h"
16+
#include "llvm/ADT/SmallVector.h"
1617
#include "llvm/ADT/StringRef.h"
1718
#include "llvm/ADT/StringSet.h"
1819
#include "llvm/BinaryFormat/MachO.h"
@@ -169,7 +170,7 @@ struct Configuration {
169170
std::vector<llvm::StringRef> systemLibraryRoots;
170171
std::vector<llvm::StringRef> librarySearchPaths;
171172
std::vector<llvm::StringRef> frameworkSearchPaths;
172-
std::vector<llvm::StringRef> runtimePaths;
173+
llvm::SmallVector<llvm::StringRef, 0> runtimePaths;
173174
std::vector<std::string> astPaths;
174175
std::vector<Symbol *> explicitUndefineds;
175176
llvm::StringSet<> explicitDynamicLookups;

lld/include/lld/Common/Args.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ int64_t getInteger(llvm::opt::InputArgList &args, unsigned key,
3030

3131
int64_t getHex(llvm::opt::InputArgList &args, unsigned key, int64_t Default);
3232

33-
std::vector<StringRef> getStrings(llvm::opt::InputArgList &args, int id);
33+
llvm::SmallVector<StringRef, 0> getStrings(llvm::opt::InputArgList &args,
34+
int id);
3435

3536
uint64_t getZOptionValue(llvm::opt::InputArgList &args, int id, StringRef key,
3637
uint64_t Default);

lld/include/lld/Common/Strings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "llvm/ADT/ArrayRef.h"
1313
#include "llvm/ADT/Optional.h"
14+
#include "llvm/ADT/SmallVector.h"
1415
#include "llvm/ADT/StringRef.h"
1516
#include "llvm/Demangle/Demangle.h"
1617
#include "llvm/Support/GlobPattern.h"
@@ -26,7 +27,7 @@ inline std::string demangle(llvm::StringRef symName, bool shouldDemangle) {
2627
return std::string(symName);
2728
}
2829

29-
std::vector<uint8_t> parseHex(llvm::StringRef s);
30+
llvm::SmallVector<uint8_t, 0> parseHex(llvm::StringRef s);
3031
bool isValidCIdentifier(llvm::StringRef s);
3132

3233
// Write the contents of the a buffer to a file

lld/wasm/Config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLD_WASM_CONFIG_H
1010
#define LLD_WASM_CONFIG_H
1111

12+
#include "llvm/ADT/SmallVector.h"
1213
#include "llvm/ADT/StringRef.h"
1314
#include "llvm/ADT/StringSet.h"
1415
#include "llvm/BinaryFormat/Wasm.h"
@@ -72,7 +73,7 @@ struct Configuration {
7273
llvm::StringSet<> allowUndefinedSymbols;
7374
llvm::StringSet<> exportedSymbols;
7475
std::vector<llvm::StringRef> requiredExports;
75-
std::vector<llvm::StringRef> searchPaths;
76+
llvm::SmallVector<llvm::StringRef, 0> searchPaths;
7677
llvm::CachePruningPolicy thinLTOCachePolicy;
7778
llvm::Optional<std::vector<std::string>> features;
7879

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,10 +1282,7 @@ SmallVector<ValueTypeFromRangeType<R>, Size> to_vector(R &&Range) {
12821282
return {std::begin(Range), std::end(Range)};
12831283
}
12841284
template <typename R>
1285-
SmallVector<ValueTypeFromRangeType<R>,
1286-
CalculateSmallVectorDefaultInlinedElements<
1287-
ValueTypeFromRangeType<R>>::value>
1288-
to_vector(R &&Range) {
1285+
SmallVector<ValueTypeFromRangeType<R>> to_vector(R &&Range) {
12891286
return {std::begin(Range), std::end(Range)};
12901287
}
12911288

llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ class Block : public Addressable {
303303
/// Add an edge to this block.
304304
void addEdge(Edge::Kind K, Edge::OffsetT Offset, Symbol &Target,
305305
Edge::AddendT Addend) {
306-
assert(!isZeroFill() && "Adding edge to zero-fill block?");
306+
assert((K == Edge::KeepAlive || !isZeroFill()) &&
307+
"Adding edge to zero-fill block?");
307308
Edges.push_back(Edge(K, Offset, Target, Addend));
308309
}
309310

llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
set(LLVM_TARGET_DEFINITIONS COFFOptions.td)
2+
tablegen(LLVM COFFOptions.inc -gen-opt-parser-defs)
3+
add_public_tablegen_target(JITLinkTableGen)
4+
15
add_llvm_component_library(LLVMJITLink
26
DWARFRecordSectionSplitter.cpp
37
EHFrameSupport.cpp
@@ -23,6 +27,7 @@ add_llvm_component_library(LLVMJITLink
2327

2428
# COFF
2529
COFF.cpp
30+
COFFDirectiveParser.cpp
2631
COFFLinkGraphBuilder.cpp
2732
COFF_x86_64.cpp
2833

@@ -36,10 +41,12 @@ add_llvm_component_library(LLVMJITLink
3641

3742
DEPENDS
3843
intrinsics_gen
44+
JITLinkTableGen
3945

4046
LINK_COMPONENTS
4147
BinaryFormat
4248
Object
49+
Option
4350
OrcTargetProcess
4451
Support
4552
)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//===-- COFFDirectiveParser.cpp - JITLink coff directive parser --*- C++ -*===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// MSVC COFF directive parser
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "COFFDirectiveParser.h"
14+
15+
using namespace llvm;
16+
using namespace jitlink;
17+
18+
#define DEBUG_TYPE "jitlink"
19+
20+
// Create prefix string literals used in Options.td
21+
#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
22+
#include "COFFOptions.inc"
23+
#undef PREFIX
24+
25+
// Create table mapping all options defined in COFFOptions.td
26+
static const opt::OptTable::Info infoTable[] = {
27+
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
28+
{X1, \
29+
X2, \
30+
X10, \
31+
X11, \
32+
COFF_OPT_##ID, \
33+
opt::Option::KIND##Class, \
34+
X9, \
35+
X8, \
36+
COFF_OPT_##GROUP, \
37+
COFF_OPT_##ALIAS, \
38+
X7, \
39+
X12},
40+
#include "COFFOptions.inc"
41+
#undef OPTION
42+
};
43+
44+
class COFFOptTable : public opt::OptTable {
45+
public:
46+
COFFOptTable() : OptTable(infoTable, true) {}
47+
};
48+
49+
static COFFOptTable optTable;
50+
51+
Expected<opt::InputArgList> COFFDirectiveParser::parse(StringRef Str) {
52+
SmallVector<StringRef, 16> Tokens;
53+
SmallVector<const char *, 16> Buffer;
54+
cl::TokenizeWindowsCommandLineNoCopy(Str, saver, Tokens);
55+
for (StringRef Tok : Tokens) {
56+
bool HasNul = Tok.end() != Str.end() && Tok.data()[Tok.size()] == '\0';
57+
Buffer.push_back(HasNul ? Tok.data() : saver.save(Tok).data());
58+
}
59+
60+
unsigned missingIndex;
61+
unsigned missingCount;
62+
63+
auto Result = optTable.ParseArgs(Buffer, missingIndex, missingCount);
64+
65+
if (missingCount)
66+
return make_error<JITLinkError>(Twine("COFF directive parsing failed: ") +
67+
Result.getArgString(missingIndex) +
68+
" missing argument");
69+
LLVM_DEBUG({
70+
for (auto *arg : Result.filtered(COFF_OPT_UNKNOWN))
71+
dbgs() << "Unknown coff option argument: " << arg->getAsString(Result)
72+
<< "\n";
73+
});
74+
return std::move(Result);
75+
}

0 commit comments

Comments
 (0)