Skip to content

Commit d2b54d8

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:e61a7dc256bd530a0b9551e2732e5b5b77e2cd1e into amd-gfx:0ba2414d4826
Local branch amd-gfx 0ba2414 Merged main:44d0e9522a80e1301e96c4751b7572ae0c9cb4dd into amd-gfx:a2e75de8b74c Remote branch main e61a7dc [X86][AVX512] Use comx for compare (llvm#113567)
2 parents 0ba2414 + e61a7dc commit d2b54d8

File tree

14 files changed

+529
-21
lines changed

14 files changed

+529
-21
lines changed

clang/docs/ReleaseNotes.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ C++ Specific Potentially Breaking Changes
140140
unsigned operator""_udl_name(unsigned long long);
141141

142142
- Clang will now produce an error diagnostic when [[clang::lifetimebound]] is
143-
applied on a parameter of a function that returns void. This was previously
143+
applied on a parameter of a function that returns void. This was previously
144144
ignored and had no effect. (#GH107556)
145145

146146
.. code-block:: c++
@@ -469,7 +469,8 @@ Bug Fixes in This Version
469469
- Fixed a crash using ``__array_rank`` on 64-bit targets. (#GH113044).
470470
- The warning emitted for an unsupported register variable type now points to
471471
the unsupported type instead of the ``register`` keyword (#GH109776).
472-
- Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
472+
- Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
473+
- Fixed a crash when GNU statement expression contains invalid statement (#GH113468).
473474

474475
Bug Fixes to Compiler Builtins
475476
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/AttrDocs.td

+20-8
Original file line numberDiff line numberDiff line change
@@ -3702,20 +3702,32 @@ user-declared functions. For example:
37023702

37033703
.. code-block:: c++
37043704

3705+
#include <map>
3706+
#include <string>
3707+
3708+
using namespace std::literals;
3709+
37053710
// Returns m[key] if key is present, or default_value if not.
37063711
template<typename T, typename U>
37073712
const U &get_or_default(const std::map<T, U> &m [[clang::lifetimebound]],
37083713
const T &key, /* note, not lifetimebound */
3709-
const U &default_value [[clang::lifetimebound]]);
3714+
const U &default_value [[clang::lifetimebound]]) {
3715+
if (auto iter = m.find(key); iter != m.end()) return iter->second;
3716+
else return default_value;
3717+
}
37103718

3711-
std::map<std::string, std::string> m;
3712-
// warning: temporary "bar"s that might be bound to local reference 'val'
3713-
// will be destroyed at the end of the full-expression
3714-
const std::string &val = get_or_default(m, "foo"s, "bar"s);
3719+
int main() {
3720+
std::map<std::string, std::string> m;
3721+
// warning: temporary bound to local reference 'val1' will be destroyed
3722+
// at the end of the full-expression
3723+
const std::string &val1 = get_or_default(m, "foo"s, "bar"s);
37153724

3716-
// No warning in this case.
3717-
std::string def_val = "bar"s;
3718-
const std::string &val = get_or_default(m, "foo"s, def_val);
3725+
// No warning in this case.
3726+
std::string def_val = "bar"s;
3727+
const std::string &val2 = get_or_default(m, "foo"s, def_val);
3728+
3729+
return 0;
3730+
}
37193731

37203732
The attribute can be applied to the implicit ``this`` parameter of a member
37213733
function by writing the attribute after the function type:

clang/lib/Parse/ParseStmt.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
12431243
ParsedStmtContext::Compound |
12441244
(isStmtExpr ? ParsedStmtContext::InStmtExpr : ParsedStmtContext());
12451245

1246+
bool LastIsError = false;
12461247
while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
12471248
Tok.isNot(tok::eof)) {
12481249
if (Tok.is(tok::annot_pragma_unused)) {
@@ -1299,7 +1300,15 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
12991300

13001301
if (R.isUsable())
13011302
Stmts.push_back(R.get());
1303+
LastIsError = R.isInvalid();
13021304
}
1305+
// StmtExpr needs to do copy initialization for last statement.
1306+
// If last statement is invalid, the last statement in `Stmts` will be
1307+
// incorrect. Then the whole compound statement should also be marked as
1308+
// invalid to prevent subsequent errors.
1309+
if (isStmtExpr && LastIsError && !Stmts.empty())
1310+
return StmtError();
1311+
13031312
// Warn the user that using option `-ffp-eval-method=source` on a
13041313
// 32-bit target and feature `sse` disabled, or using
13051314
// `pragma clang fp eval_method=source` and feature `sse` disabled, is not

clang/lib/Sema/SemaChecking.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -8900,7 +8900,12 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
89008900
<< Call->getCallee()->getSourceRange());
89018901
else if (const auto *RT = PointeeTy->getAs<RecordType>()) {
89028902

8903-
bool IsTriviallyCopyableCXXRecord =
8903+
// FIXME: Do not consider incomplete types even though they may be
8904+
// completed later. GCC does not diagnose such code, but we may want to
8905+
// consider diagnosing it in the future, perhaps under a different, but
8906+
// related, diagnostic group.
8907+
bool MayBeTriviallyCopyableCXXRecord =
8908+
RT->isIncompleteType() ||
89048909
RT->desugar().isTriviallyCopyableType(Context);
89058910

89068911
if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
@@ -8910,7 +8915,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
89108915
<< ArgIdx << FnName << PointeeTy << 0);
89118916
SearchNonTrivialToInitializeField::diag(PointeeTy, Dest, *this);
89128917
} else if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
8913-
!IsTriviallyCopyableCXXRecord && ArgIdx == 0) {
8918+
!MayBeTriviallyCopyableCXXRecord && ArgIdx == 0) {
89148919
// FIXME: Limiting this warning to dest argument until we decide
89158920
// whether it's valid for source argument too.
89168921
DiagRuntimeBehavior(Dest->getExprLoc(), Dest,
@@ -8923,7 +8928,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
89238928
<< ArgIdx << FnName << PointeeTy << 1);
89248929
SearchNonTrivialToCopyField::diag(PointeeTy, Dest, *this);
89258930
} else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
8926-
!IsTriviallyCopyableCXXRecord && ArgIdx == 0) {
8931+
!MayBeTriviallyCopyableCXXRecord && ArgIdx == 0) {
89278932
// FIXME: Limiting this warning to dest argument until we decide
89288933
// whether it's valid for source argument too.
89298934
DiagRuntimeBehavior(Dest->getExprLoc(), Dest,

clang/test/SemaCXX/constexpr-string.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,6 @@ namespace MemcpyEtc {
670670
constexpr bool test_address_of_incomplete_struct_type() { // expected-error {{never produces a constant}}
671671
struct Incomplete;
672672
extern Incomplete x, y;
673-
// expected-warning@+2 {{first argument in call to '__builtin_memcpy' is a pointer to non-trivially copyable type 'Incomplete'}}
674-
// expected-note@+1 {{explicitly cast the pointer to silence this warning}}
675673
__builtin_memcpy(&x, &x, 4);
676674
// expected-note@-1 2{{cannot constant evaluate 'memcpy' between objects of incomplete type 'Incomplete'}}
677675
return true;

clang/test/SemaCXX/gh113468.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
2+
3+
constexpr int expr() {
4+
if (({
5+
int f;
6+
f = 0;
7+
if (f)
8+
break; // expected-error {{'break' statement not in loop or switch statement}}
9+
}))
10+
return 2;
11+
return 1;
12+
}

clang/test/SemaCXX/warn-memaccess.cpp

+21-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ extern "C" void *memcpy(void *s1, const void *s2, unsigned n);
77

88
class TriviallyCopyable {};
99
class NonTriviallyCopyable { NonTriviallyCopyable(const NonTriviallyCopyable&);};
10+
struct Incomplete;
1011

1112
void test_bzero(TriviallyCopyable* tc,
12-
NonTriviallyCopyable *ntc) {
13+
NonTriviallyCopyable *ntc,
14+
Incomplete* i) {
1315
// OK
1416
bzero(tc, sizeof(*tc));
1517

18+
// OK
19+
bzero(i, 10);
20+
1621
// expected-warning@+2{{first argument in call to 'bzero' is a pointer to non-trivially copyable type 'NonTriviallyCopyable'}}
1722
// expected-note@+1{{explicitly cast the pointer to silence this warning}}
1823
bzero(ntc, sizeof(*ntc));
@@ -22,10 +27,14 @@ void test_bzero(TriviallyCopyable* tc,
2227
}
2328

2429
void test_memset(TriviallyCopyable* tc,
25-
NonTriviallyCopyable *ntc) {
30+
NonTriviallyCopyable *ntc,
31+
Incomplete* i) {
2632
// OK
2733
memset(tc, 0, sizeof(*tc));
2834

35+
// OK
36+
memset(i, 0, 10);
37+
2938
// expected-warning@+2{{first argument in call to 'memset' is a pointer to non-trivially copyable type 'NonTriviallyCopyable'}}
3039
// expected-note@+1{{explicitly cast the pointer to silence this warning}}
3140
memset(ntc, 0, sizeof(*ntc));
@@ -36,10 +45,14 @@ void test_memset(TriviallyCopyable* tc,
3645

3746

3847
void test_memcpy(TriviallyCopyable* tc0, TriviallyCopyable* tc1,
39-
NonTriviallyCopyable *ntc0, NonTriviallyCopyable *ntc1) {
48+
NonTriviallyCopyable *ntc0, NonTriviallyCopyable *ntc1,
49+
Incomplete *i0, Incomplete *i1) {
4050
// OK
4151
memcpy(tc0, tc1, sizeof(*tc0));
4252

53+
// OK
54+
memcpy(i0, i1, 10);
55+
4356
// expected-warning@+2{{first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'NonTriviallyCopyable'}}
4457
// expected-note@+1{{explicitly cast the pointer to silence this warning}}
4558
memcpy(ntc0, ntc1, sizeof(*ntc0));
@@ -52,10 +65,14 @@ void test_memcpy(TriviallyCopyable* tc0, TriviallyCopyable* tc1,
5265
}
5366

5467
void test_memmove(TriviallyCopyable* tc0, TriviallyCopyable* tc1,
55-
NonTriviallyCopyable *ntc0, NonTriviallyCopyable *ntc1) {
68+
NonTriviallyCopyable *ntc0, NonTriviallyCopyable *ntc1,
69+
Incomplete *i0, Incomplete *i1) {
5670
// OK
5771
memmove(tc0, tc1, sizeof(*tc0));
5872

73+
// OK
74+
memmove(i0, i1, 10);
75+
5976
// expected-warning@+2{{first argument in call to 'memmove' is a pointer to non-trivially copyable type 'NonTriviallyCopyable'}}
6077
// expected-note@+1{{explicitly cast the pointer to silence this warning}}
6178
memmove(ntc0, ntc1, sizeof(*ntc0));
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
py -3 "%~pn0" %*
1+
py -3 "%~dpn0" %*

llvm/include/llvm/Config/llvm-config.h.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 516481
19+
#define LLVM_MAIN_REVISION 516488
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Target/X86/X86ISelLowering.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,10 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
24402440
setOperationAction(ISD::FMA, MVT::v32bf16, Legal);
24412441
setOperationAction(ISD::SETCC, MVT::v32bf16, Custom);
24422442
}
2443+
for (auto VT : {MVT::f16, MVT::f32, MVT::f64}) {
2444+
setCondCodeAction(ISD::SETOEQ, VT, Custom);
2445+
setCondCodeAction(ISD::SETUNE, VT, Custom);
2446+
}
24432447
}
24442448

24452449
if (!Subtarget.useSoftFloat() && Subtarget.hasVLX()) {
@@ -24072,6 +24076,13 @@ SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
2407224076
return IsStrict ? DAG.getMergeValues({Res, Chain}, dl) : Res;
2407324077
}
2407424078

24079+
if (Subtarget.hasAVX10_2()) {
24080+
if (CC == ISD::SETOEQ || CC == ISD::SETUNE) {
24081+
auto NewCC = (CC == ISD::SETOEQ) ? X86::COND_E : (X86::COND_NE);
24082+
return getSETCC(NewCC, DAG.getNode(X86ISD::UCOMX, dl, MVT::i32, Op0, Op1),
24083+
dl, DAG);
24084+
}
24085+
}
2407524086
// Handle floating point.
2407624087
X86::CondCode CondCode = TranslateX86CC(CC, dl, /*IsFP*/ true, Op0, Op1, DAG);
2407724088
if (CondCode == X86::COND_INVALID)

llvm/lib/Target/X86/X86InstrAVX10.td

+27
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,24 @@ defm VFNMSUB132NEPBF16 : avx10_fma3p_132_bf16<0x9E, "vfnmsub132nepbf16", X86any_
15411541
//-------------------------------------------------
15421542
// AVX10 COMEF instructions
15431543
//-------------------------------------------------
1544+
multiclass avx10_com_ef<bits<8> Opc, RegisterClass RC, ValueType VT,
1545+
SDPatternOperator OpNode, string OpcodeStr,
1546+
X86MemOperand x86memop, PatFrag ld_frag,
1547+
Domain d, X86FoldableSchedWrite sched = WriteFComX>{
1548+
let ExeDomain = d, mayRaiseFPException = 1, isCodeGenOnly = 1 in {
1549+
def rr : AVX512<Opc, MRMSrcReg, (outs), (ins RC:$src1, RC:$src2),
1550+
!strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
1551+
[(set EFLAGS, (OpNode (VT RC:$src1), RC:$src2))]>,
1552+
EVEX, EVEX_V128, Sched<[sched]>, SIMD_EXC;
1553+
let mayLoad = 1 in {
1554+
def rm : AVX512<Opc, MRMSrcMem, (outs), (ins RC:$src1, x86memop:$src2),
1555+
!strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
1556+
[(set EFLAGS, (OpNode (VT RC:$src1), (ld_frag addr:$src2)))]>,
1557+
EVEX, EVEX_V128, Sched<[sched.Folded, sched.ReadAfterFold]>, SIMD_EXC;
1558+
}
1559+
}
1560+
}
1561+
15441562
multiclass avx10_com_ef_int<bits<8> Opc, X86VectorVTInfo _, SDNode OpNode,
15451563
string OpcodeStr,
15461564
Domain d,
@@ -1564,6 +1582,15 @@ multiclass avx10_com_ef_int<bits<8> Opc, X86VectorVTInfo _, SDNode OpNode,
15641582
}
15651583

15661584
let Defs = [EFLAGS], Uses = [MXCSR], Predicates = [HasAVX10_2] in {
1585+
defm VUCOMXSDZ : avx10_com_ef<0x2e, FR64X, f64, X86ucomi512,
1586+
"vucomxsd", f64mem, loadf64, SSEPackedDouble>,
1587+
TB, XS, VEX_LIG, REX_W, EVEX_CD8<64, CD8VT1>;
1588+
defm VUCOMXSHZ : avx10_com_ef<0x2e, FR16X, f16, X86ucomi512,
1589+
"vucomxsh", f16mem, loadf16, SSEPackedSingle>,
1590+
T_MAP5, XD, EVEX_CD8<16, CD8VT1>;
1591+
defm VUCOMXSSZ : avx10_com_ef<0x2e, FR32X, f32, X86ucomi512,
1592+
"vucomxss", f32mem, loadf32, SSEPackedSingle>,
1593+
TB, XD, VEX_LIG, EVEX_CD8<32, CD8VT1>;
15671594
defm VCOMXSDZ : avx10_com_ef_int<0x2f, v2f64x_info, X86comi512,
15681595
"vcomxsd", SSEPackedDouble>,
15691596
TB, XS, VEX_LIG, REX_W, EVEX_CD8<64, CD8VT1>;

0 commit comments

Comments
 (0)