Skip to content

Commit 7d812cd

Browse files
authored
Merge branch 'llvm:main' into add_intrinsic_support
2 parents c8c3975 + 9ad4ebd commit 7d812cd

File tree

75 files changed

+1087
-239
lines changed

Some content is hidden

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

75 files changed

+1087
-239
lines changed

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
6565
const ValueDecl *VD);
6666
static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC,
6767
const ValueDecl *D) {
68-
const SourceInfo &E = S.Current->getSource(OpPC);
6968

7069
if (isa<ParmVarDecl>(D)) {
7170
if (D->getType()->isReferenceType())
7271
return false;
7372

73+
const SourceInfo &Loc = S.Current->getSource(OpPC);
7474
if (S.getLangOpts().CPlusPlus11) {
75-
S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
75+
S.FFDiag(Loc, diag::note_constexpr_function_param_value_unknown) << D;
7676
S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
7777
} else {
78-
S.FFDiag(E);
78+
S.FFDiag(Loc);
7979
}
8080
return false;
8181
}

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const void *Program::getNativePointer(unsigned Idx) {
3535
unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) {
3636
const size_t CharWidth = S->getCharByteWidth();
3737
const size_t BitWidth = CharWidth * Ctx.getCharBit();
38+
unsigned StringLength = S->getLength();
3839

3940
PrimType CharType;
4041
switch (CharWidth) {
@@ -55,15 +56,15 @@ unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) {
5556
Base = S;
5657

5758
// Create a descriptor for the string.
58-
Descriptor *Desc = allocateDescriptor(Base, CharType, Descriptor::GlobalMD,
59-
S->getLength() + 1,
60-
/*isConst=*/true,
61-
/*isTemporary=*/false,
62-
/*isMutable=*/false);
59+
Descriptor *Desc =
60+
allocateDescriptor(Base, CharType, Descriptor::GlobalMD, StringLength + 1,
61+
/*isConst=*/true,
62+
/*isTemporary=*/false,
63+
/*isMutable=*/false);
6364

6465
// Allocate storage for the string.
6566
// The byte length does not include the null terminator.
66-
unsigned I = Globals.size();
67+
unsigned GlobalIndex = Globals.size();
6768
unsigned Sz = Desc->getAllocSize();
6869
auto *G = new (Allocator, Sz) Global(Ctx.getEvalID(), Desc, /*isStatic=*/true,
6970
/*isExtern=*/false);
@@ -74,33 +75,32 @@ unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) {
7475

7576
// Construct the string in storage.
7677
const Pointer Ptr(G->block());
77-
for (unsigned I = 0, N = S->getLength(); I <= N; ++I) {
78-
Pointer Field = Ptr.atIndex(I).narrow();
79-
const uint32_t CodePoint = I == N ? 0 : S->getCodeUnit(I);
78+
for (unsigned I = 0; I <= StringLength; ++I) {
79+
Pointer Field = Ptr.atIndex(I);
80+
const uint32_t CodePoint = I == StringLength ? 0 : S->getCodeUnit(I);
8081
switch (CharType) {
8182
case PT_Sint8: {
8283
using T = PrimConv<PT_Sint8>::T;
8384
Field.deref<T>() = T::from(CodePoint, BitWidth);
84-
Field.initialize();
8585
break;
8686
}
8787
case PT_Uint16: {
8888
using T = PrimConv<PT_Uint16>::T;
8989
Field.deref<T>() = T::from(CodePoint, BitWidth);
90-
Field.initialize();
9190
break;
9291
}
9392
case PT_Uint32: {
9493
using T = PrimConv<PT_Uint32>::T;
9594
Field.deref<T>() = T::from(CodePoint, BitWidth);
96-
Field.initialize();
9795
break;
9896
}
9997
default:
10098
llvm_unreachable("unsupported character type");
10199
}
102100
}
103-
return I;
101+
Ptr.initialize();
102+
103+
return GlobalIndex;
104104
}
105105

106106
Pointer Program::getPtrGlobal(unsigned Idx) const {

lld/ELF/BPSectionOrderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ DenseMap<const InputSectionBase *, int> elf::runBalancedPartitioning(
6868
bool verbose) {
6969
// Collect candidate sections and associated symbols.
7070
SmallVector<InputSectionBase *> sections;
71-
DenseMap<CachedHashStringRef, DenseSet<unsigned>> rootSymbolToSectionIdxs;
71+
DenseMap<CachedHashStringRef, std::set<unsigned>> rootSymbolToSectionIdxs;
7272
BPOrdererELF orderer;
7373

7474
auto addSection = [&](Symbol &sym) {

lld/ELF/Config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ struct Config {
298298
bool gdbIndex;
299299
bool gnuHash = false;
300300
bool gnuUnique;
301+
bool hasDynSymTab;
301302
bool ignoreDataAddressEquality;
302303
bool ignoreFunctionAddressEquality;
303304
bool ltoCSProfileGenerate;
@@ -311,6 +312,7 @@ struct Config {
311312
bool mipsN32Abi = false;
312313
bool mmapOutputFile;
313314
bool nmagic;
315+
bool noDynamicLinker = false;
314316
bool noinhibitExec;
315317
bool nostdlib;
316318
bool oFormatBinary;

lld/ELF/Driver.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,11 @@ static StringRef getDynamicLinker(Ctx &ctx, opt::InputArgList &args) {
781781
auto *arg = args.getLastArg(OPT_dynamic_linker, OPT_no_dynamic_linker);
782782
if (!arg)
783783
return "";
784-
if (arg->getOption().getID() == OPT_no_dynamic_linker)
784+
if (arg->getOption().getID() == OPT_no_dynamic_linker) {
785+
// --no-dynamic-linker suppresses undefined weak symbols in .dynsym
786+
ctx.arg.noDynamicLinker = true;
785787
return "";
788+
}
786789
return arg->getValue();
787790
}
788791

@@ -2945,8 +2948,12 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
29452948

29462949
parseFiles(ctx, files);
29472950

2951+
// Dynamic linking is used if there is an input DSO,
2952+
// or -shared or non-static pie is specified.
2953+
ctx.hasDynsym = !ctx.sharedFiles.empty() || ctx.arg.shared ||
2954+
(ctx.arg.pie && !ctx.arg.noDynamicLinker);
29482955
// Create dynamic sections for dynamic linking and static PIE.
2949-
ctx.hasDynsym = !ctx.sharedFiles.empty() || ctx.arg.isPic;
2956+
ctx.arg.hasDynSymTab = ctx.hasDynsym || ctx.arg.isPic;
29502957

29512958
// If an entry symbol is in a static archive, pull out that file now.
29522959
if (Symbol *sym = ctx.symtab->find(ctx.arg.entry))

lld/ELF/Symbols.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,7 @@ void elf::parseVersionAndComputeIsPreemptible(Ctx &ctx) {
360360
// Symbol themselves might know their versions because symbols
361361
// can contain versions in the form of <name>@<version>.
362362
// Let them parse and update their names to exclude version suffix.
363-
// In addition, compute isExported and isPreemptible.
364363
bool hasDynsym = ctx.hasDynsym;
365-
bool maybePreemptible = ctx.sharedFiles.size() || ctx.arg.shared;
366364
for (Symbol *sym : ctx.symtab->getSymbols()) {
367365
if (sym->hasVersionSuffix)
368366
sym->parseSymbolVersion(ctx);
@@ -373,7 +371,7 @@ void elf::parseVersionAndComputeIsPreemptible(Ctx &ctx) {
373371
continue;
374372
}
375373
if (!sym->isDefined() && !sym->isCommon()) {
376-
sym->isPreemptible = maybePreemptible && computeIsPreemptible(ctx, *sym);
374+
sym->isPreemptible = computeIsPreemptible(ctx, *sym);
377375
} else if (ctx.arg.exportDynamic &&
378376
(sym->isUsedInRegularObj || !sym->ltoCanOmit)) {
379377
sym->isExported = true;

lld/ELF/SyntheticSections.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4740,7 +4740,7 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
47404740

47414741
// Add MIPS-specific sections.
47424742
if (ctx.arg.emachine == EM_MIPS) {
4743-
if (!ctx.arg.shared && ctx.hasDynsym) {
4743+
if (!ctx.arg.shared && ctx.arg.hasDynSymTab) {
47444744
ctx.in.mipsRldMap = std::make_unique<MipsRldMapSection>(ctx);
47454745
add(*ctx.in.mipsRldMap);
47464746
}
@@ -4803,7 +4803,7 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
48034803
part.relaDyn = std::make_unique<RelocationSection<ELFT>>(
48044804
ctx, relaDynName, ctx.arg.zCombreloc, threadCount);
48054805

4806-
if (ctx.hasDynsym) {
4806+
if (ctx.arg.hasDynSymTab) {
48074807
add(*part.dynSymTab);
48084808

48094809
part.verSym = std::make_unique<VersionTableSection>(ctx);

lld/ELF/Writer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ static void demoteSymbolsAndComputeIsPreemptible(Ctx &ctx) {
285285
llvm::TimeTraceScope timeScope("Demote symbols");
286286
DenseMap<InputFile *, DenseMap<SectionBase *, size_t>> sectionIndexMap;
287287
bool hasDynsym = ctx.hasDynsym;
288-
bool maybePreemptible = ctx.sharedFiles.size() || ctx.arg.shared;
289288
for (Symbol *sym : ctx.symtab->getSymbols()) {
290289
if (auto *d = dyn_cast<Defined>(sym)) {
291290
if (d->section && !d->section->isLive())
@@ -302,8 +301,7 @@ static void demoteSymbolsAndComputeIsPreemptible(Ctx &ctx) {
302301
}
303302

304303
if (hasDynsym)
305-
sym->isPreemptible = maybePreemptible &&
306-
(sym->isUndefined() || sym->isExported) &&
304+
sym->isPreemptible = (sym->isUndefined() || sym->isExported) &&
307305
computeIsPreemptible(ctx, *sym);
308306
}
309307
}
@@ -1944,7 +1942,8 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
19441942

19451943
// computeBinding might localize a linker-synthesized hidden symbol
19461944
// (e.g. __global_pointer$) that was considered exported.
1947-
if ((sym->isExported || sym->isPreemptible) && !sym->isLocal()) {
1945+
if (ctx.hasDynsym && (sym->isUndefined() || sym->isExported) &&
1946+
!sym->isLocal()) {
19481947
ctx.partitions[sym->partition - 1].dynSymTab->addSymbol(sym);
19491948
if (auto *file = dyn_cast<SharedFile>(sym->file))
19501949
if (file->isNeeded && !sym->isUndefined())

lld/MachO/BPSectionOrderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ DenseMap<const InputSection *, int> lld::macho::runBalancedPartitioning(
110110
bool compressionSortStartupFunctions, bool verbose) {
111111
// Collect candidate sections and associated symbols.
112112
SmallVector<InputSection *> sections;
113-
DenseMap<CachedHashStringRef, DenseSet<unsigned>> rootSymbolToSectionIdxs;
113+
DenseMap<CachedHashStringRef, std::set<unsigned>> rootSymbolToSectionIdxs;
114114
for (const auto *file : inputFiles) {
115115
for (auto *sec : file->sections) {
116116
for (auto &subsec : sec->subsections) {

lld/include/lld/Common/BPSectionOrdererBase.inc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "lld/Common/ErrorHandler.h"
2323
#include "llvm/ADT/CachedHashString.h"
2424
#include "llvm/ADT/DenseMap.h"
25-
#include "llvm/ADT/DenseSet.h"
25+
#include "llvm/ADT/MapVector.h"
2626
#include "llvm/ADT/SetVector.h"
2727
#include "llvm/ADT/SmallSet.h"
2828
#include "llvm/ADT/SmallVector.h"
@@ -35,6 +35,7 @@
3535
#include "llvm/Support/VirtualFileSystem.h"
3636
#include <memory>
3737
#include <optional>
38+
#include <set>
3839

3940
#define DEBUG_TYPE "bp-section-orderer"
4041

@@ -60,7 +61,7 @@ template <class D> struct BPOrderer {
6061
bool forDataCompression,
6162
bool compressionSortStartupFunctions, bool verbose,
6263
llvm::ArrayRef<Section *> sections,
63-
const DenseMap<CachedHashStringRef, DenseSet<unsigned>>
64+
const DenseMap<CachedHashStringRef, std::set<unsigned>>
6465
&rootSymbolToSectionIdxs)
6566
-> llvm::DenseMap<const Section *, int>;
6667

@@ -77,7 +78,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
7778
ArrayRef<const typename D::Section *> sections,
7879
const DenseMap<const void *, uint64_t> &sectionToIdx,
7980
ArrayRef<unsigned> sectionIdxs,
80-
DenseMap<unsigned, SmallVector<unsigned>> *duplicateSectionIdxs,
81+
DenseMap<unsigned, SmallVector<unsigned, 0>> *duplicateSectionIdxs,
8182
BPFunctionNode::UtilityNodeT &maxUN) {
8283
TimeTraceScope timeScope("Build nodes for compression");
8384

@@ -92,7 +93,7 @@ static SmallVector<std::pair<unsigned, UtilityNodes>> getUnsForCompression(
9293
hashes.clear();
9394
}
9495

95-
DenseMap<uint64_t, unsigned> hashFrequency;
96+
MapVector<uint64_t, unsigned> hashFrequency;
9697
for (auto &[sectionIdx, hashes] : sectionHashes)
9798
for (auto hash : hashes)
9899
++hashFrequency[hash];
@@ -161,7 +162,7 @@ auto BPOrderer<D>::computeOrder(
161162
StringRef profilePath, bool forFunctionCompression, bool forDataCompression,
162163
bool compressionSortStartupFunctions, bool verbose,
163164
ArrayRef<Section *> sections,
164-
const DenseMap<CachedHashStringRef, DenseSet<unsigned>>
165+
const DenseMap<CachedHashStringRef, std::set<unsigned>>
165166
&rootSymbolToSectionIdxs) -> DenseMap<const Section *, int> {
166167
TimeTraceScope timeScope("Setup Balanced Partitioning");
167168
DenseMap<const void *, uint64_t> sectionToIdx;
@@ -185,7 +186,7 @@ auto BPOrderer<D>::computeOrder(
185186
}
186187
auto &traces = reader->getTemporalProfTraces();
187188

188-
DenseMap<unsigned, BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
189+
MapVector<unsigned, BPFunctionNode::UtilityNodeT> sectionIdxToFirstUN;
189190
for (size_t traceIdx = 0; traceIdx < traces.size(); traceIdx++) {
190191
uint64_t currentSize = 0, cutoffSize = 1;
191192
size_t cutoffTimestamp = 1;
@@ -262,7 +263,7 @@ auto BPOrderer<D>::computeOrder(
262263

263264
// Map a section index (order directly) to a list of duplicate section indices
264265
// (not ordered directly).
265-
DenseMap<unsigned, SmallVector<unsigned>> duplicateSectionIdxs;
266+
DenseMap<unsigned, SmallVector<unsigned, 0>> duplicateSectionIdxs;
266267
auto unsForFunctionCompression = getUnsForCompression<D>(
267268
sections, sectionToIdx, sectionIdxsForFunctionCompression,
268269
&duplicateSectionIdxs, maxUN);

0 commit comments

Comments
 (0)