Skip to content

Commit 8978764

Browse files
author
Valery N Dmitriev
committed
Merge from 'master' to 'sycl-web' (#25)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/BackendUtil.cpp
2 parents 1094c85 + c92a8c0 commit 8978764

File tree

112 files changed

+1131
-471
lines changed

Some content is hidden

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

112 files changed

+1131
-471
lines changed

clang/include/clang-c/Index.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ enum CXCursorKind {
21672167
*/
21682168
CXCursor_ObjCSelfExpr = 147,
21692169

2170-
/** OpenMP 4.0 [2.4, Array Section].
2170+
/** OpenMP 5.0 [2.1.5, Array Section].
21712171
*/
21722172
CXCursor_OMPArraySectionExpr = 148,
21732173

clang/include/clang/AST/ExprOpenMP.h

+39-15
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,61 @@
1717
#include "clang/AST/Expr.h"
1818

1919
namespace clang {
20-
/// OpenMP 4.0 [2.4, Array Sections].
20+
/// OpenMP 5.0 [2.1.5, Array Sections].
2121
/// To specify an array section in an OpenMP construct, array subscript
2222
/// expressions are extended with the following syntax:
2323
/// \code
24+
/// [ lower-bound : length : stride ]
25+
/// [ lower-bound : length : ]
2426
/// [ lower-bound : length ]
27+
/// [ lower-bound : : stride ]
28+
/// [ lower-bound : : ]
2529
/// [ lower-bound : ]
30+
/// [ : length : stride ]
31+
/// [ : length : ]
2632
/// [ : length ]
33+
/// [ : : stride ]
34+
/// [ : : ]
2735
/// [ : ]
2836
/// \endcode
2937
/// The array section must be a subset of the original array.
3038
/// Array sections are allowed on multidimensional arrays. Base language array
3139
/// subscript expressions can be used to specify length-one dimensions of
3240
/// multidimensional array sections.
33-
/// The lower-bound and length are integral type expressions. When evaluated
41+
/// Each of the lower-bound, length, and stride expressions if specified must be
42+
/// an integral type expressions of the base language. When evaluated
3443
/// they represent a set of integer values as follows:
3544
/// \code
36-
/// { lower-bound, lower-bound + 1, lower-bound + 2,... , lower-bound + length -
37-
/// 1 }
45+
/// { lower-bound, lower-bound + stride, lower-bound + 2 * stride,... ,
46+
/// lower-bound + ((length - 1) * stride) }
3847
/// \endcode
3948
/// The lower-bound and length must evaluate to non-negative integers.
49+
/// The stride must evaluate to a positive integer.
4050
/// When the size of the array dimension is not known, the length must be
4151
/// specified explicitly.
42-
/// When the length is absent, it defaults to the size of the array dimension
43-
/// minus the lower-bound.
44-
/// When the lower-bound is absent it defaults to 0.
52+
/// When the stride is absent it defaults to 1.
53+
/// When the length is absent it defaults to ⌈(size − lower-bound)/stride⌉,
54+
/// where size is the size of the array dimension. When the lower-bound is
55+
/// absent it defaults to 0.
4556
class OMPArraySectionExpr : public Expr {
46-
enum { BASE, LOWER_BOUND, LENGTH, END_EXPR };
57+
enum { BASE, LOWER_BOUND, LENGTH, STRIDE, END_EXPR };
4758
Stmt *SubExprs[END_EXPR];
48-
SourceLocation ColonLoc;
59+
SourceLocation ColonLocFirst;
60+
SourceLocation ColonLocSecond;
4961
SourceLocation RBracketLoc;
5062

5163
public:
52-
OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, QualType Type,
53-
ExprValueKind VK, ExprObjectKind OK,
54-
SourceLocation ColonLoc, SourceLocation RBracketLoc)
55-
: Expr(OMPArraySectionExprClass, Type, VK, OK), ColonLoc(ColonLoc),
64+
OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride,
65+
QualType Type, ExprValueKind VK, ExprObjectKind OK,
66+
SourceLocation ColonLocFirst,
67+
SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
68+
: Expr(OMPArraySectionExprClass, Type, VK, OK),
69+
ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
5670
RBracketLoc(RBracketLoc) {
5771
SubExprs[BASE] = Base;
5872
SubExprs[LOWER_BOUND] = LowerBound;
5973
SubExprs[LENGTH] = Length;
74+
SubExprs[STRIDE] = Stride;
6075
setDependence(computeDependence(this));
6176
}
6277

@@ -89,13 +104,22 @@ class OMPArraySectionExpr : public Expr {
89104
/// Set length of the array section.
90105
void setLength(Expr *E) { SubExprs[LENGTH] = E; }
91106

107+
/// Get stride of array section.
108+
Expr *getStride() { return cast_or_null<Expr>(SubExprs[STRIDE]); }
109+
const Expr *getStride() const { return cast_or_null<Expr>(SubExprs[STRIDE]); }
110+
/// Set length of the array section.
111+
void setStride(Expr *E) { SubExprs[STRIDE] = E; }
112+
92113
SourceLocation getBeginLoc() const LLVM_READONLY {
93114
return getBase()->getBeginLoc();
94115
}
95116
SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
96117

97-
SourceLocation getColonLoc() const { return ColonLoc; }
98-
void setColonLoc(SourceLocation L) { ColonLoc = L; }
118+
SourceLocation getColonLocFirst() const { return ColonLocFirst; }
119+
void setColonLocFirst(SourceLocation L) { ColonLocFirst = L; }
120+
121+
SourceLocation getColonLocSecond() const { return ColonLocSecond; }
122+
void setColonLocSecond(SourceLocation L) { ColonLocSecond = L; }
99123

100124
SourceLocation getRBracketLoc() const { return RBracketLoc; }
101125
void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }

clang/include/clang/Basic/CodeGenOptions.def

-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables.
252252
CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
253253
CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer.
254254
CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
255-
CODEGENOPT(CallGraphProfile , 1, 0) ///< Run call graph profile.
256255

257256
/// Attempt to use register sized accesses to bit-fields in structures, when
258257
/// possible.

clang/include/clang/Basic/DiagnosticDriverKinds.td

+2
Original file line numberDiff line numberDiff line change
@@ -531,4 +531,6 @@ def warn_drv_libstdcxx_not_found : Warning<
531531
InGroup<DiagGroup<"stdlibcxx-not-found">>;
532532

533533
def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
534+
535+
def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognized and is not a valid setting.">;
534536
}

clang/include/clang/Basic/DiagnosticSemaKinds.td

+2
Original file line numberDiff line numberDiff line change
@@ -10105,6 +10105,8 @@ def err_omp_section_not_subset_of_array : Error<
1010510105
"array section must be a subset of the original array">;
1010610106
def err_omp_section_length_negative : Error<
1010710107
"section length is evaluated to a negative value %0">;
10108+
def err_omp_section_stride_non_positive : Error<
10109+
"section stride is evaluated to a non-positive value %0">;
1010810110
def err_omp_section_length_undefined : Error<
1010910111
"section length is unspecified and cannot be inferred because subscripted value is %select{not an array|an array of unknown bound}0">;
1011010112
def err_omp_wrong_linear_modifier : Error<

clang/include/clang/Parse/Parser.h

+3
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ class Parser : public CodeCompletionHandler {
241241
/// The "depth" of the template parameters currently being parsed.
242242
unsigned TemplateParameterDepth;
243243

244+
/// Current kind of OpenMP clause
245+
OpenMPClauseKind OMPClauseKind = llvm::omp::OMPC_unknown;
246+
244247
/// RAII class that manages the template parameter depth.
245248
class TemplateParameterDepthRAII {
246249
unsigned &Depth;

clang/include/clang/Sema/Sema.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -5126,8 +5126,11 @@ class Sema final {
51265126
SourceLocation RBLoc);
51275127

51285128
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc,
5129-
Expr *LowerBound, SourceLocation ColonLoc,
5130-
Expr *Length, SourceLocation RBLoc);
5129+
Expr *LowerBound,
5130+
SourceLocation ColonLocFirst,
5131+
SourceLocation ColonLocSecond,
5132+
Expr *Length, Expr *Stride,
5133+
SourceLocation RBLoc);
51315134
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc,
51325135
SourceLocation RParenLoc,
51335136
ArrayRef<Expr *> Dims,

clang/lib/AST/StmtPrinter.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1343,11 +1343,16 @@ void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) {
13431343
OS << "[";
13441344
if (Node->getLowerBound())
13451345
PrintExpr(Node->getLowerBound());
1346-
if (Node->getColonLoc().isValid()) {
1346+
if (Node->getColonLocFirst().isValid()) {
13471347
OS << ":";
13481348
if (Node->getLength())
13491349
PrintExpr(Node->getLength());
13501350
}
1351+
if (Node->getColonLocSecond().isValid()) {
1352+
OS << ":";
1353+
if (Node->getStride())
1354+
PrintExpr(Node->getStride());
1355+
}
13511356
OS << "]";
13521357
}
13531358

clang/lib/CodeGen/BackendUtil.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
657657
PMBuilder.SizeLevel = CodeGenOpts.OptimizeSize;
658658
PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP;
659659
PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
660+
PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
660661

661662
PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
662663
// Loop interleaving in the loop vectorizer has historically been set to be
@@ -1186,7 +1187,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
11861187
PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
11871188
PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
11881189
PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
1189-
PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile;
1190+
PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
11901191
PTO.Coroutines = LangOpts.Coroutines;
11911192

11921193
PassInstrumentationCallbacks PIC;
@@ -1604,7 +1605,7 @@ static void runThinLTOBackend(
16041605
Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops;
16051606
Conf.PTO.LoopVectorization = CGOpts.VectorizeLoop;
16061607
Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP;
1607-
Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile;
1608+
Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS;
16081609

16091610
// Context sensitive profile.
16101611
if (CGOpts.hasProfileCSIRInstr()) {

clang/lib/CodeGen/CGExpr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,7 @@ LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
38853885
else
38863886
ResultExprTy = BaseTy->getPointeeType();
38873887
llvm::Value *Idx = nullptr;
3888-
if (IsLowerBound || E->getColonLoc().isInvalid()) {
3888+
if (IsLowerBound || E->getColonLocFirst().isInvalid()) {
38893889
// Requesting lower bound or upper bound, but without provided length and
38903890
// without ':' symbol for the default length -> length = 1.
38913891
// Idx = LowerBound ?: 0;

clang/lib/CodeGen/CGOpenMPRuntime.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -7175,7 +7175,7 @@ class MappableExprsHandler {
71757175
// If there is no length associated with the expression and lower bound is
71767176
// not specified too, that means we are using the whole length of the
71777177
// base.
7178-
if (!OAE->getLength() && OAE->getColonLoc().isValid() &&
7178+
if (!OAE->getLength() && OAE->getColonLocFirst().isValid() &&
71797179
!OAE->getLowerBound())
71807180
return CGF.getTypeSize(BaseTy);
71817181

@@ -7190,7 +7190,7 @@ class MappableExprsHandler {
71907190

71917191
// If we don't have a length at this point, that is because we have an
71927192
// array section with a single element.
7193-
if (!OAE->getLength() && OAE->getColonLoc().isInvalid())
7193+
if (!OAE->getLength() && OAE->getColonLocFirst().isInvalid())
71947194
return ElemSize;
71957195

71967196
if (const Expr *LenExpr = OAE->getLength()) {
@@ -7200,7 +7200,7 @@ class MappableExprsHandler {
72007200
LenExpr->getExprLoc());
72017201
return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
72027202
}
7203-
assert(!OAE->getLength() && OAE->getColonLoc().isValid() &&
7203+
assert(!OAE->getLength() && OAE->getColonLocFirst().isValid() &&
72047204
OAE->getLowerBound() && "expected array_section[lb:].");
72057205
// Size = sizetype - lb * elemtype;
72067206
llvm::Value *LengthVal = CGF.getTypeSize(BaseTy);
@@ -7273,7 +7273,7 @@ class MappableExprsHandler {
72737273
return false;
72747274

72757275
// An array section with no colon always refer to a single element.
7276-
if (OASE->getColonLoc().isInvalid())
7276+
if (OASE->getColonLocFirst().isInvalid())
72777277
return false;
72787278

72797279
const Expr *Length = OASE->getLength();

clang/lib/Driver/Driver.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,26 @@ static llvm::Triple computeTargetTriple(const Driver &D,
494494
Target.getOS() == llvm::Triple::Minix)
495495
return Target;
496496

497+
// On AIX, the env OBJECT_MODE may affect the resulting arch variant.
498+
if (Target.isOSAIX()) {
499+
if (Optional<std::string> ObjectModeValue =
500+
llvm::sys::Process::GetEnv("OBJECT_MODE")) {
501+
StringRef ObjectMode = *ObjectModeValue;
502+
llvm::Triple::ArchType AT = llvm::Triple::UnknownArch;
503+
504+
if (ObjectMode.equals("64")) {
505+
AT = Target.get64BitArchVariant().getArch();
506+
} else if (ObjectMode.equals("32")) {
507+
AT = Target.get32BitArchVariant().getArch();
508+
} else {
509+
D.Diag(diag::err_drv_invalid_object_mode) << ObjectMode;
510+
}
511+
512+
if (AT != llvm::Triple::UnknownArch && AT != Target.getArch())
513+
Target.setArch(AT);
514+
}
515+
}
516+
497517
// Handle pseudo-target flags '-m64', '-mx32', '-m32' and '-m16'.
498518
Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32,
499519
options::OPT_m32, options::OPT_m16);

clang/lib/Frontend/CompilerInvocation.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
864864
Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
865865

866866
Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
867-
Opts.CallGraphProfile = !Opts.DisableIntegratedAS;
868867
Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
869868
Opts.SampleProfileFile =
870869
std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ));

clang/lib/Parse/ParseExpr.cpp

+21-8
Original file line numberDiff line numberDiff line change
@@ -1909,8 +1909,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
19091909
BalancedDelimiterTracker T(*this, tok::l_square);
19101910
T.consumeOpen();
19111911
Loc = T.getOpenLocation();
1912-
ExprResult Idx, Length;
1913-
SourceLocation ColonLoc;
1912+
ExprResult Idx, Length, Stride;
1913+
SourceLocation ColonLocFirst, ColonLocSecond;
19141914
PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.get());
19151915
if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
19161916
Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
@@ -1924,10 +1924,22 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
19241924
}
19251925
if (Tok.is(tok::colon)) {
19261926
// Consume ':'
1927-
ColonLoc = ConsumeToken();
1928-
if (Tok.isNot(tok::r_square))
1927+
ColonLocFirst = ConsumeToken();
1928+
if (Tok.isNot(tok::r_square) &&
1929+
(getLangOpts().OpenMP < 50 ||
1930+
((Tok.isNot(tok::colon) && getLangOpts().OpenMP >= 50))))
19291931
Length = ParseExpression();
19301932
}
1933+
if (getLangOpts().OpenMP >= 50 &&
1934+
(OMPClauseKind == llvm::omp::Clause::OMPC_to ||
1935+
OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
1936+
Tok.is(tok::colon)) {
1937+
// Consume ':'
1938+
ColonLocSecond = ConsumeToken();
1939+
if (Tok.isNot(tok::r_square)) {
1940+
Stride = ParseExpression();
1941+
}
1942+
}
19311943
} else
19321944
Idx = ParseExpression();
19331945

@@ -1937,10 +1949,11 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
19371949
Idx = Actions.CorrectDelayedTyposInExpr(Idx);
19381950
Length = Actions.CorrectDelayedTyposInExpr(Length);
19391951
if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() &&
1940-
Tok.is(tok::r_square)) {
1941-
if (ColonLoc.isValid()) {
1942-
LHS = Actions.ActOnOMPArraySectionExpr(LHS.get(), Loc, Idx.get(),
1943-
ColonLoc, Length.get(), RLoc);
1952+
!Stride.isInvalid() && Tok.is(tok::r_square)) {
1953+
if (ColonLocFirst.isValid() || ColonLocSecond.isValid()) {
1954+
LHS = Actions.ActOnOMPArraySectionExpr(
1955+
LHS.get(), Loc, Idx.get(), ColonLocFirst, ColonLocSecond,
1956+
Length.get(), Stride.get(), RLoc);
19441957
} else {
19451958
LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
19461959
Idx.get(), RLoc);

clang/lib/Parse/ParseOpenMP.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,7 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) {
24982498
///
24992499
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
25002500
OpenMPClauseKind CKind, bool FirstClause) {
2501+
OMPClauseKind = CKind;
25012502
OMPClause *Clause = nullptr;
25022503
bool ErrorFound = false;
25032504
bool WrongDirective = false;

0 commit comments

Comments
 (0)