Skip to content

Commit 3073205

Browse files
committed
Merge branch 'main' into hgh/libcxx/P0448R4-spanstream-A-strstream-replacement-using-span-charT-as-buffer
2 parents 3134a69 + 311a199 commit 3073205

File tree

326 files changed

+26653
-14048
lines changed

Some content is hidden

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

326 files changed

+26653
-14048
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,8 +1337,17 @@ void BinaryContext::processInterproceduralReferences() {
13371337
<< Function.getPrintName() << " and "
13381338
<< TargetFunction->getPrintName() << '\n';
13391339
}
1340-
if (uint64_t Offset = Address - TargetFunction->getAddress())
1341-
TargetFunction->addEntryPointAtOffset(Offset);
1340+
if (uint64_t Offset = Address - TargetFunction->getAddress()) {
1341+
if (!TargetFunction->isInConstantIsland(Address)) {
1342+
TargetFunction->addEntryPointAtOffset(Offset);
1343+
} else {
1344+
TargetFunction->setIgnored();
1345+
this->outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
1346+
<< Twine::utohexstr(Address)
1347+
<< " in constant island of function " << *TargetFunction
1348+
<< '\n';
1349+
}
1350+
}
13421351

13431352
continue;
13441353
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This test checks that we ignore functions which add an entry point that
2+
// is in a constant island.
3+
4+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5+
# RUN: %clang %cflags %t.o -pie -Wl,-q -o %t.exe
6+
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
7+
8+
# CHECK: BOLT-WARNING: Ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
9+
10+
.globl func
11+
.type func, %function
12+
func:
13+
b .Lafter_constant
14+
15+
.type constant_island, %object
16+
constant_island:
17+
.xword 0xabcdef
18+
19+
.Lafter_constant:
20+
ret
21+
.size func, .-func
22+
23+
.globl caller
24+
.type caller, %function
25+
caller:
26+
bl constant_island
27+
ret

clang/docs/HIPSupport.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ Predefined Macros
164164
- Represents wavefront memory scope in HIP (value is 2).
165165
* - ``__HIP_MEMORY_SCOPE_WORKGROUP``
166166
- Represents workgroup memory scope in HIP (value is 3).
167+
* - ``__HIP_MEMORY_SCOPE_CLUSTER``
168+
- Represents cluster memory scope in HIP (value is 6).
167169
* - ``__HIP_MEMORY_SCOPE_AGENT``
168170
- Represents agent memory scope in HIP (value is 4).
169171
* - ``__HIP_MEMORY_SCOPE_SYSTEM``

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4846,6 +4846,7 @@ currently supported:
48464846
* ``__MEMORY_SCOPE_SYSTEM``
48474847
* ``__MEMORY_SCOPE_DEVICE``
48484848
* ``__MEMORY_SCOPE_WRKGRP``
4849+
* ``__MEMORY_SCOPE_CLUSTR``
48494850
* ``__MEMORY_SCOPE_WVFRNT``
48504851
* ``__MEMORY_SCOPE_SINGLE``
48514852

clang/include/clang/Basic/SyncScope.h

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ enum class SyncScope {
4343
SystemScope,
4444
DeviceScope,
4545
WorkgroupScope,
46+
ClusterScope,
4647
WavefrontScope,
4748
SingleScope,
4849
HIPSingleThread,
4950
HIPWavefront,
5051
HIPWorkgroup,
52+
HIPCluster,
5153
HIPAgent,
5254
HIPSystem,
5355
OpenCLWorkGroup,
@@ -65,6 +67,8 @@ inline llvm::StringRef getAsString(SyncScope S) {
6567
return "device_scope";
6668
case SyncScope::WorkgroupScope:
6769
return "workgroup_scope";
70+
case SyncScope::ClusterScope:
71+
return "cluster_scope";
6872
case SyncScope::WavefrontScope:
6973
return "wavefront_scope";
7074
case SyncScope::SingleScope:
@@ -75,6 +79,8 @@ inline llvm::StringRef getAsString(SyncScope S) {
7579
return "hip_wavefront";
7680
case SyncScope::HIPWorkgroup:
7781
return "hip_workgroup";
82+
case SyncScope::HIPCluster:
83+
return "hip_cluster";
7884
case SyncScope::HIPAgent:
7985
return "hip_agent";
8086
case SyncScope::HIPSystem:
@@ -174,13 +180,18 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
174180
/// The enum values match the pre-defined macros
175181
/// __HIP_MEMORY_SCOPE_*, which are used to define memory_scope_*
176182
/// enums in hip-c.h.
183+
/// These may be present in pch files or bitcode so preserve existing values
184+
/// when adding a new ID.
177185
enum ID {
178186
SingleThread = 1,
179187
Wavefront = 2,
180188
Workgroup = 3,
181189
Agent = 4,
182190
System = 5,
183-
Last = System
191+
Cluster = 6,
192+
End,
193+
Last = End - 1,
194+
Count = Last
184195
};
185196

186197
AtomicScopeHIPModel() {}
@@ -193,10 +204,14 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
193204
return SyncScope::HIPWavefront;
194205
case Workgroup:
195206
return SyncScope::HIPWorkgroup;
207+
case Cluster:
208+
return SyncScope::HIPCluster;
196209
case Agent:
197210
return SyncScope::HIPAgent;
198211
case System:
199212
return SyncScope::HIPSystem;
213+
case End:
214+
break;
200215
}
201216
llvm_unreachable("Invalid language sync scope value");
202217
}
@@ -207,11 +222,12 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
207222
}
208223

209224
ArrayRef<unsigned> getRuntimeValues() const override {
210-
static_assert(Last == System, "Does not include all sync scopes");
211225
static const unsigned Scopes[] = {
212226
static_cast<unsigned>(SingleThread), static_cast<unsigned>(Wavefront),
213-
static_cast<unsigned>(Workgroup), static_cast<unsigned>(Agent),
214-
static_cast<unsigned>(System)};
227+
static_cast<unsigned>(Workgroup), static_cast<unsigned>(Cluster),
228+
static_cast<unsigned>(System), static_cast<unsigned>(Agent)};
229+
static_assert(sizeof(Scopes) / sizeof(Scopes[0]) == Count,
230+
"Does not include all sync scopes");
215231
return llvm::ArrayRef(Scopes);
216232
}
217233

@@ -223,14 +239,18 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
223239
/// Defines the generic atomic scope model.
224240
class AtomicScopeGenericModel : public AtomicScopeModel {
225241
public:
226-
/// The enum values match predefined built-in macros __ATOMIC_SCOPE_*.
242+
/// The enum values match predefined built-in macros __MEMORY_SCOPE_*.
243+
/// These may be present in pch files or bitcode so preserve existing values
244+
/// when adding a new ID.
227245
enum ID {
228246
System = 0,
229247
Device = 1,
230248
Workgroup = 2,
231249
Wavefront = 3,
232250
Single = 4,
233-
Last = Single
251+
Cluster = 5,
252+
Count,
253+
Last = Count - 1
234254
};
235255

236256
AtomicScopeGenericModel() = default;
@@ -243,10 +263,14 @@ class AtomicScopeGenericModel : public AtomicScopeModel {
243263
return SyncScope::SystemScope;
244264
case Workgroup:
245265
return SyncScope::WorkgroupScope;
266+
case Cluster:
267+
return SyncScope::ClusterScope;
246268
case Wavefront:
247269
return SyncScope::WavefrontScope;
248270
case Single:
249271
return SyncScope::SingleScope;
272+
case Count:
273+
break;
250274
}
251275
llvm_unreachable("Invalid language sync scope value");
252276
}
@@ -256,11 +280,12 @@ class AtomicScopeGenericModel : public AtomicScopeModel {
256280
}
257281

258282
ArrayRef<unsigned> getRuntimeValues() const override {
259-
static_assert(Last == Single, "Does not include all sync scopes");
260283
static const unsigned Scopes[] = {
261-
static_cast<unsigned>(Device), static_cast<unsigned>(System),
262-
static_cast<unsigned>(Workgroup), static_cast<unsigned>(Wavefront),
263-
static_cast<unsigned>(Single)};
284+
static_cast<unsigned>(System), static_cast<unsigned>(Device),
285+
static_cast<unsigned>(Workgroup), static_cast<unsigned>(Cluster),
286+
static_cast<unsigned>(Wavefront), static_cast<unsigned>(Single)};
287+
static_assert(sizeof(Scopes) / sizeof(Scopes[0]) == Count,
288+
"Does not include all sync scopes");
264289
return llvm::ArrayRef(Scopes);
265290
}
266291

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4457,6 +4457,79 @@ def CIR_TryOp : CIR_Op<"try",[
44574457
// Atomic operations
44584458
//===----------------------------------------------------------------------===//
44594459

4460+
def CIR_AtomicFetchKind : CIR_I32EnumAttr<
4461+
"AtomicFetchKind", "Binary opcode for atomic fetch-and-update operations", [
4462+
I32EnumAttrCase<"Add", 0, "add">,
4463+
I32EnumAttrCase<"Sub", 1, "sub">,
4464+
I32EnumAttrCase<"And", 2, "and">,
4465+
I32EnumAttrCase<"Xor", 3, "xor">,
4466+
I32EnumAttrCase<"Or", 4, "or">,
4467+
I32EnumAttrCase<"Nand", 5, "nand">,
4468+
I32EnumAttrCase<"Max", 6, "max">,
4469+
I32EnumAttrCase<"Min", 7, "min">
4470+
]>;
4471+
4472+
def CIR_AtomicFetchOp : CIR_Op<"atomic.fetch", [
4473+
AllTypesMatch<["result", "val"]>,
4474+
TypesMatchWith<"type of 'val' must match the pointee type of 'ptr'",
4475+
"ptr", "val", "mlir::cast<cir::PointerType>($_self).getPointee()">
4476+
]> {
4477+
let summary = "Atomic fetch-and-update operation";
4478+
let description = [{
4479+
C/C++ atomic fetch-and-update operation. This operation implements the C/C++
4480+
builtin functions `__atomic_<binop>_fetch`, `__atomic_fetch_<binop>`, and
4481+
`__c11_atomic_fetch_<binop>`, where `<binop>` is one of the following binary
4482+
opcodes: `add`, `sub`, `and`, `xor`, `or`, `nand`, `max`, and `min`.
4483+
4484+
This operation takes 2 arguments: a pointer `ptr` and a value `val`. The
4485+
type of `val` must match the pointee type of `ptr`. If the binary operation
4486+
is `add`, `sub`, `max`, or `min`, the type of `val` may either be an integer
4487+
type or a floating-point type. Otherwise, `val` must be an integer.
4488+
4489+
This operation atomically loads the value from `ptr`, performs the binary
4490+
operation as indicated by `binop` on the loaded value and `val`, and stores
4491+
the result back to `ptr`. If the `fetch_first` flag is present, the result
4492+
of this operation is the old value loaded from `ptr` before the binary
4493+
operation. Otherwise, the result of this operation is the result of the
4494+
binary operation.
4495+
4496+
Example:
4497+
%res = cir.atomic.fetch add seq_cst %ptr, %val
4498+
: (!cir.ptr<!s32i>, !s32i) -> !s32i
4499+
}];
4500+
let results = (outs CIR_AnyIntOrFloatType:$result);
4501+
let arguments = (ins
4502+
Arg<CIR_PtrToIntOrFloatType, "", [MemRead, MemWrite]>:$ptr,
4503+
CIR_AnyIntOrFloatType:$val,
4504+
CIR_AtomicFetchKind:$binop,
4505+
Arg<CIR_MemOrder, "memory order">:$mem_order,
4506+
UnitAttr:$is_volatile,
4507+
UnitAttr:$fetch_first
4508+
);
4509+
4510+
let assemblyFormat = [{
4511+
$binop $mem_order
4512+
(`fetch_first` $fetch_first^)?
4513+
$ptr `,` $val
4514+
(`volatile` $is_volatile^)?
4515+
`:` `(` qualified(type($ptr)) `,` qualified(type($val)) `)`
4516+
`->` type($result) attr-dict
4517+
}];
4518+
4519+
let hasVerifier = 1;
4520+
4521+
let extraLLVMLoweringPatternDecl = [{
4522+
mlir::Value buildPostOp(cir::AtomicFetchOp op, OpAdaptor adaptor,
4523+
mlir::ConversionPatternRewriter &rewriter,
4524+
mlir::Value rmwVal, bool isInt) const;
4525+
4526+
mlir::Value buildMinMaxPostOp(cir::AtomicFetchOp op, OpAdaptor adaptor,
4527+
mlir::ConversionPatternRewriter &rewriter,
4528+
mlir::Value rmwVal, bool isInt,
4529+
bool isSigned) const;
4530+
}];
4531+
}
4532+
44604533
def CIR_AtomicXchgOp : CIR_Op<"atomic.xchg", [
44614534
AllTypesMatch<["result", "val"]>,
44624535
TypesMatchWith<"type of 'val' must match the pointee type of 'ptr'",
@@ -4557,4 +4630,66 @@ def CIR_AtomicCmpXchgOp : CIR_Op<"atomic.cmpxchg", [
45574630
}];
45584631
}
45594632

4633+
def CIR_AtomicTestAndSetOp : CIR_Op<"atomic.test_and_set"> {
4634+
let summary = "Atomic test and set";
4635+
let description = [{
4636+
C/C++ atomic test and set operation. Implements the builtin function
4637+
`__atomic_test_and_set`.
4638+
4639+
The operation takes as its only operand a pointer to an 8-bit signed
4640+
integer. The operation atomically set the integer to an implementation-
4641+
defined non-zero "set" value. The result of the operation is a boolean value
4642+
indicating whether the previous value of the integer was the "set" value.
4643+
4644+
Example:
4645+
```mlir
4646+
%res = cir.atomic.test_and_set seq_cst %ptr : !cir.ptr<!s8i> -> !cir.bool
4647+
```
4648+
}];
4649+
4650+
let arguments = (ins
4651+
Arg<CIR_PtrToType<CIR_SInt8>, "", [MemRead, MemWrite]>:$ptr,
4652+
Arg<CIR_MemOrder, "memory order">:$mem_order,
4653+
OptionalAttr<I64Attr>:$alignment,
4654+
UnitAttr:$is_volatile
4655+
);
4656+
4657+
let results = (outs CIR_BoolType:$result);
4658+
4659+
let assemblyFormat = [{
4660+
$mem_order $ptr
4661+
(`volatile` $is_volatile^)?
4662+
`:` qualified(type($ptr)) `->` qualified(type($result)) attr-dict
4663+
}];
4664+
}
4665+
4666+
def CIR_AtomicClearOp : CIR_Op<"atomic.clear"> {
4667+
let summary = "Atomic clear";
4668+
let description = [{
4669+
C/C++ atomic clear operation. Implements the builtin function
4670+
`__atomic_clear`.
4671+
4672+
The operation takes as its only operand a pointer to an 8-bit signed
4673+
integer. The operation atomically sets the integer to zero.
4674+
4675+
Example:
4676+
```mlir
4677+
cir.atomic.clear seq_cst %ptr : !cir.ptr<!s8i>
4678+
```
4679+
}];
4680+
4681+
let arguments = (ins
4682+
Arg<CIR_PtrToType<CIR_SInt8>, "", [MemRead, MemWrite]>:$ptr,
4683+
Arg<CIR_MemOrder, "memory order">:$mem_order,
4684+
OptionalAttr<I64Attr>:$alignment,
4685+
UnitAttr:$is_volatile
4686+
);
4687+
4688+
let assemblyFormat = [{
4689+
$mem_order $ptr
4690+
(`volatile` $is_volatile^)?
4691+
`:` qualified(type($ptr)) attr-dict
4692+
}];
4693+
}
4694+
45604695
#endif // CLANG_CIR_DIALECT_IR_CIROPS_TD

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10021,7 +10021,7 @@ class Sema final : public SemaBase {
1002110021
public:
1002210022
DeferDiagsRAII(Sema &S, bool DeferDiags)
1002310023
: S(S), SavedDeferDiags(S.DeferDiags) {
10024-
S.DeferDiags = DeferDiags;
10024+
S.DeferDiags = SavedDeferDiags || DeferDiags;
1002510025
}
1002610026
~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
1002710027
};

clang/include/clang/Sema/SemaBase.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,13 @@ class SemaBase {
212212
};
213213

214214
/// Emit a diagnostic.
215-
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID,
216-
bool DeferHint = false);
215+
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
217216

218217
/// Emit a partial diagnostic.
219-
SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic &PD,
220-
bool DeferHint = false);
218+
SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic &PD);
221219

222220
/// Emit a compatibility diagnostic.
223-
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId,
224-
bool DeferHint = false);
221+
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId);
225222

226223
/// Build a partial diagnostic.
227224
PartialDiagnostic PDiag(unsigned DiagID = 0);

0 commit comments

Comments
 (0)