Skip to content

Commit cef1d4a

Browse files
authored
merge main into amd-staging (#685)
2 parents 1423ed0 + 4b512b4 commit cef1d4a

File tree

259 files changed

+17947
-2601
lines changed

Some content is hidden

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

259 files changed

+17947
-2601
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,20 @@ class MCPlusBuilder {
18691869
llvm_unreachable("not implemented");
18701870
}
18711871

1872+
/// Check if an Instruction is a BTI landing pad with the required properties.
1873+
/// Takes both explicit and implicit BTIs into account.
1874+
virtual bool isBTILandingPad(MCInst &Inst, bool CallTarget,
1875+
bool JumpTarget) const {
1876+
llvm_unreachable("not implemented");
1877+
return false;
1878+
}
1879+
1880+
/// Check if an Instruction is an implicit BTI c landing pad.
1881+
virtual bool isImplicitBTIC(MCInst &Inst) const {
1882+
llvm_unreachable("not implemented");
1883+
return false;
1884+
}
1885+
18721886
/// Create a BTI landing pad instruction.
18731887
virtual void createBTI(MCInst &Inst, bool CallTarget, bool JumpTarget) const {
18741888
llvm_unreachable("not implemented");

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,24 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
27822782
Inst.addOperand(MCOperand::createImm(HintNum));
27832783
}
27842784

2785+
bool isBTILandingPad(MCInst &Inst, bool CallTarget,
2786+
bool JumpTarget) const override {
2787+
unsigned HintNum = getBTIHintNum(CallTarget, JumpTarget);
2788+
bool IsExplicitBTI =
2789+
Inst.getOpcode() == AArch64::HINT && Inst.getNumOperands() == 1 &&
2790+
Inst.getOperand(0).isImm() && Inst.getOperand(0).getImm() == HintNum;
2791+
2792+
bool IsImplicitBTI = HintNum == 34 && isImplicitBTIC(Inst);
2793+
return IsExplicitBTI || IsImplicitBTI;
2794+
}
2795+
2796+
bool isImplicitBTIC(MCInst &Inst) const override {
2797+
// PACI[AB]SP are always implicitly BTI C, independently of
2798+
// SCTLR_EL1.BT[01].
2799+
return Inst.getOpcode() == AArch64::PACIASP ||
2800+
Inst.getOpcode() == AArch64::PACIBSP;
2801+
}
2802+
27852803
InstructionListType materializeAddress(const MCSymbol *Target, MCContext *Ctx,
27862804
MCPhysReg RegName,
27872805
int64_t Addend = 0) const override {

bolt/test/X86/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if not "X86" in config.root.targets:
22
config.unsupported = True
33

4-
flags = "--target=x86_64-unknown-linux-gnu -nostdlib"
4+
flags = "--target=x86_64-unknown-linux-gnu -nostdlib -mllvm -x86-asm-syntax=att"
55

66
config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))
77
config.substitutions.insert(0, ("%cxxflags", f"%cxxflags {flags}"))

bolt/test/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if not "linux" in host_triple:
55
host_triple = host_triple.split("-")[0] + "-unknown-linux-gnu"
66

77
common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -Wl,--build-id=none -pie"
8-
flags = f"--target={host_triple} -fPIE {common_linker_flags} -mllvm -x86-asm-syntax=att"
8+
flags = f"--target={host_triple} -fPIE {common_linker_flags}"
99

1010
config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))
1111
config.substitutions.insert(0, ("%cxxflags", f"%cxxflags {flags}"))

bolt/unittests/Core/MCPlusBuilder.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,22 +155,39 @@ TEST_P(MCPlusBuilderTester, AArch64_BTI) {
155155
auto II = BB->begin();
156156
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
157157
ASSERT_EQ(II->getOperand(0).getImm(), 38);
158+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, true));
158159

159160
MCInst BTIj;
160161
BC->MIB->createBTI(BTIj, false, true);
161162
II = BB->addInstruction(BTIj);
162163
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
163164
ASSERT_EQ(II->getOperand(0).getImm(), 36);
165+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, false, true));
164166

165167
MCInst BTIc;
166168
BC->MIB->createBTI(BTIc, true, false);
167169
II = BB->addInstruction(BTIc);
168170
ASSERT_EQ(II->getOpcode(), AArch64::HINT);
169171
ASSERT_EQ(II->getOperand(0).getImm(), 34);
172+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
170173

171174
MCInst BTIinvalid;
172175
ASSERT_DEATH(BC->MIB->createBTI(BTIinvalid, false, false),
173176
"No target kinds!");
177+
178+
MCInst Paciasp = MCInstBuilder(AArch64::PACIASP);
179+
II = BB->addInstruction(Paciasp);
180+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
181+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, true, true));
182+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, false, true));
183+
ASSERT_TRUE(BC->MIB->isImplicitBTIC(*II));
184+
185+
MCInst Pacibsp = MCInstBuilder(AArch64::PACIBSP);
186+
II = BB->addInstruction(Pacibsp);
187+
ASSERT_TRUE(BC->MIB->isBTILandingPad(*II, true, false));
188+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, true, true));
189+
ASSERT_FALSE(BC->MIB->isBTILandingPad(*II, false, true));
190+
ASSERT_TRUE(BC->MIB->isImplicitBTIC(*II));
174191
}
175192

176193
TEST_P(MCPlusBuilderTester, AArch64_CmpJNE) {

clang/include/clang/Analysis/FlowSensitive/ASTOps.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "clang/AST/ExprCXX.h"
2020
#include "clang/AST/Type.h"
2121
#include "clang/Analysis/FlowSensitive/StorageLocation.h"
22-
#include "llvm/ADT/DenseSet.h"
2322
#include "llvm/ADT/SetVector.h"
2423

2524
namespace clang {
@@ -145,17 +144,17 @@ struct ReferencedDecls {
145144
FieldSet Fields;
146145
/// All variables with static storage duration, notably including static
147146
/// member variables and static variables declared within a function.
148-
llvm::DenseSet<const VarDecl *> Globals;
147+
llvm::SetVector<const VarDecl *> Globals;
149148
/// Local variables, not including parameters or static variables declared
150149
/// within a function.
151-
llvm::DenseSet<const VarDecl *> Locals;
150+
llvm::SetVector<const VarDecl *> Locals;
152151
/// Free functions and member functions which are referenced (but not
153152
/// necessarily called).
154-
llvm::DenseSet<const FunctionDecl *> Functions;
153+
llvm::SetVector<const FunctionDecl *> Functions;
155154
/// When analyzing a lambda's call operator, the set of all parameters (from
156155
/// the surrounding function) that the lambda captures. Captured local
157156
/// variables are already included in `Locals` above.
158-
llvm::DenseSet<const ParmVarDecl *> LambdaCapturedParams;
157+
llvm::SetVector<const ParmVarDecl *> LambdaCapturedParams;
159158
};
160159

161160
/// Returns declarations that are declared in or referenced from `FD`.

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,10 @@ def warn_omp_invalid_attribute_for_ompx_attributes : Warning<"'ompx_attribute' c
17241724
"%0 is ignored">, InGroup<OpenMPExtensions>;
17251725
def err_omp_duplicate_modifier : Error<"duplicate modifier '%0' in '%1' clause">;
17261726
def err_omp_expected_modifier : Error<"expected modifier in '%0' clause">;
1727+
def err_omp_unknown_need_device_ptr_kind
1728+
: Error<
1729+
"invalid argument for 'need_device_ptr' kind in 'adjust_args' clause; "
1730+
"expected 'fp_nullify' or 'fb_preserve'">;
17271731

17281732
// Pragma loop support.
17291733
def err_pragma_loop_missing_argument : Error<

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
#ifndef OPENMP_THREADSET_KIND
108108
#define OPENMP_THREADSET_KIND(Name)
109109
#endif
110+
#ifndef OPENMP_NEED_DEVICE_PTR_KIND
111+
#define OPENMP_NEED_DEVICE_PTR_KIND(Name)
112+
#endif
110113

111114
// Static attributes for 'schedule' clause.
112115
OPENMP_SCHEDULE_KIND(static)
@@ -274,6 +277,10 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
274277
OPENMP_THREADSET_KIND(omp_pool)
275278
OPENMP_THREADSET_KIND(omp_team)
276279

280+
// OpenMP 6.1 modifiers for 'adjust_args' clause.
281+
OPENMP_NEED_DEVICE_PTR_KIND(fb_nullify)
282+
OPENMP_NEED_DEVICE_PTR_KIND(fb_preserve)
283+
277284
#undef OPENMP_NUMTASKS_MODIFIER
278285
#undef OPENMP_NUMTHREADS_MODIFIER
279286
#undef OPENMP_DYN_GROUPPRIVATE_MODIFIER
@@ -306,3 +313,4 @@ OPENMP_THREADSET_KIND(omp_team)
306313
#undef OPENMP_DOACROSS_MODIFIER
307314
#undef OPENMP_ALLOCATE_MODIFIER
308315
#undef OPENMP_THREADSET_KIND
316+
#undef OPENMP_NEED_DEVICE_PTR_KIND

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ enum OpenMPAdjustArgsOpKind {
211211
OMPC_ADJUST_ARGS_unknown,
212212
};
213213

214+
/// OpenMP 6.1 need_device modifier
215+
enum OpenMPNeedDevicePtrModifier {
216+
#define OPENMP_NEED_DEVICE_PTR_KIND(Name) OMPC_NEED_DEVICE_PTR_##Name,
217+
#include "clang/Basic/OpenMPKinds.def"
218+
OMPC_NEED_DEVICE_PTR_unknown,
219+
};
220+
214221
/// OpenMP bindings for the 'bind' clause.
215222
enum OpenMPBindClauseKind {
216223
#define OPENMP_BIND_KIND(Name) OMPC_BIND_##Name,

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,8 @@ class SemaOpenMP : public SemaBase {
11741174
int ExtraModifier = -1; ///< Additional modifier for linear, map, depend or
11751175
///< lastprivate clause.
11761176
int OriginalSharingModifier = 0; // Default is shared
1177+
int NeedDevicePtrModifier = 0;
1178+
SourceLocation NeedDevicePtrModifierLoc;
11771179
SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers>
11781180
MapTypeModifiers;
11791181
SmallVector<SourceLocation, NumberOfOMPMapClauseModifiers>

0 commit comments

Comments
 (0)