Upgrade to 3.7.0 RC3.

Enabled compiler-rt on amd64 and i386.  Patches greatfully acepted for
other architectures.

Remove svn patches as an alternate fix has been merged.
This commit is contained in:
Brooks Davis 2015-08-26 18:12:08 +00:00
parent 4d39a37ba6
commit cdf5c08d47
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=395384
6 changed files with 90 additions and 1414 deletions

View file

@ -1,8 +1,7 @@
# $FreeBSD$
PORTNAME= llvm
DISTVERSION= 3.7.0rc2
PORTREVISION= 1
DISTVERSION= 3.7.0rc3
CATEGORIES= devel lang
MASTER_SITES= http://llvm.org/${PRE_}releases/${LLVM_RELEASE}/${RCDIR}
DISTNAME= ${PORTNAME}-${DISTVERSION}.src
@ -30,21 +29,22 @@ SUB_LIST= LLVM_PREFIX="${LLVM_PREFIX}" LLVM_SUFFIX="${LLVM_SUFFIX}"
CMAKE_INSTALL_PREFIX= ${LLVM_PREFIX}
CMAKE_ARGS= -DBUILD_SHARED_LIBS=ON
OPTIONS_DEFINE= CLANG DOCS GOLD LIT LLD LLDB
OPTIONS_DEFINE= CLANG COMPILER_RT DOCS GOLD LIT LLD LLDB
OPTIONS_DEFINE_amd64= OPENMP
OPTIONS_DEFAULT= CLANG GOLD LIT LLD LLDB
OPTIONS_DEFAULT_amd64= OPENMP
OPTIONS_DEFAULT_amd64= COMPILER_RT OPENMP
OPTIONS_DEFAULT_i386= COMPILER_RT
OPTIONS_SUB= yes
CLANG_DESC= Build clang
CLANG_EXTRA_PATCHES= \
${PATCHDIR}/clang-patch-tools_clang_lib_Headers_CMakeLists.txt \
${PATCHDIR}/clang-patch-svn-244209 \
${PATCHDIR}/clang-patch-svn-245041
${PATCHDIR}/clang-patch-tools_clang_lib_Headers_CMakeLists.txt
CLANG_CONFLICTS_INSTALL= clang-devel-3.[1234567]*
CLANG_DISTFILES= cfe-${DISTVERSION}.src${EXTRACT_SUFX}
CLANG_CMAKE_ON= -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp
CLANG_PORTDOCS= clang
COMPILER_RT_DESC= Build compiler-rt (sanitizers)
COMPILER_RT_DISTFILES= compiler-rt-${DISTVERSION}.src${EXTRACT_SUFX}
DOCS_PORTDOCS= llvm
DOCS_CMAKE_ON= -DLLVM_ENABLE_SPHINX=ON \
-DSPHINX_WARNINGS_AS_ERRORS=OFF \
@ -63,7 +63,7 @@ GOLD_CMAKE_ON= -DLLVM_BINUTILS_INCDIR=${LOCALBASE}/include
GOLD_BUILD_DEPENDS= ld.gold:${PORTSDIR}/devel/binutils
# Emulate USE_GITHUB's ${WRKSRC_tag} to reduce diffs to ../llvm-devel
.for option in CLANG LLD LLDB OPENMP
.for option in CLANG COMPILER_RT LLD LLDB OPENMP
WRKSRC_${option:tl}= ${WRKDIR}/${${option}_DISTFILES:S/${EXTRACT_SUFX}//}
.endfor
@ -122,6 +122,49 @@ COMMANDS+= clang \
MAN1SRCS+= clang.1
.endif
.if ${PORT_OPTIONS:MCOMPILER_RT}
SAN_LIBDIR=${LLVM_PREFIX}/lib/clang/${LLVM_RELEASE}/lib/freebsd
.if ${ARCH} == "amd64"
# Disable i386 variants on amd64.
EXTRA_PATCHES+= \
${PATCHDIR}/compiler-rt-patch-tools_compiler-rt_cmake_config-ix.cmake
PLIST_FILES+= \
${SAN_LIBDIR}/libclang_rt.asan-preinit-x86_64.a \
${SAN_LIBDIR}/libclang_rt.asan-x86_64.a \
${SAN_LIBDIR}/libclang_rt.asan-x86_64.a.syms \
${SAN_LIBDIR}/libclang_rt.asan-x86_64.so \
${SAN_LIBDIR}/libclang_rt.asan_cxx-x86_64.a \
${SAN_LIBDIR}/libclang_rt.asan_cxx-x86_64.a.syms \
${SAN_LIBDIR}/libclang_rt.builtins-x86_64.a \
${SAN_LIBDIR}/libclang_rt.dd-x86_64.a \
${SAN_LIBDIR}/libclang_rt.dyndd-x86_64.so \
${SAN_LIBDIR}/libclang_rt.lsan-x86_64.a \
${SAN_LIBDIR}/libclang_rt.profile-x86_64.a \
${SAN_LIBDIR}/libclang_rt.safestack-x86_64.a \
${SAN_LIBDIR}/libclang_rt.tsan-x86_64.a \
${SAN_LIBDIR}/libclang_rt.tsan-x86_64.a.syms \
${SAN_LIBDIR}/libclang_rt.tsan_cxx-x86_64.a \
${SAN_LIBDIR}/libclang_rt.tsan_cxx-x86_64.a.syms \
${SAN_LIBDIR}/libclang_rt.ubsan_standalone-x86_64.a \
${SAN_LIBDIR}/libclang_rt.ubsan_standalone-x86_64.a.syms \
${SAN_LIBDIR}/libclang_rt.ubsan_standalone_cxx-x86_64.a \
${SAN_LIBDIR}/libclang_rt.ubsan_standalone_cxx-x86_64.a.syms
.elif ${ARCH} == "i386"
PLIST_FILES+= \
${SAN_LIBDIR}/libclang_rt.asan-i386.a \
${SAN_LIBDIR}/libclang_rt.asan-i386.so \
${SAN_LIBDIR}/libclang_rt.asan-preinit-i386.a \
${SAN_LIBDIR}/libclang_rt.asan_cxx-i386.a \
${SAN_LIBDIR}/libclang_rt.builtins-i386.a \
${SAN_LIBDIR}/libclang_rt.profile-i386.a \
${SAN_LIBDIR}/libclang_rt.safestack-i386.a \
${SAN_LIBDIR}/libclang_rt.ubsan_standalone-i386.a \
${SAN_LIBDIR}/libclang_rt.ubsan_standalone_cxx-i386.a
.else
BROKEN= no packaging data for sanitizers on ${ARCH}. Disable COMPILER_RT.
.endif
.endif
.if ${PORT_OPTIONS:MLIT}
MAN1SRCS+= lit.1 FileCheck.1
_USES_PYTHON= python
@ -169,6 +212,9 @@ PLIST_SUB:= ${PLIST_SUB:NLLDB=*} LLDB="@comment "
post-extract-CLANG-on:
${MV} ${WRKSRC_clang} ${PATCH_WRKSRC}/tools/clang
post-extract-COMPILER_RT-on:
${MV} ${WRKSRC_compiler_rt} ${PATCH_WRKSRC}/tools/compiler-rt
post-extract-LLD-on:
${MV} ${WRKSRC_lld} ${PATCH_WRKSRC}/tools/lld
@ -261,7 +307,7 @@ build-plist:
${FIND} ${STAGEDIR}${PYTHON_SITELIBDIR}/lit${LLVM_SUFFIX} -type f | \
${SED} -e 's|${STAGEDIR}${PYTHON_SITELIBDIR}|%%LIT%%%%PYTHON_SITELIBDIR%%|' | \
${SORT} >> ${PLIST}.tmp
awk '{if ($$0 ~ /clang/ && $$0 !~ /omp.h/) {printf "%%%%CLANG%%%%"} if ($$0 ~ /lld/ && $$0 !~ /lldb/) {printf "%%%%LLD%%%%"} if ($$0 ~ /(argdumper|lldb)/) {printf "%%%%LLDB%%%%"} if ($$0 ~ /lib.*omp/) {printf "%%%%OPENMP%%%%"} if ($$0 ~ /LLVMgold/) {printf "%%%%GOLD%%%%"} print}' ${PLIST}.tmp >> ${PLIST}
awk '{if ($$0 ~ /clang/ && $$0 !~ /(omp.h|libclang_rt|sanitizer|blacklist.txt)/) {printf "%%%%CLANG%%%%"} if ($$0 ~ /(sanitizer|blacklist.txt)/) {printf "%%%%COMPILER_RT%%%%"} if ($$0 ~ /lld/ && $$0 !~ /lldb/) {printf "%%%%LLD%%%%"} if ($$0 ~ /(argdumper|lldb)/) {printf "%%%%LLDB%%%%"} if ($$0 ~ /lib.*omp/) {printf "%%%%OPENMP%%%%"} if ($$0 ~ /LLVMgold/) {printf "%%%%GOLD%%%%"} if ($$0 !~ /libclang_rt/) {print}}' ${PLIST}.tmp >> ${PLIST}
${RM} -f ${PLIST}.tmp
check-commands:

View file

@ -1,10 +1,12 @@
SHA256 (llvm-3.7.0rc2.src.tar.xz) = 36a79ba3198afb5c973d89ec2e4ef1d4587d97fa3b3f51fb1badcd7c0c868213
SIZE (llvm-3.7.0rc2.src.tar.xz) = 14624620
SHA256 (cfe-3.7.0rc2.src.tar.xz) = a371a416af039eec9291b9acc167911ad9c8d9f3494111c8e53beb07b7f5dfaa
SIZE (cfe-3.7.0rc2.src.tar.xz) = 9141532
SHA256 (lld-3.7.0rc2.src.tar.xz) = 849a99def4c4ccc1639989d7296680fe36b845391a728a0cb75b41e91a9fc9c4
SIZE (lld-3.7.0rc2.src.tar.xz) = 586280
SHA256 (lldb-3.7.0rc2.src.tar.xz) = 56a3e14de7568f1fa151f7d1af014dfc4f54e589c062ba04b2d9b7ae1f28e1ae
SIZE (lldb-3.7.0rc2.src.tar.xz) = 10645800
SHA256 (openmp-3.7.0rc2.src.tar.xz) = 0a23f842d92dd7a434b5725f9bee5dec7493131589abcfdbc0c54cfec7b04696
SIZE (openmp-3.7.0rc2.src.tar.xz) = 2250736
SHA256 (llvm-3.7.0rc3.src.tar.xz) = 906d08033a223163eef00dfa865ac06816c389ee60bc3612c608a407e846bda5
SIZE (llvm-3.7.0rc3.src.tar.xz) = 14631476
SHA256 (cfe-3.7.0rc3.src.tar.xz) = da5507898510903c6f4bb80288980af4baa26234d2eefdcf8fd023738c48c06b
SIZE (cfe-3.7.0rc3.src.tar.xz) = 9146940
SHA256 (compiler-rt-3.7.0rc3.src.tar.xz) = 0e822f587363c19e4d527a3f7c43eaf80ab14c1e057e9baa28337b69dc5a1a6b
SIZE (compiler-rt-3.7.0rc3.src.tar.xz) = 1194088
SHA256 (lld-3.7.0rc3.src.tar.xz) = b944d2ca653ecc04411641890e77a830a9c1de51b7918b6c3647f39590d9f73c
SIZE (lld-3.7.0rc3.src.tar.xz) = 586324
SHA256 (lldb-3.7.0rc3.src.tar.xz) = 5db4abd1cc1883e55cd3322d525475e7e91483a32f7d27dd23fe3914ee43f10d
SIZE (lldb-3.7.0rc3.src.tar.xz) = 10649692
SHA256 (openmp-3.7.0rc3.src.tar.xz) = 0c40502684f15bd76c275bffc404985b6d411b79d97f22608284106744a9a2d2
SIZE (openmp-3.7.0rc3.src.tar.xz) = 2250412

View file

@ -1,688 +0,0 @@
------------------------------------------------------------------------
r244209 | abataev | 2015-08-06 12:30:57 +0000 (Thu, 06 Aug 2015) | 4 lines
[OPENMP 4.1] Allow references in init expression for loop-based constructs.
OpenMP 4.1 allows to use variables with reference types in private clauses and, therefore, in init expressions of the cannonical loop forms.
------------------------------------------------------------------------
Index: lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- tools/clang/lib/CodeGen/CGStmtOpenMP.cpp (revision 244208)
+++ tools/clang/lib/CodeGen/CGStmtOpenMP.cpp (revision 244209)
@@ -680,15 +680,22 @@
static void emitPrivateLoopCounters(CodeGenFunction &CGF,
CodeGenFunction::OMPPrivateScope &LoopScope,
- ArrayRef<Expr *> Counters) {
+ ArrayRef<Expr *> Counters,
+ ArrayRef<Expr *> PrivateCounters) {
+ auto I = PrivateCounters.begin();
for (auto *E : Counters) {
- auto VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
- (void)LoopScope.addPrivate(VD, [&]() -> llvm::Value *{
+ auto *VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
+ auto *PrivateVD = cast<VarDecl>(cast<DeclRefExpr>(*I)->getDecl());
+ llvm::Value *Addr;
+ (void)LoopScope.addPrivate(PrivateVD, [&]() -> llvm::Value * {
// Emit var without initialization.
- auto VarEmission = CGF.EmitAutoVarAlloca(*VD);
+ auto VarEmission = CGF.EmitAutoVarAlloca(*PrivateVD);
CGF.EmitAutoVarCleanups(VarEmission);
- return VarEmission.getAllocatedAddress();
+ Addr = VarEmission.getAllocatedAddress();
+ return Addr;
});
+ (void)LoopScope.addPrivate(VD, [&]() -> llvm::Value * { return Addr; });
+ ++I;
}
}
@@ -697,7 +704,8 @@
llvm::BasicBlock *FalseBlock, uint64_t TrueCount) {
{
CodeGenFunction::OMPPrivateScope PreCondScope(CGF);
- emitPrivateLoopCounters(CGF, PreCondScope, S.counters());
+ emitPrivateLoopCounters(CGF, PreCondScope, S.counters(),
+ S.private_counters());
const VarDecl *IVDecl =
cast<VarDecl>(cast<DeclRefExpr>(S.getIterationVariable())->getDecl());
bool IsRegistered = PreCondScope.addPrivate(IVDecl, [&]() -> llvm::Value *{
@@ -835,7 +843,8 @@
bool HasLastprivateClause;
{
OMPPrivateScope LoopScope(CGF);
- emitPrivateLoopCounters(CGF, LoopScope, S.counters());
+ emitPrivateLoopCounters(CGF, LoopScope, S.counters(),
+ S.private_counters());
emitPrivateLinearVars(CGF, S, LoopScope);
CGF.EmitOMPPrivateClause(S, LoopScope);
CGF.EmitOMPReductionClauseInit(S, LoopScope);
@@ -1124,7 +1133,8 @@
EmitOMPPrivateClause(S, LoopScope);
HasLastprivateClause = EmitOMPLastprivateClauseInit(S, LoopScope);
EmitOMPReductionClauseInit(S, LoopScope);
- emitPrivateLoopCounters(*this, LoopScope, S.counters());
+ emitPrivateLoopCounters(*this, LoopScope, S.counters(),
+ S.private_counters());
emitPrivateLinearVars(*this, S, LoopScope);
(void)LoopScope.Privatize();
Index: lib/Serialization/ASTWriterStmt.cpp
===================================================================
--- tools/clang/lib/Serialization/ASTWriterStmt.cpp (revision 244208)
+++ tools/clang/lib/Serialization/ASTWriterStmt.cpp (revision 244209)
@@ -1957,6 +1957,9 @@
for (auto I : D->counters()) {
Writer.AddStmt(I);
}
+ for (auto I : D->private_counters()) {
+ Writer.AddStmt(I);
+ }
for (auto I : D->updates()) {
Writer.AddStmt(I);
}
Index: lib/Serialization/ASTReaderStmt.cpp
===================================================================
--- tools/clang/lib/Serialization/ASTReaderStmt.cpp (revision 244208)
+++ tools/clang/lib/Serialization/ASTReaderStmt.cpp (revision 244209)
@@ -2113,6 +2113,10 @@
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
Sub.push_back(Reader.ReadSubExpr());
+ D->setPrivateCounters(Sub);
+ Sub.clear();
+ for (unsigned i = 0; i < CollapsedNum; ++i)
+ Sub.push_back(Reader.ReadSubExpr());
D->setUpdates(Sub);
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
Index: lib/Sema/SemaOpenMP.cpp
===================================================================
--- tools/clang/lib/Sema/SemaOpenMP.cpp (revision 244208)
+++ tools/clang/lib/Sema/SemaOpenMP.cpp (revision 244209)
@@ -2251,6 +2251,9 @@
Expr *BuildPreCond(Scope *S, Expr *Cond) const;
/// \brief Build reference expression to the counter be used for codegen.
Expr *BuildCounterVar() const;
+ /// \brief Build reference expression to the private counter be used for
+ /// codegen.
+ Expr *BuildPrivateCounterVar() const;
/// \brief Build initization of the counter be used for codegen.
Expr *BuildCounterInit() const;
/// \brief Build step of the counter be used for codegen.
@@ -2414,7 +2417,7 @@
} else if (auto DS = dyn_cast<DeclStmt>(S)) {
if (DS->isSingleDecl()) {
if (auto Var = dyn_cast_or_null<VarDecl>(DS->getSingleDecl())) {
- if (Var->hasInit()) {
+ if (Var->hasInit() && !Var->getType()->isReferenceType()) {
// Accept non-canonical init form here but emit ext. warning.
if (Var->getInitStyle() != VarDecl::CInit && EmitDiags)
SemaRef.Diag(S->getLocStart(),
@@ -2699,9 +2702,21 @@
/// \brief Build reference expression to the counter be used for codegen.
Expr *OpenMPIterationSpaceChecker::BuildCounterVar() const {
- return buildDeclRefExpr(SemaRef, Var, Var->getType(), DefaultLoc);
+ return buildDeclRefExpr(SemaRef, Var, Var->getType().getNonReferenceType(),
+ DefaultLoc);
}
+Expr *OpenMPIterationSpaceChecker::BuildPrivateCounterVar() const {
+ if (Var && !Var->isInvalidDecl()) {
+ auto Type = Var->getType().getNonReferenceType();
+ auto *PrivateVar = buildVarDecl(SemaRef, DefaultLoc, Type, Var->getName());
+ if (PrivateVar->isInvalidDecl())
+ return nullptr;
+ return buildDeclRefExpr(SemaRef, PrivateVar, Type, DefaultLoc);
+ }
+ return nullptr;
+}
+
/// \brief Build initization of the counter be used for codegen.
Expr *OpenMPIterationSpaceChecker::BuildCounterInit() const { return LB; }
@@ -2717,6 +2732,8 @@
Expr *NumIterations;
/// \brief The loop counter variable.
Expr *CounterVar;
+ /// \brief Private loop counter variable.
+ Expr *PrivateCounterVar;
/// \brief This is initializer for the initial value of #CounterVar.
Expr *CounterInit;
/// \brief This is step for the #CounterVar used to generate its update:
@@ -2801,7 +2818,7 @@
// A variable of signed or unsigned integer type.
// For C++, a variable of a random access iterator type.
// For C, a variable of a pointer type.
- auto VarType = Var->getType();
+ auto VarType = Var->getType().getNonReferenceType();
if (!VarType->isDependentType() && !VarType->isIntegerType() &&
!VarType->isPointerType() &&
!(SemaRef.getLangOpts().CPlusPlus && VarType->isOverloadableType())) {
@@ -2877,6 +2894,7 @@
ResultIterSpace.NumIterations = ISC.BuildNumIterations(
DSA.getCurScope(), /* LimitedType */ isOpenMPWorksharingDirective(DKind));
ResultIterSpace.CounterVar = ISC.BuildCounterVar();
+ ResultIterSpace.PrivateCounterVar = ISC.BuildPrivateCounterVar();
ResultIterSpace.CounterInit = ISC.BuildCounterInit();
ResultIterSpace.CounterStep = ISC.BuildCounterStep();
ResultIterSpace.InitSrcRange = ISC.GetInitSrcRange();
@@ -2887,6 +2905,7 @@
HasErrors |= (ResultIterSpace.PreCond == nullptr ||
ResultIterSpace.NumIterations == nullptr ||
ResultIterSpace.CounterVar == nullptr ||
+ ResultIterSpace.PrivateCounterVar == nullptr ||
ResultIterSpace.CounterInit == nullptr ||
ResultIterSpace.CounterStep == nullptr);
@@ -3286,6 +3305,7 @@
}
// Save results
Built.Counters[Cnt] = IS.CounterVar;
+ Built.PrivateCounters[Cnt] = IS.PrivateCounterVar;
Built.Updates[Cnt] = Update.get();
Built.Finals[Cnt] = Final.get();
}
Index: lib/AST/Stmt.cpp
===================================================================
--- tools/clang/lib/AST/Stmt.cpp (revision 244208)
+++ tools/clang/lib/AST/Stmt.cpp (revision 244209)
@@ -1496,6 +1496,13 @@
std::copy(A.begin(), A.end(), getCounters().begin());
}
+void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
+ assert(A.size() == getCollapsedNumber() && "Number of loop private counters "
+ "is not the same as the collapsed "
+ "number");
+ std::copy(A.begin(), A.end(), getPrivateCounters().begin());
+}
+
void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
assert(A.size() == getCollapsedNumber() &&
"Number of counter updates is not the same as the collapsed number");
@@ -1661,6 +1668,7 @@
Dir->setInit(Exprs.Init);
Dir->setInc(Exprs.Inc);
Dir->setCounters(Exprs.Counters);
+ Dir->setPrivateCounters(Exprs.PrivateCounters);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1707,6 +1715,7 @@
Dir->setNextLowerBound(Exprs.NLB);
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
+ Dir->setPrivateCounters(Exprs.PrivateCounters);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1753,6 +1762,7 @@
Dir->setNextLowerBound(Exprs.NLB);
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
+ Dir->setPrivateCounters(Exprs.PrivateCounters);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1908,6 +1918,7 @@
Dir->setNextLowerBound(Exprs.NLB);
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
+ Dir->setPrivateCounters(Exprs.PrivateCounters);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1952,6 +1963,7 @@
Dir->setNextLowerBound(Exprs.NLB);
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
+ Dir->setPrivateCounters(Exprs.PrivateCounters);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
Index: test/OpenMP/for_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/for_loop_messages.cpp (revision 244208)
+++ tools/clang/test/OpenMP/for_loop_messages.cpp (revision 244209)
@@ -66,24 +66,24 @@
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
#pragma omp parallel
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (int &ref = ii; ref < 10; ref++) {
}
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (int i; i < 10; i++)
c[i] = a[i];
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (int i = 0, j = 0; i < 10; ++i)
c[i] = a[i];
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (; ii < 10; ++ii)
c[ii] = a[ii];
@@ -90,13 +90,13 @@
#pragma omp parallel
// expected-warning@+3 {{expression result unused}}
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (ii + 1; ii < 10; ++ii)
c[ii] = a[ii];
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (c[ii] = 0; ii < 10; ++ii)
c[ii] = a[ii];
@@ -446,7 +446,7 @@
for (GoodIter I = begin; I < end; ++I)
++I;
#pragma omp parallel
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (GoodIter &I = begin; I < end; ++I)
++I;
@@ -485,7 +485,7 @@
for (begin = begin0; begin < end; ++begin)
++begin;
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for
for (++begin; begin < end; ++begin)
++begin;
Index: test/OpenMP/parallel_for_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/parallel_for_loop_messages.cpp (revision 244208)
+++ tools/clang/test/OpenMP/parallel_for_loop_messages.cpp (revision 244209)
@@ -54,32 +54,32 @@
for (double fi = 0; fi < 10.0; fi++) {
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (int &ref = ii; ref < 10; ref++) {
}
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (int i; i < 10; i++)
c[i] = a[i];
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (int i = 0, j = 0; i < 10; ++i)
c[i] = a[i];
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (; ii < 10; ++ii)
c[ii] = a[ii];
// expected-warning@+3 {{expression result unused}}
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (ii + 1; ii < 10; ++ii)
c[ii] = a[ii];
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (c[ii] = 0; ii < 10; ++ii)
c[ii] = a[ii];
@@ -374,7 +374,7 @@
#pragma omp parallel for
for (GoodIter I = begin; I < end; ++I)
++I;
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (GoodIter &I = begin; I < end; ++I)
++I;
@@ -405,7 +405,7 @@
#pragma omp parallel for
for (begin = begin0; begin < end; ++begin)
++begin;
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for
for (++begin; begin < end; ++begin)
++begin;
Index: test/OpenMP/simd_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/simd_loop_messages.cpp (revision 244208)
+++ tools/clang/test/OpenMP/simd_loop_messages.cpp (revision 244209)
@@ -45,32 +45,32 @@
for (double fi = 0; fi < 10.0; fi++) {
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
- // expected-error@+2 {{variable must be of integer or random access iterator type}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (int &ref = ii; ref < 10; ref++) {
}
- // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (int i; i < 10; i++)
c[i] = a[i];
- // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (int i = 0, j = 0; i < 10; ++i)
c[i] = a[i];
- // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (;ii < 10; ++ii)
c[ii] = a[ii];
// expected-warning@+3 {{expression result unused}}
- // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (ii + 1;ii < 10; ++ii)
c[ii] = a[ii];
- // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (c[ii] = 0;ii < 10; ++ii)
c[ii] = a[ii];
@@ -364,7 +364,7 @@
#pragma omp simd
for (GoodIter I = begin; I < end; ++I)
++I;
- // expected-error@+2 {{variable must be of integer or random access iterator type}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (GoodIter &I = begin; I < end; ++I)
++I;
@@ -393,7 +393,7 @@
#pragma omp simd
for (begin = GoodIter(1,2); begin < end; ++begin)
++begin;
- // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+ // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (++begin; begin < end; ++begin)
++begin;
Index: test/OpenMP/parallel_for_simd_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp (revision 244208)
+++ tools/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp (revision 244209)
@@ -54,32 +54,32 @@
for (double fi = 0; fi < 10.0; fi++) {
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (int &ref = ii; ref < 10; ref++) {
}
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (int i; i < 10; i++)
c[i] = a[i];
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (int i = 0, j = 0; i < 10; ++i)
c[i] = a[i];
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (; ii < 10; ++ii)
c[ii] = a[ii];
// expected-warning@+3 {{expression result unused}}
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (ii + 1; ii < 10; ++ii)
c[ii] = a[ii];
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (c[ii] = 0; ii < 10; ++ii)
c[ii] = a[ii];
@@ -375,7 +375,7 @@
#pragma omp parallel for simd
for (GoodIter I = begin; I < end; ++I)
++I;
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (GoodIter &I = begin; I < end; ++I)
++I;
@@ -406,7 +406,7 @@
#pragma omp parallel for simd
for (begin = begin0; begin < end; ++begin)
++begin;
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp parallel for simd
for (++begin; begin < end; ++begin)
++begin;
Index: test/OpenMP/for_codegen.cpp
===================================================================
--- tools/clang/test/OpenMP/for_codegen.cpp (revision 244208)
+++ tools/clang/test/OpenMP/for_codegen.cpp (revision 244209)
@@ -411,6 +411,21 @@
}
}
+// CHECK-LABEL: for_with_references
+void for_with_references() {
+// CHECK: [[I:%.+]] = alloca i8,
+// CHECK: [[CNT:%.+]] = alloca i8*,
+// CHECK: [[CNT_PRIV:%.+]] = alloca i8,
+// CHECK: call void @__kmpc_for_static_init_4(
+// CHECK-NOT: load i8, i8* [[CNT]],
+// CHECK: call void @__kmpc_for_static_fini(
+ char i = 0;
+ char &cnt = i;
+#pragma omp for
+ for (cnt = 0; cnt < 2; ++cnt)
+ k = cnt;
+}
+
struct Bool {
Bool(bool b) : b(b) {}
operator bool() const { return b; }
Index: test/OpenMP/for_simd_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/for_simd_loop_messages.cpp (revision 244208)
+++ tools/clang/test/OpenMP/for_simd_loop_messages.cpp (revision 244209)
@@ -63,24 +63,24 @@
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
#pragma omp parallel
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (int &ref = ii; ref < 10; ref++) {
}
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (int i; i < 10; i++)
c[i] = a[i];
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (int i = 0, j = 0; i < 10; ++i)
c[i] = a[i];
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (; ii < 10; ++ii)
c[ii] = a[ii];
@@ -87,13 +87,13 @@
#pragma omp parallel
// expected-warning@+3 {{expression result unused}}
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (ii + 1; ii < 10; ++ii)
c[ii] = a[ii];
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (c[ii] = 0; ii < 10; ++ii)
c[ii] = a[ii];
@@ -430,7 +430,7 @@
for (GoodIter I = begin; I < end; ++I)
++I;
#pragma omp parallel
-// expected-error@+2 {{variable must be of integer or random access iterator type}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (GoodIter &I = begin; I < end; ++I)
++I;
@@ -469,7 +469,7 @@
for (begin = begin0; begin < end; ++begin)
++begin;
#pragma omp parallel
-// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp for simd
for (++begin; begin < end; ++begin)
++begin;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- tools/clang/include/clang/Basic/DiagnosticSemaKinds.td (revision 244208)
+++ tools/clang/include/clang/Basic/DiagnosticSemaKinds.td (revision 244209)
@@ -7545,8 +7545,8 @@
def err_omp_local_var_in_threadprivate_init : Error<
"variable with local storage in initial value of threadprivate variable">;
def err_omp_loop_not_canonical_init : Error<
- "initialization clause of OpenMP for loop must be of the form "
- "'var = init' or 'T var = init'">;
+ "initialization clause of OpenMP for loop is not in canonical form "
+ "('var = init' or 'T var = init')">;
def ext_omp_loop_not_canonical_init : ExtWarn<
"initialization clause of OpenMP for loop is not in canonical form "
"('var = init' or 'T var = init')">, InGroup<OpenMPLoopForm>;
Index: include/clang/AST/StmtOpenMP.h
===================================================================
--- tools/clang/include/clang/AST/StmtOpenMP.h (revision 244208)
+++ tools/clang/include/clang/AST/StmtOpenMP.h (revision 244209)
@@ -311,11 +311,18 @@
return MutableArrayRef<Expr *>(Storage, CollapsedNum);
}
+ /// \brief Get the private counters storage.
+ MutableArrayRef<Expr *> getPrivateCounters() {
+ Expr **Storage = reinterpret_cast<Expr **>(&*std::next(
+ child_begin(), getArraysOffset(getDirectiveKind()) + CollapsedNum));
+ return MutableArrayRef<Expr *>(Storage, CollapsedNum);
+ }
+
/// \brief Get the updates storage.
MutableArrayRef<Expr *> getUpdates() {
Expr **Storage = reinterpret_cast<Expr **>(
&*std::next(child_begin(),
- getArraysOffset(getDirectiveKind()) + CollapsedNum));
+ getArraysOffset(getDirectiveKind()) + 2 * CollapsedNum));
return MutableArrayRef<Expr *>(Storage, CollapsedNum);
}
@@ -323,7 +330,7 @@
MutableArrayRef<Expr *> getFinals() {
Expr **Storage = reinterpret_cast<Expr **>(
&*std::next(child_begin(),
- getArraysOffset(getDirectiveKind()) + 2 * CollapsedNum));
+ getArraysOffset(getDirectiveKind()) + 3 * CollapsedNum));
return MutableArrayRef<Expr *>(Storage, CollapsedNum);
}
@@ -358,7 +365,7 @@
static unsigned numLoopChildren(unsigned CollapsedNum,
OpenMPDirectiveKind Kind) {
return getArraysOffset(Kind) +
- 3 * CollapsedNum; // Counters, Updates and Finals
+ 4 * CollapsedNum; // Counters, PrivateCounters, Updates and Finals
}
void setIterationVariable(Expr *IV) {
@@ -414,6 +421,7 @@
*std::next(child_begin(), NextUpperBoundOffset) = NUB;
}
void setCounters(ArrayRef<Expr *> A);
+ void setPrivateCounters(ArrayRef<Expr *> A);
void setUpdates(ArrayRef<Expr *> A);
void setFinals(ArrayRef<Expr *> A);
@@ -453,6 +461,8 @@
Expr *NUB;
/// \brief Counters Loop counters.
SmallVector<Expr *, 4> Counters;
+ /// \brief PrivateCounters Loop counters.
+ SmallVector<Expr *, 4> PrivateCounters;
/// \brief Expressions for loop counters update for CodeGen.
SmallVector<Expr *, 4> Updates;
/// \brief Final loop counter values for GodeGen.
@@ -484,10 +494,12 @@
NLB = nullptr;
NUB = nullptr;
Counters.resize(Size);
+ PrivateCounters.resize(Size);
Updates.resize(Size);
Finals.resize(Size);
for (unsigned i = 0; i < Size; ++i) {
Counters[i] = nullptr;
+ PrivateCounters[i] = nullptr;
Updates[i] = nullptr;
Finals[i] = nullptr;
}
@@ -584,6 +596,12 @@
return const_cast<OMPLoopDirective *>(this)->getCounters();
}
+ ArrayRef<Expr *> private_counters() { return getPrivateCounters(); }
+
+ ArrayRef<Expr *> private_counters() const {
+ return const_cast<OMPLoopDirective *>(this)->getPrivateCounters();
+ }
+
ArrayRef<Expr *> updates() { return getUpdates(); }
ArrayRef<Expr *> updates() const {

View file

@ -1,707 +0,0 @@
------------------------------------------------------------------------
r245041 | abataev | 2015-08-14 12:25:37 +0000 (Fri, 14 Aug 2015) | 4 lines
[OPENMP] Fix for http://llvm.org/PR24371: Assert failure compiling blender 2.75.
blender uses statements expression in condition of the loop under control of the '#pragma omp parallel for'. This condition is used several times in different expressions required for codegen of the loop directive. If there are some variables defined in statement expression, it fires an assert during codegen because of redefinition of the same variables.
We have to rebuild several expression to be sure that all variables are unique.
------------------------------------------------------------------------
Index: lib/Sema/SemaOpenMP.cpp
===================================================================
--- tools/clang/lib/Sema/SemaOpenMP.cpp (revision 245040)
+++ tools/clang/lib/Sema/SemaOpenMP.cpp (revision 245041)
@@ -12,6 +12,7 @@
///
//===----------------------------------------------------------------------===//
+#include "TreeTransform.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/Decl.h"
@@ -2609,20 +2610,85 @@
return true;
}
+namespace {
+// Transform variables declared in GNU statement expressions to new ones to
+// avoid crash on codegen.
+class TransformToNewDefs : public TreeTransform<TransformToNewDefs> {
+ typedef TreeTransform<TransformToNewDefs> BaseTransform;
+
+public:
+ TransformToNewDefs(Sema &SemaRef) : BaseTransform(SemaRef) {}
+
+ Decl *TransformDefinition(SourceLocation Loc, Decl *D) {
+ if (auto *VD = cast<VarDecl>(D))
+ if (!isa<ParmVarDecl>(D) && !isa<VarTemplateSpecializationDecl>(D) &&
+ !isa<ImplicitParamDecl>(D)) {
+ auto *NewVD = VarDecl::Create(
+ SemaRef.Context, VD->getDeclContext(), VD->getLocStart(),
+ VD->getLocation(), VD->getIdentifier(), VD->getType(),
+ VD->getTypeSourceInfo(), VD->getStorageClass());
+ NewVD->setTSCSpec(VD->getTSCSpec());
+ NewVD->setInit(VD->getInit());
+ NewVD->setInitStyle(VD->getInitStyle());
+ NewVD->setExceptionVariable(VD->isExceptionVariable());
+ NewVD->setNRVOVariable(VD->isNRVOVariable());
+ NewVD->setCXXForRangeDecl(VD->isInExternCXXContext());
+ NewVD->setConstexpr(VD->isConstexpr());
+ NewVD->setInitCapture(VD->isInitCapture());
+ NewVD->setPreviousDeclInSameBlockScope(
+ VD->isPreviousDeclInSameBlockScope());
+ VD->getDeclContext()->addHiddenDecl(NewVD);
+ transformedLocalDecl(VD, NewVD);
+ return NewVD;
+ }
+ return BaseTransform::TransformDefinition(Loc, D);
+ }
+
+ ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
+ if (auto *NewD = TransformDecl(E->getExprLoc(), E->getDecl()))
+ if (E->getDecl() != NewD) {
+ NewD->setReferenced();
+ NewD->markUsed(SemaRef.Context);
+ return DeclRefExpr::Create(
+ SemaRef.Context, E->getQualifierLoc(), E->getTemplateKeywordLoc(),
+ cast<ValueDecl>(NewD), E->refersToEnclosingVariableOrCapture(),
+ E->getNameInfo(), E->getType(), E->getValueKind());
+ }
+ return BaseTransform::TransformDeclRefExpr(E);
+ }
+};
+}
+
/// \brief Build the expression to calculate the number of iterations.
Expr *
OpenMPIterationSpaceChecker::BuildNumIterations(Scope *S,
const bool LimitedType) const {
+ TransformToNewDefs Transform(SemaRef);
ExprResult Diff;
- if (Var->getType()->isIntegerType() || Var->getType()->isPointerType() ||
+ auto VarType = Var->getType().getNonReferenceType();
+ if (VarType->isIntegerType() || VarType->isPointerType() ||
SemaRef.getLangOpts().CPlusPlus) {
// Upper - Lower
- Expr *Upper = TestIsLessOp ? UB : LB;
- Expr *Lower = TestIsLessOp ? LB : UB;
+ auto *UBExpr = TestIsLessOp ? UB : LB;
+ auto *LBExpr = TestIsLessOp ? LB : UB;
+ Expr *Upper = Transform.TransformExpr(UBExpr).get();
+ Expr *Lower = Transform.TransformExpr(LBExpr).get();
+ if (!Upper || !Lower)
+ return nullptr;
+ Upper = SemaRef.PerformImplicitConversion(Upper, UBExpr->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true)
+ .get();
+ Lower = SemaRef.PerformImplicitConversion(Lower, LBExpr->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true)
+ .get();
+ if (!Upper || !Lower)
+ return nullptr;
Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Sub, Upper, Lower);
- if (!Diff.isUsable() && Var->getType()->getAsCXXRecordDecl()) {
+ if (!Diff.isUsable() && VarType->getAsCXXRecordDecl()) {
// BuildBinOp already emitted error, this one is to point user to upper
// and lower bound, and to tell what is passed to 'operator-'.
SemaRef.Diag(Upper->getLocStart(), diag::err_omp_loop_diff_cxx)
@@ -2643,8 +2709,15 @@
return nullptr;
// Upper - Lower [- 1] + Step
- Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Add, Diff.get(),
- Step->IgnoreImplicit());
+ auto NewStep = Transform.TransformExpr(Step->IgnoreImplicit());
+ if (NewStep.isInvalid())
+ return nullptr;
+ NewStep = SemaRef.PerformImplicitConversion(
+ NewStep.get(), Step->IgnoreImplicit()->getType(), Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ if (NewStep.isInvalid())
+ return nullptr;
+ Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Add, Diff.get(), NewStep.get());
if (!Diff.isUsable())
return nullptr;
@@ -2654,15 +2727,35 @@
return nullptr;
// (Upper - Lower [- 1] + Step) / Step
- Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Div, Diff.get(),
- Step->IgnoreImplicit());
+ NewStep = Transform.TransformExpr(Step->IgnoreImplicit());
+ if (NewStep.isInvalid())
+ return nullptr;
+ NewStep = SemaRef.PerformImplicitConversion(
+ NewStep.get(), Step->IgnoreImplicit()->getType(), Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ if (NewStep.isInvalid())
+ return nullptr;
+ Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Div, Diff.get(), NewStep.get());
if (!Diff.isUsable())
return nullptr;
// OpenMP runtime requires 32-bit or 64-bit loop variables.
+ QualType Type = Diff.get()->getType();
+ auto &C = SemaRef.Context;
+ bool UseVarType = VarType->hasIntegerRepresentation() &&
+ C.getTypeSize(Type) > C.getTypeSize(VarType);
+ if (!Type->isIntegerType() || UseVarType) {
+ unsigned NewSize =
+ UseVarType ? C.getTypeSize(VarType) : C.getTypeSize(Type);
+ bool IsSigned = UseVarType ? VarType->hasSignedIntegerRepresentation()
+ : Type->hasSignedIntegerRepresentation();
+ Type = C.getIntTypeForBitwidth(NewSize, IsSigned);
+ Diff = SemaRef.PerformImplicitConversion(
+ Diff.get(), Type, Sema::AA_Converting, /*AllowExplicit=*/true);
+ if (!Diff.isUsable())
+ return nullptr;
+ }
if (LimitedType) {
- auto &C = SemaRef.Context;
- QualType Type = Diff.get()->getType();
unsigned NewSize = (C.getTypeSize(Type) > 32) ? 64 : 32;
if (NewSize != C.getTypeSize(Type)) {
if (NewSize < C.getTypeSize(Type)) {
@@ -2671,7 +2764,8 @@
<< InitSrcRange << ConditionSrcRange;
}
QualType NewType = C.getIntTypeForBitwidth(
- NewSize, Type->hasSignedIntegerRepresentation());
+ NewSize, Type->hasSignedIntegerRepresentation() ||
+ C.getTypeSize(Type) < NewSize);
Diff = SemaRef.PerformImplicitConversion(Diff.get(), NewType,
Sema::AA_Converting, true);
if (!Diff.isUsable())
@@ -2686,10 +2780,24 @@
// Try to build LB <op> UB, where <op> is <, >, <=, or >=.
bool Suppress = SemaRef.getDiagnostics().getSuppressAllDiagnostics();
SemaRef.getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
+ TransformToNewDefs Transform(SemaRef);
+
+ auto NewLB = Transform.TransformExpr(LB);
+ auto NewUB = Transform.TransformExpr(UB);
+ if (NewLB.isInvalid() || NewUB.isInvalid())
+ return Cond;
+ NewLB = SemaRef.PerformImplicitConversion(NewLB.get(), LB->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ NewUB = SemaRef.PerformImplicitConversion(NewUB.get(), UB->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ if (NewLB.isInvalid() || NewUB.isInvalid())
+ return Cond;
auto CondExpr = SemaRef.BuildBinOp(
S, DefaultLoc, TestIsLessOp ? (TestIsStrictOp ? BO_LT : BO_LE)
: (TestIsStrictOp ? BO_GT : BO_GE),
- LB, UB);
+ NewLB.get(), NewUB.get());
if (CondExpr.isUsable()) {
CondExpr = SemaRef.PerformImplicitConversion(
CondExpr.get(), SemaRef.Context.BoolTy, /*Action=*/Sema::AA_Casting,
@@ -2912,6 +3020,31 @@
return HasErrors;
}
+/// \brief Build 'VarRef = Start.
+static ExprResult BuildCounterInit(Sema &SemaRef, Scope *S, SourceLocation Loc,
+ ExprResult VarRef, ExprResult Start) {
+ TransformToNewDefs Transform(SemaRef);
+ // Build 'VarRef = Start.
+ auto NewStart = Transform.TransformExpr(Start.get()->IgnoreImplicit());
+ if (NewStart.isInvalid())
+ return ExprError();
+ NewStart = SemaRef.PerformImplicitConversion(
+ NewStart.get(), Start.get()->IgnoreImplicit()->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ if (NewStart.isInvalid())
+ return ExprError();
+ NewStart = SemaRef.PerformImplicitConversion(
+ NewStart.get(), VarRef.get()->getType(), Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ if (!NewStart.isUsable())
+ return ExprError();
+
+ auto Init =
+ SemaRef.BuildBinOp(S, Loc, BO_Assign, VarRef.get(), NewStart.get());
+ return Init;
+}
+
/// \brief Build 'VarRef = Start + Iter * Step'.
static ExprResult BuildCounterUpdate(Sema &SemaRef, Scope *S,
SourceLocation Loc, ExprResult VarRef,
@@ -2923,14 +3056,33 @@
!Step.isUsable())
return ExprError();
- ExprResult Update = SemaRef.BuildBinOp(S, Loc, BO_Mul, Iter.get(),
- Step.get()->IgnoreImplicit());
+ TransformToNewDefs Transform(SemaRef);
+ auto NewStep = Transform.TransformExpr(Step.get()->IgnoreImplicit());
+ if (NewStep.isInvalid())
+ return ExprError();
+ NewStep = SemaRef.PerformImplicitConversion(
+ NewStep.get(), Step.get()->IgnoreImplicit()->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ if (NewStep.isInvalid())
+ return ExprError();
+ ExprResult Update =
+ SemaRef.BuildBinOp(S, Loc, BO_Mul, Iter.get(), NewStep.get());
if (!Update.isUsable())
return ExprError();
// Build 'VarRef = Start + Iter * Step'.
+ auto NewStart = Transform.TransformExpr(Start.get()->IgnoreImplicit());
+ if (NewStart.isInvalid())
+ return ExprError();
+ NewStart = SemaRef.PerformImplicitConversion(
+ NewStart.get(), Start.get()->IgnoreImplicit()->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true);
+ if (NewStart.isInvalid())
+ return ExprError();
Update = SemaRef.BuildBinOp(S, Loc, (Subtract ? BO_Sub : BO_Add),
- Start.get()->IgnoreImplicit(), Update.get());
+ NewStart.get(), Update.get());
if (!Update.isUsable())
return ExprError();
@@ -3050,8 +3202,18 @@
// true).
auto PreCond = ExprResult(IterSpaces[0].PreCond);
auto N0 = IterSpaces[0].NumIterations;
- ExprResult LastIteration32 = WidenIterationCount(32 /* Bits */, N0, SemaRef);
- ExprResult LastIteration64 = WidenIterationCount(64 /* Bits */, N0, SemaRef);
+ ExprResult LastIteration32 = WidenIterationCount(
+ 32 /* Bits */, SemaRef.PerformImplicitConversion(
+ N0->IgnoreImpCasts(), N0->getType(),
+ Sema::AA_Converting, /*AllowExplicit=*/true)
+ .get(),
+ SemaRef);
+ ExprResult LastIteration64 = WidenIterationCount(
+ 64 /* Bits */, SemaRef.PerformImplicitConversion(
+ N0->IgnoreImpCasts(), N0->getType(),
+ Sema::AA_Converting, /*AllowExplicit=*/true)
+ .get(),
+ SemaRef);
if (!LastIteration32.isUsable() || !LastIteration64.isUsable())
return NestedLoopCount;
@@ -3068,11 +3230,19 @@
auto N = IterSpaces[Cnt].NumIterations;
AllCountsNeedLessThan32Bits &= C.getTypeSize(N->getType()) < 32;
if (LastIteration32.isUsable())
- LastIteration32 = SemaRef.BuildBinOp(CurScope, SourceLocation(), BO_Mul,
- LastIteration32.get(), N);
+ LastIteration32 = SemaRef.BuildBinOp(
+ CurScope, SourceLocation(), BO_Mul, LastIteration32.get(),
+ SemaRef.PerformImplicitConversion(N->IgnoreImpCasts(), N->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true)
+ .get());
if (LastIteration64.isUsable())
- LastIteration64 = SemaRef.BuildBinOp(CurScope, SourceLocation(), BO_Mul,
- LastIteration64.get(), N);
+ LastIteration64 = SemaRef.BuildBinOp(
+ CurScope, SourceLocation(), BO_Mul, LastIteration64.get(),
+ SemaRef.PerformImplicitConversion(N->IgnoreImpCasts(), N->getType(),
+ Sema::AA_Converting,
+ /*AllowExplicit=*/true)
+ .get());
}
// Choose either the 32-bit or 64-bit version.
@@ -3233,6 +3403,7 @@
// Build updates and final values of the loop counters.
bool HasErrors = false;
Built.Counters.resize(NestedLoopCount);
+ Built.Inits.resize(NestedLoopCount);
Built.Updates.resize(NestedLoopCount);
Built.Finals.resize(NestedLoopCount);
{
@@ -3266,6 +3437,12 @@
SemaRef, cast<VarDecl>(cast<DeclRefExpr>(IS.CounterVar)->getDecl()),
IS.CounterVar->getType(), IS.CounterVar->getExprLoc(),
/*RefersToCapture=*/true);
+ ExprResult Init = BuildCounterInit(SemaRef, CurScope, UpdLoc, CounterVar,
+ IS.CounterInit);
+ if (!Init.isUsable()) {
+ HasErrors = true;
+ break;
+ }
ExprResult Update =
BuildCounterUpdate(SemaRef, CurScope, UpdLoc, CounterVar,
IS.CounterInit, Iter, IS.CounterStep, IS.Subtract);
@@ -3306,6 +3483,7 @@
// Save results
Built.Counters[Cnt] = IS.CounterVar;
Built.PrivateCounters[Cnt] = IS.PrivateCounterVar;
+ Built.Inits[Cnt] = Init.get();
Built.Updates[Cnt] = Update.get();
Built.Finals[Cnt] = Final.get();
}
Index: lib/AST/Stmt.cpp
===================================================================
--- tools/clang/lib/AST/Stmt.cpp (revision 245040)
+++ tools/clang/lib/AST/Stmt.cpp (revision 245041)
@@ -1503,6 +1503,12 @@
std::copy(A.begin(), A.end(), getPrivateCounters().begin());
}
+void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
+ assert(A.size() == getCollapsedNumber() &&
+ "Number of counter inits is not the same as the collapsed number");
+ std::copy(A.begin(), A.end(), getInits().begin());
+}
+
void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
assert(A.size() == getCollapsedNumber() &&
"Number of counter updates is not the same as the collapsed number");
@@ -1669,6 +1675,7 @@
Dir->setInc(Exprs.Inc);
Dir->setCounters(Exprs.Counters);
Dir->setPrivateCounters(Exprs.PrivateCounters);
+ Dir->setInits(Exprs.Inits);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1716,6 +1723,7 @@
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
Dir->setPrivateCounters(Exprs.PrivateCounters);
+ Dir->setInits(Exprs.Inits);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1763,6 +1771,7 @@
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
Dir->setPrivateCounters(Exprs.PrivateCounters);
+ Dir->setInits(Exprs.Inits);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1919,6 +1928,7 @@
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
Dir->setPrivateCounters(Exprs.PrivateCounters);
+ Dir->setInits(Exprs.Inits);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
@@ -1964,6 +1974,7 @@
Dir->setNextUpperBound(Exprs.NUB);
Dir->setCounters(Exprs.Counters);
Dir->setPrivateCounters(Exprs.PrivateCounters);
+ Dir->setInits(Exprs.Inits);
Dir->setUpdates(Exprs.Updates);
Dir->setFinals(Exprs.Finals);
return Dir;
Index: lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- tools/clang/lib/CodeGen/CGStmtOpenMP.cpp (revision 245040)
+++ tools/clang/lib/CodeGen/CGStmtOpenMP.cpp (revision 245041)
@@ -706,27 +706,9 @@
CodeGenFunction::OMPPrivateScope PreCondScope(CGF);
emitPrivateLoopCounters(CGF, PreCondScope, S.counters(),
S.private_counters());
- const VarDecl *IVDecl =
- cast<VarDecl>(cast<DeclRefExpr>(S.getIterationVariable())->getDecl());
- bool IsRegistered = PreCondScope.addPrivate(IVDecl, [&]() -> llvm::Value *{
- // Emit var without initialization.
- auto VarEmission = CGF.EmitAutoVarAlloca(*IVDecl);
- CGF.EmitAutoVarCleanups(VarEmission);
- return VarEmission.getAllocatedAddress();
- });
- assert(IsRegistered && "counter already registered as private");
- // Silence the warning about unused variable.
- (void)IsRegistered;
(void)PreCondScope.Privatize();
- // Initialize internal counter to 0 to calculate initial values of real
- // counters.
- LValue IV = CGF.EmitLValue(S.getIterationVariable());
- CGF.EmitStoreOfScalar(
- llvm::ConstantInt::getNullValue(
- IV.getAddress()->getType()->getPointerElementType()),
- CGF.EmitLValue(S.getIterationVariable()), /*isInit=*/true);
// Get initial values of real counters.
- for (auto I : S.updates()) {
+ for (auto I : S.inits()) {
CGF.EmitIgnoredExpr(I);
}
}
Index: lib/Serialization/ASTWriterStmt.cpp
===================================================================
--- tools/clang/lib/Serialization/ASTWriterStmt.cpp (revision 245040)
+++ tools/clang/lib/Serialization/ASTWriterStmt.cpp (revision 245041)
@@ -1965,6 +1965,9 @@
for (auto I : D->private_counters()) {
Writer.AddStmt(I);
}
+ for (auto I : D->inits()) {
+ Writer.AddStmt(I);
+ }
for (auto I : D->updates()) {
Writer.AddStmt(I);
}
Index: lib/Serialization/ASTReaderStmt.cpp
===================================================================
--- tools/clang/lib/Serialization/ASTReaderStmt.cpp (revision 245040)
+++ tools/clang/lib/Serialization/ASTReaderStmt.cpp (revision 245041)
@@ -2125,6 +2125,10 @@
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
Sub.push_back(Reader.ReadSubExpr());
+ D->setInits(Sub);
+ Sub.clear();
+ for (unsigned i = 0; i < CollapsedNum; ++i)
+ Sub.push_back(Reader.ReadSubExpr());
D->setUpdates(Sub);
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
Index: test/OpenMP/for_codegen.cpp
===================================================================
--- tools/clang/test/OpenMP/for_codegen.cpp (revision 245040)
+++ tools/clang/test/OpenMP/for_codegen.cpp (revision 245041)
@@ -329,16 +329,11 @@
// CHECK: [[A_ADDR:%.+]] = alloca i8,
// CHECK: [[I_ADDR:%.+]] = alloca i8,
char a = 0;
- // CHECK: store i32 0, i32* [[IV_ADDR:%.+]],
+ // CHECK: store i8 0,
+ // CHECK: store i32
+ // CHECK: store i8
// CHECK: [[A:%.+]] = load i8, i8* [[A_ADDR]],
// CHECK: [[CONV:%.+]] = sext i8 [[A]] to i32
- // CHECK: [[IV:%.+]] = load i32, i32* [[IV_ADDR]],
- // CHECK: [[MUL:%.+]] = mul nsw i32 [[IV]], 1
- // CHECK: [[ADD:%.+]] = add nsw i32 [[CONV]], [[MUL]]
- // CHECK: [[CONV:%.+]] = trunc i32 [[ADD]] to i8
- // CHECK: store i8 [[CONV]], i8* [[I_ADDR]],
- // CHECK: [[A:%.+]] = load i8, i8* [[A_ADDR]],
- // CHECK: [[CONV:%.+]] = sext i8 [[A]] to i32
// CHECK: [[CMP:%.+]] = icmp slt i32 [[CONV]], 10
// CHECK: br i1 [[CMP]], label %[[PRECOND_THEN:[^,]+]], label %[[PRECOND_END:[^,]+]]
// CHECK: [[PRECOND_THEN]]
@@ -482,4 +477,14 @@
// CHECK: call void @__kmpc_for_static_init_8(
// CHECK: call void @__kmpc_for_static_fini(
+void loop_with_stmt_expr() {
+#pragma omp for
+ for (int i = __extension__({float b = 0;b; }); i < __extension__({double c = 1;c; }); i += __extension__({char d = 1; d; }))
+ ;
+}
+// CHECK-LABEL: loop_with_stmt_expr
+// CHECK: call i32 @__kmpc_global_thread_num(
+// CHECK: call void @__kmpc_for_static_init_4(
+// CHECK: call void @__kmpc_for_static_fini(
+
#endif // HEADER
Index: test/OpenMP/for_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/for_loop_messages.cpp (revision 245040)
+++ tools/clang/test/OpenMP/for_loop_messages.cpp (revision 245041)
@@ -422,12 +422,12 @@
typedef int difference_type;
typedef std::random_access_iterator_tag iterator_category;
};
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
int operator-(GoodIter a, GoodIter b) { return 0; }
// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
GoodIter operator-(GoodIter a) { return a; }
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
@@ -478,7 +478,7 @@
#pragma omp for
for (begin = GoodIter(0); begin < end; ++begin)
++begin;
-// expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'Iter0')}}
// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
#pragma omp parallel
#pragma omp for
Index: test/OpenMP/parallel_for_simd_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp (revision 245040)
+++ tools/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp (revision 245041)
@@ -353,12 +353,12 @@
typedef int difference_type;
typedef std::random_access_iterator_tag iterator_category;
};
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
int operator-(GoodIter a, GoodIter b) { return 0; }
// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
GoodIter operator-(GoodIter a) { return a; }
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
@@ -401,7 +401,7 @@
#pragma omp parallel for simd
for (begin = GoodIter(0); begin < end; ++begin)
++begin;
-// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'Iter0')}}
// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
#pragma omp parallel for simd
for (begin = begin0; begin < end; ++begin)
Index: test/OpenMP/for_simd_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/for_simd_loop_messages.cpp (revision 245040)
+++ tools/clang/test/OpenMP/for_simd_loop_messages.cpp (revision 245041)
@@ -406,12 +406,12 @@
typedef int difference_type;
typedef std::random_access_iterator_tag iterator_category;
};
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
int operator-(GoodIter a, GoodIter b) { return 0; }
// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
GoodIter operator-(GoodIter a) { return a; }
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
@@ -463,7 +463,7 @@
for (begin = GoodIter(0); begin < end; ++begin)
++begin;
#pragma omp parallel
-// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'Iter0')}}
// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
#pragma omp for simd
for (begin = begin0; begin < end; ++begin)
Index: test/OpenMP/parallel_for_loop_messages.cpp
===================================================================
--- tools/clang/test/OpenMP/parallel_for_loop_messages.cpp (revision 245040)
+++ tools/clang/test/OpenMP/parallel_for_loop_messages.cpp (revision 245041)
@@ -352,12 +352,12 @@
typedef int difference_type;
typedef std::random_access_iterator_tag iterator_category;
};
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
int operator-(GoodIter a, GoodIter b) { return 0; }
// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
GoodIter operator-(GoodIter a) { return a; }
-// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 2nd argument}}
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
@@ -400,7 +400,7 @@
#pragma omp parallel for
for (begin = GoodIter(0); begin < end; ++begin)
++begin;
-// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'Iter0')}}
// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
#pragma omp parallel for
for (begin = begin0; begin < end; ++begin)
Index: include/clang/AST/StmtOpenMP.h
===================================================================
--- tools/clang/include/clang/AST/StmtOpenMP.h (revision 245040)
+++ tools/clang/include/clang/AST/StmtOpenMP.h (revision 245041)
@@ -319,7 +319,7 @@
}
/// \brief Get the updates storage.
- MutableArrayRef<Expr *> getUpdates() {
+ MutableArrayRef<Expr *> getInits() {
Expr **Storage = reinterpret_cast<Expr **>(
&*std::next(child_begin(),
getArraysOffset(getDirectiveKind()) + 2 * CollapsedNum));
@@ -326,11 +326,19 @@
return MutableArrayRef<Expr *>(Storage, CollapsedNum);
}
+ /// \brief Get the updates storage.
+ MutableArrayRef<Expr *> getUpdates() {
+ Expr **Storage = reinterpret_cast<Expr **>(
+ &*std::next(child_begin(),
+ getArraysOffset(getDirectiveKind()) + 3 * CollapsedNum));
+ return MutableArrayRef<Expr *>(Storage, CollapsedNum);
+ }
+
/// \brief Get the final counter updates storage.
MutableArrayRef<Expr *> getFinals() {
Expr **Storage = reinterpret_cast<Expr **>(
&*std::next(child_begin(),
- getArraysOffset(getDirectiveKind()) + 3 * CollapsedNum));
+ getArraysOffset(getDirectiveKind()) + 4 * CollapsedNum));
return MutableArrayRef<Expr *>(Storage, CollapsedNum);
}
@@ -364,8 +372,9 @@
/// \brief Children number.
static unsigned numLoopChildren(unsigned CollapsedNum,
OpenMPDirectiveKind Kind) {
- return getArraysOffset(Kind) +
- 4 * CollapsedNum; // Counters, PrivateCounters, Updates and Finals
+ return getArraysOffset(Kind) + 5 * CollapsedNum; // Counters,
+ // PrivateCounters, Inits,
+ // Updates and Finals
}
void setIterationVariable(Expr *IV) {
@@ -422,6 +431,7 @@
}
void setCounters(ArrayRef<Expr *> A);
void setPrivateCounters(ArrayRef<Expr *> A);
+ void setInits(ArrayRef<Expr *> A);
void setUpdates(ArrayRef<Expr *> A);
void setFinals(ArrayRef<Expr *> A);
@@ -463,6 +473,8 @@
SmallVector<Expr *, 4> Counters;
/// \brief PrivateCounters Loop counters.
SmallVector<Expr *, 4> PrivateCounters;
+ /// \brief Expressions for loop counters inits for CodeGen.
+ SmallVector<Expr *, 4> Inits;
/// \brief Expressions for loop counters update for CodeGen.
SmallVector<Expr *, 4> Updates;
/// \brief Final loop counter values for GodeGen.
@@ -495,11 +507,13 @@
NUB = nullptr;
Counters.resize(Size);
PrivateCounters.resize(Size);
+ Inits.resize(Size);
Updates.resize(Size);
Finals.resize(Size);
for (unsigned i = 0; i < Size; ++i) {
Counters[i] = nullptr;
PrivateCounters[i] = nullptr;
+ Inits[i] = nullptr;
Updates[i] = nullptr;
Finals[i] = nullptr;
}
@@ -602,6 +616,12 @@
return const_cast<OMPLoopDirective *>(this)->getPrivateCounters();
}
+ ArrayRef<Expr *> inits() { return getInits(); }
+
+ ArrayRef<Expr *> inits() const {
+ return const_cast<OMPLoopDirective *>(this)->getInits();
+ }
+
ArrayRef<Expr *> updates() { return getUpdates(); }
ArrayRef<Expr *> updates() const {

View file

@ -0,0 +1,13 @@
--- tools/compiler-rt/cmake/config-ix.cmake.orig 2015-08-20 13:35:01 UTC
+++ tools/compiler-rt/cmake/config-ix.cmake
@@ -180,8 +180,8 @@ elseif(NOT APPLE) # Supported archs for
# FIXME: We build runtimes for both i686 and i386, as "clang -m32" may
# target different variant than "$CMAKE_C_COMPILER -m32". This part should
# be gone after we resolve PR14109.
- test_target_arch(i686 __i686__ "-m32")
- test_target_arch(i386 __i386__ "-m32")
+ #test_target_arch(i686 __i686__ "-m32")
+ #test_target_arch(i386 __i386__ "-m32")
else()
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
test_target_arch(i386 "" "")

View file

@ -1775,6 +1775,7 @@ llvm37/include/llvm/Transforms/Vectorize.h
llvm37/lib/BugpointPasses.so
llvm37/lib/LLVMHello.so
%%GOLD%%llvm37/lib/LLVMgold.so
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/asan_blacklist.txt
%%CLANG%%llvm37/lib/clang/3.7.0/include/Intrin.h
%%CLANG%%llvm37/lib/clang/3.7.0/include/__stddef_max_align_t.h
%%CLANG%%llvm37/lib/clang/3.7.0/include/__wmmintrin_aes.h
@ -1823,6 +1824,15 @@ llvm37/lib/LLVMHello.so
%%CLANG%%llvm37/lib/clang/3.7.0/include/rdseedintrin.h
%%CLANG%%llvm37/lib/clang/3.7.0/include/rtmintrin.h
%%CLANG%%llvm37/lib/clang/3.7.0/include/s390intrin.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/allocator_interface.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/asan_interface.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/common_interface_defs.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/coverage_interface.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/dfsan_interface.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/linux_syscall_hooks.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/lsan_interface.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/msan_interface.h
%%COMPILER_RT%%llvm37/lib/clang/3.7.0/include/sanitizer/tsan_interface_atomic.h
%%CLANG%%llvm37/lib/clang/3.7.0/include/shaintrin.h
%%CLANG%%llvm37/lib/clang/3.7.0/include/smmintrin.h
%%CLANG%%llvm37/lib/clang/3.7.0/include/tbmintrin.h