Skip to content

Commit b0f65b1

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/calleesaved
2 parents d60c0b8 + d46902e commit b0f65b1

File tree

49 files changed

+3331
-959
lines changed

Some content is hidden

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

49 files changed

+3331
-959
lines changed

bolt/include/bolt/Core/Linker.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ class BOLTLinker {
4646
/// Return the address and size of a symbol or std::nullopt if it cannot be
4747
/// found.
4848
virtual std::optional<SymbolInfo> lookupSymbolInfo(StringRef Name) const = 0;
49-
50-
/// Return the address of a symbol or std::nullopt if it cannot be found.
51-
std::optional<uint64_t> lookupSymbol(StringRef Name) const {
52-
if (const auto Info = lookupSymbolInfo(Name))
53-
return Info->Address;
54-
return std::nullopt;
55-
}
5649
};
5750

5851
} // namespace bolt

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,21 +4259,21 @@ void BinaryFunction::updateOutputValues(const BOLTLinker &Linker) {
42594259

42604260
if (BC.HasRelocations || isInjected()) {
42614261
if (hasConstantIsland()) {
4262-
const auto DataAddress =
4263-
Linker.lookupSymbol(getFunctionConstantIslandLabel()->getName());
4264-
assert(DataAddress && "Cannot find function CI symbol");
4265-
setOutputDataAddress(*DataAddress);
4262+
const auto IslandLabelSymInfo =
4263+
Linker.lookupSymbolInfo(getFunctionConstantIslandLabel()->getName());
4264+
assert(IslandLabelSymInfo && "Cannot find function CI symbol");
4265+
setOutputDataAddress(IslandLabelSymInfo->Address);
42664266
for (auto It : Islands->Offsets) {
42674267
const uint64_t OldOffset = It.first;
42684268
BinaryData *BD = BC.getBinaryDataAtAddress(getAddress() + OldOffset);
42694269
if (!BD)
42704270
continue;
42714271

42724272
MCSymbol *Symbol = It.second;
4273-
const auto NewAddress = Linker.lookupSymbol(Symbol->getName());
4274-
assert(NewAddress && "Cannot find CI symbol");
4273+
const auto SymInfo = Linker.lookupSymbolInfo(Symbol->getName());
4274+
assert(SymInfo && "Cannot find CI symbol");
42754275
auto &Section = *getCodeSection();
4276-
const auto NewOffset = *NewAddress - Section.getOutputAddress();
4276+
const auto NewOffset = SymInfo->Address - Section.getOutputAddress();
42774277
BD->setOutputLocation(Section, NewOffset);
42784278
}
42794279
}
@@ -4298,10 +4298,10 @@ void BinaryFunction::updateOutputValues(const BOLTLinker &Linker) {
42984298
FF.setAddress(ColdStartSymbolInfo->Address);
42994299
FF.setImageSize(ColdStartSymbolInfo->Size);
43004300
if (hasConstantIsland()) {
4301-
const auto DataAddress = Linker.lookupSymbol(
4301+
const auto SymInfo = Linker.lookupSymbolInfo(
43024302
getFunctionColdConstantIslandLabel()->getName());
4303-
assert(DataAddress && "Cannot find cold CI symbol");
4304-
setOutputColdDataAddress(*DataAddress);
4303+
assert(SymInfo && "Cannot find cold CI symbol");
4304+
setOutputColdDataAddress(SymInfo->Address);
43054305
}
43064306
}
43074307
}

bolt/lib/Rewrite/JITLinkLinker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ struct JITLinkLinker::Context : jitlink::JITLinkContext {
125125
std::string SymName = (*Symbol.first).str();
126126
LLVM_DEBUG(dbgs() << "BOLT: looking for " << SymName << "\n");
127127

128-
if (auto Address = Linker.lookupSymbol(SymName)) {
128+
if (auto SymInfo = Linker.lookupSymbolInfo(SymName)) {
129129
LLVM_DEBUG(dbgs() << "Resolved to address 0x"
130-
<< Twine::utohexstr(*Address) << "\n");
130+
<< Twine::utohexstr(SymInfo->Address) << "\n");
131131
AllResults[Symbol.first] = orc::ExecutorSymbolDef(
132-
orc::ExecutorAddr(*Address), JITSymbolFlags());
132+
orc::ExecutorAddr(SymInfo->Address), JITSymbolFlags());
133133
continue;
134134
}
135135

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5907,9 +5907,9 @@ void RewriteInstance::writeEHFrameHeader() {
59075907
}
59085908

59095909
uint64_t RewriteInstance::getNewValueForSymbol(const StringRef Name) {
5910-
auto Value = Linker->lookupSymbol(Name);
5910+
auto Value = Linker->lookupSymbolInfo(Name);
59115911
if (Value)
5912-
return *Value;
5912+
return Value->Address;
59135913

59145914
// Return the original value if we haven't emitted the symbol.
59155915
BinaryData *BD = BC->getBinaryDataByName(Name);

bolt/lib/RuntimeLibs/HugifyRuntimeLibrary.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ void HugifyRuntimeLibrary::link(BinaryContext &BC, StringRef ToolPath,
6868

6969
assert(!RuntimeStartAddress &&
7070
"We don't currently support linking multiple runtime libraries");
71-
RuntimeStartAddress = Linker.lookupSymbol("__bolt_hugify_self").value_or(0);
72-
if (!RuntimeStartAddress) {
71+
auto StartSymInfo = Linker.lookupSymbolInfo("__bolt_hugify_self");
72+
if (!StartSymInfo) {
7373
errs() << "BOLT-ERROR: hugify library does not define __bolt_hugify_self: "
7474
<< LibPath << "\n";
7575
exit(1);
7676
}
77+
RuntimeStartAddress = StartSymInfo->Address;
7778
}

bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,35 @@ void InstrumentationRuntimeLibrary::link(
203203
if (BC.isMachO())
204204
return;
205205

206-
RuntimeFiniAddress = Linker.lookupSymbol("__bolt_instr_fini").value_or(0);
207-
if (!RuntimeFiniAddress) {
206+
std::optional<BOLTLinker::SymbolInfo> FiniSymInfo =
207+
Linker.lookupSymbolInfo("__bolt_instr_fini");
208+
if (!FiniSymInfo) {
208209
errs() << "BOLT-ERROR: instrumentation library does not define "
209210
"__bolt_instr_fini: "
210211
<< LibPath << "\n";
211212
exit(1);
212213
}
213-
RuntimeStartAddress = Linker.lookupSymbol("__bolt_instr_start").value_or(0);
214-
if (!RuntimeStartAddress) {
214+
RuntimeFiniAddress = FiniSymInfo->Address;
215+
216+
std::optional<BOLTLinker::SymbolInfo> StartSymInfo =
217+
Linker.lookupSymbolInfo("__bolt_instr_start");
218+
if (!StartSymInfo) {
215219
errs() << "BOLT-ERROR: instrumentation library does not define "
216220
"__bolt_instr_start: "
217221
<< LibPath << "\n";
218222
exit(1);
219223
}
224+
RuntimeStartAddress = StartSymInfo->Address;
225+
220226
outs() << "BOLT-INFO: output linked against instrumentation runtime "
221227
"library, lib entry point is 0x"
222228
<< Twine::utohexstr(RuntimeStartAddress) << "\n";
229+
230+
std::optional<BOLTLinker::SymbolInfo> ClearSymInfo =
231+
Linker.lookupSymbolInfo("__bolt_instr_clear_counters");
232+
const uint64_t ClearSymAddress = ClearSymInfo ? ClearSymInfo->Address : 0;
223233
outs() << "BOLT-INFO: clear procedure is 0x"
224-
<< Twine::utohexstr(
225-
Linker.lookupSymbol("__bolt_instr_clear_counters").value_or(0))
226-
<< "\n";
234+
<< Twine::utohexstr(ClearSymAddress) << "\n";
227235

228236
emitTablesAsELFNote(BC);
229237
}

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
473473
(State.Column + State.Line->Last->TotalLength - Previous.TotalLength >
474474
getColumnLimit(State) ||
475475
CurrentState.BreakBeforeParameter) &&
476-
(!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
477-
(Style.BreakConstructorInitializers != FormatStyle::BCIS_BeforeColon ||
478-
Style.ColumnLimit > 0 || Current.NewlinesBefore > 0)) {
476+
((!Current.isTrailingComment() && Style.ColumnLimit > 0) ||
477+
Current.NewlinesBefore > 0)) {
479478
return true;
480479
}
481480

clang/lib/Index/IndexTypeSourceInfo.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "clang/AST/PrettyPrinter.h"
1212
#include "clang/AST/RecursiveASTVisitor.h"
1313
#include "clang/AST/TypeLoc.h"
14+
#include "clang/Sema/HeuristicResolver.h"
1415
#include "llvm/ADT/ScopeExit.h"
1516

1617
using namespace clang;
@@ -207,27 +208,8 @@ class TypeIndexer : public RecursiveASTVisitor<TypeIndexer> {
207208
}
208209

209210
bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
210-
const DependentNameType *DNT = TL.getTypePtr();
211-
const NestedNameSpecifier *NNS = DNT->getQualifier();
212-
const Type *T = NNS->getAsType();
213-
if (!T)
214-
return true;
215-
const TemplateSpecializationType *TST =
216-
T->getAs<TemplateSpecializationType>();
217-
if (!TST)
218-
return true;
219-
TemplateName TN = TST->getTemplateName();
220-
const ClassTemplateDecl *TD =
221-
dyn_cast_or_null<ClassTemplateDecl>(TN.getAsTemplateDecl());
222-
if (!TD)
223-
return true;
224-
CXXRecordDecl *RD = TD->getTemplatedDecl();
225-
if (!RD->hasDefinition())
226-
return true;
227-
RD = RD->getDefinition();
228-
DeclarationName Name(DNT->getIdentifier());
229-
std::vector<const NamedDecl *> Symbols = RD->lookupDependentName(
230-
Name, [](const NamedDecl *ND) { return isa<TypeDecl>(ND); });
211+
std::vector<const NamedDecl *> Symbols =
212+
IndexCtx.getResolver()->resolveDependentNameType(TL.getTypePtr());
231213
if (Symbols.size() != 1)
232214
return true;
233215
return IndexCtx.handleReference(Symbols[0], TL.getNameLoc(), Parent,

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4803,7 +4803,8 @@ bool Sema::checkVarDeclRedefinition(VarDecl *Old, VarDecl *New) {
48034803
(New->getFormalLinkage() == Linkage::Internal || New->isInline() ||
48044804
isa<VarTemplateSpecializationDecl>(New) ||
48054805
New->getDescribedVarTemplate() || New->getNumTemplateParameterLists() ||
4806-
New->getDeclContext()->isDependentContext())) {
4806+
New->getDeclContext()->isDependentContext() ||
4807+
New->hasAttr<SelectAnyAttr>())) {
48074808
// The previous definition is hidden, and multiple definitions are
48084809
// permitted (in separate TUs). Demote this to a declaration.
48094810
New->demoteThisDefinitionToDeclaration();

clang/test/Modules/pr127943.cppm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++20 %t/repro.cppm -fdeclspec -emit-module-interface -o %t/repro.pcm
6+
// RUN: %clang_cc1 -std=c++20 %t/source.cpp -fdeclspec -fsyntax-only -verify -fprebuilt-module-path=%t
7+
8+
//--- repro_decl.hpp
9+
#pragma once
10+
11+
extern "C"
12+
{
13+
__declspec(selectany) int foo = 0;
14+
}
15+
16+
//--- repro.cppm
17+
module;
18+
#include "repro_decl.hpp"
19+
20+
export module repro;
21+
22+
export inline int func()
23+
{
24+
return foo;
25+
}
26+
27+
//--- source.cpp
28+
// expected-no-diagnostics
29+
import repro;
30+
31+
#include "repro_decl.hpp"

0 commit comments

Comments
 (0)