Skip to content

Commit 226e581

Browse files
committed
merge main into amd-staging
Disabled: [Offload] libomptarget force dlopen vendor libraries by default. (llvm#92788) Change-Id: Ibe7da67ea294b76e9d159372e1d6151fe6b5cba2
2 parents 3d4d5ed + f2bbb4c commit 226e581

File tree

162 files changed

+2071
-981
lines changed

Some content is hidden

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

162 files changed

+2071
-981
lines changed

bolt/include/bolt/Passes/MCF.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ namespace bolt {
1515
class BinaryFunction;
1616
class DataflowInfoManager;
1717

18-
enum MCFCostFunction : char {
19-
MCF_DISABLE = 0,
20-
MCF_LINEAR,
21-
MCF_QUADRATIC,
22-
MCF_LOG,
23-
MCF_BLAMEFTS
24-
};
25-
2618
/// Implement the idea in "SamplePGO - The Power of Profile Guided Optimizations
2719
/// without the Usability Burden" by Diego Novillo to make basic block counts
2820
/// equal if we show that A dominates B, B post-dominates A and they are in the
@@ -33,22 +25,6 @@ void equalizeBBCounts(DataflowInfoManager &Info, BinaryFunction &BF);
3325
/// we only have bb count.
3426
void estimateEdgeCounts(BinaryFunction &BF);
3527

36-
/// Entry point for computing a min-cost flow for the CFG with the goal
37-
/// of fixing the flow of the CFG edges, that is, making sure it obeys the
38-
/// flow-conservation equation SumInEdges = SumOutEdges.
39-
///
40-
/// To do this, we create an instance of the min-cost flow problem in a
41-
/// similar way as the one discussed in the work of Roy Levin "Completing
42-
/// Incomplete Edge Profile by Applying Minimum Cost Circulation Algorithms".
43-
/// We do a few things differently, though. We don't populate edge counts using
44-
/// weights coming from a static branch prediction technique and we don't
45-
/// use the same cost function.
46-
///
47-
/// If cost function BlameFTs is used, assign all remaining flow to
48-
/// fall-throughs. This is used when the sampling is based on taken branches
49-
/// that do not account for them.
50-
void solveMCF(BinaryFunction &BF, MCFCostFunction CostFunction);
51-
5228
} // end namespace bolt
5329
} // end namespace llvm
5430

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ class BoltAddressTranslation {
107107

108108
/// If available, fetch the address of the hot part linked to the cold part
109109
/// at \p Address. Return 0 otherwise.
110-
uint64_t fetchParentAddress(uint64_t Address) const;
110+
uint64_t fetchParentAddress(uint64_t Address) const {
111+
auto Iter = ColdPartSource.find(Address);
112+
if (Iter == ColdPartSource.end())
113+
return 0;
114+
return Iter->second;
115+
}
111116

112117
/// True if the input binary has a translation table we can use to convert
113118
/// addresses when aggregating profile
@@ -278,7 +283,9 @@ class BoltAddressTranslation {
278283

279284
/// Returns the number of basic blocks in a function.
280285
size_t getNumBasicBlocks(uint64_t OutputAddress) const {
281-
return NumBasicBlocksMap.at(OutputAddress);
286+
auto It = NumBasicBlocksMap.find(OutputAddress);
287+
assert(It != NumBasicBlocksMap.end());
288+
return It->second;
282289
}
283290

284291
private:

bolt/lib/Core/BinaryContext.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,10 +934,13 @@ std::string BinaryContext::generateJumpTableName(const BinaryFunction &BF,
934934
uint64_t Offset = 0;
935935
if (const JumpTable *JT = BF.getJumpTableContainingAddress(Address)) {
936936
Offset = Address - JT->getAddress();
937-
auto Itr = JT->Labels.find(Offset);
938-
if (Itr != JT->Labels.end())
939-
return std::string(Itr->second->getName());
940-
Id = JumpTableIds.at(JT->getAddress());
937+
auto JTLabelsIt = JT->Labels.find(Offset);
938+
if (JTLabelsIt != JT->Labels.end())
939+
return std::string(JTLabelsIt->second->getName());
940+
941+
auto JTIdsIt = JumpTableIds.find(JT->getAddress());
942+
assert(JTIdsIt != JumpTableIds.end());
943+
Id = JTIdsIt->second;
941944
} else {
942945
Id = JumpTableIds[Address] = BF.JumpTables.size();
943946
}

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,9 @@ void BinaryEmitter::emitJumpTable(const JumpTable &JT, MCSection *HotSection,
813813
// determining its destination.
814814
std::map<MCSymbol *, uint64_t> LabelCounts;
815815
if (opts::JumpTables > JTS_SPLIT && !JT.Counts.empty()) {
816-
MCSymbol *CurrentLabel = JT.Labels.at(0);
816+
auto It = JT.Labels.find(0);
817+
assert(It != JT.Labels.end());
818+
MCSymbol *CurrentLabel = It->second;
817819
uint64_t CurrentLabelCount = 0;
818820
for (unsigned Index = 0; Index < JT.Entries.size(); ++Index) {
819821
auto LI = JT.Labels.find(Index * JT.EntrySize);

bolt/lib/Core/DynoStats.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ void DynoStats::print(raw_ostream &OS, const DynoStats *Other,
114114
for (auto &Stat : llvm::reverse(SortedHistogram)) {
115115
OS << format("%20s,%'18lld", Printer->getOpcodeName(Stat.second).data(),
116116
Stat.first * opts::DynoStatsScale);
117-
118-
MaxOpcodeHistogramTy MaxMultiMap = OpcodeHistogram.at(Stat.second).second;
117+
auto It = OpcodeHistogram.find(Stat.second);
118+
assert(It != OpcodeHistogram.end());
119+
MaxOpcodeHistogramTy MaxMultiMap = It->second.second;
119120
// Start with function name:BB offset with highest execution count.
120121
for (auto &Max : llvm::reverse(MaxMultiMap)) {
121122
OS << format(", %'18lld, ", Max.first * opts::DynoStatsScale)

bolt/lib/Passes/BinaryFunctionCallGraph.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ std::deque<BinaryFunction *> BinaryFunctionCallGraph::buildTraversalOrder() {
5656
std::stack<NodeId> Worklist;
5757

5858
for (BinaryFunction *Func : Funcs) {
59-
const NodeId Id = FuncToNodeId.at(Func);
59+
auto It = FuncToNodeId.find(Func);
60+
assert(It != FuncToNodeId.end());
61+
const NodeId Id = It->second;
6062
Worklist.push(Id);
6163
NodeStatus[Id] = NEW;
6264
}

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,23 +1563,28 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
15631563
const bool Ascending =
15641564
opts::DynoStatsSortOrderOpt == opts::DynoStatsSortOrder::Ascending;
15651565

1566-
if (SortAll) {
1567-
llvm::stable_sort(Functions,
1568-
[Ascending, &Stats](const BinaryFunction *A,
1569-
const BinaryFunction *B) {
1570-
return Ascending ? Stats.at(A) < Stats.at(B)
1571-
: Stats.at(B) < Stats.at(A);
1572-
});
1573-
} else {
1574-
llvm::stable_sort(
1575-
Functions, [Ascending, &Stats](const BinaryFunction *A,
1576-
const BinaryFunction *B) {
1577-
const DynoStats &StatsA = Stats.at(A);
1578-
const DynoStats &StatsB = Stats.at(B);
1579-
return Ascending ? StatsA.lessThan(StatsB, opts::PrintSortedBy)
1580-
: StatsB.lessThan(StatsA, opts::PrintSortedBy);
1581-
});
1582-
}
1566+
std::function<bool(const DynoStats &, const DynoStats &)>
1567+
DynoStatsComparator =
1568+
SortAll ? [](const DynoStats &StatsA,
1569+
const DynoStats &StatsB) { return StatsA < StatsB; }
1570+
: [](const DynoStats &StatsA, const DynoStats &StatsB) {
1571+
return StatsA.lessThan(StatsB, opts::PrintSortedBy);
1572+
};
1573+
1574+
llvm::stable_sort(Functions,
1575+
[Ascending, &Stats, DynoStatsComparator](
1576+
const BinaryFunction *A, const BinaryFunction *B) {
1577+
auto StatsItr = Stats.find(A);
1578+
assert(StatsItr != Stats.end());
1579+
const DynoStats &StatsA = StatsItr->second;
1580+
1581+
StatsItr = Stats.find(B);
1582+
assert(StatsItr != Stats.end());
1583+
const DynoStats &StatsB = StatsItr->second;
1584+
1585+
return Ascending ? DynoStatsComparator(StatsA, StatsB)
1586+
: DynoStatsComparator(StatsB, StatsA);
1587+
});
15831588

15841589
BC.outs() << "BOLT-INFO: top functions sorted by ";
15851590
if (SortAll) {

bolt/lib/Passes/CacheMetrics.cpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,20 @@ calcTSPScore(const std::vector<BinaryFunction *> &BinaryFunctions,
6767
for (BinaryBasicBlock *DstBB : SrcBB->successors()) {
6868
if (SrcBB != DstBB && BI->Count != BinaryBasicBlock::COUNT_NO_PROFILE) {
6969
JumpCount += BI->Count;
70-
if (BBAddr.at(SrcBB) + BBSize.at(SrcBB) == BBAddr.at(DstBB))
70+
71+
auto BBAddrIt = BBAddr.find(SrcBB);
72+
assert(BBAddrIt != BBAddr.end());
73+
uint64_t SrcBBAddr = BBAddrIt->second;
74+
75+
auto BBSizeIt = BBSize.find(SrcBB);
76+
assert(BBSizeIt != BBSize.end());
77+
uint64_t SrcBBSize = BBSizeIt->second;
78+
79+
BBAddrIt = BBAddr.find(DstBB);
80+
assert(BBAddrIt != BBAddr.end());
81+
uint64_t DstBBAddr = BBAddrIt->second;
82+
83+
if (SrcBBAddr + SrcBBSize == DstBBAddr)
7184
Score += BI->Count;
7285
}
7386
++BI;
@@ -149,29 +162,39 @@ double expectedCacheHitRatio(
149162
for (BinaryFunction *BF : BinaryFunctions) {
150163
if (BF->getLayout().block_empty())
151164
continue;
152-
const uint64_t Page =
153-
BBAddr.at(BF->getLayout().block_front()) / ITLBPageSize;
154-
PageSamples[Page] += FunctionSamples.at(BF);
165+
auto BBAddrIt = BBAddr.find(BF->getLayout().block_front());
166+
assert(BBAddrIt != BBAddr.end());
167+
const uint64_t Page = BBAddrIt->second / ITLBPageSize;
168+
169+
auto FunctionSamplesIt = FunctionSamples.find(BF);
170+
assert(FunctionSamplesIt != FunctionSamples.end());
171+
PageSamples[Page] += FunctionSamplesIt->second;
155172
}
156173

157174
// Computing the expected number of misses for every function
158175
double Misses = 0;
159176
for (BinaryFunction *BF : BinaryFunctions) {
160177
// Skip the function if it has no samples
161-
if (BF->getLayout().block_empty() || FunctionSamples.at(BF) == 0.0)
178+
auto FunctionSamplesIt = FunctionSamples.find(BF);
179+
assert(FunctionSamplesIt != FunctionSamples.end());
180+
double Samples = FunctionSamplesIt->second;
181+
if (BF->getLayout().block_empty() || Samples == 0.0)
162182
continue;
163-
double Samples = FunctionSamples.at(BF);
164-
const uint64_t Page =
165-
BBAddr.at(BF->getLayout().block_front()) / ITLBPageSize;
183+
184+
auto BBAddrIt = BBAddr.find(BF->getLayout().block_front());
185+
assert(BBAddrIt != BBAddr.end());
186+
const uint64_t Page = BBAddrIt->second / ITLBPageSize;
166187
// The probability that the page is not present in the cache
167188
const double MissProb =
168189
pow(1.0 - PageSamples[Page] / TotalSamples, ITLBEntries);
169190

170191
// Processing all callers of the function
171192
for (std::pair<BinaryFunction *, uint64_t> Pair : Calls[BF]) {
172193
BinaryFunction *SrcFunction = Pair.first;
173-
const uint64_t SrcPage =
174-
BBAddr.at(SrcFunction->getLayout().block_front()) / ITLBPageSize;
194+
195+
BBAddrIt = BBAddr.find(SrcFunction->getLayout().block_front());
196+
assert(BBAddrIt != BBAddr.end());
197+
const uint64_t SrcPage = BBAddrIt->second / ITLBPageSize;
175198
// Is this a 'long' or a 'short' call?
176199
if (Page != SrcPage) {
177200
// This is a miss

bolt/lib/Passes/Inliner.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ Inliner::inlineCall(BinaryBasicBlock &CallerBB,
355355
std::vector<BinaryBasicBlock *> Successors(BB.succ_size());
356356
llvm::transform(BB.successors(), Successors.begin(),
357357
[&InlinedBBMap](const BinaryBasicBlock *BB) {
358-
return InlinedBBMap.at(BB);
358+
auto It = InlinedBBMap.find(BB);
359+
assert(It != InlinedBBMap.end());
360+
return It->second;
359361
});
360362

361363
if (CallerFunction.hasValidProfile() && Callee.hasValidProfile())

bolt/lib/Passes/MCF.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,10 @@ namespace opts {
2929

3030
extern cl::OptionCategory BoltOptCategory;
3131

32-
extern cl::opt<bool> TimeOpts;
33-
3432
static cl::opt<bool> IterativeGuess(
3533
"iterative-guess",
3634
cl::desc("in non-LBR mode, guess edge counts using iterative technique"),
3735
cl::Hidden, cl::cat(BoltOptCategory));
38-
39-
static cl::opt<bool> UseRArcs(
40-
"mcf-use-rarcs",
41-
cl::desc("in MCF, consider the possibility of cancelling flow to balance "
42-
"edges"),
43-
cl::Hidden, cl::cat(BoltOptCategory));
44-
4536
} // namespace opts
4637

4738
namespace llvm {
@@ -462,9 +453,5 @@ void estimateEdgeCounts(BinaryFunction &BF) {
462453
recalculateBBCounts(BF, /*AllEdges=*/false);
463454
}
464455

465-
void solveMCF(BinaryFunction &BF, MCFCostFunction CostFunction) {
466-
llvm_unreachable("not implemented");
467-
}
468-
469456
} // namespace bolt
470457
} // namespace llvm

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,6 @@ BoltAddressTranslation::getFallthroughsInTrace(uint64_t FuncAddress,
547547
return Res;
548548
}
549549

550-
uint64_t BoltAddressTranslation::fetchParentAddress(uint64_t Address) const {
551-
auto Iter = ColdPartSource.find(Address);
552-
if (Iter == ColdPartSource.end())
553-
return 0;
554-
return Iter->second;
555-
}
556-
557550
bool BoltAddressTranslation::enabledFor(
558551
llvm::object::ELFObjectFileBase *InputFile) const {
559552
for (const SectionRef &Section : InputFile->sections()) {

bolt/lib/Profile/StaleProfileMatching.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType &BlockOrder) {
372372

373373
// Create necessary metadata for the flow function
374374
for (FlowJump &Jump : Func.Jumps) {
375-
Func.Blocks.at(Jump.Source).SuccJumps.push_back(&Jump);
376-
Func.Blocks.at(Jump.Target).PredJumps.push_back(&Jump);
375+
assert(Jump.Source < Func.Blocks.size());
376+
Func.Blocks[Jump.Source].SuccJumps.push_back(&Jump);
377+
assert(Jump.Target < Func.Blocks.size());
378+
Func.Blocks[Jump.Target].PredJumps.push_back(&Jump);
377379
}
378380
return Func;
379381
}

clang-tools-extra/clangd/Hover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ fetchTemplateParameters(const TemplateParameterList *Params,
262262
if (NTTP->hasDefaultArgument()) {
263263
P.Default.emplace();
264264
llvm::raw_string_ostream Out(*P.Default);
265-
NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP);
265+
NTTP->getDefaultArgument().getArgument().print(PP, Out,
266+
/*IncludeType=*/false);
266267
}
267268
} else if (const auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
268269
P.Type = printType(TTPD, PP);

clang/docs/ReleaseNotes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ C++ Specific Potentially Breaking Changes
5959
- Clang now performs semantic analysis for unary operators with dependent operands
6060
that are known to be of non-class non-enumeration type prior to instantiation.
6161

62+
This change uncovered a bug in libstdc++ 14.1.0 which may cause compile failures
63+
on systems using that version of libstdc++ and Clang 19, with an error that looks
64+
something like this:
65+
66+
.. code-block:: text
67+
68+
<source>:4:5: error: expression is not assignable
69+
4 | ++this;
70+
| ^ ~~~~
71+
72+
To fix this, update libstdc++ to version 14.1.1 or greater.
73+
6274
ABI Changes in This Version
6375
---------------------------
6476
- Fixed Microsoft name mangling of implicitly defined variables used for thread
@@ -766,6 +778,7 @@ Miscellaneous Bug Fixes
766778

767779
- Fixed an infinite recursion in ASTImporter, on return type declared inside
768780
body of C++11 lambda without trailing return (#GH68775).
781+
- Fixed declaration name source location of instantiated function definitions (GH71161).
769782

770783
Miscellaneous Clang Crashes Fixed
771784
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,9 @@ class ASTNodeTraverser
704704
if (const auto *E = D->getPlaceholderTypeConstraint())
705705
Visit(E);
706706
if (D->hasDefaultArgument())
707-
Visit(D->getDefaultArgument(), SourceRange(),
708-
D->getDefaultArgStorage().getInheritedFrom(),
709-
D->defaultArgumentWasInherited() ? "inherited from" : "previous");
707+
dumpTemplateArgumentLoc(
708+
D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(),
709+
D->defaultArgumentWasInherited() ? "inherited from" : "previous");
710710
}
711711

712712
void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) {

clang/include/clang/AST/Decl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,8 @@ class FunctionDecl : public DeclaratorDecl,
21882188

21892189
void setRangeEnd(SourceLocation E) { EndRangeLoc = E; }
21902190

2191+
void setDeclarationNameLoc(DeclarationNameLoc L) { DNLoc = L; }
2192+
21912193
/// Returns the location of the ellipsis of a variadic function.
21922194
SourceLocation getEllipsisLoc() const {
21932195
const auto *FPT = getType()->getAs<FunctionProtoType>();

clang/include/clang/AST/DeclTemplate.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,8 @@ class NonTypeTemplateParmDecl final
13601360

13611361
/// The default template argument, if any, and whether or not
13621362
/// it was inherited.
1363-
using DefArgStorage = DefaultArgStorage<NonTypeTemplateParmDecl, Expr *>;
1363+
using DefArgStorage =
1364+
DefaultArgStorage<NonTypeTemplateParmDecl, TemplateArgumentLoc *>;
13641365
DefArgStorage DefaultArgument;
13651366

13661367
// FIXME: Collapse this into TemplateParamPosition; or, just move depth/index
@@ -1430,7 +1431,10 @@ class NonTypeTemplateParmDecl final
14301431
bool hasDefaultArgument() const { return DefaultArgument.isSet(); }
14311432

14321433
/// Retrieve the default argument, if any.
1433-
Expr *getDefaultArgument() const { return DefaultArgument.get(); }
1434+
const TemplateArgumentLoc &getDefaultArgument() const {
1435+
static const TemplateArgumentLoc NoneLoc;
1436+
return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc;
1437+
}
14341438

14351439
/// Retrieve the location of the default argument, if any.
14361440
SourceLocation getDefaultArgumentLoc() const;
@@ -1444,7 +1448,8 @@ class NonTypeTemplateParmDecl final
14441448
/// Set the default argument for this template parameter, and
14451449
/// whether that default argument was inherited from another
14461450
/// declaration.
1447-
void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); }
1451+
void setDefaultArgument(const ASTContext &C,
1452+
const TemplateArgumentLoc &DefArg);
14481453
void setInheritedDefaultArgument(const ASTContext &C,
14491454
NonTypeTemplateParmDecl *Parm) {
14501455
DefaultArgument.setInherited(C, Parm);

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ DEF_TRAVERSE_DECL(NonTypeTemplateParmDecl, {
23202320
// A non-type template parameter, e.g. "S" in template<int S> class Foo ...
23212321
TRY_TO(TraverseDeclaratorHelper(D));
23222322
if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2323-
TRY_TO(TraverseStmt(D->getDefaultArgument()));
2323+
TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
23242324
})
23252325

23262326
DEF_TRAVERSE_DECL(ParmVarDecl, {

0 commit comments

Comments
 (0)