Skip to content

Commit e233907

Browse files
committed
merge main into amd-staging
2 parents 4cace7e + efd96af commit e233907

File tree

71 files changed

+1610
-3406
lines changed

Some content is hidden

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

71 files changed

+1610
-3406
lines changed

.ci/all_requirements.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ ml-dtypes==0.5.1 ; python_version < "3.13" \
194194
--hash=sha256:d13755f8e8445b3870114e5b6240facaa7cb0c3361e54beba3e07fa912a6e12b \
195195
--hash=sha256:fd918d4e6a4e0c110e2e05be7a7814d10dc1b95872accbf6512b80a109b71ae1
196196
# via -r mlir/python/requirements.txt
197-
nanobind==2.7.0 \
198-
--hash=sha256:73b12d0e751d140d6c1bf4b215e18818a8debfdb374f08dc3776ad208d808e74 \
199-
--hash=sha256:f9f1b160580c50dcf37b6495a0fd5ec61dc0d95dae5f8004f87dd9ad7eb46b34
197+
nanobind==2.9.2 \
198+
--hash=sha256:c37957ffd5eac7eda349cff3622ecd32e5ee1244ecc912c99b5bc8188bafd16e \
199+
--hash=sha256:e7608472de99d375759814cab3e2c94aba3f9ec80e62cfef8ced495ca5c27d6e
200200
# via -r mlir/python/requirements.txt
201201
numpy==2.0.2 \
202202
--hash=sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a \
@@ -383,6 +383,10 @@ swig==4.3.1 \
383383
--hash=sha256:efec16327029f682f649a26da726bb0305be8800bd0f1fa3e81bf0769cf5b476 \
384384
--hash=sha256:fc496c0d600cf1bb2d91e28d3d6eae9c4301e5ea7a0dec5a4281b5efed4245a8
385385
# via -r lldb/test/requirements.txt
386+
typing-extensions==4.15.0 \
387+
--hash=sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466 \
388+
--hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548
389+
# via -r mlir/python/requirements.txt
386390
urllib3==2.5.0 \
387391
--hash=sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760 \
388392
--hash=sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc

clang-tools-extra/clang-tidy/custom/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
99
QueryCheck.cpp
1010

1111
LINK_LIBS
12+
clangQuery
1213
clangTidy
1314
clangTidyBugproneModule
1415
clangTidyMiscModule
@@ -31,7 +32,6 @@ if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
3132
clangDynamicASTMatchers
3233
clangFrontend
3334
clangLex
34-
clangQuery
3535
clangSerialization
3636
clangTooling
3737
)

clang/lib/AST/Expr.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,18 @@ Stmt *BlockExpr::getBody() {
25452545
// Generic Expression Routines
25462546
//===----------------------------------------------------------------------===//
25472547

2548+
/// Helper to determine wether \c E is a CXXConstructExpr constructing
2549+
/// a DecompositionDecl. Used to skip Clang-generated calls to std::get
2550+
/// for structured bindings.
2551+
static bool IsDecompositionDeclRefExpr(const Expr *E) {
2552+
const auto *Unwrapped = E->IgnoreUnlessSpelledInSource();
2553+
const auto *Ref = dyn_cast<DeclRefExpr>(Unwrapped);
2554+
if (!Ref)
2555+
return false;
2556+
2557+
return isa_and_nonnull<DecompositionDecl>(Ref->getDecl());
2558+
}
2559+
25482560
bool Expr::isReadIfDiscardedInCPlusPlus11() const {
25492561
// In C++11, discarded-value expressions of a certain form are special,
25502562
// according to [expr]p10:
@@ -3159,10 +3171,39 @@ Expr *Expr::IgnoreUnlessSpelledInSource() {
31593171
}
31603172
return E;
31613173
};
3174+
3175+
// Used when Clang generates calls to std::get for decomposing
3176+
// structured bindings.
3177+
auto IgnoreImplicitCallSingleStep = [](Expr *E) {
3178+
auto *C = dyn_cast<CallExpr>(E);
3179+
if (!C)
3180+
return E;
3181+
3182+
// Looking for calls to a std::get, which usually just takes
3183+
// 1 argument (i.e., the structure being decomposed). If it has
3184+
// more than 1 argument, the others need to be defaulted.
3185+
unsigned NumArgs = C->getNumArgs();
3186+
if (NumArgs == 0 || (NumArgs > 1 && !isa<CXXDefaultArgExpr>(C->getArg(1))))
3187+
return E;
3188+
3189+
Expr *A = C->getArg(0);
3190+
3191+
// This was spelled out in source. Don't ignore.
3192+
if (A->getSourceRange() != E->getSourceRange())
3193+
return E;
3194+
3195+
// If the argument refers to a DecompositionDecl construction,
3196+
// ignore it.
3197+
if (IsDecompositionDeclRefExpr(A))
3198+
return A;
3199+
3200+
return E;
3201+
};
3202+
31623203
return IgnoreExprNodes(
31633204
this, IgnoreImplicitSingleStep, IgnoreImplicitCastsExtraSingleStep,
31643205
IgnoreParensOnlySingleStep, IgnoreImplicitConstructorSingleStep,
3165-
IgnoreImplicitMemberCallSingleStep);
3206+
IgnoreImplicitMemberCallSingleStep, IgnoreImplicitCallSingleStep);
31663207
}
31673208

31683209
bool Expr::isDefaultArgument() const {

clang/test/DebugInfo/CXX/structured-binding.cpp

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg.declare"
1+
// RUN: %clang_cc1 -std=c++23 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg.declare"
22

3+
// CHECK: define {{.*}} i32 @_Z1fv
34
// CHECK: #dbg_declare(ptr %{{[a-z]+}}, ![[VAR_0:[0-9]+]], !DIExpression(),
45
// CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_1:[0-9]+]], !DIExpression(),
56
// CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_2:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 4),
67
// CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_3:[0-9]+]], !DIExpression(DW_OP_deref),
78
// CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_4:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 4),
89
// CHECK: #dbg_declare(ptr %z1, ![[VAR_5:[0-9]+]], !DIExpression()
910
// CHECK: #dbg_declare(ptr %z2, ![[VAR_6:[0-9]+]], !DIExpression()
11+
// CHECK: #dbg_declare(ptr %k, ![[VAR_7:[0-9]+]], !DIExpression()
12+
// CHECK: #dbg_declare(ptr %v, ![[VAR_8:[0-9]+]], !DIExpression()
13+
// CHECK: #dbg_declare(ptr %w, ![[VAR_9:[0-9]+]], !DIExpression()
14+
// CHECK: #dbg_declare(ptr %m, ![[VAR_10:[0-9]+]], !DIExpression()
15+
// CHECK: #dbg_declare(ptr %n, ![[VAR_11:[0-9]+]], !DIExpression()
16+
// CHECK: #dbg_declare(ptr %s, ![[VAR_12:[0-9]+]], !DIExpression()
17+
// CHECK: #dbg_declare(ptr %p, ![[VAR_13:[0-9]+]], !DIExpression()
1018
// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y1_DEBUG_LOC:[0-9]+]]
1119
// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y2_DEBUG_LOC:[0-9]+]]
1220
// CHECK: load ptr, ptr %z2, {{.*}}!dbg ![[Z2_DEBUG_LOC:[0-9]+]]
@@ -20,6 +28,13 @@
2028
// CHECK: ![[VAR_4]] = !DILocalVariable(name: "y2", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
2129
// CHECK: ![[VAR_5]] = !DILocalVariable(name: "z1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
2230
// CHECK: ![[VAR_6]] = !DILocalVariable(name: "z2", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
31+
// CHECK: ![[VAR_7]] = !DILocalVariable(name: "k", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
32+
// CHECK: ![[VAR_8]] = !DILocalVariable(name: "v", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
33+
// CHECK: ![[VAR_9]] = !DILocalVariable(name: "w", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
34+
// CHECK: ![[VAR_10]] = !DILocalVariable(name: "m", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
35+
// CHECK: ![[VAR_11]] = !DILocalVariable(name: "n", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
36+
// CHECK: ![[VAR_12]] = !DILocalVariable(name: "s", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
37+
// CHECK: ![[VAR_13]] = !DILocalVariable(name: "p", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
2338

2439
struct A {
2540
int x;
@@ -34,6 +49,22 @@ struct B {
3449
template<> int get<1>() { return z; }
3550
};
3651

52+
struct C {
53+
int w;
54+
int z;
55+
template<int> int get(this C&& self);
56+
template<> int get<0>(this C&& self) { return self.w; }
57+
template<> int get<1>(this C&& self) { return self.z; }
58+
};
59+
60+
struct D {
61+
int w;
62+
int z;
63+
template<int> int get(int unused = 0);
64+
template<> int get<0>(int unused) { return w; }
65+
template<> int get<1>(int unused) { return z; }
66+
};
67+
3768
// Note: the following declarations are necessary for decomposition of tuple-like
3869
// structured bindings
3970
namespace std {
@@ -44,7 +75,35 @@ struct tuple_size<B> {
4475
static constexpr unsigned value = 2;
4576
};
4677

78+
template<>
79+
struct tuple_size<C> {
80+
static constexpr unsigned value = 2;
81+
};
82+
83+
template<>
84+
struct tuple_size<D> {
85+
static constexpr unsigned value = 2;
86+
};
87+
4788
template<unsigned, typename T> struct tuple_element { using type = int; };
89+
90+
// Decomposition of tuple-like bindings but where the `get` methods
91+
// are declared as free functions.
92+
struct triple {
93+
int k;
94+
int v;
95+
int w;
96+
};
97+
98+
template<>
99+
struct tuple_size<triple> {
100+
static constexpr unsigned value = 3;
101+
};
102+
103+
template <unsigned I> int get(triple);
104+
template <> int get<0>(triple p) { return p.k; }
105+
template <> int get<1>(triple p) { return p.v; }
106+
template <> int get<2>(triple p) { return p.w; }
48107
} // namespace std
49108

50109
int f() {
@@ -58,6 +117,9 @@ int f() {
58117
auto &[c1, c2] = cmplx;
59118
int vctr __attribute__ ((vector_size (sizeof(int)*2)))= {1, 2};
60119
auto &[v1, v2] = vctr;
120+
auto [k, v, w] = std::triple{3, 4, 5};
121+
auto [m, n] = C{2, 3};
122+
auto [s, p] = D{2, 3};
61123
return //
62124
x1 //
63125
+ //

clang/test/Modules/no-stale-modtime.m

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,45 @@
33

44
// RUN: rm -rf %t
55
// RUN: mkdir -p %t
6-
// This could be replaced by diamond_*, except we want to modify the top header
7-
// RUN: echo '@import l; @import r;' > %t/b.h
8-
// RUN: echo '@import t; // fromt l' > %t/l.h
9-
// RUN: echo '@import t; // fromt r' > %t/r.h
6+
// RUN: split-file %s %t
107

11-
// RUN: echo '// top' > %t/t.h-1
128
// RUN: cat %t/t.h-1 > %t/t.h
139

14-
// RUN: echo 'module b { header "b.h" } module l { header "l.h" }' > %t/module.modulemap-1
15-
// RUN: echo 'module r { header "r.h" } module t { header "t.h" }' > %t/module.modulemap-2
16-
// RUN: cat %t/module.modulemap-1 %t/module.modulemap-2 > %t/module.modulemap
17-
1810
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
19-
// RUN: -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
20-
// RUN: | FileCheck -check-prefix=REBUILD-ALL %s
11+
// RUN: -I %t -fsyntax-only %t/main.m -Rmodule-build 2>&1 \
12+
// RUN: | FileCheck -check-prefix=REBUILD-ALL %t/main.m
2113
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
22-
// RUN: -I %t -fsyntax-only %s -Rmodule-build -verify
14+
// RUN: -I %t -fsyntax-only %t/main.m -Rmodule-build -verify
2315

2416
// Add an identifier to ensure everything depending on t is out of date
25-
// RUN: echo 'extern int a;' > %t/t.h-2
2617
// RUN: cat %t/t.h-1 %t/t.h-2 > %t/t.h
2718

2819
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
29-
// RUN: -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
30-
// RUN: | FileCheck -check-prefix=REBUILD-ALL %s
20+
// RUN: -I %t -fsyntax-only %t/main.m -Rmodule-build 2>&1 \
21+
// RUN: | FileCheck -check-prefix=REBUILD-ALL %t/main.m
3122
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
32-
// RUN: -I %t -fsyntax-only %s -Rmodule-build -verify
23+
// RUN: -I %t -fsyntax-only %t/main.m -Rmodule-build -verify
24+
25+
//--- b.h
26+
@import l; @import r;
27+
28+
//--- l.h
29+
@import t; // fromt l
30+
31+
//--- r.h
32+
@import t; // fromt r
33+
34+
//--- t.h-1
35+
// top
36+
37+
//--- t.h-2
38+
extern int a;
39+
40+
//--- module.modulemap
41+
module b { header "b.h" } module l { header "l.h" }
42+
module r { header "r.h" } module t { header "t.h" }
43+
44+
//--- main.m
3345

3446
// REBUILD-ALL: building module 'b'
3547
// REBUILD-ALL: building module 'l'
@@ -38,5 +50,4 @@
3850

3951
// Use -verify when expecting no modules to be rebuilt.
4052
// expected-no-diagnostics
41-
4253
@import b;

clang/unittests/AST/ASTTraverserTest.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,12 @@ struct Pair
11741174
int x, y;
11751175
};
11761176
1177+
// Tuple-like structure with a `get` method that has a default argument.
1178+
struct Pair2
1179+
{
1180+
int x, y;
1181+
};
1182+
11771183
// Note: these utilities are required to force binding to tuple like structure
11781184
namespace std
11791185
{
@@ -1188,6 +1194,12 @@ namespace std
11881194
static constexpr size_t value = 2;
11891195
};
11901196
1197+
template <>
1198+
struct tuple_size<Pair2>
1199+
{
1200+
static constexpr size_t value = 2;
1201+
};
1202+
11911203
template <size_t I, class T>
11921204
struct tuple_element
11931205
{
@@ -1199,12 +1211,17 @@ namespace std
11991211
template <size_t I>
12001212
int &&get(Pair &&p);
12011213
1214+
template <size_t I>
1215+
int &&get(Pair2 &&p, int unused = 0);
1216+
12021217
void decompTuple()
12031218
{
12041219
Pair p{1, 2};
12051220
auto [a, b] = p;
12061221
12071222
a = 3;
1223+
1224+
auto [c, d] = Pair2{3, 4};
12081225
}
12091226
12101227
)cpp",
@@ -1586,6 +1603,62 @@ DecompositionDecl ''
15861603
|-DeclRefExpr 'p'
15871604
|-BindingDecl 'a'
15881605
`-BindingDecl 'b'
1606+
)cpp");
1607+
}
1608+
1609+
{
1610+
auto FN = ast_matchers::match(
1611+
functionDecl(hasName("decompTuple"),
1612+
hasDescendant(callExpr(hasAncestor(varDecl(
1613+
hasName("a"),
1614+
hasAncestor(bindingDecl()))))
1615+
.bind("decomp_call"))),
1616+
AST2->getASTContext());
1617+
EXPECT_EQ(FN.size(), 1u);
1618+
1619+
EXPECT_EQ(dumpASTString(TK_AsIs, FN[0].getNodeAs<CallExpr>("decomp_call")),
1620+
R"cpp(
1621+
CallExpr
1622+
|-ImplicitCastExpr
1623+
| `-DeclRefExpr 'get'
1624+
`-ImplicitCastExpr
1625+
`-DeclRefExpr ''
1626+
)cpp");
1627+
1628+
EXPECT_EQ(dumpASTString(TK_IgnoreUnlessSpelledInSource,
1629+
FN[0].getNodeAs<CallExpr>("decomp_call")),
1630+
R"cpp(
1631+
DeclRefExpr ''
1632+
)cpp");
1633+
}
1634+
1635+
{
1636+
auto FN = ast_matchers::match(
1637+
functionDecl(hasName("decompTuple"),
1638+
hasDescendant(callExpr(hasAncestor(varDecl(
1639+
hasName("c"),
1640+
hasAncestor(bindingDecl()))))
1641+
.bind("decomp_call_with_default"))),
1642+
AST2->getASTContext());
1643+
EXPECT_EQ(FN.size(), 1u);
1644+
1645+
EXPECT_EQ(dumpASTString(TK_AsIs, FN[0].getNodeAs<CallExpr>(
1646+
"decomp_call_with_default")),
1647+
R"cpp(
1648+
CallExpr
1649+
|-ImplicitCastExpr
1650+
| `-DeclRefExpr 'get'
1651+
|-ImplicitCastExpr
1652+
| `-DeclRefExpr ''
1653+
`-CXXDefaultArgExpr
1654+
`-IntegerLiteral
1655+
)cpp");
1656+
1657+
EXPECT_EQ(
1658+
dumpASTString(TK_IgnoreUnlessSpelledInSource,
1659+
FN[0].getNodeAs<CallExpr>("decomp_call_with_default")),
1660+
R"cpp(
1661+
DeclRefExpr ''
15891662
)cpp");
15901663
}
15911664
}

libc/test/shared/shared_math_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
5757
EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::cosf(0.0f));
5858
EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::coshf(0.0f));
5959
EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::cospif(0.0f));
60-
EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::dsqrtl(0.0f));
6160
EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::erff(0.0f));
6261
EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::exp10f(0.0f));
6362
EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::expf(0.0f));
@@ -77,6 +76,7 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
7776
EXPECT_FP_EQ(0x0p+0, LIBC_NAMESPACE::shared::atan2(0.0, 0.0));
7877
EXPECT_FP_EQ(0x0p+0, LIBC_NAMESPACE::shared::cbrt(0.0));
7978
EXPECT_FP_EQ(0x1p+0, LIBC_NAMESPACE::shared::cos(0.0));
79+
EXPECT_FP_EQ(0x0p+0, LIBC_NAMESPACE::shared::dsqrtl(0.0));
8080
EXPECT_FP_EQ(0x1p+0, LIBC_NAMESPACE::shared::exp(0.0));
8181
EXPECT_FP_EQ(0x1p+0, LIBC_NAMESPACE::shared::exp10(0.0));
8282
}

0 commit comments

Comments
 (0)