Skip to content

Commit 2c923a1

Browse files
committed
merge main into amd-staging
Reverts: breaks taretid_multi_image 374f655 [OpenMP] Fix passing target id features to AMDGPU offloading (llvm#94765) Change-Id: I5f56fd191a6cb0e399157bd868fd4d473683254a
2 parents 91d7d4e + 75b89cc commit 2c923a1

File tree

285 files changed

+9766
-3944
lines changed

Some content is hidden

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

285 files changed

+9766
-3944
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,12 +1706,9 @@ class MCPlusBuilder {
17061706
}
17071707

17081708
/// Reverses the branch condition in Inst and update its taken target to TBB.
1709-
///
1710-
/// Returns true on success.
1711-
virtual bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
1709+
virtual void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
17121710
MCContext *Ctx) const {
17131711
llvm_unreachable("not implemented");
1714-
return false;
17151712
}
17161713

17171714
virtual bool replaceBranchCondition(MCInst &Inst, const MCSymbol *TBB,
@@ -1751,12 +1748,9 @@ class MCPlusBuilder {
17511748
}
17521749

17531750
/// Sets the taken target of the branch instruction to Target.
1754-
///
1755-
/// Returns true on success.
1756-
virtual bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
1751+
virtual void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
17571752
MCContext *Ctx) const {
17581753
llvm_unreachable("not implemented");
1759-
return false;
17601754
}
17611755

17621756
/// Extract a symbol and an addend out of the fixup value expression.

bolt/lib/Passes/VeneerElimination.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
7777
continue;
7878

7979
VeneerCallers++;
80-
if (!BC.MIB->replaceBranchTarget(
81-
Instr, VeneerDestinations[TargetSymbol], BC.Ctx.get())) {
82-
return createFatalBOLTError(
83-
"BOLT-ERROR: updating veneer call destination failed\n");
84-
}
80+
BC.MIB->replaceBranchTarget(Instr, VeneerDestinations[TargetSymbol],
81+
BC.Ctx.get());
8582
}
8683
}
8784
}

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
616616
return getTargetAddend(Op.getExpr());
617617
}
618618

619-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
619+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
620620
MCContext *Ctx) const override {
621621
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
622622
"Invalid instruction");
@@ -638,7 +638,6 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
638638

639639
*OI = MCOperand::createExpr(
640640
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
641-
return true;
642641
}
643642

644643
/// Matches indirect branch patterns in AArch64 related to a jump table (JT),
@@ -969,7 +968,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
969968
}
970969
}
971970

972-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
971+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
973972
MCContext *Ctx) const override {
974973
if (isTB(Inst) || isCB(Inst)) {
975974
Inst.setOpcode(getInvertedBranchOpcode(Inst.getOpcode()));
@@ -984,7 +983,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
984983
LLVM_DEBUG(Inst.dump());
985984
llvm_unreachable("Unrecognized branch instruction");
986985
}
987-
return replaceBranchTarget(Inst, TBB, Ctx);
986+
replaceBranchTarget(Inst, TBB, Ctx);
988987
}
989988

990989
int getPCRelEncodingSize(const MCInst &Inst) const override {

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
151151
}
152152
}
153153

154-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
154+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
155155
MCContext *Ctx) const override {
156156
auto Opcode = getInvertedBranchOpcode(Inst.getOpcode());
157157
Inst.setOpcode(Opcode);
158-
return replaceBranchTarget(Inst, TBB, Ctx);
158+
replaceBranchTarget(Inst, TBB, Ctx);
159159
}
160160

161-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
161+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
162162
MCContext *Ctx) const override {
163163
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
164164
"Invalid instruction");
@@ -170,7 +170,6 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
170170

171171
Inst.getOperand(SymOpIndex) = MCOperand::createExpr(
172172
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
173-
return true;
174173
}
175174

176175
IndirectBranchType analyzeIndirectBranch(

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,14 +2794,13 @@ class X86MCPlusBuilder : public MCPlusBuilder {
27942794
Inst.addOperand(MCOperand::createImm(CC));
27952795
}
27962796

2797-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
2797+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
27982798
MCContext *Ctx) const override {
27992799
unsigned InvCC = getInvertedCondCode(getCondCode(Inst));
28002800
assert(InvCC != X86::COND_INVALID && "invalid branch instruction");
28012801
Inst.getOperand(Info->get(Inst.getOpcode()).NumOperands - 1).setImm(InvCC);
28022802
Inst.getOperand(0) = MCOperand::createExpr(
28032803
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
2804-
return true;
28052804
}
28062805

28072806
bool replaceBranchCondition(MCInst &Inst, const MCSymbol *TBB, MCContext *Ctx,
@@ -2844,13 +2843,12 @@ class X86MCPlusBuilder : public MCPlusBuilder {
28442843
}
28452844
}
28462845

2847-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
2846+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
28482847
MCContext *Ctx) const override {
28492848
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
28502849
"Invalid instruction");
28512850
Inst.getOperand(0) = MCOperand::createExpr(
28522851
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
2853-
return true;
28542852
}
28552853

28562854
MCPhysReg getX86R11() const override { return X86::R11; }

clang/include/clang/AST/ASTUnresolvedSet.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "clang/AST/ASTVector.h"
1818
#include "clang/AST/DeclAccessPair.h"
19+
#include "clang/AST/DeclID.h"
1920
#include "clang/AST/UnresolvedSet.h"
2021
#include "clang/Basic/Specifiers.h"
2122
#include <cassert>
@@ -56,6 +57,10 @@ class ASTUnresolvedSet {
5657
Decls.push_back(DeclAccessPair::make(D, AS), C);
5758
}
5859

60+
void addLazyDecl(ASTContext &C, GlobalDeclID ID, AccessSpecifier AS) {
61+
Decls.push_back(DeclAccessPair::makeLazy(ID.get(), AS), C);
62+
}
63+
5964
/// Replaces the given declaration with the new one, once.
6065
///
6166
/// \return true if the set changed
@@ -109,10 +114,10 @@ class LazyASTUnresolvedSet {
109114

110115
void reserve(ASTContext &C, unsigned N) { Impl.reserve(C, N); }
111116

112-
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS) {
117+
void addLazyDecl(ASTContext &C, GlobalDeclID ID, AccessSpecifier AS) {
113118
assert(Impl.empty() || Impl.Decls.isLazy());
114119
Impl.Decls.setLazy(true);
115-
Impl.addDecl(C, reinterpret_cast<NamedDecl *>(ID << 2), AS);
120+
Impl.addLazyDecl(C, ID, AS);
116121
}
117122
};
118123

clang/include/clang/AST/DeclAccessPair.h

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "clang/Basic/Specifiers.h"
2121
#include "llvm/Support/DataTypes.h"
22+
#include "llvm/Support/Endian.h"
2223

2324
namespace clang {
2425

@@ -27,9 +28,17 @@ class NamedDecl;
2728
/// A POD class for pairing a NamedDecl* with an access specifier.
2829
/// Can be put into unions.
2930
class DeclAccessPair {
30-
uintptr_t Ptr; // we'd use llvm::PointerUnion, but it isn't trivial
31+
/// Use the lower 2 bit to store AccessSpecifier. Use the higher
32+
/// 61 bit to store the pointer to a NamedDecl or the DeclID to
33+
/// a NamedDecl. If the 3rd bit is set, storing the DeclID, otherwise
34+
/// storing the pointer.
35+
llvm::support::detail::packed_endian_specific_integral<
36+
uint64_t, llvm::endianness::native, alignof(void *)>
37+
Ptr;
3138

32-
enum { Mask = 0x3 };
39+
enum { ASMask = 0x3, Mask = 0x7 };
40+
41+
bool isDeclID() const { return (Ptr >> 2) & 0x1; }
3342

3443
public:
3544
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS) {
@@ -38,12 +47,22 @@ class DeclAccessPair {
3847
return p;
3948
}
4049

50+
static DeclAccessPair makeLazy(uint64_t ID, AccessSpecifier AS) {
51+
DeclAccessPair p;
52+
p.Ptr = (ID << 3) | (0x1 << 2) | uint64_t(AS);
53+
return p;
54+
}
55+
56+
uint64_t getDeclID() const {
57+
assert(isDeclID());
58+
return (~Mask & Ptr) >> 3;
59+
}
60+
4161
NamedDecl *getDecl() const {
62+
assert(!isDeclID());
4263
return reinterpret_cast<NamedDecl*>(~Mask & Ptr);
4364
}
44-
AccessSpecifier getAccess() const {
45-
return AccessSpecifier(Mask & Ptr);
46-
}
65+
AccessSpecifier getAccess() const { return AccessSpecifier(ASMask & Ptr); }
4766

4867
void setDecl(NamedDecl *D) {
4968
set(D, getAccess());
@@ -52,12 +71,18 @@ class DeclAccessPair {
5271
set(getDecl(), AS);
5372
}
5473
void set(NamedDecl *D, AccessSpecifier AS) {
55-
Ptr = uintptr_t(AS) | reinterpret_cast<uintptr_t>(D);
74+
Ptr = uint64_t(AS) | reinterpret_cast<uint64_t>(D);
5675
}
5776

5877
operator NamedDecl*() const { return getDecl(); }
5978
NamedDecl *operator->() const { return getDecl(); }
6079
};
80+
81+
// Make sure DeclAccessPair is pointer-aligned types.
82+
static_assert(alignof(DeclAccessPair) == alignof(void *));
83+
// Make sure DeclAccessPair is still POD.
84+
static_assert(std::is_standard_layout_v<DeclAccessPair> &&
85+
std::is_trivial_v<DeclAccessPair>);
6186
}
6287

6388
#endif

clang/include/clang/AST/DeclBase.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,7 @@ class alignas(8) Decl {
701701

702702
/// Set the owning module ID. This may only be called for
703703
/// deserialized Decls.
704-
void setOwningModuleID(unsigned ID) {
705-
assert(isFromASTFile() && "Only works on a deserialized declaration");
706-
*((unsigned*)this - 2) = ID;
707-
}
704+
void setOwningModuleID(unsigned ID);
708705

709706
public:
710707
/// Determine the availability of the given declaration.
@@ -777,19 +774,11 @@ class alignas(8) Decl {
777774

778775
/// Retrieve the global declaration ID associated with this
779776
/// declaration, which specifies where this Decl was loaded from.
780-
GlobalDeclID getGlobalID() const {
781-
if (isFromASTFile())
782-
return (*((const GlobalDeclID *)this - 1));
783-
return GlobalDeclID();
784-
}
777+
GlobalDeclID getGlobalID() const;
785778

786779
/// Retrieve the global ID of the module that owns this particular
787780
/// declaration.
788-
unsigned getOwningModuleID() const {
789-
if (isFromASTFile())
790-
return *((const unsigned*)this - 2);
791-
return 0;
792-
}
781+
unsigned getOwningModuleID() const;
793782

794783
private:
795784
Module *getOwningModuleSlow() const;

clang/include/clang/AST/DeclID.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "llvm/ADT/DenseMapInfo.h"
2020
#include "llvm/ADT/iterator.h"
2121

22+
#include <climits>
23+
2224
namespace clang {
2325

2426
/// Predefined declaration IDs.
@@ -107,12 +109,16 @@ class DeclIDBase {
107109
///
108110
/// DeclID should only be used directly in serialization. All other users
109111
/// should use LocalDeclID or GlobalDeclID.
110-
using DeclID = uint32_t;
112+
using DeclID = uint64_t;
111113

112114
protected:
113115
DeclIDBase() : ID(PREDEF_DECL_NULL_ID) {}
114116
explicit DeclIDBase(DeclID ID) : ID(ID) {}
115117

118+
explicit DeclIDBase(unsigned LocalID, unsigned ModuleFileIndex) {
119+
ID = (DeclID)LocalID | ((DeclID)ModuleFileIndex << 32);
120+
}
121+
116122
public:
117123
DeclID get() const { return ID; }
118124

@@ -124,6 +130,10 @@ class DeclIDBase {
124130

125131
bool isInvalid() const { return ID == PREDEF_DECL_NULL_ID; }
126132

133+
unsigned getModuleFileIndex() const { return ID >> 32; }
134+
135+
unsigned getLocalDeclIndex() const;
136+
127137
friend bool operator==(const DeclIDBase &LHS, const DeclIDBase &RHS) {
128138
return LHS.ID == RHS.ID;
129139
}
@@ -156,6 +166,9 @@ class LocalDeclID : public DeclIDBase {
156166
LocalDeclID(PredefinedDeclIDs ID) : Base(ID) {}
157167
explicit LocalDeclID(DeclID ID) : Base(ID) {}
158168

169+
explicit LocalDeclID(unsigned LocalID, unsigned ModuleFileIndex)
170+
: Base(LocalID, ModuleFileIndex) {}
171+
159172
LocalDeclID &operator++() {
160173
++ID;
161174
return *this;
@@ -175,6 +188,9 @@ class GlobalDeclID : public DeclIDBase {
175188
GlobalDeclID() : Base() {}
176189
explicit GlobalDeclID(DeclID ID) : Base(ID) {}
177190

191+
explicit GlobalDeclID(unsigned LocalID, unsigned ModuleFileIndex)
192+
: Base(LocalID, ModuleFileIndex) {}
193+
178194
// For DeclIDIterator<GlobalDeclID> to be able to convert a GlobalDeclID
179195
// to a LocalDeclID.
180196
explicit operator LocalDeclID() const { return LocalDeclID(this->ID); }

clang/include/clang/AST/UnresolvedSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class UnresolvedSetIterator : public llvm::iterator_adaptor_base<
4747
// temporaries with defaulted ctors are not zero initialized.
4848
UnresolvedSetIterator() : iterator_adaptor_base(nullptr) {}
4949

50+
uint64_t getDeclID() const { return I->getDeclID(); }
5051
NamedDecl *getDecl() const { return I->getDecl(); }
5152
void setDecl(NamedDecl *ND) const { return I->setDecl(ND); }
5253
AccessSpecifier getAccess() const { return I->getAccess(); }

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ def note_using_decl_class_member_workaround : Note<
607607
"a const variable|a constexpr variable}0 instead">;
608608
def err_using_decl_can_not_refer_to_namespace : Error<
609609
"using declaration cannot refer to a namespace">;
610+
def note_namespace_using_decl : Note<
611+
"did you mean 'using namespace'?">;
610612
def warn_cxx17_compat_using_decl_scoped_enumerator: Warning<
611613
"using declaration naming a scoped enumerator is incompatible with "
612614
"C++ standards before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore;
@@ -6088,9 +6090,9 @@ def err_redefinition_different_concept : Error<
60886090
"redefinition of concept %0 with different template parameters or requirements">;
60896091
def err_tag_reference_non_tag : Error<
60906092
"%select{non-struct type|non-class type|non-union type|non-enum "
6091-
"type|typedef|type alias|template|type alias template|template "
6092-
"template argument}1 %0 cannot be referenced with a "
6093-
"%select{struct|interface|union|class|enum}2 specifier">;
6093+
"type|typedef|type alias|template|alias template|template "
6094+
"template argument}1 %0 cannot be referenced with the '"
6095+
"%select{struct|interface|union|class|enum}2' specifier">;
60946096
def err_tag_reference_conflict : Error<
60956097
"implicit declaration introduced by elaborated type conflicts with a "
60966098
"%select{non-struct type|non-class type|non-union type|non-enum "

clang/include/clang/Driver/ToolChain.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ class ToolChain {
212212

213213
/// Executes the given \p Executable and returns the stdout.
214214
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
215-
executeToolChainProgram(StringRef Executable) const;
215+
executeToolChainProgram(StringRef Executable,
216+
unsigned SecondsToWait = 0) const;
216217

217218
void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
218219

0 commit comments

Comments
 (0)