Skip to content

Commit ed851fa

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/113324-follow_up
2 parents 3ad3b6c + 0f04043 commit ed851fa

File tree

133 files changed

+5421
-2222
lines changed

Some content is hidden

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

133 files changed

+5421
-2222
lines changed

clang/docs/AMDGPUSupport.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ Predefined Macros
5050
* - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
5151
- Defined if unsafe floating-point atomics are allowed.
5252
* - ``__AMDGCN_WAVEFRONT_SIZE__``
53-
- Defines the wavefront size. Allowed values are 32 and 64.
53+
- Defines the wavefront size. Allowed values are 32 and 64 (deprecated).
5454
* - ``__AMDGCN_WAVEFRONT_SIZE``
55-
- Alias to ``__AMDGCN_WAVEFRONT_SIZE__``. To be deprecated.
55+
- Alias to ``__AMDGCN_WAVEFRONT_SIZE__`` (deprecated).
5656
* - ``__HAS_FMAF__``
5757
- Defined if FMAF instruction is available (deprecated).
5858
* - ``__HAS_LDEXPF__``

clang/docs/HIPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Predefined Macros
178178

179179
Note that some architecture specific AMDGPU macros will have default values when
180180
used from the HIP host compilation. Other :doc:`AMDGPU macros <AMDGPUSupport>`
181-
like ``__AMDGCN_WAVEFRONT_SIZE__`` will default to 64 for example.
181+
like ``__AMDGCN_WAVEFRONT_SIZE__`` (deprecated) will default to 64 for example.
182182

183183
Compilation Modes
184184
=================

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12747,6 +12747,19 @@ def err_acc_gang_reduction_numgangs_conflict
1274712747
def err_reduction_op_mismatch
1274812748
: Error<"OpenACC 'reduction' variable must have the same operator in all "
1274912749
"nested constructs (%0 vs %1)">;
12750+
def err_acc_loop_variable_type
12751+
: Error<"loop variable of loop associated with an OpenACC 'loop' construct "
12752+
"must be of integer, pointer, or random-access-iterator type (is "
12753+
"%0)">;
12754+
def err_acc_loop_variable
12755+
: Error<"OpenACC 'loop' construct must have initialization clause in "
12756+
"canonical form ('var = init' or 'T var = init')">;
12757+
def err_acc_loop_terminating_condition
12758+
: Error<"OpenACC 'loop' construct must have a terminating condition">;
12759+
def err_acc_loop_not_monotonic
12760+
: Error<"OpenACC 'loop' variable must monotonically increase or decrease "
12761+
"('++', '--', or compound assignment)">;
12762+
1275012763
// AMDGCN builtins diagnostics
1275112764
def err_amdgcn_global_load_lds_size_invalid_value : Error<"invalid size value">;
1275212765
def note_amdgcn_global_load_lds_size_valid_value : Note<"size must be 1, 2, or 4">;

clang/include/clang/Basic/MacroBuilder.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ class MacroBuilder {
2626
MacroBuilder(raw_ostream &Output) : Out(Output) {}
2727

2828
/// Append a \#define line for macro of the form "\#define Name Value\n".
29-
void defineMacro(const Twine &Name, const Twine &Value = "1") {
29+
/// If DeprecationMsg is provided, also append a pragma to deprecate the
30+
/// defined macro.
31+
void defineMacro(const Twine &Name, const Twine &Value = "1",
32+
Twine DeprecationMsg = "") {
3033
Out << "#define " << Name << ' ' << Value << '\n';
34+
if (!DeprecationMsg.isTriviallyEmpty())
35+
Out << "#pragma clang deprecated(" << Name << ", \"" << DeprecationMsg
36+
<< "\")\n";
3137
}
3238

3339
/// Append a \#undef line for Name. Name should be of the form XXX

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,43 @@ class SemaOpenACC : public SemaBase {
118118
/// 'loop' clause enforcement, where this is 'blocked' by a compute construct.
119119
llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
120120

121+
// Type to check the info about the 'for stmt'.
122+
struct ForStmtBeginChecker {
123+
SemaOpenACC &SemaRef;
124+
SourceLocation ForLoc;
125+
bool IsRangeFor = false;
126+
std::optional<const CXXForRangeStmt *> RangeFor = nullptr;
127+
const Stmt *Init = nullptr;
128+
bool InitChanged = false;
129+
std::optional<const Stmt *> Cond = nullptr;
130+
std::optional<const Stmt *> Inc = nullptr;
131+
// Prevent us from checking 2x, which can happen with collapse & tile.
132+
bool AlreadyChecked = false;
133+
134+
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
135+
std::optional<const CXXForRangeStmt *> S)
136+
: SemaRef(SemaRef), ForLoc(ForLoc), IsRangeFor(true), RangeFor(S) {}
137+
138+
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
139+
const Stmt *I, bool InitChanged,
140+
std::optional<const Stmt *> C,
141+
std::optional<const Stmt *> Inc)
142+
: SemaRef(SemaRef), ForLoc(ForLoc), IsRangeFor(false), Init(I),
143+
InitChanged(InitChanged), Cond(C), Inc(Inc) {}
144+
// Do the checking for the For/Range-For. Currently this implements the 'not
145+
// seq' restrictions only, and should be called either if we know we are a
146+
// top-level 'for' (the one associated via associated-stmt), or extended via
147+
// 'collapse'.
148+
void check();
149+
150+
const ValueDecl *checkInit();
151+
void checkCond();
152+
void checkInc(const ValueDecl *Init);
153+
};
154+
155+
/// Helper function for checking the 'for' and 'range for' stmts.
156+
void ForStmtBeginHelper(SourceLocation ForLoc, ForStmtBeginChecker &C);
157+
121158
public:
122159
ComputeConstructInfo &getActiveComputeConstructInfo() {
123160
return ActiveComputeConstructInfo;
@@ -137,6 +174,11 @@ class SemaOpenACC : public SemaBase {
137174
/// permits us to implement the restriction of no further 'gang', 'vector', or
138175
/// 'worker' clauses.
139176
SourceLocation LoopVectorClauseLoc;
177+
/// If there is a current 'active' loop construct that does NOT have a 'seq'
178+
/// clause on it, this has that source location. This permits us to implement
179+
/// the 'loop' restrictions on the loop variable. This can be extended via
180+
/// 'collapse', so we need to keep this around for a while.
181+
SourceLocation LoopWithoutSeqLoc;
140182

141183
// Redeclaration of the version in OpenACCClause.h.
142184
using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
@@ -568,8 +610,19 @@ class SemaOpenACC : public SemaBase {
568610
void ActOnWhileStmt(SourceLocation WhileLoc);
569611
// Called when we encounter a 'do' statement, before looking at its 'body'.
570612
void ActOnDoStmt(SourceLocation DoLoc);
613+
// Called when we encounter a 'for' statement, before looking at its 'body',
614+
// for the 'range-for'. 'ActOnForStmtEnd' is used after the body.
615+
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor,
616+
const Stmt *RangeFor);
617+
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *RangeFor);
571618
// Called when we encounter a 'for' statement, before looking at its 'body'.
572-
void ActOnForStmtBegin(SourceLocation ForLoc);
619+
// 'ActOnForStmtEnd' is used after the body.
620+
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First,
621+
const Stmt *Second, const Stmt *Third);
622+
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *OldFirst,
623+
const Stmt *First, const Stmt *OldSecond,
624+
const Stmt *Second, const Stmt *OldThird,
625+
const Stmt *Third);
573626
// Called when we encounter a 'for' statement, after we've consumed/checked
574627
// the body. This is necessary for a number of checks on the contents of the
575628
// 'for' statement.
@@ -598,7 +651,9 @@ class SemaOpenACC : public SemaBase {
598651
/// Called when we encounter an associated statement for our construct, this
599652
/// should check legality of the statement as it appertains to this Construct.
600653
StmtResult ActOnAssociatedStmt(SourceLocation DirectiveLoc,
601-
OpenACCDirectiveKind K, StmtResult AssocStmt);
654+
OpenACCDirectiveKind K,
655+
ArrayRef<const OpenACCClause *> Clauses,
656+
StmtResult AssocStmt);
602657

603658
/// Called after the directive has been completely parsed, including the
604659
/// declaration group or associated statement.
@@ -712,12 +767,13 @@ class SemaOpenACC : public SemaBase {
712767
SourceLocation OldLoopGangClauseOnKernelLoc;
713768
SourceLocation OldLoopWorkerClauseLoc;
714769
SourceLocation OldLoopVectorClauseLoc;
770+
SourceLocation OldLoopWithoutSeqLoc;
715771
llvm::SmallVector<OpenACCLoopConstruct *> ParentlessLoopConstructs;
716772
llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
717773
LoopInConstructRAII LoopRAII;
718774

719775
public:
720-
AssociatedStmtRAII(SemaOpenACC &, OpenACCDirectiveKind,
776+
AssociatedStmtRAII(SemaOpenACC &, OpenACCDirectiveKind, SourceLocation,
721777
ArrayRef<const OpenACCClause *>,
722778
ArrayRef<OpenACCClause *>);
723779
void SetCollapseInfoBeforeAssociatedStmt(

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,12 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
337337
if (hasFastFMA())
338338
Builder.defineMacro("FP_FAST_FMA");
339339

340-
Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE__", Twine(WavefrontSize));
341-
// ToDo: deprecate this macro for naming consistency.
342-
Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE", Twine(WavefrontSize));
340+
Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE__", Twine(WavefrontSize),
341+
"compile-time-constant access to the wavefront size will "
342+
"be removed in a future release");
343+
Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE", Twine(WavefrontSize),
344+
"compile-time-constant access to the wavefront size will "
345+
"be removed in a future release");
343346
Builder.defineMacro("__AMDGCN_CUMODE__", Twine(CUMode));
344347
}
345348

clang/lib/Headers/emmintrin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4627,7 +4627,7 @@ _mm_movepi64_pi64(__m128i __a) {
46274627
/// \returns A 128-bit integer vector. The lower 64 bits contain the value from
46284628
/// the operand. The upper 64 bits are assigned zeros.
46294629
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_movpi64_epi64(__m64 __a) {
4630-
return __extension__(__m128i)(__v2di){(long long)__a, 0};
4630+
return __builtin_shufflevector((__v1di)__a, _mm_setzero_si64(), 0, 1);
46314631
}
46324632

46334633
/// Moves the lower 64 bits of a 128-bit integer vector to a 128-bit

clang/lib/Headers/stdalign.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#ifndef __STDALIGN_H
1111
#define __STDALIGN_H
1212

13-
#if defined(__MVS__) && __has_include_next(<stdalign.h>)
14-
#include_next <stdalign.h>
15-
#else
16-
1713
#if defined(__cplusplus) || \
1814
(defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L)
1915
#ifndef __cplusplus
@@ -25,5 +21,4 @@
2521
#define __alignof_is_defined 1
2622
#endif /* __STDC_VERSION__ */
2723

28-
#endif /* __MVS__ */
2924
#endif /* __STDALIGN_H */

clang/lib/Parse/ParseOpenACC.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,14 +1498,15 @@ StmtResult Parser::ParseOpenACCDirectiveStmt() {
14981498
return StmtError();
14991499

15001500
StmtResult AssocStmt;
1501-
SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
1502-
getActions().OpenACC(), DirInfo.DirKind, {}, DirInfo.Clauses);
1501+
SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(getActions().OpenACC(),
1502+
DirInfo.DirKind, DirInfo.DirLoc,
1503+
{}, DirInfo.Clauses);
15031504
if (doesDirectiveHaveAssociatedStmt(DirInfo.DirKind)) {
15041505
ParsingOpenACCDirectiveRAII DirScope(*this, /*Value=*/false);
15051506
ParseScope ACCScope(this, getOpenACCScopeFlags(DirInfo.DirKind));
15061507

15071508
AssocStmt = getActions().OpenACC().ActOnAssociatedStmt(
1508-
DirInfo.StartLoc, DirInfo.DirKind, ParseStatement());
1509+
DirInfo.StartLoc, DirInfo.DirKind, DirInfo.Clauses, ParseStatement());
15091510
}
15101511

15111512
return getActions().OpenACC().ActOnEndStmtDirective(

clang/lib/Parse/ParseStmt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2360,7 +2360,11 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
23602360
// OpenACC Restricts a for-loop inside of certain construct/clause
23612361
// combinations, so diagnose that here in OpenACC mode.
23622362
SemaOpenACC::LoopInConstructRAII LCR{getActions().OpenACC()};
2363-
getActions().OpenACC().ActOnForStmtBegin(ForLoc);
2363+
if (ForRangeInfo.ParsedForRangeDecl())
2364+
getActions().OpenACC().ActOnRangeForStmtBegin(ForLoc, ForRangeStmt.get());
2365+
else
2366+
getActions().OpenACC().ActOnForStmtBegin(
2367+
ForLoc, FirstPart.get(), SecondPart.get().second, ThirdPart.get());
23642368

23652369
// C99 6.8.5p5 - In C99, the body of the for statement is a scope, even if
23662370
// there is no compound stmt. C90 does not have this clause. We only do this

0 commit comments

Comments
 (0)