Skip to content

Commit 60b619d

Browse files
committed
Merge "merge main into amd-staging" into amd-staging
2 parents 96f975a + 867cd4e commit 60b619d

File tree

92 files changed

+2122
-517
lines changed

Some content is hidden

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

92 files changed

+2122
-517
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4017,7 +4017,8 @@ purposes of calls. For example:
40174017

40184018
If a type is trivial for the purposes of calls, has a non-trivial destructor,
40194019
and is passed as an argument by value, the convention is that the callee will
4020-
destroy the object before returning.
4020+
destroy the object before returning. The lifetime of the copy of the parameter
4021+
in the caller ends without a destructor call when the call begins.
40214022

40224023
If a type is trivial for the purpose of calls, it is assumed to be trivially
40234024
relocatable for the purpose of ``__is_trivially_relocatable``.

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ isInUnspecifiedUntypedContext(internal::Matcher<Stmt> InnerMatcher) {
366366
// 4. `std::span<T>{a, n}`, where `a` is of an array-of-T with constant size
367367
// `n`
368368
// 5. `std::span<T>{any, 0}`
369+
// 6. `std::span<T>{std::addressof(...), 1}`
369370
AST_MATCHER(CXXConstructExpr, isSafeSpanTwoParamConstruct) {
370371
assert(Node.getNumArgs() == 2 &&
371372
"expecting a two-parameter std::span constructor");
@@ -410,6 +411,15 @@ AST_MATCHER(CXXConstructExpr, isSafeSpanTwoParamConstruct) {
410411
// Check form 3:
411412
return Arg1CV && Arg1CV->isOne();
412413
break;
414+
case Stmt::CallExprClass:
415+
if (const auto *CE = dyn_cast<CallExpr>(Arg0)) {
416+
const auto FnDecl = CE->getDirectCallee();
417+
if (FnDecl && FnDecl->getNameAsString() == "addressof" &&
418+
FnDecl->isInStdNamespace()) {
419+
return Arg1CV && Arg1CV->isOne();
420+
}
421+
}
422+
break;
413423
default:
414424
break;
415425
}

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ bool checkValidAfterDeviceType(
434434
// This is only a requirement on compute and loop constructs so far, so this
435435
// is fine otherwise.
436436
if (!isOpenACCComputeDirectiveKind(NewClause.getDirectiveKind()) &&
437+
!isOpenACCCombinedDirectiveKind(NewClause.getDirectiveKind()) &&
437438
NewClause.getDirectiveKind() != OpenACCDirectiveKind::Loop)
438439
return false;
439440

@@ -625,10 +626,11 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitTileClause(
625626

626627
OpenACCClause *SemaOpenACCClauseVisitor::VisitIfClause(
627628
SemaOpenACC::OpenACCParsedClause &Clause) {
628-
// Restrictions only properly implemented on 'compute' constructs, and
629-
// 'compute' constructs are the only construct that can do anything with
630-
// this yet, so skip/treat as unimplemented in this case.
631-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
629+
// Restrictions only properly implemented on 'compute'/'combined' constructs,
630+
// and 'compute'/'combined' constructs are the only construct that can do
631+
// anything with this yet, so skip/treat as unimplemented in this case.
632+
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
633+
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()))
632634
return isNotImplemented();
633635

634636
// There is no prose in the standard that says duplicates aren't allowed,
@@ -661,7 +663,8 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitSelfClause(
661663
// Restrictions only properly implemented on 'compute' constructs, and
662664
// 'compute' constructs are the only construct that can do anything with
663665
// this yet, so skip/treat as unimplemented in this case.
664-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
666+
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
667+
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()))
665668
return isNotImplemented();
666669

667670
// TODO OpenACC: When we implement this for 'update', this takes a

clang/test/AST/ast-print-openacc-combined-construct.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,19 @@ void foo() {
7171
#pragma acc kernels loop dtype(AnotherIdent)
7272
for(int i = 0;i<5;++i);
7373

74+
int i;
75+
float array[5];
76+
77+
// CHECK: #pragma acc parallel loop self(i == 3)
78+
// CHECK-NEXT: for (int i = 0; i < 5; ++i)
79+
// CHECK-NEXT: ;
80+
#pragma acc parallel loop self(i == 3)
81+
for(int i = 0;i<5;++i);
82+
83+
// CHECK: #pragma acc kernels loop if(i == array[1])
84+
// CHECK-NEXT: for (int i = 0; i < 5; ++i)
85+
// CHECK-NEXT: ;
86+
#pragma acc kernels loop if(i == array[1])
87+
for(int i = 0;i<5;++i);
7488

7589
}

clang/test/ParserOpenACC/parse-clauses.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,9 @@ void IfClause() {
266266
}
267267

268268
void SelfClause() {
269-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented, clause ignored}}
270269
#pragma acc serial loop self
271270
for(int i = 0; i < 5;++i) {}
272271

273-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented, clause ignored}}
274272
#pragma acc serial loop self, seq
275273
for(int i = 0; i < 5;++i) {}
276274

@@ -293,18 +291,15 @@ void SelfClause() {
293291
#pragma acc serial loop self(, seq
294292
for(int i = 0; i < 5;++i) {}
295293

296-
// expected-error@+2{{expected identifier}}
297-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented, clause ignored}}
294+
// expected-error@+1{{expected identifier}}
298295
#pragma acc serial loop self)
299296
for(int i = 0; i < 5;++i) {}
300297

301-
// expected-error@+2{{expected identifier}}
302-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented, clause ignored}}
298+
// expected-error@+1{{expected identifier}}
303299
#pragma acc serial loop self) seq
304300
for(int i = 0; i < 5;++i) {}
305301

306-
// expected-error@+2{{expected identifier}}
307-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented, clause ignored}}
302+
// expected-error@+1{{expected identifier}}
308303
#pragma acc serial loop self), seq
309304
for(int i = 0; i < 5;++i) {}
310305

clang/test/SemaCXX/warn-unsafe-buffer-usage-in-container-span-construct.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ namespace std {
2121

2222
template< class T >
2323
T&& move( T&& t ) noexcept;
24+
25+
template <class _Tp>
26+
_Tp* addressof(_Tp& __x) {
27+
return &__x;
28+
}
29+
2430
}
2531

2632
namespace irrelevant_constructors {
@@ -74,15 +80,26 @@ namespace construct_wt_ptr_size {
7480
return std::span<int>{p, 10}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
7581
}
7682

83+
// addressof method defined outside std namespace.
84+
template <class _Tp>
85+
_Tp* addressof(_Tp& __x) {
86+
return &__x;
87+
}
88+
7789
void notWarnSafeCases(unsigned n, int *p) {
7890
int X;
7991
unsigned Y = 10;
8092
std::span<int> S = std::span{&X, 1}; // no-warning
93+
S = std::span{std::addressof(X), 1}; // no-warning
8194
int Arr[10];
8295
typedef int TenInts_t[10];
8396
TenInts_t Arr2;
8497

8598
S = std::span{&X, 2}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
99+
S = std::span{std::addressof(X), 2}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
100+
// Warn when a non std method also named addressof
101+
S = std::span{addressof(X), 1}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
102+
86103
S = std::span{new int[10], 10}; // no-warning
87104
S = std::span{new int[n], n}; // no-warning
88105
S = std::span{new int, 1}; // no-warning

clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,8 @@ void uses() {
6060
// expected-warning@+1{{OpenACC clause 'default' not yet implemented}}
6161
#pragma acc parallel loop auto default(none)
6262
for(unsigned i = 0; i < 5; ++i);
63-
// TODOexpected-error@+1{{OpenACC 'if' clause is not valid on 'parallel loop' directive}}
64-
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
6563
#pragma acc parallel loop auto if(1)
6664
for(unsigned i = 0; i < 5; ++i);
67-
// TODOexpected-error@+1{{OpenACC 'self' clause is not valid on 'parallel loop' directive}}
68-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented}}
6965
#pragma acc parallel loop auto self
7066
for(unsigned i = 0; i < 5; ++i);
7167
// TODOexpected-error@+1{{OpenACC 'copy' clause is not valid on 'parallel loop' directive}}
@@ -234,12 +230,8 @@ void uses() {
234230
// expected-warning@+1{{OpenACC clause 'default' not yet implemented}}
235231
#pragma acc parallel loop default(none) auto
236232
for(unsigned i = 0; i < 5; ++i);
237-
// TODOexpected-error@+1{{OpenACC 'if' clause is not valid on 'parallel loop' directive}}
238-
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
239233
#pragma acc parallel loop if(1) auto
240234
for(unsigned i = 0; i < 5; ++i);
241-
// TODOexpected-error@+1{{OpenACC 'self' clause is not valid on 'parallel loop' directive}}
242-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented}}
243235
#pragma acc parallel loop self auto
244236
for(unsigned i = 0; i < 5; ++i);
245237
// TODOexpected-error@+1{{OpenACC 'copy' clause is not valid on 'parallel loop' directive}}
@@ -409,12 +401,8 @@ void uses() {
409401
// expected-warning@+1{{OpenACC clause 'default' not yet implemented}}
410402
#pragma acc parallel loop independent default(none)
411403
for(unsigned i = 0; i < 5; ++i);
412-
// TODOexpected-error@+1{{OpenACC 'if' clause is not valid on 'parallel loop' directive}}
413-
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
414404
#pragma acc parallel loop independent if(1)
415405
for(unsigned i = 0; i < 5; ++i);
416-
// TODOexpected-error@+1{{OpenACC 'self' clause is not valid on 'parallel loop' directive}}
417-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented}}
418406
#pragma acc parallel loop independent self
419407
for(unsigned i = 0; i < 5; ++i);
420408
// TODOexpected-error@+1{{OpenACC 'copy' clause is not valid on 'parallel loop' directive}}
@@ -583,12 +571,8 @@ void uses() {
583571
// expected-warning@+1{{OpenACC clause 'default' not yet implemented}}
584572
#pragma acc parallel loop default(none) independent
585573
for(unsigned i = 0; i < 5; ++i);
586-
// TODOexpected-error@+1{{OpenACC 'if' clause is not valid on 'parallel loop' directive}}
587-
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
588574
#pragma acc parallel loop if(1) independent
589575
for(unsigned i = 0; i < 5; ++i);
590-
// TODOexpected-error@+1{{OpenACC 'self' clause is not valid on 'parallel loop' directive}}
591-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented}}
592576
#pragma acc parallel loop self independent
593577
for(unsigned i = 0; i < 5; ++i);
594578
// TODOexpected-error@+1{{OpenACC 'copy' clause is not valid on 'parallel loop' directive}}
@@ -764,12 +748,8 @@ void uses() {
764748
// expected-warning@+1{{OpenACC clause 'default' not yet implemented}}
765749
#pragma acc parallel loop seq default(none)
766750
for(unsigned i = 0; i < 5; ++i);
767-
// TODOexpected-error@+1{{OpenACC 'if' clause is not valid on 'parallel loop' directive}}
768-
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
769751
#pragma acc parallel loop seq if(1)
770752
for(unsigned i = 0; i < 5; ++i);
771-
// TODOexpected-error@+1{{OpenACC 'self' clause is not valid on 'parallel loop' directive}}
772-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented}}
773753
#pragma acc parallel loop seq self
774754
for(unsigned i = 0; i < 5; ++i);
775755
// TODOexpected-error@+1{{OpenACC 'copy' clause is not valid on 'parallel loop' directive}}
@@ -944,12 +924,8 @@ void uses() {
944924
// expected-warning@+1{{OpenACC clause 'default' not yet implemented}}
945925
#pragma acc parallel loop default(none) seq
946926
for(unsigned i = 0; i < 5; ++i);
947-
// TODOexpected-error@+1{{OpenACC 'if' clause is not valid on 'parallel loop' directive}}
948-
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
949927
#pragma acc parallel loop if(1) seq
950928
for(unsigned i = 0; i < 5; ++i);
951-
// TODOexpected-error@+1{{OpenACC 'self' clause is not valid on 'parallel loop' directive}}
952-
// expected-warning@+1{{OpenACC clause 'self' not yet implemented}}
953929
#pragma acc parallel loop self seq
954930
for(unsigned i = 0; i < 5; ++i);
955931
// TODOexpected-error@+1{{OpenACC 'copy' clause is not valid on 'parallel loop' directive}}

0 commit comments

Comments
 (0)