Skip to content

Commit cd0a74a

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:8fddef8483dc into origin/amd-gfx:2a168546b75e
Local branch origin/amd-gfx 2a16854 Merged main:9fe6f6a0d430 into origin/amd-gfx:3be6366ceae6 Remote branch main 8fddef8 [SelectionDAG] Introducing a new ISD::POISON SDNode to represent the poison value in the IR. (llvm#125883)
2 parents 2a16854 + 8fddef8 commit cd0a74a

File tree

57 files changed

+624
-216
lines changed

Some content is hidden

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

57 files changed

+624
-216
lines changed

clang/include/clang/AST/Expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6757,7 +6757,7 @@ class PseudoObjectExpr final
67576757
/// and corresponding __opencl_atomic_* for OpenCL 2.0.
67586758
/// All of these instructions take one primary pointer, at least one memory
67596759
/// order. The instructions for which getScopeModel returns non-null value
6760-
/// take one synch scope.
6760+
/// take one sync scope.
67616761
class AtomicExpr : public Expr {
67626762
public:
67636763
enum AtomicOp {

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9076,7 +9076,7 @@ def err_atomic_op_needs_atomic_int : Error<
90769076
def warn_atomic_op_has_invalid_memory_order : Warning<
90779077
"%select{|success |failure }0memory order argument to atomic operation is invalid">,
90789078
InGroup<DiagGroup<"atomic-memory-ordering">>;
9079-
def err_atomic_op_has_invalid_synch_scope : Error<
9079+
def err_atomic_op_has_invalid_sync_scope : Error<
90809080
"synchronization scope argument to atomic operation is invalid">;
90819081
def warn_atomic_implicit_seq_cst : Warning<
90829082
"implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary">,

clang/include/clang/Basic/SyncScope.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121

2222
namespace clang {
2323

24-
/// Defines synch scope values used internally by clang.
24+
/// Defines sync scope values used internally by clang.
2525
///
2626
/// The enum values start from 0 and are contiguous. They are mainly used for
27-
/// enumerating all supported synch scope values and mapping them to LLVM
28-
/// synch scopes. Their numerical values may be different from the corresponding
29-
/// synch scope enums used in source languages.
27+
/// enumerating all supported sync scope values and mapping them to LLVM
28+
/// sync scopes. Their numerical values may be different from the corresponding
29+
/// sync scope enums used in source languages.
3030
///
31-
/// In atomic builtin and expressions, language-specific synch scope enums are
31+
/// In atomic builtin and expressions, language-specific sync scope enums are
3232
/// used. Currently only OpenCL memory scope enums are supported and assumed
3333
/// to be used by all languages. However, in the future, other languages may
34-
/// define their own set of synch scope enums. The language-specific synch scope
34+
/// define their own set of sync scope enums. The language-specific sync scope
3535
/// values are represented by class AtomicScopeModel and its derived classes.
3636
///
3737
/// To add a new enum value:
@@ -88,39 +88,39 @@ inline llvm::StringRef getAsString(SyncScope S) {
8888
case SyncScope::OpenCLSubGroup:
8989
return "opencl_subgroup";
9090
}
91-
llvm_unreachable("Invalid synch scope");
91+
llvm_unreachable("Invalid sync scope");
9292
}
9393

9494
/// Defines the kind of atomic scope models.
9595
enum class AtomicScopeModelKind { None, OpenCL, HIP, Generic };
9696

97-
/// Defines the interface for synch scope model.
97+
/// Defines the interface for sync scope model.
9898
class AtomicScopeModel {
9999
public:
100100
virtual ~AtomicScopeModel() {}
101-
/// Maps language specific synch scope values to internal
101+
/// Maps language specific sync scope values to internal
102102
/// SyncScope enum.
103103
virtual SyncScope map(unsigned S) const = 0;
104104

105-
/// Check if the compile-time constant synch scope value
105+
/// Check if the compile-time constant sync scope value
106106
/// is valid.
107107
virtual bool isValid(unsigned S) const = 0;
108108

109-
/// Get all possible synch scope values that might be
109+
/// Get all possible sync scope values that might be
110110
/// encountered at runtime for the current language.
111111
virtual ArrayRef<unsigned> getRuntimeValues() const = 0;
112112

113113
/// If atomic builtin function is called with invalid
114-
/// synch scope value at runtime, it will fall back to a valid
115-
/// synch scope value returned by this function.
114+
/// sync scope value at runtime, it will fall back to a valid
115+
/// sync scope value returned by this function.
116116
virtual unsigned getFallBackValue() const = 0;
117117

118118
/// Create an atomic scope model by AtomicScopeModelKind.
119119
/// \return an empty std::unique_ptr for AtomicScopeModelKind::None.
120120
static std::unique_ptr<AtomicScopeModel> create(AtomicScopeModelKind K);
121121
};
122122

123-
/// Defines the synch scope model for OpenCL.
123+
/// Defines the sync scope model for OpenCL.
124124
class AtomicScopeOpenCLModel : public AtomicScopeModel {
125125
public:
126126
/// The enum values match the pre-defined macros
@@ -147,7 +147,7 @@ class AtomicScopeOpenCLModel : public AtomicScopeModel {
147147
case SubGroup:
148148
return SyncScope::OpenCLSubGroup;
149149
}
150-
llvm_unreachable("Invalid language synch scope value");
150+
llvm_unreachable("Invalid language sync scope value");
151151
}
152152

153153
bool isValid(unsigned S) const override {
@@ -156,7 +156,7 @@ class AtomicScopeOpenCLModel : public AtomicScopeModel {
156156
}
157157

158158
ArrayRef<unsigned> getRuntimeValues() const override {
159-
static_assert(Last == SubGroup, "Does not include all synch scopes");
159+
static_assert(Last == SubGroup, "Does not include all sync scopes");
160160
static const unsigned Scopes[] = {
161161
static_cast<unsigned>(WorkGroup), static_cast<unsigned>(Device),
162162
static_cast<unsigned>(AllSVMDevices), static_cast<unsigned>(SubGroup)};
@@ -168,7 +168,7 @@ class AtomicScopeOpenCLModel : public AtomicScopeModel {
168168
}
169169
};
170170

171-
/// Defines the synch scope model for HIP.
171+
/// Defines the sync scope model for HIP.
172172
class AtomicScopeHIPModel : public AtomicScopeModel {
173173
public:
174174
/// The enum values match the pre-defined macros
@@ -198,7 +198,7 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
198198
case System:
199199
return SyncScope::HIPSystem;
200200
}
201-
llvm_unreachable("Invalid language synch scope value");
201+
llvm_unreachable("Invalid language sync scope value");
202202
}
203203

204204
bool isValid(unsigned S) const override {
@@ -207,7 +207,7 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
207207
}
208208

209209
ArrayRef<unsigned> getRuntimeValues() const override {
210-
static_assert(Last == System, "Does not include all synch scopes");
210+
static_assert(Last == System, "Does not include all sync scopes");
211211
static const unsigned Scopes[] = {
212212
static_cast<unsigned>(SingleThread), static_cast<unsigned>(Wavefront),
213213
static_cast<unsigned>(Workgroup), static_cast<unsigned>(Agent),

clang/lib/CodeGen/CGAtomic.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *Expr, Address Dest,
781781
llvm::Value *Scope) {
782782
auto ScopeModel = Expr->getScopeModel();
783783

784-
// LLVM atomic instructions always have synch scope. If clang atomic
785-
// expression has no scope operand, use default LLVM synch scope.
784+
// LLVM atomic instructions always have sync scope. If clang atomic
785+
// expression has no scope operand, use default LLVM sync scope.
786786
if (!ScopeModel) {
787787
llvm::SyncScope::ID SS;
788788
if (CGF.getLangOpts().OpenCL)
@@ -821,8 +821,8 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *Expr, Address Dest,
821821
CGF.createBasicBlock("atomic.scope.continue", CGF.CurFn);
822822

823823
auto *SC = Builder.CreateIntCast(Scope, Builder.getInt32Ty(), false);
824-
// If unsupported synch scope is encountered at run time, assume a fallback
825-
// synch scope value.
824+
// If unsupported sync scope is encountered at run time, assume a fallback
825+
// sync scope value.
826826
auto FallBack = ScopeModel->getFallBackValue();
827827
llvm::SwitchInst *SI = Builder.CreateSwitch(SC, BB[FallBack]);
828828
for (auto S : Scopes) {

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4229,7 +4229,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
42294229
if (std::optional<llvm::APSInt> Result =
42304230
Scope->getIntegerConstantExpr(Context)) {
42314231
if (!ScopeModel->isValid(Result->getZExtValue()))
4232-
Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope)
4232+
Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_sync_scope)
42334233
<< Scope->getSourceRange();
42344234
}
42354235
SubExprs.push_back(Scope);

clang/test/SemaOpenCL/atomic-ops.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void memory_checks(atomic_int *Ap, int *p, int val) {
159159
(void)__opencl_atomic_compare_exchange_weak(Ap, p, val, memory_order_seq_cst, memory_order_relaxed, memory_scope_work_group);
160160
}
161161

162-
void synchscope_checks(atomic_int *Ap, int scope) {
162+
void syncscope_checks(atomic_int *Ap, int scope) {
163163
(void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_item); // expected-error{{synchronization scope argument to atomic operation is invalid}}
164164
(void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_group);
165165
(void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_device);

flang/include/flang/Optimizer/Builder/FIRBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
150150
mlir::Block *getAllocaBlock();
151151

152152
/// Safely create a reference type to the type `eleTy`.
153-
mlir::Type getRefType(mlir::Type eleTy);
153+
mlir::Type getRefType(mlir::Type eleTy, bool isVolatile = false);
154154

155155
/// Create a sequence of `eleTy` with `rank` dimensions of unknown size.
156156
mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank = 1);

flang/include/flang/Optimizer/Dialect/FIRType.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ inline bool isa_char_string(mlir::Type t) {
221221
/// (since they may hold one), and are not considered to be unknown size.
222222
bool isa_unknown_size_box(mlir::Type t);
223223

224+
/// Returns true iff `t` is a type capable of representing volatility and has
225+
/// the volatile attribute set.
226+
bool isa_volatile_type(mlir::Type t);
227+
224228
/// Returns true iff `t` is a fir.char type and has an unknown length.
225229
inline bool characterWithDynamicLen(mlir::Type t) {
226230
if (auto charTy = mlir::dyn_cast<fir::CharacterType>(t))
@@ -474,6 +478,10 @@ inline mlir::Type updateTypeForUnlimitedPolymorphic(mlir::Type ty) {
474478
return ty;
475479
}
476480

481+
/// Re-create the given type with the given volatility, if this is a type
482+
/// that can represent volatility.
483+
mlir::Type updateTypeWithVolatility(mlir::Type type, bool isVolatile);
484+
477485
/// Replace the element type of \p type by \p newElementType, preserving
478486
/// all other layers of the type (fir.ref/ptr/heap/array/box/class).
479487
/// If \p turnBoxIntoClass and the input is a fir.box, it will be turned into

flang/include/flang/Optimizer/Dialect/FIRTypes.td

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,24 @@ def fir_BoxType : FIR_Type<"Box", "box", [], "BaseBoxType"> {
7777
to) whether the entity is an array, its size, or what type it has.
7878
}];
7979

80-
let parameters = (ins "mlir::Type":$eleTy);
80+
let parameters = (ins "mlir::Type":$eleTy, "bool":$isVolatile);
8181

8282
let skipDefaultBuilders = 1;
8383

8484
let builders = [
8585
TypeBuilderWithInferredContext<(ins
86-
"mlir::Type":$eleTy), [{
87-
return Base::get(eleTy.getContext(), eleTy);
86+
"mlir::Type":$eleTy, CArg<"bool", "false">:$isVolatile), [{
87+
return Base::get(eleTy.getContext(), eleTy, isVolatile);
8888
}]>,
8989
];
9090

9191
let extraClassDeclaration = [{
9292
mlir::Type getElementType() const { return getEleTy(); }
93+
bool isVolatile() const { return getIsVolatile(); }
9394
}];
9495

9596
let genVerifyDecl = 1;
96-
97-
let assemblyFormat = "`<` $eleTy `>`";
97+
let hasCustomAssemblyFormat = 1;
9898
}
9999

100100
def fir_CharacterType : FIR_Type<"Character", "char"> {
@@ -146,16 +146,20 @@ def fir_ClassType : FIR_Type<"Class", "class", [], "BaseBoxType"> {
146146
is equivalent to a fir.box type with a dynamic type.
147147
}];
148148

149-
let parameters = (ins "mlir::Type":$eleTy);
149+
let parameters = (ins "mlir::Type":$eleTy, "bool":$isVolatile);
150150

151151
let builders = [
152-
TypeBuilderWithInferredContext<(ins "mlir::Type":$eleTy), [{
153-
return $_get(eleTy.getContext(), eleTy);
152+
TypeBuilderWithInferredContext<(ins "mlir::Type":$eleTy, CArg<"bool", "false">:$isVolatile), [{
153+
return $_get(eleTy.getContext(), eleTy, isVolatile);
154154
}]>
155155
];
156156

157+
let extraClassDeclaration = [{
158+
bool isVolatile() const { return getIsVolatile(); }
159+
}];
160+
157161
let genVerifyDecl = 1;
158-
let assemblyFormat = "`<` $eleTy `>`";
162+
let hasCustomAssemblyFormat = 1;
159163
}
160164

161165
def fir_FieldType : FIR_Type<"Field", "field"> {
@@ -363,18 +367,19 @@ def fir_ReferenceType : FIR_Type<"Reference", "ref"> {
363367
The type of a reference to an entity in memory.
364368
}];
365369

366-
let parameters = (ins "mlir::Type":$eleTy);
370+
let parameters = (ins "mlir::Type":$eleTy, "bool":$isVolatile);
367371

368372
let skipDefaultBuilders = 1;
369373

370374
let builders = [
371-
TypeBuilderWithInferredContext<(ins "mlir::Type":$elementType), [{
372-
return Base::get(elementType.getContext(), elementType);
375+
TypeBuilderWithInferredContext<(ins "mlir::Type":$elementType, CArg<"bool", "false">:$isVolatile), [{
376+
return Base::get(elementType.getContext(), elementType, isVolatile);
373377
}]>,
374378
];
375379

376380
let extraClassDeclaration = [{
377381
mlir::Type getElementType() const { return getEleTy(); }
382+
bool isVolatile() const { return getIsVolatile(); }
378383
}];
379384

380385
let genVerifyDecl = 1;

flang/lib/Optimizer/Builder/FIRBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ fir::FirOpBuilder::getNamedGlobal(mlir::ModuleOp modOp,
105105
return modOp.lookupSymbol<fir::GlobalOp>(name);
106106
}
107107

108-
mlir::Type fir::FirOpBuilder::getRefType(mlir::Type eleTy) {
108+
mlir::Type fir::FirOpBuilder::getRefType(mlir::Type eleTy, bool isVolatile) {
109109
assert(!mlir::isa<fir::ReferenceType>(eleTy) && "cannot be a reference type");
110-
return fir::ReferenceType::get(eleTy);
110+
return fir::ReferenceType::get(eleTy, isVolatile);
111111
}
112112

113113
mlir::Type fir::FirOpBuilder::getVarLenSeqTy(mlir::Type eleTy, unsigned rank) {

0 commit comments

Comments
 (0)