Skip to content

Commit 6909f94

Browse files
committed
Merge from 'main' to 'sycl-web' (42 commits)
CONFLICT (content): Merge conflict in clang/lib/Serialization/ASTReaderStmt.cpp
2 parents 13349d4 + 2ce9a79 commit 6909f94

File tree

144 files changed

+4938
-797
lines changed

Some content is hidden

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

144 files changed

+4938
-797
lines changed

bolt/lib/Passes/LongJmp.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,23 @@ LongJmpPass::replaceTargetWithStub(BinaryBasicBlock &BB, MCInst &Inst,
202202
}
203203
} else if (LocalStubsIter != Stubs.end() &&
204204
LocalStubsIter->second.count(TgtBB)) {
205-
// If we are replacing a local stub (because it is now out of range),
206-
// use its target instead of creating a stub to jump to another stub
205+
// The TgtBB and TgtSym now are the local out-of-range stub and its label.
206+
// So, we are attempting to restore BB to its previous state without using
207+
// this stub.
207208
TgtSym = BC.MIB->getTargetSymbol(*TgtBB->begin());
208-
TgtBB = BB.getSuccessor(TgtSym, BI);
209+
assert(TgtSym &&
210+
"First instruction is expected to contain a target symbol.");
211+
BinaryBasicBlock *TgtBBSucc = TgtBB->getSuccessor(TgtSym, BI);
212+
213+
// TgtBB might have no successor. e.g. a stub for a function call.
214+
if (TgtBBSucc) {
215+
BB.replaceSuccessor(TgtBB, TgtBBSucc, BI.Count, BI.MispredictedCount);
216+
assert(TgtBB->getExecutionCount() >= BI.Count &&
217+
"At least equal or greater than the branch count.");
218+
TgtBB->setExecutionCount(TgtBB->getExecutionCount() - BI.Count);
219+
}
220+
221+
TgtBB = TgtBBSucc;
209222
}
210223

211224
BinaryBasicBlock *StubBB = lookupLocalStub(BB, Inst, TgtSym, DotAddress);

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ class HighlightingsBuilder {
418418
public:
419419
HighlightingsBuilder(const ParsedAST &AST, const HighlightingFilter &Filter)
420420
: TB(AST.getTokens()), SourceMgr(AST.getSourceManager()),
421-
LangOpts(AST.getLangOpts()), Filter(Filter) {}
421+
LangOpts(AST.getLangOpts()), Filter(Filter),
422+
Resolver(AST.getHeuristicResolver()) {}
422423

423424
HighlightingToken &addToken(SourceLocation Loc, HighlightingKind Kind) {
424425
auto Range = getRangeForSourceLocation(Loc);
@@ -589,7 +590,7 @@ class HighlightingsBuilder {
589590
HighlightingFilter Filter;
590591
std::vector<HighlightingToken> Tokens;
591592
std::map<Range, llvm::SmallVector<HighlightingModifier, 1>> ExtraModifiers;
592-
const HeuristicResolver *Resolver = nullptr;
593+
const HeuristicResolver *Resolver;
593594
// returned from addToken(InvalidLoc)
594595
HighlightingToken InvalidHighlightingToken;
595596
};

clang/include/clang/Serialization/ASTReader.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,12 +2415,7 @@ class BitsUnpacker {
24152415
BitsUnpacker(BitsUnpacker &&) = delete;
24162416
BitsUnpacker operator=(const BitsUnpacker &) = delete;
24172417
BitsUnpacker operator=(BitsUnpacker &&) = delete;
2418-
~BitsUnpacker() {
2419-
#ifndef NDEBUG
2420-
while (isValid())
2421-
assert(!getNextBit() && "There are unprocessed bits!");
2422-
#endif
2423-
}
2418+
~BitsUnpacker() = default;
24242419

24252420
void updateValue(uint32_t V) {
24262421
Value = V;

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,50 @@ static const char *const DataLayoutStringAMDGCN =
3737
"-ni:7:8";
3838

3939
const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
40-
Generic, // Default
41-
Global, // opencl_global
42-
Local, // opencl_local
43-
Constant, // opencl_constant
44-
Private, // opencl_private
45-
Generic, // opencl_generic
46-
Global, // opencl_global_device
47-
Global, // opencl_global_host
48-
Global, // cuda_device
49-
Constant, // cuda_constant
50-
Local, // cuda_shared
51-
Global, // sycl_global
52-
Global, // sycl_global_device
53-
Global, // sycl_global_host
54-
Local, // sycl_local
55-
Private, // sycl_private
56-
Generic, // ptr32_sptr
57-
Generic, // ptr32_uptr
58-
Generic, // ptr64
59-
Generic, // hlsl_groupshared
40+
llvm::AMDGPUAS::FLAT_ADDRESS, // Default
41+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // opencl_global
42+
llvm::AMDGPUAS::LOCAL_ADDRESS, // opencl_local
43+
llvm::AMDGPUAS::CONSTANT_ADDRESS, // opencl_constant
44+
llvm::AMDGPUAS::PRIVATE_ADDRESS, // opencl_private
45+
llvm::AMDGPUAS::FLAT_ADDRESS, // opencl_generic
46+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // opencl_global_device
47+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // opencl_global_host
48+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // cuda_device
49+
llvm::AMDGPUAS::CONSTANT_ADDRESS, // cuda_constant
50+
llvm::AMDGPUAS::LOCAL_ADDRESS, // cuda_shared
51+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // sycl_global
52+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // sycl_global_device
53+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // sycl_global_host
54+
llvm::AMDGPUAS::LOCAL_ADDRESS, // sycl_local
55+
llvm::AMDGPUAS::PRIVATE_ADDRESS, // sycl_private
56+
llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_sptr
57+
llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_uptr
58+
llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
59+
llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
6060
};
6161

6262
const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
63-
Private, // Default
64-
Global, // opencl_global
65-
Local, // opencl_local
66-
Constant, // opencl_constant
67-
Private, // opencl_private
68-
Generic, // opencl_generic
69-
Global, // opencl_global_device
70-
Global, // opencl_global_host
71-
Global, // cuda_device
72-
Constant, // cuda_constant
73-
Local, // cuda_shared
63+
llvm::AMDGPUAS::PRIVATE_ADDRESS, // Default
64+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // opencl_global
65+
llvm::AMDGPUAS::LOCAL_ADDRESS, // opencl_local
66+
llvm::AMDGPUAS::CONSTANT_ADDRESS, // opencl_constant
67+
llvm::AMDGPUAS::PRIVATE_ADDRESS, // opencl_private
68+
llvm::AMDGPUAS::FLAT_ADDRESS, // opencl_generic
69+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // opencl_global_device
70+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // opencl_global_host
71+
llvm::AMDGPUAS::GLOBAL_ADDRESS, // cuda_device
72+
llvm::AMDGPUAS::CONSTANT_ADDRESS, // cuda_constant
73+
llvm::AMDGPUAS::LOCAL_ADDRESS, // cuda_shared
7474
// SYCL address space values for this map are dummy
75-
Generic, // sycl_global
76-
Generic, // sycl_global_device
77-
Generic, // sycl_global_host
78-
Generic, // sycl_local
79-
Generic, // sycl_private
80-
Generic, // ptr32_sptr
81-
Generic, // ptr32_uptr
82-
Generic, // ptr64
83-
Generic, // hlsl_groupshared
75+
llvm::AMDGPUAS::FLAT_ADDRESS, // sycl_global
76+
llvm::AMDGPUAS::FLAT_ADDRESS, // sycl_global_device
77+
llvm::AMDGPUAS::FLAT_ADDRESS, // sycl_global_host
78+
llvm::AMDGPUAS::FLAT_ADDRESS, // sycl_local
79+
llvm::AMDGPUAS::FLAT_ADDRESS, // sycl_private
80+
llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_sptr
81+
llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_uptr
82+
llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
83+
llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
8484

8585
};
8686
} // namespace targets

clang/lib/Basic/Targets/AMDGPU.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "clang/Basic/TargetInfo.h"
1818
#include "clang/Basic/TargetOptions.h"
1919
#include "llvm/ADT/StringSet.h"
20+
#include "llvm/Support/AMDGPUAddrSpace.h"
2021
#include "llvm/Support/Compiler.h"
2122
#include "llvm/TargetParser/TargetParser.h"
2223
#include "llvm/TargetParser/Triple.h"
@@ -29,13 +30,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
2930

3031
static const char *const GCCRegNames[];
3132

32-
enum AddrSpace {
33-
Generic = 0,
34-
Global = 1,
35-
Local = 3,
36-
Constant = 4,
37-
Private = 5
38-
};
3933
static const LangASMap AMDGPUDefIsGenMap;
4034
static const LangASMap AMDGPUDefIsPrivMap;
4135

@@ -106,7 +100,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
106100
return 32;
107101
unsigned TargetAS = getTargetAddressSpace(AS);
108102

109-
if (TargetAS == Private || TargetAS == Local)
103+
if (TargetAS == llvm::AMDGPUAS::PRIVATE_ADDRESS ||
104+
TargetAS == llvm::AMDGPUAS::LOCAL_ADDRESS)
110105
return 32;
111106

112107
return 64;
@@ -378,7 +373,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
378373
}
379374

380375
std::optional<LangAS> getConstantAddressSpace() const override {
381-
return getLangASFromTargetAS(Constant);
376+
return getLangASFromTargetAS(llvm::AMDGPUAS::CONSTANT_ADDRESS);
382377
}
383378

384379
const llvm::omp::GV &getGridValue() const override {
@@ -394,7 +389,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
394389

395390
/// \returns Target specific vtbl ptr address space.
396391
unsigned getVtblPtrAddressSpace() const override {
397-
return static_cast<unsigned>(Constant);
392+
return static_cast<unsigned>(llvm::AMDGPUAS::CONSTANT_ADDRESS);
398393
}
399394

400395
/// \returns If a target requires an address within a target specific address
@@ -407,9 +402,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
407402
getDWARFAddressSpace(unsigned AddressSpace) const override {
408403
const unsigned DWARF_Private = 1;
409404
const unsigned DWARF_Local = 2;
410-
if (AddressSpace == Private) {
405+
if (AddressSpace == llvm::AMDGPUAS::PRIVATE_ADDRESS) {
411406
return DWARF_Private;
412-
} else if (AddressSpace == Local) {
407+
} else if (AddressSpace == llvm::AMDGPUAS::LOCAL_ADDRESS) {
413408
return DWARF_Local;
414409
} else {
415410
return std::nullopt;

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
10451045
getInstrProfOptions(CodeGenOpts, LangOpts))
10461046
PB.registerPipelineStartEPCallback(
10471047
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
1048-
MPM.addPass(InstrProfiling(*Options, false));
1048+
MPM.addPass(InstrProfilingLoweringPass(*Options, false));
10491049
});
10501050

10511051
// TODO: Consider passing the MemoryProfileOutput to the pass builder via

clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "llvm/Support/AlignOf.h"
1515
#include "llvm/Support/Errno.h"
1616
#include "llvm/Support/Error.h"
17-
#include "llvm/Support/MathExtras.h"
1817
#include "llvm/Support/Path.h"
1918
#include <atomic>
2019
#include <condition_variable>
@@ -25,6 +24,7 @@
2524
#include <vector>
2625

2726
#include <fcntl.h>
27+
#include <limits.h>
2828
#include <optional>
2929
#include <sys/epoll.h>
3030
#include <sys/inotify.h>

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ void ASTDeclReader::Visit(Decl *D) {
583583
}
584584

585585
void ASTDeclReader::VisitDecl(Decl *D) {
586+
BitsUnpacker DeclBits(Record.readInt());
587+
bool HasStandaloneLexicalDC = DeclBits.getNextBit();
588+
586589
if (D->isTemplateParameter() || D->isTemplateParameterPack() ||
587590
isa<ParmVarDecl, ObjCTypeParamDecl>(D)) {
588591
// We don't want to deserialize the DeclContext of a template
@@ -592,7 +595,8 @@ void ASTDeclReader::VisitDecl(Decl *D) {
592595
// return type of the function). Use the translation unit DeclContext as a
593596
// placeholder.
594597
GlobalDeclID SemaDCIDForTemplateParmDecl = readDeclID();
595-
GlobalDeclID LexicalDCIDForTemplateParmDecl = readDeclID();
598+
GlobalDeclID LexicalDCIDForTemplateParmDecl =
599+
HasStandaloneLexicalDC ? readDeclID() : 0;
596600
if (!LexicalDCIDForTemplateParmDecl)
597601
LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl;
598602
Reader.addPendingDeclContextInfo(D,
@@ -601,7 +605,8 @@ void ASTDeclReader::VisitDecl(Decl *D) {
601605
D->setDeclContext(Reader.getContext().getTranslationUnitDecl());
602606
} else {
603607
auto *SemaDC = readDeclAs<DeclContext>();
604-
auto *LexicalDC = readDeclAs<DeclContext>();
608+
auto *LexicalDC =
609+
HasStandaloneLexicalDC ? readDeclAs<DeclContext>() : nullptr;
605610
if (!LexicalDC)
606611
LexicalDC = SemaDC;
607612
// If the context is a class, we might not have actually merged it yet, in
@@ -618,7 +623,6 @@ void ASTDeclReader::VisitDecl(Decl *D) {
618623
}
619624
D->setLocation(ThisDeclLoc);
620625

621-
BitsUnpacker DeclBits(Record.readInt());
622626
D->InvalidDecl = DeclBits.getNextBit();
623627
bool HasAttrs = DeclBits.getNextBit();
624628
D->setImplicit(DeclBits.getNextBit());
@@ -765,7 +769,7 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) {
765769
TD->setCompleteDefinitionRequired(TagDeclBits.getNextBit());
766770
TD->setBraceRange(readSourceRange());
767771

768-
switch (Record.readInt()) {
772+
switch (TagDeclBits.getNextBits(/*Width=*/2)) {
769773
case 0:
770774
break;
771775
case 1: { // ExtInfo
@@ -1089,7 +1093,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
10891093
FD->setCachedLinkage((Linkage)FunctionDeclBits.getNextBits(/*Width=*/3));
10901094

10911095
FD->EndRangeLoc = readSourceLocation();
1092-
FD->setDefaultLoc(readSourceLocation());
1096+
if (FD->isExplicitlyDefaulted())
1097+
FD->setDefaultLoc(readSourceLocation());
10931098

10941099
FD->ODRHash = Record.readInt();
10951100
FD->setHasODRHash(true);
@@ -1703,7 +1708,7 @@ void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
17031708
unsigned isObjCMethodParam = ParmVarDeclBits.getNextBit();
17041709
unsigned scopeDepth = ParmVarDeclBits.getNextBits(/*Width=*/7);
17051710
unsigned scopeIndex = ParmVarDeclBits.getNextBits(/*Width=*/8);
1706-
unsigned declQualifier = Record.readInt();
1711+
unsigned declQualifier = ParmVarDeclBits.getNextBits(/*Width=*/7);
17071712
if (isObjCMethodParam) {
17081713
assert(scopeDepth == 0);
17091714
PD->setObjCMethodScopeInfo(scopeIndex);
@@ -1716,7 +1721,9 @@ void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
17161721
PD->ParmVarDeclBits.HasInheritedDefaultArg = ParmVarDeclBits.getNextBit();
17171722
if (ParmVarDeclBits.getNextBit()) // hasUninstantiatedDefaultArg.
17181723
PD->setUninstantiatedDefaultArg(Record.readExpr());
1719-
PD->ExplicitObjectParameterIntroducerLoc = Record.readSourceLocation();
1724+
1725+
if (ParmVarDeclBits.getNextBit()) // Valid explicit object parameter
1726+
PD->ExplicitObjectParameterIntroducerLoc = Record.readSourceLocation();
17201727

17211728
// FIXME: If this is a redeclaration of a function from another module, handle
17221729
// inheritance of default arguments.

0 commit comments

Comments
 (0)