summaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorJonas Hahnfeld <hahnjo@hahnjo.de>2017-10-20 20:16:17 +0000
committerJonas Hahnfeld <hahnjo@hahnjo.de>2017-10-20 20:16:17 +0000
commitd194f2aeb2ae7ac5e7e5c7b41638e042665b0d05 (patch)
tree1e7679bef305ba570d61a6ac02133e842466eda1 /lib/Sema
parentf20a280b3ba367e83e1c21cfd4366cd55b8d20cb (diff)
downloadclang-d194f2aeb2ae7ac5e7e5c7b41638e042665b0d05.tar.gz
Revert "[OpenMP] Avoid VLAs for some reductions on array sections"
This breaks at least two buildbots: http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/1175 http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/10478 This reverts commit r316229 during local investigation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaOpenMP.cpp83
1 files changed, 1 insertions, 82 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index bf89eb0b2f..a024888fbf 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -9330,68 +9330,6 @@ struct ReductionData {
};
} // namespace
-static bool CheckOMPArraySectionConstantForReduction(
- ASTContext &Context, const OMPArraySectionExpr *OASE, bool &SingleElement,
- SmallVectorImpl<llvm::APSInt> &ArraySizes) {
- const Expr *Length = OASE->getLength();
- if (Length == nullptr) {
- // For array sections of the form [1:] or [:], we would need to analyze
- // the lower bound...
- if (OASE->getColonLoc().isValid())
- return false;
-
- // This is an array subscript which has implicit length 1!
- SingleElement = true;
- ArraySizes.push_back(llvm::APSInt::get(1));
- } else {
- llvm::APSInt ConstantLengthValue;
- if (!Length->EvaluateAsInt(ConstantLengthValue, Context))
- return false;
-
- SingleElement = (ConstantLengthValue.getSExtValue() == 1);
- ArraySizes.push_back(ConstantLengthValue);
- }
-
- // Get the base of this array section and walk up from there.
- const Expr *Base = OASE->getBase()->IgnoreParenImpCasts();
-
- // We require length = 1 for all array sections except the right-most to
- // guarantee that the memory region is contiguous and has no holes in it.
- while (const auto *TempOASE = dyn_cast<OMPArraySectionExpr>(Base)) {
- Length = TempOASE->getLength();
- if (Length == nullptr) {
- // For array sections of the form [1:] or [:], we would need to analyze
- // the lower bound...
- if (OASE->getColonLoc().isValid())
- return false;
-
- // This is an array subscript which has implicit length 1!
- ArraySizes.push_back(llvm::APSInt::get(1));
- } else {
- llvm::APSInt ConstantLengthValue;
- if (!Length->EvaluateAsInt(ConstantLengthValue, Context) ||
- ConstantLengthValue.getSExtValue() != 1)
- return false;
-
- ArraySizes.push_back(ConstantLengthValue);
- }
- Base = TempOASE->getBase()->IgnoreParenImpCasts();
- }
-
- // If we have a single element, we don't need to add the implicit lengths.
- if (!SingleElement) {
- while (const auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base)) {
- // Has implicit length 1!
- ArraySizes.push_back(llvm::APSInt::get(1));
- Base = TempASE->getBase()->IgnoreParenImpCasts();
- }
- }
-
- // This array section can be privatized as a single value or as a constant
- // sized array.
- return true;
-}
-
static bool ActOnOMPReductionKindClause(
Sema &S, DSAStackTy *Stack, OpenMPClauseKind ClauseKind,
ArrayRef<Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc,
@@ -9690,26 +9628,7 @@ static bool ActOnOMPReductionKindClause(
auto *RHSVD = buildVarDecl(S, ELoc, Type, D->getName(),
D->hasAttrs() ? &D->getAttrs() : nullptr);
auto PrivateTy = Type;
-
- // Try if we can determine constant lengths for all array sections and avoid
- // the VLA.
- bool ConstantLengthOASE = false;
- if (OASE) {
- bool SingleElement;
- llvm::SmallVector<llvm::APSInt, 4> ArraySizes;
- ConstantLengthOASE = CheckOMPArraySectionConstantForReduction(
- Context, OASE, SingleElement, ArraySizes);
-
- // If we don't have a single element, we must emit a constant array type.
- if (ConstantLengthOASE && !SingleElement) {
- for (auto &Size : ArraySizes) {
- PrivateTy = Context.getConstantArrayType(
- PrivateTy, Size, ArrayType::Normal, /*IndexTypeQuals=*/0);
- }
- }
- }
-
- if ((OASE && !ConstantLengthOASE) ||
+ if (OASE ||
(!ASE &&
D->getType().getNonReferenceType()->isVariablyModifiedType())) {
// For arrays/array sections only: