Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103

git-svn-id: https://llvm.org/svn/llvm-project/polly/branches/google@360714 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/stable/LICENSE.txt b/stable/LICENSE.txt
index 3b204a8..51f1de3 100644
--- a/stable/LICENSE.txt
+++ b/stable/LICENSE.txt
@@ -1,5 +1,240 @@
 ==============================================================================
-Polly Release License
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+    1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+    2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+    3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+    4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+    5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+    6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+    7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+    8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+    9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+    END OF TERMS AND CONDITIONS
+
+    APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+    Copyright [yyyy] [name of copyright owner]
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+   `LICENSE` file at the top containing the specific license and restrictions
+   which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+   file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
 ==============================================================================
 University of Illinois/NCSA
 Open Source License
@@ -36,26 +271,3 @@
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
 SOFTWARE.
-
-==============================================================================
-Copyrights and Licenses for Third Party Software Distributed with LLVM:
-==============================================================================
-The Polly software contains code written by third parties.   Such software will
-have its own individual LICENSE.TXT file in the directory in which it appears.
-This file will describe the copyrights, license, and restrictions which apply
-to that code.
-
-The disclaimer of warranty in the University of Illinois Open Source License
-applies to all code in the Polly Distribution, and nothing in any of the other
-licenses gives permission to use the names of the Polly Team or promote products
-derived from this Software.
-
-The following pieces of software have additional or alternate copyrights,
-licenses, and/or restrictions:
-
-Program             Directory
--------             ---------
-jsoncpp             lib/External/JSON
-
-
-
diff --git a/stable/docs/ReleaseNotes.rst b/stable/docs/ReleaseNotes.rst
index abae9ff..a9e8c98 100644
--- a/stable/docs/ReleaseNotes.rst
+++ b/stable/docs/ReleaseNotes.rst
@@ -1,8 +1,8 @@
 ============================
-Release Notes 8.0 (upcoming)
+Release Notes 9.0 (upcoming)
 ============================
 
-In Polly 8 the following important changes have been incorporated.
+In Polly 9 the following important changes have been incorporated.
 
 .. warning::
 
diff --git a/stable/docs/TipsAndTricks.rst b/stable/docs/TipsAndTricks.rst
index d399da8..146da04 100644
--- a/stable/docs/TipsAndTricks.rst
+++ b/stable/docs/TipsAndTricks.rst
@@ -47,7 +47,7 @@
 the regression.
 
 LLVM has a single repository that contains all projects. It can be cloned at:
-`<https://github.com/llvm-project/llvm-project-20170507>`_. How to bisect on a
+`<https://github.com/llvm/llvm-project>`_. How to bisect on a
 git repository is explained here
 `<https://www.metaltoad.com/blog/beginners-guide-git-bisect-process-elimination>`_.
 The bisect process can also be automated as explained here:
diff --git a/stable/docs/UsingPollyWithClang.rst b/stable/docs/UsingPollyWithClang.rst
index 3198a41..b6f3705 100644
--- a/stable/docs/UsingPollyWithClang.rst
+++ b/stable/docs/UsingPollyWithClang.rst
@@ -37,6 +37,38 @@
 
   clang -O3 -mllvm -polly -mllvm -polly-parallel -lgomp file.c
 
+Switching the OpenMP backend
+----------------------------
+
+The following CL switch allows to choose Polly's OpenMP-backend:
+
+       -polly-omp-backend[=BACKEND]
+              choose the OpenMP backend; BACKEND can be 'GNU' (the default) or 'LLVM';
+
+The OpenMP backends can be further influenced using the following CL switches:
+
+
+       -polly-num-threads[=NUM]
+              set the number of threads to use; NUM may be any positive integer (default: 0, which equals automatic/OMP runtime);
+
+       -polly-scheduling[=SCHED]
+              set the OpenMP scheduling type; SCHED can be 'static', 'dynamic', 'guided' or 'runtime' (the default);
+
+       -polly-scheduling-chunksize[=CHUNK]
+              set the chunksize (for the selected scheduling type); CHUNK may be any strictly positive integer (otherwise it will default to 1);
+
+Note that at the time of writing, the GNU backend may only use the
+`polly-num-threads` and `polly-scheduling` switches, where the latter also has
+to be set to "runtime".
+
+Example: Use alternative backend with dynamic scheduling, four threads and
+chunksize of one (additional switches).
+
+.. code-block:: console
+
+  -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=4
+  -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1
+
 Automatic Vector code generation
 ================================
 
diff --git a/stable/docs/conf.py b/stable/docs/conf.py
index 45629da..a881b91 100644
--- a/stable/docs/conf.py
+++ b/stable/docs/conf.py
@@ -49,9 +49,9 @@
 # built documents.
 #
 # The short X.Y version.
-version = '8.0-devel'
+version = '9.0-devel'
 # The full version, including alpha/beta/rc tags.
-release = '8.0-devel'
+release = '9.0-devel'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/stable/include/polly/Canonicalization.h b/stable/include/polly/Canonicalization.h
index 1d0fc96..763f2df 100644
--- a/stable/include/polly/Canonicalization.h
+++ b/stable/include/polly/Canonicalization.h
@@ -1,16 +1,19 @@
 //===--- Canonicalization.h - Set of canonicalization passes ----*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
 #ifndef POLLY_CANONICALIZATION_H
 #define POLLY_CANONICALIZATION_H
 
-#include "llvm/IR/LegacyPassManager.h"
+namespace llvm {
+namespace legacy {
+class PassManagerBase;
+}
+} // namespace llvm
 
 namespace polly {
 
diff --git a/stable/include/polly/CodeGen/BlockGenerators.h b/stable/include/polly/CodeGen/BlockGenerators.h
index fca0edc..f2c52c8 100644
--- a/stable/include/polly/CodeGen/BlockGenerators.h
+++ b/stable/include/polly/CodeGen/BlockGenerators.h
@@ -1,9 +1,8 @@
 //===-BlockGenerators.h - Helper to generate code for statements-*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,24 +16,12 @@
 #define POLLY_BLOCK_GENERATORS_H
 
 #include "polly/CodeGen/IRBuilder.h"
-#include "polly/Support/GICHelper.h"
 #include "polly/Support/ScopHelper.h"
-#include "llvm/ADT/MapVector.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
-#include "isl/map.h"
-
-struct isl_ast_build;
-struct isl_id_to_ast_expr;
-
-namespace llvm {
-class Pass;
-class Region;
-class ScalarEvolution;
-} // namespace llvm
+#include "isl/isl-noexceptions.h"
 
 namespace polly {
 using namespace llvm;
-class ScopStmt;
 class MemoryAccess;
 class ScopArrayInfo;
 class IslExprBuilder;
diff --git a/stable/include/polly/CodeGen/CodeGeneration.h b/stable/include/polly/CodeGen/CodeGeneration.h
index bd1b826..b32f312 100644
--- a/stable/include/polly/CodeGen/CodeGeneration.h
+++ b/stable/include/polly/CodeGen/CodeGeneration.h
@@ -1,29 +1,20 @@
 //===- polly/CodeGeneration.h - The Polly code generator --------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
 #ifndef POLLY_CODEGENERATION_H
 #define POLLY_CODEGENERATION_H
 
-#include "IRBuilder.h"
-#include "polly/Config/config.h"
+#include "polly/CodeGen/IRBuilder.h"
 #include "polly/ScopPass.h"
 #include "llvm/IR/PassManager.h"
 
-namespace llvm {
-
-class BasicBlock;
-} // namespace llvm
-
 namespace polly {
 
-class Scop;
-
 enum VectorizerChoice {
   VECTORIZER_NONE,
   VECTORIZER_STRIPMINE,
diff --git a/stable/include/polly/CodeGen/IRBuilder.h b/stable/include/polly/CodeGen/IRBuilder.h
index dcfc348..8033ffa 100644
--- a/stable/include/polly/CodeGen/IRBuilder.h
+++ b/stable/include/polly/CodeGen/IRBuilder.h
@@ -1,9 +1,8 @@
 //===- Codegen/IRBuilder.h - The IR builder used by Polly -*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,12 +15,11 @@
 #define POLLY_CODEGEN_IRBUILDER_H
 
 #include "llvm/ADT/MapVector.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/ValueMap.h"
 
 namespace llvm {
+class Loop;
+class SCEV;
 class ScalarEvolution;
 } // namespace llvm
 
diff --git a/stable/include/polly/CodeGen/IslAst.h b/stable/include/polly/CodeGen/IslAst.h
index 059205c..1a842b8 100644
--- a/stable/include/polly/CodeGen/IslAst.h
+++ b/stable/include/polly/CodeGen/IslAst.h
@@ -1,9 +1,8 @@
 //===- IslAst.h - Interface to the isl code generator -----------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -22,34 +21,14 @@
 #ifndef POLLY_ISLAST_H
 #define POLLY_ISLAST_H
 
-#include "polly/Config/config.h"
 #include "polly/ScopPass.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/IR/PassManager.h"
-#include "isl/ast.h"
 #include "isl/ctx.h"
-#include <memory>
-
-namespace llvm {
-
-class PassRegistry;
-class raw_ostream;
-
-void initializeIslAstInfoWrapperPassPass(PassRegistry &);
-} // namespace llvm
-
-struct isl_ast_build;
-struct isl_ast_expr;
-struct isl_ast_node;
-struct isl_pw_aff;
-struct isl_pw_multi_aff;
-struct isl_union_map;
 
 namespace polly {
 
 struct Dependences;
-class MemoryAccess;
-class Scop;
 
 class IslAst {
 public:
diff --git a/stable/include/polly/CodeGen/IslExprBuilder.h b/stable/include/polly/CodeGen/IslExprBuilder.h
index c036463..fe727cd 100644
--- a/stable/include/polly/CodeGen/IslExprBuilder.h
+++ b/stable/include/polly/CodeGen/IslExprBuilder.h
@@ -1,9 +1,8 @@
 //===-IslExprBuilder.h - Helper to generate code for isl AST expressions --===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -14,19 +13,9 @@
 
 #include "polly/CodeGen/IRBuilder.h"
 #include "polly/Support/ScopHelper.h"
-
-#include "llvm/ADT/MapVector.h"
-#include "isl/ast.h"
 #include "isl/isl-noexceptions.h"
 
 namespace llvm {
-class DataLayout;
-class ScalarEvolution;
-} // namespace llvm
-
-struct isl_id;
-
-namespace llvm {
 // Provide PointerLikeTypeTraits for isl_id.
 template <> struct PointerLikeTypeTraits<isl_id *> {
 
diff --git a/stable/include/polly/CodeGen/IslNodeBuilder.h b/stable/include/polly/CodeGen/IslNodeBuilder.h
index 0d3d3af..47bec72 100644
--- a/stable/include/polly/CodeGen/IslNodeBuilder.h
+++ b/stable/include/polly/CodeGen/IslNodeBuilder.h
@@ -1,9 +1,8 @@
 //=- IslNodeBuilder.cpp - Translate an isl AST into a LLVM-IR AST -*- C++ -*-=//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -18,48 +17,20 @@
 #include "polly/CodeGen/BlockGenerators.h"
 #include "polly/CodeGen/IslExprBuilder.h"
 #include "polly/ScopDetectionDiagnostic.h"
-#include "polly/Support/ScopHelper.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Analysis/ScalarEvolutionExpressions.h"
 #include "llvm/IR/InstrTypes.h"
 #include "isl/ctx.h"
 #include "isl/isl-noexceptions.h"
-#include <utility>
-#include <vector>
 
 using namespace llvm;
 using namespace polly;
 
-namespace llvm {
-
-class BasicBlock;
-class DataLayout;
-class DominatorTree;
-class Function;
-class Instruction;
-class Loop;
-class LoopInfo;
-class ScalarEvolution;
-class SCEV;
-class Type;
-class Value;
-} // namespace llvm
-
 namespace polly {
 
 struct InvariantEquivClassTy;
-class MemoryAccess;
-class Scop;
-class ScopStmt;
 } // namespace polly
 
-struct isl_ast_node;
-struct isl_ast_build;
-struct isl_union_map;
-
 struct SubtreeReferences {
   LoopInfo &LI;
   ScalarEvolution &SE;
diff --git a/stable/include/polly/CodeGen/LoopGenerators.h b/stable/include/polly/CodeGen/LoopGenerators.h
index fe13299..152f816 100644
--- a/stable/include/polly/CodeGen/LoopGenerators.h
+++ b/stable/include/polly/CodeGen/LoopGenerators.h
@@ -1,9 +1,8 @@
 //===- LoopGenerators.h - IR helper to create loops -------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,19 +15,26 @@
 
 #include "polly/CodeGen/IRBuilder.h"
 #include "polly/Support/ScopHelper.h"
-
 #include "llvm/ADT/SetVector.h"
-#include "llvm/IR/ValueMap.h"
-
-namespace llvm {
-class Value;
-class Pass;
-class BasicBlock;
-} // namespace llvm
 
 namespace polly {
 using namespace llvm;
 
+/// General scheduling types of parallel OpenMP for loops.
+/// Initialization values taken from OpenMP's enum in kmp.h: sched_type.
+/// Currently, only 'static' scheduling may change from chunked to non-chunked.
+enum class OMPGeneralSchedulingType {
+  StaticChunked = 33,
+  StaticNonChunked = 34,
+  Dynamic = 35,
+  Guided = 36,
+  Runtime = 37
+};
+
+extern int PollyNumThreads;
+extern OMPGeneralSchedulingType PollyScheduling;
+extern int PollyChunkSize;
+
 /// Create a scalar do/for-style loop.
 ///
 /// @param LowerBound         The starting value of the induction variable.
@@ -133,7 +139,7 @@
                             SetVector<Value *> &Values, ValueMapT &VMap,
                             BasicBlock::iterator *LoopBody);
 
-private:
+protected:
   /// The IR builder we use to create instructions.
   PollyIRBuilder &Builder;
 
@@ -150,38 +156,6 @@
   Module *M;
 
 public:
-  /// The functions below can be used if one does not want to generate a
-  /// specific OpenMP parallel loop, but generate individual parts of it
-  /// (e.g., the subfunction definition).
-
-  /// Create a runtime library call to spawn the worker threads.
-  ///
-  /// @param SubFn      The subfunction which holds the loop body.
-  /// @param SubFnParam The parameter for the subfunction (basically the struct
-  ///                   filled with the outside values).
-  /// @param LB         The lower bound for the loop we parallelize.
-  /// @param UB         The upper bound for the loop we parallelize.
-  /// @param Stride     The stride of the loop we parallelize.
-  void createCallSpawnThreads(Value *SubFn, Value *SubFnParam, Value *LB,
-                              Value *UB, Value *Stride);
-
-  /// Create a runtime library call to join the worker threads.
-  void createCallJoinThreads();
-
-  /// Create a runtime library call to get the next work item.
-  ///
-  /// @param LBPtr A pointer value to store the work item begin in.
-  /// @param UBPtr A pointer value to store the work item end in.
-  ///
-  /// @returns A true value if the work item is not empty.
-  Value *createCallGetWorkItem(Value *LBPtr, Value *UBPtr);
-
-  /// Create a runtime library call to allow cleanup of the thread.
-  ///
-  /// @note This function is called right before the thread will exit the
-  ///       subfunction and only if the runtime system depends on it.
-  void createCallCleanupThread();
-
   /// Create a struct for all @p Values and store them in there.
   ///
   /// @param Values The values which should be stored in the struct.
@@ -199,8 +173,30 @@
                                Value *Struct, ValueMapT &VMap);
 
   /// Create the definition of the parallel subfunction.
+  ///
+  /// @return A pointer to the subfunction.
   Function *createSubFnDefinition();
 
+  /// Create the runtime library calls for spawn and join of the worker threads.
+  /// Additionally, places a call to the specified subfunction.
+  ///
+  /// @param SubFn      The subfunction which holds the loop body.
+  /// @param SubFnParam The parameter for the subfunction (basically the struct
+  ///                   filled with the outside values).
+  /// @param LB         The lower bound for the loop we parallelize.
+  /// @param UB         The upper bound for the loop we parallelize.
+  /// @param Stride     The stride of the loop we parallelize.
+  virtual void deployParallelExecution(Value *SubFn, Value *SubFnParam,
+                                       Value *LB, Value *UB, Value *Stride) = 0;
+
+  /// Prepare the definition of the parallel subfunction.
+  /// Creates the argument list and names them (as well as the subfunction).
+  ///
+  /// @param F A pointer to the (parallel) subfunction's parent function.
+  ///
+  /// @return The pointer to the (parallel) subfunction.
+  virtual Function *prepareSubFnDefinition(Function *F) const = 0;
+
   /// Create the parallel subfunction.
   ///
   /// @param Stride The induction variable increment.
@@ -212,9 +208,9 @@
   /// @param SubFn  The newly created subfunction is returned here.
   ///
   /// @return The newly created induction variable.
-  Value *createSubFn(Value *Stride, AllocaInst *Struct,
-                     SetVector<Value *> UsedValues, ValueMapT &VMap,
-                     Function **SubFn);
+  virtual std::tuple<Value *, Function *>
+  createSubFn(Value *Stride, AllocaInst *Struct, SetVector<Value *> UsedValues,
+              ValueMapT &VMap) = 0;
 };
 } // end namespace polly
 #endif
diff --git a/stable/include/polly/CodeGen/LoopGeneratorsGOMP.h b/stable/include/polly/CodeGen/LoopGeneratorsGOMP.h
new file mode 100644
index 0000000..083be75
--- /dev/null
+++ b/stable/include/polly/CodeGen/LoopGeneratorsGOMP.h
@@ -0,0 +1,75 @@
+//===- LoopGeneratorsGOMP.h - IR helper to create loops ---------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains functions to create scalar and OpenMP parallel loops
+// as LLVM-IR.
+//
+//===----------------------------------------------------------------------===//
+#ifndef POLLY_LOOP_GENERATORS_GOMP_H
+#define POLLY_LOOP_GENERATORS_GOMP_H
+
+#include "polly/CodeGen/IRBuilder.h"
+#include "polly/CodeGen/LoopGenerators.h"
+#include "polly/Support/ScopHelper.h"
+#include "llvm/ADT/SetVector.h"
+
+namespace polly {
+using namespace llvm;
+
+/// This ParallelLoopGenerator subclass handles the generation of parallelized
+/// code, utilizing the GNU OpenMP library.
+class ParallelLoopGeneratorGOMP : public ParallelLoopGenerator {
+public:
+  /// Create a parallel loop generator for the current function.
+  ParallelLoopGeneratorGOMP(PollyIRBuilder &Builder, LoopInfo &LI,
+                            DominatorTree &DT, const DataLayout &DL)
+      : ParallelLoopGenerator(Builder, LI, DT, DL) {}
+
+  // The functions below may be used if one does not want to generate a
+  // specific OpenMP parallel loop, but generate individual parts of it
+  // (e.g. the subfunction definition).
+
+  /// Create a runtime library call to spawn the worker threads.
+  ///
+  /// @param SubFn      The subfunction which holds the loop body.
+  /// @param SubFnParam The parameter for the subfunction (basically the struct
+  ///                   filled with the outside values).
+  /// @param LB         The lower bound for the loop we parallelize.
+  /// @param UB         The upper bound for the loop we parallelize.
+  /// @param Stride     The stride of the loop we parallelize.
+  void createCallSpawnThreads(Value *SubFn, Value *SubFnParam, Value *LB,
+                              Value *UB, Value *Stride);
+
+  void deployParallelExecution(Value *SubFn, Value *SubFnParam, Value *LB,
+                               Value *UB, Value *Stride) override;
+
+  virtual Function *prepareSubFnDefinition(Function *F) const override;
+
+  std::tuple<Value *, Function *> createSubFn(Value *Stride, AllocaInst *Struct,
+                                              SetVector<Value *> UsedValues,
+                                              ValueMapT &VMap) override;
+
+  /// Create a runtime library call to join the worker threads.
+  void createCallJoinThreads();
+
+  /// Create a runtime library call to get the next work item.
+  ///
+  /// @param LBPtr A pointer value to store the work item begin in.
+  /// @param UBPtr A pointer value to store the work item end in.
+  ///
+  /// @returns A true value if the work item is not empty.
+  Value *createCallGetWorkItem(Value *LBPtr, Value *UBPtr);
+
+  /// Create a runtime library call to allow cleanup of the thread.
+  ///
+  /// @note This function is called right before the thread will exit the
+  ///       subfunction and only if the runtime system depends on it.
+  void createCallCleanupThread();
+};
+} // end namespace polly
+#endif
diff --git a/stable/include/polly/CodeGen/LoopGeneratorsKMP.h b/stable/include/polly/CodeGen/LoopGeneratorsKMP.h
new file mode 100644
index 0000000..d9a6916
--- /dev/null
+++ b/stable/include/polly/CodeGen/LoopGeneratorsKMP.h
@@ -0,0 +1,144 @@
+//===- LoopGeneratorsKMP.h - IR helper to create loops ----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains functions to create scalar and OpenMP parallel loops
+// as LLVM-IR.
+//
+//===----------------------------------------------------------------------===//
+#ifndef POLLY_LOOP_GENERATORS_KMP_H
+#define POLLY_LOOP_GENERATORS_KMP_H
+
+#include "polly/CodeGen/IRBuilder.h"
+#include "polly/CodeGen/LoopGenerators.h"
+#include "polly/Support/ScopHelper.h"
+#include "llvm/ADT/SetVector.h"
+
+namespace polly {
+using namespace llvm;
+
+/// This ParallelLoopGenerator subclass handles the generation of parallelized
+/// code, utilizing the LLVM OpenMP library.
+class ParallelLoopGeneratorKMP : public ParallelLoopGenerator {
+public:
+  /// Create a parallel loop generator for the current function.
+  ParallelLoopGeneratorKMP(PollyIRBuilder &Builder, LoopInfo &LI,
+                           DominatorTree &DT, const DataLayout &DL)
+      : ParallelLoopGenerator(Builder, LI, DT, DL) {
+    SourceLocationInfo = createSourceLocation();
+  }
+
+protected:
+  /// The source location struct of this loop.
+  /// ident_t = type { i32, i32, i32, i32, i8* }
+  GlobalValue *SourceLocationInfo;
+
+  /// Convert the combination of given chunk size and scheduling type (which
+  /// might have been set via the command line) into the corresponding
+  /// scheduling type. This may result (e.g.) in a 'change' from
+  /// "static chunked" scheduling to "static non-chunked" (regarding the
+  /// provided and returned scheduling types).
+  ///
+  /// @param ChunkSize    The chunk size, set via command line or its default.
+  /// @param Scheduling   The scheduling, set via command line or its default.
+  ///
+  /// @return The corresponding OMPGeneralSchedulingType.
+  OMPGeneralSchedulingType
+  getSchedType(int ChunkSize, OMPGeneralSchedulingType Scheduling) const;
+
+  /// Returns True if 'LongType' is 64bit wide, otherwise: False.
+  bool is64BitArch();
+
+public:
+  // The functions below may be used if one does not want to generate a
+  // specific OpenMP parallel loop, but generate individual parts of it
+  // (e.g. the subfunction definition).
+
+  /// Create a runtime library call to spawn the worker threads.
+  ///
+  /// @param SubFn      The subfunction which holds the loop body.
+  /// @param SubFnParam The parameter for the subfunction (basically the struct
+  ///                   filled with the outside values).
+  /// @param LB         The lower bound for the loop we parallelize.
+  /// @param UB         The upper bound for the loop we parallelize.
+  /// @param Stride     The stride of the loop we parallelize.
+  void createCallSpawnThreads(Value *SubFn, Value *SubFnParam, Value *LB,
+                              Value *UB, Value *Stride);
+
+  void deployParallelExecution(Value *SubFn, Value *SubFnParam, Value *LB,
+                               Value *UB, Value *Stride) override;
+
+  virtual Function *prepareSubFnDefinition(Function *F) const override;
+
+  std::tuple<Value *, Function *> createSubFn(Value *Stride, AllocaInst *Struct,
+                                              SetVector<Value *> UsedValues,
+                                              ValueMapT &VMap) override;
+
+  /// Create a runtime library call to get the current global thread number.
+  ///
+  /// @return A Value ref which holds the current global thread number.
+  Value *createCallGlobalThreadNum();
+
+  /// Create a runtime library call to request a number of threads.
+  /// Which will be used in the next OpenMP section (by the next fork).
+  ///
+  /// @param GlobalThreadID   The global thread ID.
+  /// @param NumThreads       The number of threads to use.
+  void createCallPushNumThreads(Value *GlobalThreadID, Value *NumThreads);
+
+  /// Create a runtime library call to prepare the OpenMP runtime.
+  /// For dynamically scheduled loops, saving the loop arguments.
+  ///
+  /// @param GlobalThreadID   The global thread ID.
+  /// @param LB               The loop's lower bound.
+  /// @param UB               The loop's upper bound.
+  /// @param Inc              The loop increment.
+  /// @param ChunkSize        The chunk size of the parallel loop.
+  void createCallDispatchInit(Value *GlobalThreadID, Value *LB, Value *UB,
+                              Value *Inc, Value *ChunkSize);
+
+  /// Create a runtime library call to retrieve the next (dynamically)
+  /// allocated chunk of work for this thread.
+  ///
+  /// @param GlobalThreadID   The global thread ID.
+  /// @param IsLastPtr        Pointer to a flag, which is set to 1 if this is
+  ///                         the last chunk of work, or 0 otherwise.
+  /// @param LBPtr            Pointer to the lower bound for the next chunk.
+  /// @param UBPtr            Pointer to the upper bound for the next chunk.
+  /// @param StridePtr        Pointer to the stride for the next chunk.
+  ///
+  /// @return A Value which holds 1 if there is work to be done, 0 otherwise.
+  Value *createCallDispatchNext(Value *GlobalThreadID, Value *IsLastPtr,
+                                Value *LBPtr, Value *UBPtr, Value *StridePtr);
+
+  /// Create a runtime library call to prepare the OpenMP runtime.
+  /// For statically scheduled loops, saving the loop arguments.
+  ///
+  /// @param GlobalThreadID   The global thread ID.
+  /// @param IsLastPtr        Pointer to a flag, which is set to 1 if this is
+  ///                         the last chunk of work, or 0 otherwise.
+  /// @param LBPtr            Pointer to the lower bound for the next chunk.
+  /// @param UBPtr            Pointer to the upper bound for the next chunk.
+  /// @param StridePtr        Pointer to the stride for the next chunk.
+  /// @param ChunkSize        The chunk size of the parallel loop.
+  void createCallStaticInit(Value *GlobalThreadID, Value *IsLastPtr,
+                            Value *LBPtr, Value *UBPtr, Value *StridePtr,
+                            Value *ChunkSize);
+
+  /// Create a runtime library call to mark the end of
+  /// a statically scheduled loop.
+  ///
+  /// @param GlobalThreadID   The global thread ID.
+  void createCallStaticFini(Value *GlobalThreadID);
+
+  /// Create the current source location.
+  ///
+  /// TODO: Generates only(!) dummy values.
+  GlobalVariable *createSourceLocation();
+};
+} // end namespace polly
+#endif
diff --git a/stable/include/polly/CodeGen/PPCGCodeGeneration.h b/stable/include/polly/CodeGen/PPCGCodeGeneration.h
index 9a9a143..d003fb2 100644
--- a/stable/include/polly/CodeGen/PPCGCodeGeneration.h
+++ b/stable/include/polly/CodeGen/PPCGCodeGeneration.h
@@ -1,9 +1,8 @@
 //===--- polly/PPCGCodeGeneration.h - Polly Accelerator Code Generation. --===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/CodeGen/PerfMonitor.h b/stable/include/polly/CodeGen/PerfMonitor.h
index 77b59b4..81aa4c7 100644
--- a/stable/include/polly/CodeGen/PerfMonitor.h
+++ b/stable/include/polly/CodeGen/PerfMonitor.h
@@ -1,9 +1,8 @@
 //===--- PerfMonitor.h --- Monitor time spent in scops --------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
@@ -12,13 +11,6 @@
 
 #include "polly/CodeGen/IRBuilder.h"
 
-namespace llvm {
-class Function;
-class Module;
-class Value;
-class Instruction;
-} // namespace llvm
-
 namespace polly {
 
 class PerfMonitor {
diff --git a/stable/include/polly/CodeGen/RuntimeDebugBuilder.h b/stable/include/polly/CodeGen/RuntimeDebugBuilder.h
index a0820f9..c40b53c 100644
--- a/stable/include/polly/CodeGen/RuntimeDebugBuilder.h
+++ b/stable/include/polly/CodeGen/RuntimeDebugBuilder.h
@@ -1,9 +1,8 @@
 //===--- RuntimeDebugBuilder.h --- Helper to insert prints into LLVM-IR ---===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/CodeGen/Utils.h b/stable/include/polly/CodeGen/Utils.h
index 0452c44..0678e34 100644
--- a/stable/include/polly/CodeGen/Utils.h
+++ b/stable/include/polly/CodeGen/Utils.h
@@ -1,9 +1,8 @@
 //===- Utils.h - Utility functions for code generation ----------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/CodePreparation.h b/stable/include/polly/CodePreparation.h
index 326465f..fb1942b 100644
--- a/stable/include/polly/CodePreparation.h
+++ b/stable/include/polly/CodePreparation.h
@@ -1,9 +1,8 @@
 //===- polly/ScopPreparation.h - Code preparation pass ----------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Config/config.h.cmake b/stable/include/polly/Config/config.h.cmake
index 728eedd..aaa101f 100644
--- a/stable/include/polly/Config/config.h.cmake
+++ b/stable/include/polly/Config/config.h.cmake
@@ -1,9 +1,8 @@
 //===- polly/Config.h ------------ Configuration of Polly -------*- C++ -*-===//
 //
-//                      The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/DeLICM.h b/stable/include/polly/DeLICM.h
index 8aeefb6..7ef382f 100644
--- a/stable/include/polly/DeLICM.h
+++ b/stable/include/polly/DeLICM.h
@@ -1,9 +1,8 @@
 //===------ DeLICM.h --------------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -18,11 +17,12 @@
 #ifndef POLLY_DELICM_H
 #define POLLY_DELICM_H
 
-#include "polly/Support/GICHelper.h"
+#include "isl/isl-noexceptions.h"
 
 namespace llvm {
 class PassRegistry;
 class Pass;
+class raw_ostream;
 } // namespace llvm
 
 namespace polly {
diff --git a/stable/include/polly/DependenceInfo.h b/stable/include/polly/DependenceInfo.h
index 59ae2aa..d66be81 100644
--- a/stable/include/polly/DependenceInfo.h
+++ b/stable/include/polly/DependenceInfo.h
@@ -1,9 +1,8 @@
 //===--- polly/DependenceInfo.h - Polyhedral dependency analysis *- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -27,21 +26,10 @@
 #include "isl/ctx.h"
 #include "isl/isl-noexceptions.h"
 
-struct isl_pw_aff;
-struct isl_union_map;
-struct isl_union_set;
-struct isl_map;
-struct isl_set;
-struct clast_for;
-
 using namespace llvm;
 
 namespace polly {
 
-class Scop;
-class ScopStmt;
-class MemoryAccess;
-
 /// The accumulated dependence information for a SCoP.
 ///
 /// The Dependences struct holds all dependence information we collect and
@@ -314,7 +302,6 @@
 } // namespace polly
 
 namespace llvm {
-class PassRegistry;
 void initializeDependenceInfoPass(llvm::PassRegistry &);
 void initializeDependenceInfoWrapperPassPass(llvm::PassRegistry &);
 } // namespace llvm
diff --git a/stable/include/polly/FlattenAlgo.h b/stable/include/polly/FlattenAlgo.h
index f5bc757..6fdca8f 100644
--- a/stable/include/polly/FlattenAlgo.h
+++ b/stable/include/polly/FlattenAlgo.h
@@ -1,9 +1,8 @@
 //===------ FlattenAlgo.h --------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -15,7 +14,7 @@
 #ifndef POLLY_FLATTENALGO_H
 #define POLLY_FLATTENALGO_H
 
-#include "polly/Support/GICHelper.h"
+#include "isl/isl-noexceptions.h"
 
 namespace polly {
 /// Recursively flatten a schedule.
diff --git a/stable/include/polly/FlattenSchedule.h b/stable/include/polly/FlattenSchedule.h
index 0e30473..2b9fa4f 100644
--- a/stable/include/polly/FlattenSchedule.h
+++ b/stable/include/polly/FlattenSchedule.h
@@ -1,9 +1,8 @@
 //===------ FlattenSchedule.h ----------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/ForwardOpTree.h b/stable/include/polly/ForwardOpTree.h
index 3e23be8..d4f879c 100644
--- a/stable/include/polly/ForwardOpTree.h
+++ b/stable/include/polly/ForwardOpTree.h
@@ -1,9 +1,8 @@
 //===- ForwardOpTree.h ------------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/JSONExporter.h b/stable/include/polly/JSONExporter.h
index 8252dd4..92aaacc 100644
--- a/stable/include/polly/JSONExporter.h
+++ b/stable/include/polly/JSONExporter.h
@@ -1,9 +1,8 @@
 //===- polly/JSONExporter.h - Import/Export to/from jscop files.-*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/stable/include/polly/LinkAllPasses.h b/stable/include/polly/LinkAllPasses.h
index 56a7330..ed05f83 100644
--- a/stable/include/polly/LinkAllPasses.h
+++ b/stable/include/polly/LinkAllPasses.h
@@ -1,9 +1,8 @@
 //===- polly/LinkAllPasses.h ----------- Reference All Passes ---*- C++ -*-===//
 //
-//                      The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -25,9 +24,7 @@
 
 namespace llvm {
 class Pass;
-class PassInfo;
 class PassRegistry;
-class RegionPass;
 } // namespace llvm
 
 namespace polly {
diff --git a/stable/include/polly/Options.h b/stable/include/polly/Options.h
index 62e0960..91a3a84 100644
--- a/stable/include/polly/Options.h
+++ b/stable/include/polly/Options.h
@@ -1,9 +1,8 @@
 //===--------------- polly/Options.h - The Polly option category *- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/PolyhedralInfo.h b/stable/include/polly/PolyhedralInfo.h
index 40c6ea6..cec288d 100644
--- a/stable/include/polly/PolyhedralInfo.h
+++ b/stable/include/polly/PolyhedralInfo.h
@@ -1,9 +1,8 @@
 //===- polly/PolyhedralInfo.h - PolyhedralInfo class definition -*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 ///
@@ -18,8 +17,9 @@
 #define POLLY_POLYHEDRAL_INFO_H
 
 #include "llvm/Pass.h"
+#include "isl/aff_type.h"
 #include "isl/ctx.h"
-#include "isl/union_map.h"
+#include "isl/union_map_type.h"
 
 namespace llvm {
 class Loop;
diff --git a/stable/include/polly/PruneUnprofitable.h b/stable/include/polly/PruneUnprofitable.h
index 6101b7e..3327e14 100644
--- a/stable/include/polly/PruneUnprofitable.h
+++ b/stable/include/polly/PruneUnprofitable.h
@@ -1,9 +1,8 @@
 //===- PruneUnprofitable.h --------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/RegisterPasses.h b/stable/include/polly/RegisterPasses.h
index dc2aa25..2126db9 100644
--- a/stable/include/polly/RegisterPasses.h
+++ b/stable/include/polly/RegisterPasses.h
@@ -1,9 +1,8 @@
 //===------ polly/RegisterPasses.h - Register the Polly passes *- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -14,9 +13,8 @@
 #ifndef POLLY_REGISTER_PASSES_H
 #define POLLY_REGISTER_PASSES_H
 
-#include "llvm/IR/LegacyPassManager.h"
-
 namespace llvm {
+class PassRegistry;
 namespace legacy {
 class PassManagerBase;
 } // namespace legacy
diff --git a/stable/include/polly/ScheduleOptimizer.h b/stable/include/polly/ScheduleOptimizer.h
index ef44f34..c32ddfa 100644
--- a/stable/include/polly/ScheduleOptimizer.h
+++ b/stable/include/polly/ScheduleOptimizer.h
@@ -1,9 +1,8 @@
 //===- polly/ScheduleOptimizer.h - The Schedule Optimizer -------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/stable/include/polly/ScopBuilder.h b/stable/include/polly/ScopBuilder.h
index 247e238..54d48be 100644
--- a/stable/include/polly/ScopBuilder.h
+++ b/stable/include/polly/ScopBuilder.h
@@ -1,9 +1,8 @@
 //===- polly/ScopBuilder.h --------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -21,30 +20,6 @@
 #include "polly/Support/ScopHelper.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/SmallVector.h"
-#include <algorithm>
-#include <memory>
-#include <utility>
-
-namespace llvm {
-
-class AssumptionCache;
-class BasicBlock;
-class DataLayout;
-class DominatorTree;
-class Instruction;
-class LoopInfo;
-class PassRegistry;
-class PHINode;
-class Region;
-class ScalarEvolution;
-class SCEV;
-class Type;
-class Value;
-
-void initializeScopInfoRegionPassPass(PassRegistry &);
-void initializeScopInfoWrapperPassPass(PassRegistry &);
-} // end namespace llvm
 
 namespace polly {
 
diff --git a/stable/include/polly/ScopDetection.h b/stable/include/polly/ScopDetection.h
index 31d54d8..a174b4b 100644
--- a/stable/include/polly/ScopDetection.h
+++ b/stable/include/polly/ScopDetection.h
@@ -1,9 +1,8 @@
 //===- ScopDetection.h - Detect Scops ---------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -49,46 +48,16 @@
 
 #include "polly/ScopDetectionDiagnostic.h"
 #include "polly/Support/ScopHelper.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AliasSetTracker.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
 #include "llvm/Pass.h"
-#include <algorithm>
-#include <map>
-#include <memory>
 #include <set>
-#include <string>
-#include <utility>
-#include <vector>
 
 using namespace llvm;
 
 namespace llvm {
-
-class BasicBlock;
-class BranchInst;
-class CallInst;
-class DebugLoc;
-class DominatorTree;
-class Function;
-class Instruction;
-class IntrinsicInst;
-class Loop;
-class LoopInfo;
-class OptimizationRemarkEmitter;
-class PassRegistry;
-class raw_ostream;
-class ScalarEvolution;
-class SCEV;
-class SCEVUnknown;
-class SwitchInst;
-class Value;
-
 void initializeScopDetectionWrapperPassPass(PassRegistry &);
 } // namespace llvm
 
diff --git a/stable/include/polly/ScopDetectionDiagnostic.h b/stable/include/polly/ScopDetectionDiagnostic.h
index 200c77f..6824615 100644
--- a/stable/include/polly/ScopDetectionDiagnostic.h
+++ b/stable/include/polly/ScopDetectionDiagnostic.h
@@ -1,9 +1,8 @@
 //===- ScopDetectionDiagnostic.h - Diagnostic for ScopDetection -*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -21,15 +20,10 @@
 #ifndef POLLY_SCOPDETECTIONDIAGNOSTIC_H
 #define POLLY_SCOPDETECTIONDIAGNOSTIC_H
 
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/Instruction.h"
 #include <cstddef>
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
 
 using namespace llvm;
 
@@ -38,10 +32,8 @@
 class AliasSet;
 class BasicBlock;
 class OptimizationRemarkEmitter;
-class raw_ostream;
 class Region;
 class SCEV;
-class Value;
 } // namespace llvm
 
 namespace polly {
diff --git a/stable/include/polly/ScopInfo.h b/stable/include/polly/ScopInfo.h
index c6bf0e5..5f48f64 100644
--- a/stable/include/polly/ScopInfo.h
+++ b/stable/include/polly/ScopInfo.h
@@ -1,9 +1,8 @@
 //===- polly/ScopInfo.h -----------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -20,75 +19,31 @@
 
 #include "polly/ScopDetection.h"
 #include "polly/Support/SCEVAffinator.h"
-#include "polly/Support/ScopHelper.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/iterator_range.h"
 #include "llvm/Analysis/RegionPass.h"
-#include "llvm/Analysis/ScalarEvolutionExpressions.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Pass.h"
-#include "llvm/Support/Casting.h"
 #include "isl/isl-noexceptions.h"
-#include <algorithm>
 #include <cassert>
 #include <cstddef>
 #include <forward_list>
-#include <functional>
-#include <list>
-#include <map>
-#include <memory>
-#include <string>
-#include <tuple>
-#include <utility>
-#include <vector>
 
 using namespace llvm;
 
 namespace llvm {
-
-class AssumptionCache;
-class BasicBlock;
-class DataLayout;
-class DominatorTree;
-class Function;
-class Loop;
-class LoopInfo;
-class OptimizationRemarkEmitter;
-class PassRegistry;
-class raw_ostream;
-class ScalarEvolution;
-class SCEV;
-class Type;
-class Value;
-
 void initializeScopInfoRegionPassPass(PassRegistry &);
 void initializeScopInfoWrapperPassPass(PassRegistry &);
 } // end namespace llvm
 
-struct isl_map;
-struct isl_pw_multi_aff;
-struct isl_schedule;
-struct isl_set;
-struct isl_union_map;
-
 namespace polly {
 
 class MemoryAccess;
-class Scop;
-class ScopStmt;
 
 //===---------------------------------------------------------------------===//
 
diff --git a/stable/include/polly/ScopPass.h b/stable/include/polly/ScopPass.h
index 5507e3e..edaadf2 100644
--- a/stable/include/polly/ScopPass.h
+++ b/stable/include/polly/ScopPass.h
@@ -1,9 +1,8 @@
 //===--------- ScopPass.h - Pass for Static Control Parts --------*-C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Simplify.h b/stable/include/polly/Simplify.h
index 20c0517..fb6a015 100644
--- a/stable/include/polly/Simplify.h
+++ b/stable/include/polly/Simplify.h
@@ -1,9 +1,8 @@
 //===------ Simplify.h ------------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Support/DumpModulePass.h b/stable/include/polly/Support/DumpModulePass.h
index 9b16051..8299cfd 100644
--- a/stable/include/polly/Support/DumpModulePass.h
+++ b/stable/include/polly/Support/DumpModulePass.h
@@ -1,9 +1,8 @@
 //===------ DumpModulePass.h ------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Support/GICHelper.h b/stable/include/polly/Support/GICHelper.h
index 335501a..ca8abe4 100644
--- a/stable/include/polly/Support/GICHelper.h
+++ b/stable/include/polly/Support/GICHelper.h
@@ -1,9 +1,8 @@
 //===- Support/GICHelper.h -- Helper functions for ISL --------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,23 +16,9 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/Support/raw_ostream.h"
-#include "isl/aff.h"
 #include "isl/ctx.h"
 #include "isl/isl-noexceptions.h"
-#include "isl/map.h"
 #include "isl/options.h"
-#include "isl/set.h"
-#include "isl/union_map.h"
-#include "isl/union_set.h"
-#include <functional>
-#include <string>
-
-struct isl_schedule;
-struct isl_multi_aff;
-
-namespace llvm {
-class Value;
-} // namespace llvm
 
 namespace polly {
 
diff --git a/stable/include/polly/Support/ISLOStream.h b/stable/include/polly/Support/ISLOStream.h
index fd9c941..08853a2 100644
--- a/stable/include/polly/Support/ISLOStream.h
+++ b/stable/include/polly/Support/ISLOStream.h
@@ -1,9 +1,8 @@
 //===------ IslOstream.h ----------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Support/ISLOperators.h b/stable/include/polly/Support/ISLOperators.h
index 640777d..28fee01 100644
--- a/stable/include/polly/Support/ISLOperators.h
+++ b/stable/include/polly/Support/ISLOperators.h
@@ -1,9 +1,8 @@
 //===------ ISLOperators.h --------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Support/ISLTools.h b/stable/include/polly/Support/ISLTools.h
index afb68fc..fab0dae 100644
--- a/stable/include/polly/Support/ISLTools.h
+++ b/stable/include/polly/Support/ISLTools.h
@@ -1,9 +1,8 @@
 //===------ ISLTools.h ------------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -15,8 +14,8 @@
 #ifndef POLLY_ISLTOOLS_H
 #define POLLY_ISLTOOLS_H
 
-#include "polly/Support/GICHelper.h"
-#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/iterator.h"
+#include "isl/isl-noexceptions.h"
 
 namespace isl {
 inline namespace noexceptions {
diff --git a/stable/include/polly/Support/LinkGPURuntime.h b/stable/include/polly/Support/LinkGPURuntime.h
index 85a6189..c632d45 100644
--- a/stable/include/polly/Support/LinkGPURuntime.h
+++ b/stable/include/polly/Support/LinkGPURuntime.h
@@ -1,9 +1,8 @@
 //===- Support/LinkGPURuntime.h -- Headerfile to help force-link GPURuntime  =//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Support/SCEVAffinator.h b/stable/include/polly/Support/SCEVAffinator.h
index 586d299..4aad9a6 100644
--- a/stable/include/polly/Support/SCEVAffinator.h
+++ b/stable/include/polly/Support/SCEVAffinator.h
@@ -1,9 +1,8 @@
 //===------ polly/SCEVAffinator.h - Create isl expressions from SCEVs -----===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -14,21 +13,11 @@
 #ifndef POLLY_SCEV_AFFINATOR_H
 #define POLLY_SCEV_AFFINATOR_H
 
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
-
 #include "isl/isl-noexceptions.h"
 
-namespace llvm {
-class Region;
-class BasicBlock;
-class DataLayout;
-class ScalarEvolution;
-} // namespace llvm
-
 namespace polly {
 class Scop;
-class ScopStmt;
 
 /// The result type of the SCEVAffinator.
 ///
diff --git a/stable/include/polly/Support/SCEVValidator.h b/stable/include/polly/Support/SCEVValidator.h
index c8a6293..a341dc0 100644
--- a/stable/include/polly/Support/SCEVValidator.h
+++ b/stable/include/polly/Support/SCEVValidator.h
@@ -1,9 +1,8 @@
 //===--- SCEVValidator.h - Detect Scops -------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 // Checks if a SCEV expression represents a valid affine expression.
@@ -13,17 +12,9 @@
 #define POLLY_SCEV_VALIDATOR_H
 
 #include "polly/Support/ScopHelper.h"
-#include "llvm/ADT/SetVector.h"
 
 namespace llvm {
-class Region;
-class SCEV;
 class SCEVConstant;
-class ScalarEvolution;
-class Value;
-class Loop;
-class LoadInst;
-class CallInst;
 } // namespace llvm
 
 namespace polly {
diff --git a/stable/include/polly/Support/ScopHelper.h b/stable/include/polly/Support/ScopHelper.h
index 4fec771..02c669a 100644
--- a/stable/include/polly/Support/ScopHelper.h
+++ b/stable/include/polly/Support/ScopHelper.h
@@ -1,9 +1,8 @@
 //===------ Support/ScopHelper.h -- Some Helper Functions for Scop. -------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -14,13 +13,10 @@
 #ifndef POLLY_SUPPORT_IRHELPER_H
 #define POLLY_SUPPORT_IRHELPER_H
 
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/ValueHandle.h"
-#include <tuple>
-#include <vector>
 
 namespace llvm {
 class LoopInfo;
@@ -31,7 +27,6 @@
 class Pass;
 class DominatorTree;
 class RegionInfo;
-class GetElementPtrInst;
 } // namespace llvm
 
 namespace polly {
diff --git a/stable/include/polly/Support/ScopLocation.h b/stable/include/polly/Support/ScopLocation.h
index 50d0011..a6d5779 100644
--- a/stable/include/polly/Support/ScopLocation.h
+++ b/stable/include/polly/Support/ScopLocation.h
@@ -1,9 +1,8 @@
 //=== ScopLocation.h -- Debug location helper for ScopDetection -*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/Support/VirtualInstruction.h b/stable/include/polly/Support/VirtualInstruction.h
index 9794d35..90bf04f 100644
--- a/stable/include/polly/Support/VirtualInstruction.h
+++ b/stable/include/polly/Support/VirtualInstruction.h
@@ -1,9 +1,8 @@
 //===------ VirtualInstruction.cpp ------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/include/polly/ZoneAlgo.h b/stable/include/polly/ZoneAlgo.h
index c4f5deb..a93868d 100644
--- a/stable/include/polly/ZoneAlgo.h
+++ b/stable/include/polly/ZoneAlgo.h
@@ -1,9 +1,8 @@
 //===------ ZoneAlgo.h ------------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/lib/Analysis/DependenceInfo.cpp b/stable/lib/Analysis/DependenceInfo.cpp
index cec3fe2..173c292 100644
--- a/stable/lib/Analysis/DependenceInfo.cpp
+++ b/stable/lib/Analysis/DependenceInfo.cpp
@@ -1,9 +1,8 @@
 //===- DependenceInfo.cpp - Calculate dependency information for a Scop. --===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -27,15 +26,14 @@
 #include "polly/Support/GICHelper.h"
 #include "polly/Support/ISLTools.h"
 #include "llvm/Support/Debug.h"
-#include <isl/aff.h>
-#include <isl/ctx.h>
-#include <isl/flow.h>
-#include <isl/map.h>
-#include <isl/options.h>
-#include <isl/schedule.h>
-#include <isl/set.h>
-#include <isl/union_map.h>
-#include <isl/union_set.h>
+#include "isl/aff.h"
+#include "isl/ctx.h"
+#include "isl/flow.h"
+#include "isl/map.h"
+#include "isl/schedule.h"
+#include "isl/set.h"
+#include "isl/union_map.h"
+#include "isl/union_set.h"
 
 using namespace polly;
 using namespace llvm;
diff --git a/stable/lib/Analysis/PolyhedralInfo.cpp b/stable/lib/Analysis/PolyhedralInfo.cpp
index e9179c7..2b5ed6f 100644
--- a/stable/lib/Analysis/PolyhedralInfo.cpp
+++ b/stable/lib/Analysis/PolyhedralInfo.cpp
@@ -1,21 +1,21 @@
 //===--------- PolyhedralInfo.cpp  - Create Scops from LLVM IR-------------===//
-///
-///                     The LLVM Compiler Infrastructure
-///
-/// This file is distributed under the University of Illinois Open Source
-/// License. See LICENSE.TXT for details.
-///
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
 //===----------------------------------------------------------------------===//
-///
-/// An interface to the Polyhedral analysis engine(Polly) of LLVM.
-///
-/// This pass provides an interface to the polyhedral analysis performed by
-/// Polly.
-///
-/// This interface provides basic interface like isParallel, isVectorizable
-/// that can be used in LLVM transformation passes.
-///
-/// Work in progress, this file is subject to change.
+//
+// An interface to the Polyhedral analysis engine(Polly) of LLVM.
+//
+// This pass provides an interface to the polyhedral analysis performed by
+// Polly.
+//
+// This interface provides basic interface like isParallel, isVectorizable
+// that can be used in LLVM transformation passes.
+//
+// Work in progress, this file is subject to change.
+//
 //===----------------------------------------------------------------------===//
 
 #include "polly/PolyhedralInfo.h"
@@ -26,8 +26,7 @@
 #include "polly/Support/GICHelper.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Support/Debug.h"
-#include <isl/map.h>
-#include <isl/union_map.h>
+#include "isl/union_map.h"
 
 using namespace llvm;
 using namespace polly;
diff --git a/stable/lib/Analysis/PruneUnprofitable.cpp b/stable/lib/Analysis/PruneUnprofitable.cpp
index da1ef52..f2780a3 100644
--- a/stable/lib/Analysis/PruneUnprofitable.cpp
+++ b/stable/lib/Analysis/PruneUnprofitable.cpp
@@ -1,9 +1,8 @@
 //===- PruneUnprofitable.cpp ----------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,7 +16,6 @@
 #include "polly/ScopPass.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/DebugLoc.h"
-#include "llvm/Pass.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/stable/lib/Analysis/ScopBuilder.cpp b/stable/lib/Analysis/ScopBuilder.cpp
index 7d1e781..3c44429 100644
--- a/stable/lib/Analysis/ScopBuilder.cpp
+++ b/stable/lib/Analysis/ScopBuilder.cpp
@@ -1,9 +1,8 @@
 //===- ScopBuilder.cpp ----------------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,17 +16,13 @@
 #include "polly/ScopBuilder.h"
 #include "polly/Options.h"
 #include "polly/ScopDetection.h"
-#include "polly/ScopDetectionDiagnostic.h"
 #include "polly/ScopInfo.h"
 #include "polly/Support/GICHelper.h"
 #include "polly/Support/SCEVValidator.h"
 #include "polly/Support/ScopHelper.h"
 #include "polly/Support/VirtualInstruction.h"
-#include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/EquivalenceClasses.h"
-#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
@@ -37,31 +32,23 @@
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
 #include "llvm/IR/BasicBlock.h"
-#include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/InstrTypes.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Operator.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Use.h"
 #include "llvm/IR/Value.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cassert>
-#include <string>
-#include <tuple>
-#include <vector>
 
 using namespace llvm;
 using namespace polly;
diff --git a/stable/lib/Analysis/ScopDetection.cpp b/stable/lib/Analysis/ScopDetection.cpp
index 23b714d..25732b7 100644
--- a/stable/lib/Analysis/ScopDetection.cpp
+++ b/stable/lib/Analysis/ScopDetection.cpp
@@ -1,9 +1,8 @@
 //===- ScopDetection.cpp - Detect Scops -----------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -51,22 +50,16 @@
 #include "polly/Support/SCEVValidator.h"
 #include "polly/Support/ScopHelper.h"
 #include "polly/Support/ScopLocation.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/MemoryLocation.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
 #include "llvm/IR/BasicBlock.h"
-#include "llvm/IR/Constants.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/DiagnosticInfo.h"
@@ -77,27 +70,14 @@
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Intrinsics.h"
-#include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
 #include "llvm/Pass.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/Regex.h"
 #include "llvm/Support/raw_ostream.h"
-#include <algorithm>
 #include <cassert>
-#include <memory>
-#include <stack>
-#include <string>
-#include <utility>
-#include <vector>
 
 using namespace llvm;
 using namespace polly;
diff --git a/stable/lib/Analysis/ScopDetectionDiagnostic.cpp b/stable/lib/Analysis/ScopDetectionDiagnostic.cpp
index a0c3712..e58b47d 100644
--- a/stable/lib/Analysis/ScopDetectionDiagnostic.cpp
+++ b/stable/lib/Analysis/ScopDetectionDiagnostic.cpp
@@ -1,9 +1,8 @@
 //===- ScopDetectionDiagnostic.cpp - Error diagnostics --------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/lib/Analysis/ScopGraphPrinter.cpp b/stable/lib/Analysis/ScopGraphPrinter.cpp
index 3908694..8f5d6d2 100644
--- a/stable/lib/Analysis/ScopGraphPrinter.cpp
+++ b/stable/lib/Analysis/ScopGraphPrinter.cpp
@@ -1,9 +1,8 @@
 //===- GraphPrinter.cpp - Create a DOT output describing the Scop. --------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/lib/Analysis/ScopInfo.cpp b/stable/lib/Analysis/ScopInfo.cpp
index 896a1b6..f7e7898 100644
--- a/stable/lib/Analysis/ScopInfo.cpp
+++ b/stable/lib/Analysis/ScopInfo.cpp
@@ -1,9 +1,8 @@
 //===- ScopInfo.cpp -------------------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -30,19 +29,11 @@
 #include "polly/Support/ScopHelper.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/PostOrderIterator.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/AliasSetTracker.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/LoopInfo.h"
@@ -51,58 +42,29 @@
 #include "llvm/Analysis/RegionIterator.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
-#include "llvm/IR/Argument.h"
 #include "llvm/IR/BasicBlock.h"
-#include "llvm/IR/CFG.h"
 #include "llvm/IR/ConstantRange.h"
-#include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugLoc.h"
-#include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/InstrTypes.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
-#include "llvm/IR/Use.h"
-#include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
-#include "llvm/Pass.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include "isl/aff.h"
-#include "isl/constraint.h"
 #include "isl/local_space.h"
 #include "isl/map.h"
 #include "isl/options.h"
-#include "isl/printer.h"
-#include "isl/schedule.h"
-#include "isl/schedule_node.h"
 #include "isl/set.h"
-#include "isl/union_map.h"
-#include "isl/union_set.h"
-#include "isl/val.h"
-#include <algorithm>
 #include <cassert>
-#include <cstdlib>
-#include <cstring>
-#include <deque>
-#include <iterator>
-#include <memory>
-#include <string>
-#include <tuple>
-#include <utility>
-#include <vector>
 
 using namespace llvm;
 using namespace polly;
@@ -844,7 +806,7 @@
   if (Range.isFullSet())
     return;
 
-  if (Range.isWrappedSet() || Range.isSignWrappedSet())
+  if (Range.isUpperWrapped() || Range.isSignWrappedSet())
     return;
 
   bool isWrapping = Range.isSignWrappedSet();
diff --git a/stable/lib/Analysis/ScopPass.cpp b/stable/lib/Analysis/ScopPass.cpp
index b91d66a..6e29998 100644
--- a/stable/lib/Analysis/ScopPass.cpp
+++ b/stable/lib/Analysis/ScopPass.cpp
@@ -1,9 +1,8 @@
 //===- ScopPass.cpp - The base class of Passes that operate on Polly IR ---===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -13,8 +12,6 @@
 
 #include "polly/ScopPass.h"
 #include "polly/ScopInfo.h"
-
-#include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
diff --git a/stable/lib/CMakeLists.txt b/stable/lib/CMakeLists.txt
index 9546541..41f1908 100644
--- a/stable/lib/CMakeLists.txt
+++ b/stable/lib/CMakeLists.txt
@@ -36,6 +36,8 @@
   CodeGen/BlockGenerators.cpp
   ${ISL_CODEGEN_FILES}
   CodeGen/LoopGenerators.cpp
+  CodeGen/LoopGeneratorsGOMP.cpp
+  CodeGen/LoopGeneratorsKMP.cpp
   CodeGen/IRBuilder.cpp
   CodeGen/Utils.cpp
   CodeGen/RuntimeDebugBuilder.cpp
@@ -158,4 +160,3 @@
   # Check if we are building as part of an LLVM build
   add_dependencies(PollyCore intrinsics_gen)
 endif()
-
diff --git a/stable/lib/CodeGen/BlockGenerators.cpp b/stable/lib/CodeGen/BlockGenerators.cpp
index 2248f15..389c8ac 100644
--- a/stable/lib/CodeGen/BlockGenerators.cpp
+++ b/stable/lib/CodeGen/BlockGenerators.cpp
@@ -1,9 +1,8 @@
 //===--- BlockGenerators.cpp - Generate code for statements -----*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -14,26 +13,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/CodeGen/BlockGenerators.h"
-#include "polly/CodeGen/CodeGeneration.h"
 #include "polly/CodeGen/IslExprBuilder.h"
 #include "polly/CodeGen/RuntimeDebugBuilder.h"
 #include "polly/Options.h"
 #include "polly/ScopInfo.h"
-#include "polly/Support/GICHelper.h"
-#include "polly/Support/SCEVValidator.h"
 #include "polly/Support/ScopHelper.h"
 #include "polly/Support/VirtualInstruction.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
-#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Module.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/Local.h"
-#include "isl/aff.h"
 #include "isl/ast.h"
-#include "isl/ast_build.h"
-#include "isl/set.h"
 #include <deque>
 
 using namespace llvm;
diff --git a/stable/lib/CodeGen/CodeGeneration.cpp b/stable/lib/CodeGen/CodeGeneration.cpp
index 1169d76..784b7d8 100644
--- a/stable/lib/CodeGen/CodeGeneration.cpp
+++ b/stable/lib/CodeGen/CodeGeneration.cpp
@@ -1,9 +1,8 @@
 //===- CodeGeneration.cpp - Code generate the Scops using ISL. ---------======//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -28,34 +27,21 @@
 #include "polly/DependenceInfo.h"
 #include "polly/LinkAllPasses.h"
 #include "polly/Options.h"
-#include "polly/ScopDetectionDiagnostic.h"
 #include "polly/ScopInfo.h"
 #include "polly/Support/ScopHelper.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/BasicAliasAnalysis.h"
-#include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/RegionInfo.h"
-#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
-#include "llvm/IR/Instruction.h"
-#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Intrinsics.h"
-#include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
-#include "llvm/Pass.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include "isl/ast.h"
 #include <cassert>
-#include <utility>
 
 using namespace llvm;
 using namespace polly;
diff --git a/stable/lib/CodeGen/CodegenCleanup.cpp b/stable/lib/CodeGen/CodegenCleanup.cpp
index 2e54dfd..b1cf935 100644
--- a/stable/lib/CodeGen/CodegenCleanup.cpp
+++ b/stable/lib/CodeGen/CodegenCleanup.cpp
@@ -1,9 +1,8 @@
 //===- CodegenCleanup.cpp -------------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
@@ -13,8 +12,6 @@
 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/LegacyPassManager.h"
-#include "llvm/PassInfo.h"
-#include "llvm/PassRegistry.h"
 #include "llvm/PassSupport.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
diff --git a/stable/lib/CodeGen/IRBuilder.cpp b/stable/lib/CodeGen/IRBuilder.cpp
index 4c94b9b..435be74 100644
--- a/stable/lib/CodeGen/IRBuilder.cpp
+++ b/stable/lib/CodeGen/IRBuilder.cpp
@@ -1,9 +1,8 @@
 //===------ PollyIRBuilder.cpp --------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,7 +16,6 @@
 #include "polly/Support/ScopHelper.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/Metadata.h"
-#include "llvm/Support/Debug.h"
 
 using namespace llvm;
 using namespace polly;
diff --git a/stable/lib/CodeGen/IslAst.cpp b/stable/lib/CodeGen/IslAst.cpp
index 1862950..8ccbeda 100644
--- a/stable/lib/CodeGen/IslAst.cpp
+++ b/stable/lib/CodeGen/IslAst.cpp
@@ -1,9 +1,8 @@
 //===- IslAst.cpp - isl code generator interface --------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -38,8 +37,6 @@
 #include "polly/Support/GICHelper.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Function.h"
-#include "llvm/Pass.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 #include "isl/aff.h"
@@ -47,7 +44,6 @@
 #include "isl/ast_build.h"
 #include "isl/id.h"
 #include "isl/isl-noexceptions.h"
-#include "isl/map.h"
 #include "isl/printer.h"
 #include "isl/schedule.h"
 #include "isl/set.h"
@@ -55,10 +51,6 @@
 #include "isl/val.h"
 #include <cassert>
 #include <cstdlib>
-#include <cstring>
-#include <map>
-#include <string>
-#include <utility>
 
 #define DEBUG_TYPE "polly-ast"
 
diff --git a/stable/lib/CodeGen/IslExprBuilder.cpp b/stable/lib/CodeGen/IslExprBuilder.cpp
index 0a4dd91..c8e2984 100644
--- a/stable/lib/CodeGen/IslExprBuilder.cpp
+++ b/stable/lib/CodeGen/IslExprBuilder.cpp
@@ -1,9 +1,8 @@
 //===------ IslExprBuilder.cpp ----- Code generate isl AST expressions ----===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -14,8 +13,6 @@
 #include "polly/Options.h"
 #include "polly/ScopInfo.h"
 #include "polly/Support/GICHelper.h"
-#include "polly/Support/ScopHelper.h"
-#include "llvm/Support/Debug.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
 using namespace llvm;
diff --git a/stable/lib/CodeGen/IslNodeBuilder.cpp b/stable/lib/CodeGen/IslNodeBuilder.cpp
index 0e2ed1c..492944c 100644
--- a/stable/lib/CodeGen/IslNodeBuilder.cpp
+++ b/stable/lib/CodeGen/IslNodeBuilder.cpp
@@ -1,9 +1,8 @@
 //===- IslNodeBuilder.cpp - Translate an isl AST into a LLVM-IR AST -------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,12 +16,11 @@
 #include "polly/CodeGen/CodeGeneration.h"
 #include "polly/CodeGen/IslAst.h"
 #include "polly/CodeGen/IslExprBuilder.h"
-#include "polly/CodeGen/LoopGenerators.h"
+#include "polly/CodeGen/LoopGeneratorsGOMP.h"
+#include "polly/CodeGen/LoopGeneratorsKMP.h"
 #include "polly/CodeGen/RuntimeDebugBuilder.h"
-#include "polly/Config/config.h"
 #include "polly/Options.h"
 #include "polly/ScopInfo.h"
-#include "polly/Support/GICHelper.h"
 #include "polly/Support/ISLTools.h"
 #include "polly/Support/SCEVValidator.h"
 #include "polly/Support/ScopHelper.h"
@@ -81,6 +79,9 @@
 STATISTIC(VectorLoops, "Number of generated vector for-loops");
 STATISTIC(IfConditions, "Number of generated if-conditions");
 
+/// OpenMP backend options
+enum class OpenMPBackend { GNU, LLVM };
+
 static cl::opt<bool> PollyGenerateRTCPrint(
     "polly-codegen-emit-rtc-print",
     cl::desc("Emit code that prints the runtime check result dynamically."),
@@ -100,6 +101,12 @@
     cl::desc("The size of the first level cache line size specified in bytes."),
     cl::Hidden, cl::init(64), cl::ZeroOrMore, cl::cat(PollyCategory));
 
+static cl::opt<OpenMPBackend> PollyOmpBackend(
+    "polly-omp-backend", cl::desc("Choose the OpenMP library to use:"),
+    cl::values(clEnumValN(OpenMPBackend::GNU, "GNU", "GNU OpenMP"),
+               clEnumValN(OpenMPBackend::LLVM, "LLVM", "LLVM OpenMP")),
+    cl::Hidden, cl::init(OpenMPBackend::GNU), cl::cat(PollyCategory));
+
 isl::ast_expr IslNodeBuilder::getUpperBound(isl::ast_node For,
                                             ICmpInst::Predicate &Predicate) {
   isl::ast_expr Cond = For.for_get_cond();
@@ -669,10 +676,21 @@
   }
 
   ValueMapT NewValues;
-  ParallelLoopGenerator ParallelLoopGen(Builder, LI, DT, DL);
 
-  IV = ParallelLoopGen.createParallelLoop(ValueLB, ValueUB, ValueInc,
-                                          SubtreeValues, NewValues, &LoopBody);
+  std::unique_ptr<ParallelLoopGenerator> ParallelLoopGenPtr;
+
+  switch (PollyOmpBackend) {
+  case OpenMPBackend::GNU:
+    ParallelLoopGenPtr.reset(
+        new ParallelLoopGeneratorGOMP(Builder, LI, DT, DL));
+    break;
+  case OpenMPBackend::LLVM:
+    ParallelLoopGenPtr.reset(new ParallelLoopGeneratorKMP(Builder, LI, DT, DL));
+    break;
+  }
+
+  IV = ParallelLoopGenPtr->createParallelLoop(
+      ValueLB, ValueUB, ValueInc, SubtreeValues, NewValues, &LoopBody);
   BasicBlock::iterator AfterLoop = Builder.GetInsertPoint();
   Builder.SetInsertPoint(&*LoopBody);
 
diff --git a/stable/lib/CodeGen/LoopGenerators.cpp b/stable/lib/CodeGen/LoopGenerators.cpp
index 368a645..4df1cef 100644
--- a/stable/lib/CodeGen/LoopGenerators.cpp
+++ b/stable/lib/CodeGen/LoopGenerators.cpp
@@ -1,17 +1,18 @@
 //===------ LoopGenerators.cpp -  IR helper to create loops ---------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
-// This file contains functions to create scalar and parallel loops as LLVM-IR.
+// This file contains functions to create scalar loops and orchestrate the
+// creation of parallel loops as LLVM-IR.
 //
 //===----------------------------------------------------------------------===//
 
 #include "polly/CodeGen/LoopGenerators.h"
+#include "polly/Options.h"
 #include "polly/ScopDetection.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/IR/DataLayout.h"
@@ -23,10 +24,36 @@
 using namespace llvm;
 using namespace polly;
 
-static cl::opt<int>
-    PollyNumThreads("polly-num-threads",
-                    cl::desc("Number of threads to use (0 = auto)"), cl::Hidden,
-                    cl::init(0));
+int polly::PollyNumThreads;
+OMPGeneralSchedulingType polly::PollyScheduling;
+int polly::PollyChunkSize;
+
+static cl::opt<int, true>
+    XPollyNumThreads("polly-num-threads",
+                     cl::desc("Number of threads to use (0 = auto)"),
+                     cl::Hidden, cl::location(polly::PollyNumThreads),
+                     cl::init(0), cl::cat(PollyCategory));
+
+static cl::opt<OMPGeneralSchedulingType, true> XPollyScheduling(
+    "polly-scheduling",
+    cl::desc("Scheduling type of parallel OpenMP for loops"),
+    cl::values(clEnumValN(OMPGeneralSchedulingType::StaticChunked, "static",
+                          "Static scheduling"),
+               clEnumValN(OMPGeneralSchedulingType::Dynamic, "dynamic",
+                          "Dynamic scheduling"),
+               clEnumValN(OMPGeneralSchedulingType::Guided, "guided",
+                          "Guided scheduling"),
+               clEnumValN(OMPGeneralSchedulingType::Runtime, "runtime",
+                          "Runtime determined (OMP_SCHEDULE)")),
+    cl::Hidden, cl::location(polly::PollyScheduling),
+    cl::init(OMPGeneralSchedulingType::Runtime), cl::Optional,
+    cl::cat(PollyCategory));
+
+static cl::opt<int, true>
+    XPollyChunkSize("polly-scheduling-chunksize",
+                    cl::desc("Chunksize to use by the OpenMP runtime calls"),
+                    cl::Hidden, cl::location(polly::PollyChunkSize),
+                    cl::init(0), cl::Optional, cl::cat(PollyCategory));
 
 // We generate a loop of either of the following structures:
 //
@@ -148,11 +175,13 @@
 Value *ParallelLoopGenerator::createParallelLoop(
     Value *LB, Value *UB, Value *Stride, SetVector<Value *> &UsedValues,
     ValueMapT &Map, BasicBlock::iterator *LoopBody) {
-  Function *SubFn;
 
   AllocaInst *Struct = storeValuesIntoStruct(UsedValues);
   BasicBlock::iterator BeforeLoop = Builder.GetInsertPoint();
-  Value *IV = createSubFn(Stride, Struct, UsedValues, Map, &SubFn);
+
+  Value *IV;
+  Function *SubFn;
+  std::tie(IV, SubFn) = createSubFn(Stride, Struct, UsedValues, Map);
   *LoopBody = Builder.GetInsertPoint();
   Builder.SetInsertPoint(&*BeforeLoop);
 
@@ -163,102 +192,15 @@
   // whereas the codegenForSequential function creates a <= comparison.
   UB = Builder.CreateAdd(UB, ConstantInt::get(LongType, 1));
 
-  // Tell the runtime we start a parallel loop
-  createCallSpawnThreads(SubFn, SubFnParam, LB, UB, Stride);
-  Builder.CreateCall(SubFn, SubFnParam);
-  createCallJoinThreads();
+  // Execute the prepared subfunction in parallel.
+  deployParallelExecution(SubFn, SubFnParam, LB, UB, Stride);
 
   return IV;
 }
 
-void ParallelLoopGenerator::createCallSpawnThreads(Value *SubFn,
-                                                   Value *SubFnParam, Value *LB,
-                                                   Value *UB, Value *Stride) {
-  const std::string Name = "GOMP_parallel_loop_runtime_start";
-
-  Function *F = M->getFunction(Name);
-
-  // If F is not available, declare it.
-  if (!F) {
-    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
-
-    Type *Params[] = {PointerType::getUnqual(FunctionType::get(
-                          Builder.getVoidTy(), Builder.getInt8PtrTy(), false)),
-                      Builder.getInt8PtrTy(),
-                      Builder.getInt32Ty(),
-                      LongType,
-                      LongType,
-                      LongType};
-
-    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
-    F = Function::Create(Ty, Linkage, Name, M);
-  }
-
-  Value *NumberOfThreads = Builder.getInt32(PollyNumThreads);
-  Value *Args[] = {SubFn, SubFnParam, NumberOfThreads, LB, UB, Stride};
-
-  Builder.CreateCall(F, Args);
-}
-
-Value *ParallelLoopGenerator::createCallGetWorkItem(Value *LBPtr,
-                                                    Value *UBPtr) {
-  const std::string Name = "GOMP_loop_runtime_next";
-
-  Function *F = M->getFunction(Name);
-
-  // If F is not available, declare it.
-  if (!F) {
-    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
-    Type *Params[] = {LongType->getPointerTo(), LongType->getPointerTo()};
-    FunctionType *Ty = FunctionType::get(Builder.getInt8Ty(), Params, false);
-    F = Function::Create(Ty, Linkage, Name, M);
-  }
-
-  Value *Args[] = {LBPtr, UBPtr};
-  Value *Return = Builder.CreateCall(F, Args);
-  Return = Builder.CreateICmpNE(
-      Return, Builder.CreateZExt(Builder.getFalse(), Return->getType()));
-  return Return;
-}
-
-void ParallelLoopGenerator::createCallJoinThreads() {
-  const std::string Name = "GOMP_parallel_end";
-
-  Function *F = M->getFunction(Name);
-
-  // If F is not available, declare it.
-  if (!F) {
-    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
-
-    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
-    F = Function::Create(Ty, Linkage, Name, M);
-  }
-
-  Builder.CreateCall(F, {});
-}
-
-void ParallelLoopGenerator::createCallCleanupThread() {
-  const std::string Name = "GOMP_loop_end_nowait";
-
-  Function *F = M->getFunction(Name);
-
-  // If F is not available, declare it.
-  if (!F) {
-    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
-
-    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
-    F = Function::Create(Ty, Linkage, Name, M);
-  }
-
-  Builder.CreateCall(F, {});
-}
-
 Function *ParallelLoopGenerator::createSubFnDefinition() {
   Function *F = Builder.GetInsertBlock()->getParent();
-  std::vector<Type *> Arguments(1, Builder.getInt8PtrTy());
-  FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false);
-  Function *SubFn = Function::Create(FT, Function::InternalLinkage,
-                                     F->getName() + "_polly_subfn", M);
+  Function *SubFn = prepareSubFnDefinition(F);
 
   // Certain backends (e.g., NVPTX) do not support '.'s in function names.
   // Hence, we ensure that all '.'s are replaced by '_'s.
@@ -269,9 +211,6 @@
   // Do not run any polly pass on the new function.
   SubFn->addFnAttr(PollySkipFnAttr);
 
-  Function::arg_iterator AI = SubFn->arg_begin();
-  AI->setName("polly.par.userContext");
-
   return SubFn;
 }
 
@@ -311,71 +250,3 @@
     Map[OldValues[i]] = NewValue;
   }
 }
-
-Value *ParallelLoopGenerator::createSubFn(Value *Stride, AllocaInst *StructData,
-                                          SetVector<Value *> Data,
-                                          ValueMapT &Map, Function **SubFnPtr) {
-  BasicBlock *PrevBB, *HeaderBB, *ExitBB, *CheckNextBB, *PreHeaderBB, *AfterBB;
-  Value *LBPtr, *UBPtr, *UserContext, *Ret1, *HasNextSchedule, *LB, *UB, *IV;
-  Function *SubFn = createSubFnDefinition();
-  LLVMContext &Context = SubFn->getContext();
-
-  // Store the previous basic block.
-  PrevBB = Builder.GetInsertBlock();
-
-  // Create basic blocks.
-  HeaderBB = BasicBlock::Create(Context, "polly.par.setup", SubFn);
-  ExitBB = BasicBlock::Create(Context, "polly.par.exit", SubFn);
-  CheckNextBB = BasicBlock::Create(Context, "polly.par.checkNext", SubFn);
-  PreHeaderBB = BasicBlock::Create(Context, "polly.par.loadIVBounds", SubFn);
-
-  DT.addNewBlock(HeaderBB, PrevBB);
-  DT.addNewBlock(ExitBB, HeaderBB);
-  DT.addNewBlock(CheckNextBB, HeaderBB);
-  DT.addNewBlock(PreHeaderBB, HeaderBB);
-
-  // Fill up basic block HeaderBB.
-  Builder.SetInsertPoint(HeaderBB);
-  LBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.LBPtr");
-  UBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.UBPtr");
-  UserContext = Builder.CreateBitCast(
-      &*SubFn->arg_begin(), StructData->getType(), "polly.par.userContext");
-
-  extractValuesFromStruct(Data, StructData->getAllocatedType(), UserContext,
-                          Map);
-  Builder.CreateBr(CheckNextBB);
-
-  // Add code to check if another set of iterations will be executed.
-  Builder.SetInsertPoint(CheckNextBB);
-  Ret1 = createCallGetWorkItem(LBPtr, UBPtr);
-  HasNextSchedule = Builder.CreateTrunc(Ret1, Builder.getInt1Ty(),
-                                        "polly.par.hasNextScheduleBlock");
-  Builder.CreateCondBr(HasNextSchedule, PreHeaderBB, ExitBB);
-
-  // Add code to load the iv bounds for this set of iterations.
-  Builder.SetInsertPoint(PreHeaderBB);
-  LB = Builder.CreateLoad(LBPtr, "polly.par.LB");
-  UB = Builder.CreateLoad(UBPtr, "polly.par.UB");
-
-  // Subtract one as the upper bound provided by OpenMP is a < comparison
-  // whereas the codegenForSequential function creates a <= comparison.
-  UB = Builder.CreateSub(UB, ConstantInt::get(LongType, 1),
-                         "polly.par.UBAdjusted");
-
-  Builder.CreateBr(CheckNextBB);
-  Builder.SetInsertPoint(&*--Builder.GetInsertPoint());
-  IV = createLoop(LB, UB, Stride, Builder, LI, DT, AfterBB, ICmpInst::ICMP_SLE,
-                  nullptr, true, /* UseGuard */ false);
-
-  BasicBlock::iterator LoopBody = Builder.GetInsertPoint();
-
-  // Add code to terminate this subfunction.
-  Builder.SetInsertPoint(ExitBB);
-  createCallCleanupThread();
-  Builder.CreateRetVoid();
-
-  Builder.SetInsertPoint(&*LoopBody);
-  *SubFnPtr = SubFn;
-
-  return IV;
-}
diff --git a/stable/lib/CodeGen/LoopGeneratorsGOMP.cpp b/stable/lib/CodeGen/LoopGeneratorsGOMP.cpp
new file mode 100644
index 0000000..9c93af9
--- /dev/null
+++ b/stable/lib/CodeGen/LoopGeneratorsGOMP.cpp
@@ -0,0 +1,223 @@
+//===------ LoopGeneratorsGOMP.cpp - IR helper to create loops ------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains functions to create parallel loops as LLVM-IR.
+//
+//===----------------------------------------------------------------------===//
+
+#include "polly/CodeGen/LoopGeneratorsGOMP.h"
+#include "llvm/IR/Dominators.h"
+#include "llvm/IR/Module.h"
+
+using namespace llvm;
+using namespace polly;
+
+void ParallelLoopGeneratorGOMP::createCallSpawnThreads(Value *SubFn,
+                                                       Value *SubFnParam,
+                                                       Value *LB, Value *UB,
+                                                       Value *Stride) {
+  const std::string Name = "GOMP_parallel_loop_runtime_start";
+
+  Function *F = M->getFunction(Name);
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+
+    Type *Params[] = {PointerType::getUnqual(FunctionType::get(
+                          Builder.getVoidTy(), Builder.getInt8PtrTy(), false)),
+                      Builder.getInt8PtrTy(),
+                      Builder.getInt32Ty(),
+                      LongType,
+                      LongType,
+                      LongType};
+
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Value *Args[] = {SubFn, SubFnParam, Builder.getInt32(PollyNumThreads),
+                   LB,    UB,         Stride};
+
+  Builder.CreateCall(F, Args);
+}
+
+void ParallelLoopGeneratorGOMP::deployParallelExecution(Value *SubFn,
+                                                        Value *SubFnParam,
+                                                        Value *LB, Value *UB,
+                                                        Value *Stride) {
+  // Tell the runtime we start a parallel loop
+  createCallSpawnThreads(SubFn, SubFnParam, LB, UB, Stride);
+  Builder.CreateCall(SubFn, SubFnParam);
+  createCallJoinThreads();
+}
+
+Function *ParallelLoopGeneratorGOMP::prepareSubFnDefinition(Function *F) const {
+  FunctionType *FT =
+      FunctionType::get(Builder.getVoidTy(), {Builder.getInt8PtrTy()}, false);
+  Function *SubFn = Function::Create(FT, Function::InternalLinkage,
+                                     F->getName() + "_polly_subfn", M);
+  // Name the function's arguments
+  SubFn->arg_begin()->setName("polly.par.userContext");
+  return SubFn;
+}
+
+// Create a subfunction of the following (preliminary) structure:
+//
+//    PrevBB
+//       |
+//       v
+//    HeaderBB
+//       |   _____
+//       v  v    |
+//   CheckNextBB  PreHeaderBB
+//       |\       |
+//       | \______/
+//       |
+//       v
+//     ExitBB
+//
+// HeaderBB will hold allocations and loading of variables.
+// CheckNextBB will check for more work.
+// If there is more work to do: go to PreHeaderBB, otherwise go to ExitBB.
+// PreHeaderBB loads the new boundaries (& will lead to the loop body later on).
+// ExitBB marks the end of the parallel execution.
+std::tuple<Value *, Function *>
+ParallelLoopGeneratorGOMP::createSubFn(Value *Stride, AllocaInst *StructData,
+                                       SetVector<Value *> Data,
+                                       ValueMapT &Map) {
+  if (PollyScheduling != OMPGeneralSchedulingType::Runtime) {
+    // User tried to influence the scheduling type (currently not supported)
+    errs() << "warning: Polly's GNU OpenMP backend solely "
+              "supports the scheduling type 'runtime'.\n";
+  }
+
+  if (PollyChunkSize != 0) {
+    // User tried to influence the chunk size (currently not supported)
+    errs() << "warning: Polly's GNU OpenMP backend solely "
+              "supports the default chunk size.\n";
+  }
+
+  Function *SubFn = createSubFnDefinition();
+  LLVMContext &Context = SubFn->getContext();
+
+  // Store the previous basic block.
+  BasicBlock *PrevBB = Builder.GetInsertBlock();
+
+  // Create basic blocks.
+  BasicBlock *HeaderBB = BasicBlock::Create(Context, "polly.par.setup", SubFn);
+  BasicBlock *ExitBB = BasicBlock::Create(Context, "polly.par.exit", SubFn);
+  BasicBlock *CheckNextBB =
+      BasicBlock::Create(Context, "polly.par.checkNext", SubFn);
+  BasicBlock *PreHeaderBB =
+      BasicBlock::Create(Context, "polly.par.loadIVBounds", SubFn);
+
+  DT.addNewBlock(HeaderBB, PrevBB);
+  DT.addNewBlock(ExitBB, HeaderBB);
+  DT.addNewBlock(CheckNextBB, HeaderBB);
+  DT.addNewBlock(PreHeaderBB, HeaderBB);
+
+  // Fill up basic block HeaderBB.
+  Builder.SetInsertPoint(HeaderBB);
+  Value *LBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.LBPtr");
+  Value *UBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.UBPtr");
+  Value *UserContext = Builder.CreateBitCast(
+      &*SubFn->arg_begin(), StructData->getType(), "polly.par.userContext");
+
+  extractValuesFromStruct(Data, StructData->getAllocatedType(), UserContext,
+                          Map);
+  Builder.CreateBr(CheckNextBB);
+
+  // Add code to check if another set of iterations will be executed.
+  Builder.SetInsertPoint(CheckNextBB);
+  Value *Next = createCallGetWorkItem(LBPtr, UBPtr);
+  Value *HasNextSchedule = Builder.CreateTrunc(
+      Next, Builder.getInt1Ty(), "polly.par.hasNextScheduleBlock");
+  Builder.CreateCondBr(HasNextSchedule, PreHeaderBB, ExitBB);
+
+  // Add code to load the iv bounds for this set of iterations.
+  Builder.SetInsertPoint(PreHeaderBB);
+  Value *LB = Builder.CreateLoad(LBPtr, "polly.par.LB");
+  Value *UB = Builder.CreateLoad(UBPtr, "polly.par.UB");
+
+  // Subtract one as the upper bound provided by OpenMP is a < comparison
+  // whereas the codegenForSequential function creates a <= comparison.
+  UB = Builder.CreateSub(UB, ConstantInt::get(LongType, 1),
+                         "polly.par.UBAdjusted");
+
+  Builder.CreateBr(CheckNextBB);
+  Builder.SetInsertPoint(&*--Builder.GetInsertPoint());
+  BasicBlock *AfterBB;
+  Value *IV =
+      createLoop(LB, UB, Stride, Builder, LI, DT, AfterBB, ICmpInst::ICMP_SLE,
+                 nullptr, true, /* UseGuard */ false);
+
+  BasicBlock::iterator LoopBody = Builder.GetInsertPoint();
+
+  // Add code to terminate this subfunction.
+  Builder.SetInsertPoint(ExitBB);
+  createCallCleanupThread();
+  Builder.CreateRetVoid();
+
+  Builder.SetInsertPoint(&*LoopBody);
+
+  return std::make_tuple(IV, SubFn);
+}
+
+Value *ParallelLoopGeneratorGOMP::createCallGetWorkItem(Value *LBPtr,
+                                                        Value *UBPtr) {
+  const std::string Name = "GOMP_loop_runtime_next";
+
+  Function *F = M->getFunction(Name);
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+    Type *Params[] = {LongType->getPointerTo(), LongType->getPointerTo()};
+    FunctionType *Ty = FunctionType::get(Builder.getInt8Ty(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Value *Args[] = {LBPtr, UBPtr};
+  Value *Return = Builder.CreateCall(F, Args);
+  Return = Builder.CreateICmpNE(
+      Return, Builder.CreateZExt(Builder.getFalse(), Return->getType()));
+  return Return;
+}
+
+void ParallelLoopGeneratorGOMP::createCallJoinThreads() {
+  const std::string Name = "GOMP_parallel_end";
+
+  Function *F = M->getFunction(Name);
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Builder.CreateCall(F, {});
+}
+
+void ParallelLoopGeneratorGOMP::createCallCleanupThread() {
+  const std::string Name = "GOMP_loop_end_nowait";
+
+  Function *F = M->getFunction(Name);
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Builder.CreateCall(F, {});
+}
diff --git a/stable/lib/CodeGen/LoopGeneratorsKMP.cpp b/stable/lib/CodeGen/LoopGeneratorsKMP.cpp
new file mode 100644
index 0000000..d2ebdbc
--- /dev/null
+++ b/stable/lib/CodeGen/LoopGeneratorsKMP.cpp
@@ -0,0 +1,506 @@
+//===------ LoopGeneratorsKMP.cpp - IR helper to create loops -------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains functions to create parallel loops as LLVM-IR.
+//
+//===----------------------------------------------------------------------===//
+
+#include "polly/CodeGen/LoopGeneratorsKMP.h"
+#include "llvm/IR/Dominators.h"
+#include "llvm/IR/Module.h"
+
+using namespace llvm;
+using namespace polly;
+
+void ParallelLoopGeneratorKMP::createCallSpawnThreads(Value *SubFn,
+                                                      Value *SubFnParam,
+                                                      Value *LB, Value *UB,
+                                                      Value *Stride) {
+  const std::string Name = "__kmpc_fork_call";
+  Function *F = M->getFunction(Name);
+  Type *KMPCMicroTy = M->getTypeByName("kmpc_micro");
+
+  if (!KMPCMicroTy) {
+    // void (*kmpc_micro)(kmp_int32 *global_tid, kmp_int32 *bound_tid, ...)
+    Type *MicroParams[] = {Builder.getInt32Ty()->getPointerTo(),
+                           Builder.getInt32Ty()->getPointerTo()};
+
+    KMPCMicroTy = FunctionType::get(Builder.getVoidTy(), MicroParams, true);
+  }
+
+  // If F is not available, declare it.
+  if (!F) {
+    StructType *IdentTy = M->getTypeByName("struct.ident_t");
+
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+    Type *Params[] = {IdentTy->getPointerTo(), Builder.getInt32Ty(),
+                      KMPCMicroTy->getPointerTo()};
+
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, true);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Value *Task = Builder.CreatePointerBitCastOrAddrSpaceCast(
+      SubFn, KMPCMicroTy->getPointerTo());
+
+  Value *Args[] = {SourceLocationInfo,
+                   Builder.getInt32(4) /* Number of arguments (w/o Task) */,
+                   Task,
+                   LB,
+                   UB,
+                   Stride,
+                   SubFnParam};
+
+  Builder.CreateCall(F, Args);
+}
+
+void ParallelLoopGeneratorKMP::deployParallelExecution(Value *SubFn,
+                                                       Value *SubFnParam,
+                                                       Value *LB, Value *UB,
+                                                       Value *Stride) {
+  // Inform OpenMP runtime about the number of threads if greater than zero
+  if (PollyNumThreads > 0) {
+    Value *GlobalThreadID = createCallGlobalThreadNum();
+    createCallPushNumThreads(GlobalThreadID, Builder.getInt32(PollyNumThreads));
+  }
+
+  // Tell the runtime we start a parallel loop
+  createCallSpawnThreads(SubFn, SubFnParam, LB, UB, Stride);
+}
+
+Function *ParallelLoopGeneratorKMP::prepareSubFnDefinition(Function *F) const {
+  std::vector<Type *> Arguments = {Builder.getInt32Ty()->getPointerTo(),
+                                   Builder.getInt32Ty()->getPointerTo(),
+                                   LongType,
+                                   LongType,
+                                   LongType,
+                                   Builder.getInt8PtrTy()};
+
+  FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false);
+  Function *SubFn = Function::Create(FT, Function::InternalLinkage,
+                                     F->getName() + "_polly_subfn", M);
+  // Name the function's arguments
+  Function::arg_iterator AI = SubFn->arg_begin();
+  AI->setName("polly.kmpc.global_tid");
+  std::advance(AI, 1);
+  AI->setName("polly.kmpc.bound_tid");
+  std::advance(AI, 1);
+  AI->setName("polly.kmpc.lb");
+  std::advance(AI, 1);
+  AI->setName("polly.kmpc.ub");
+  std::advance(AI, 1);
+  AI->setName("polly.kmpc.inc");
+  std::advance(AI, 1);
+  AI->setName("polly.kmpc.shared");
+
+  return SubFn;
+}
+
+// Create a subfunction of the following (preliminary) structure:
+//
+//    PrevBB
+//       |
+//       v
+//    HeaderBB
+//       |   _____
+//       v  v    |
+//   CheckNextBB  PreHeaderBB
+//       |\       |
+//       | \______/
+//       |
+//       v
+//     ExitBB
+//
+// HeaderBB will hold allocations, loading of variables and kmp-init calls.
+// CheckNextBB will check for more work (dynamic) or will be "empty" (static).
+// If there is more work to do: go to PreHeaderBB, otherwise go to ExitBB.
+// PreHeaderBB loads the new boundaries (& will lead to the loop body later on).
+// Just like CheckNextBB: PreHeaderBB is empty in the static scheduling case.
+// ExitBB marks the end of the parallel execution.
+// The possibly empty BasicBlocks will automatically be removed.
+std::tuple<Value *, Function *>
+ParallelLoopGeneratorKMP::createSubFn(Value *StrideNotUsed,
+                                      AllocaInst *StructData,
+                                      SetVector<Value *> Data, ValueMapT &Map) {
+  Function *SubFn = createSubFnDefinition();
+  LLVMContext &Context = SubFn->getContext();
+
+  // Store the previous basic block.
+  BasicBlock *PrevBB = Builder.GetInsertBlock();
+
+  // Create basic blocks.
+  BasicBlock *HeaderBB = BasicBlock::Create(Context, "polly.par.setup", SubFn);
+  BasicBlock *ExitBB = BasicBlock::Create(Context, "polly.par.exit", SubFn);
+  BasicBlock *CheckNextBB =
+      BasicBlock::Create(Context, "polly.par.checkNext", SubFn);
+  BasicBlock *PreHeaderBB =
+      BasicBlock::Create(Context, "polly.par.loadIVBounds", SubFn);
+
+  DT.addNewBlock(HeaderBB, PrevBB);
+  DT.addNewBlock(ExitBB, HeaderBB);
+  DT.addNewBlock(CheckNextBB, HeaderBB);
+  DT.addNewBlock(PreHeaderBB, HeaderBB);
+
+  // Fill up basic block HeaderBB.
+  Builder.SetInsertPoint(HeaderBB);
+  Value *LBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.LBPtr");
+  Value *UBPtr = Builder.CreateAlloca(LongType, nullptr, "polly.par.UBPtr");
+  Value *IsLastPtr = Builder.CreateAlloca(Builder.getInt32Ty(), nullptr,
+                                          "polly.par.lastIterPtr");
+  Value *StridePtr =
+      Builder.CreateAlloca(LongType, nullptr, "polly.par.StridePtr");
+
+  // Get iterator for retrieving the previously defined parameters.
+  Function::arg_iterator AI = SubFn->arg_begin();
+  // First argument holds "global thread ID".
+  Value *IDPtr = &*AI;
+  // Skip "bound thread ID" since it is not used (but had to be defined).
+  std::advance(AI, 2);
+  // Move iterator to: LB, UB, Stride, Shared variable struct.
+  Value *LB = &*AI;
+  std::advance(AI, 1);
+  Value *UB = &*AI;
+  std::advance(AI, 1);
+  Value *Stride = &*AI;
+  std::advance(AI, 1);
+  Value *Shared = &*AI;
+
+  Value *UserContext = Builder.CreateBitCast(Shared, StructData->getType(),
+                                             "polly.par.userContext");
+
+  extractValuesFromStruct(Data, StructData->getAllocatedType(), UserContext,
+                          Map);
+
+  const int Alignment = (is64BitArch()) ? 8 : 4;
+  Value *ID =
+      Builder.CreateAlignedLoad(IDPtr, Alignment, "polly.par.global_tid");
+
+  Builder.CreateAlignedStore(LB, LBPtr, Alignment);
+  Builder.CreateAlignedStore(UB, UBPtr, Alignment);
+  Builder.CreateAlignedStore(Builder.getInt32(0), IsLastPtr, Alignment);
+  Builder.CreateAlignedStore(Stride, StridePtr, Alignment);
+
+  // Subtract one as the upper bound provided by openmp is a < comparison
+  // whereas the codegenForSequential function creates a <= comparison.
+  Value *AdjustedUB = Builder.CreateAdd(UB, ConstantInt::get(LongType, -1),
+                                        "polly.indvar.UBAdjusted");
+
+  Value *ChunkSize =
+      ConstantInt::get(LongType, std::max<int>(PollyChunkSize, 1));
+
+  switch (PollyScheduling) {
+  case OMPGeneralSchedulingType::Dynamic:
+  case OMPGeneralSchedulingType::Guided:
+  case OMPGeneralSchedulingType::Runtime:
+    // "DYNAMIC" scheduling types are handled below (including 'runtime')
+    {
+      UB = AdjustedUB;
+      createCallDispatchInit(ID, LB, UB, Stride, ChunkSize);
+      Value *HasWork =
+          createCallDispatchNext(ID, IsLastPtr, LBPtr, UBPtr, StridePtr);
+      Value *HasIteration =
+          Builder.CreateICmp(llvm::CmpInst::Predicate::ICMP_EQ, HasWork,
+                             Builder.getInt32(1), "polly.hasIteration");
+      Builder.CreateCondBr(HasIteration, PreHeaderBB, ExitBB);
+
+      Builder.SetInsertPoint(CheckNextBB);
+      HasWork = createCallDispatchNext(ID, IsLastPtr, LBPtr, UBPtr, StridePtr);
+      HasIteration =
+          Builder.CreateICmp(llvm::CmpInst::Predicate::ICMP_EQ, HasWork,
+                             Builder.getInt32(1), "polly.hasWork");
+      Builder.CreateCondBr(HasIteration, PreHeaderBB, ExitBB);
+
+      Builder.SetInsertPoint(PreHeaderBB);
+      LB = Builder.CreateAlignedLoad(LBPtr, Alignment, "polly.indvar.LB");
+      UB = Builder.CreateAlignedLoad(UBPtr, Alignment, "polly.indvar.UB");
+    }
+    break;
+  case OMPGeneralSchedulingType::StaticChunked:
+  case OMPGeneralSchedulingType::StaticNonChunked:
+    // "STATIC" scheduling types are handled below
+    {
+      createCallStaticInit(ID, IsLastPtr, LBPtr, UBPtr, StridePtr, ChunkSize);
+
+      LB = Builder.CreateAlignedLoad(LBPtr, Alignment, "polly.indvar.LB");
+      UB = Builder.CreateAlignedLoad(UBPtr, Alignment, "polly.indvar.UB");
+
+      Value *AdjUBOutOfBounds =
+          Builder.CreateICmp(llvm::CmpInst::Predicate::ICMP_SLT, UB, AdjustedUB,
+                             "polly.adjustedUBOutOfBounds");
+
+      UB = Builder.CreateSelect(AdjUBOutOfBounds, UB, AdjustedUB);
+      Builder.CreateAlignedStore(UB, UBPtr, Alignment);
+
+      Value *HasIteration = Builder.CreateICmp(
+          llvm::CmpInst::Predicate::ICMP_SLE, LB, UB, "polly.hasIteration");
+      Builder.CreateCondBr(HasIteration, PreHeaderBB, ExitBB);
+
+      Builder.SetInsertPoint(CheckNextBB);
+      Builder.CreateBr(ExitBB);
+
+      Builder.SetInsertPoint(PreHeaderBB);
+    }
+    break;
+  }
+
+  Builder.CreateBr(CheckNextBB);
+  Builder.SetInsertPoint(&*--Builder.GetInsertPoint());
+  BasicBlock *AfterBB;
+  Value *IV = createLoop(LB, UB, Stride, Builder, LI, DT, AfterBB,
+                         ICmpInst::ICMP_SLE, nullptr, true,
+                         /* UseGuard */ false);
+
+  BasicBlock::iterator LoopBody = Builder.GetInsertPoint();
+
+  // Add code to terminate this subfunction.
+  Builder.SetInsertPoint(ExitBB);
+  // Static (i.e. non-dynamic) scheduling types, are terminated with a fini-call
+  if (PollyScheduling == OMPGeneralSchedulingType::StaticChunked) {
+    createCallStaticFini(ID);
+  }
+  Builder.CreateRetVoid();
+  Builder.SetInsertPoint(&*LoopBody);
+
+  return std::make_tuple(IV, SubFn);
+}
+
+Value *ParallelLoopGeneratorKMP::createCallGlobalThreadNum() {
+  const std::string Name = "__kmpc_global_thread_num";
+  Function *F = M->getFunction(Name);
+
+  // If F is not available, declare it.
+  if (!F) {
+    StructType *IdentTy = M->getTypeByName("struct.ident_t");
+
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+    Type *Params[] = {IdentTy->getPointerTo()};
+
+    FunctionType *Ty = FunctionType::get(Builder.getInt32Ty(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  return Builder.CreateCall(F, {SourceLocationInfo});
+}
+
+void ParallelLoopGeneratorKMP::createCallPushNumThreads(Value *GlobalThreadID,
+                                                        Value *NumThreads) {
+  const std::string Name = "__kmpc_push_num_threads";
+  Function *F = M->getFunction(Name);
+
+  // If F is not available, declare it.
+  if (!F) {
+    StructType *IdentTy = M->getTypeByName("struct.ident_t");
+
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+    Type *Params[] = {IdentTy->getPointerTo(), Builder.getInt32Ty(),
+                      Builder.getInt32Ty()};
+
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Value *Args[] = {SourceLocationInfo, GlobalThreadID, NumThreads};
+
+  Builder.CreateCall(F, Args);
+}
+
+void ParallelLoopGeneratorKMP::createCallStaticInit(Value *GlobalThreadID,
+                                                    Value *IsLastPtr,
+                                                    Value *LBPtr, Value *UBPtr,
+                                                    Value *StridePtr,
+                                                    Value *ChunkSize) {
+  const std::string Name =
+      is64BitArch() ? "__kmpc_for_static_init_8" : "__kmpc_for_static_init_4";
+  Function *F = M->getFunction(Name);
+  StructType *IdentTy = M->getTypeByName("struct.ident_t");
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+
+    Type *Params[] = {IdentTy->getPointerTo(),
+                      Builder.getInt32Ty(),
+                      Builder.getInt32Ty(),
+                      Builder.getInt32Ty()->getPointerTo(),
+                      LongType->getPointerTo(),
+                      LongType->getPointerTo(),
+                      LongType->getPointerTo(),
+                      LongType,
+                      LongType};
+
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  // The parameter 'ChunkSize' will hold strictly positive integer values,
+  // regardless of PollyChunkSize's value
+  Value *Args[] = {
+      SourceLocationInfo,
+      GlobalThreadID,
+      Builder.getInt32(int(getSchedType(PollyChunkSize, PollyScheduling))),
+      IsLastPtr,
+      LBPtr,
+      UBPtr,
+      StridePtr,
+      ConstantInt::get(LongType, 1),
+      ChunkSize};
+
+  Builder.CreateCall(F, Args);
+}
+
+void ParallelLoopGeneratorKMP::createCallStaticFini(Value *GlobalThreadID) {
+  const std::string Name = "__kmpc_for_static_fini";
+  Function *F = M->getFunction(Name);
+  StructType *IdentTy = M->getTypeByName("struct.ident_t");
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+    Type *Params[] = {IdentTy->getPointerTo(), Builder.getInt32Ty()};
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Value *Args[] = {SourceLocationInfo, GlobalThreadID};
+
+  Builder.CreateCall(F, Args);
+}
+
+void ParallelLoopGeneratorKMP::createCallDispatchInit(Value *GlobalThreadID,
+                                                      Value *LB, Value *UB,
+                                                      Value *Inc,
+                                                      Value *ChunkSize) {
+  const std::string Name =
+      is64BitArch() ? "__kmpc_dispatch_init_8" : "__kmpc_dispatch_init_4";
+  Function *F = M->getFunction(Name);
+  StructType *IdentTy = M->getTypeByName("struct.ident_t");
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+
+    Type *Params[] = {IdentTy->getPointerTo(),
+                      Builder.getInt32Ty(),
+                      Builder.getInt32Ty(),
+                      LongType,
+                      LongType,
+                      LongType,
+                      LongType};
+
+    FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  // The parameter 'ChunkSize' will hold strictly positive integer values,
+  // regardless of PollyChunkSize's value
+  Value *Args[] = {
+      SourceLocationInfo,
+      GlobalThreadID,
+      Builder.getInt32(int(getSchedType(PollyChunkSize, PollyScheduling))),
+      LB,
+      UB,
+      Inc,
+      ChunkSize};
+
+  Builder.CreateCall(F, Args);
+}
+
+Value *ParallelLoopGeneratorKMP::createCallDispatchNext(Value *GlobalThreadID,
+                                                        Value *IsLastPtr,
+                                                        Value *LBPtr,
+                                                        Value *UBPtr,
+                                                        Value *StridePtr) {
+  const std::string Name =
+      is64BitArch() ? "__kmpc_dispatch_next_8" : "__kmpc_dispatch_next_4";
+  Function *F = M->getFunction(Name);
+  StructType *IdentTy = M->getTypeByName("struct.ident_t");
+
+  // If F is not available, declare it.
+  if (!F) {
+    GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
+
+    Type *Params[] = {IdentTy->getPointerTo(),
+                      Builder.getInt32Ty(),
+                      Builder.getInt32Ty()->getPointerTo(),
+                      LongType->getPointerTo(),
+                      LongType->getPointerTo(),
+                      LongType->getPointerTo()};
+
+    FunctionType *Ty = FunctionType::get(Builder.getInt32Ty(), Params, false);
+    F = Function::Create(Ty, Linkage, Name, M);
+  }
+
+  Value *Args[] = {SourceLocationInfo, GlobalThreadID, IsLastPtr, LBPtr, UBPtr,
+                   StridePtr};
+
+  return Builder.CreateCall(F, Args);
+}
+
+// TODO: This function currently creates a source location dummy. It might be
+// necessary to (actually) provide information, in the future.
+GlobalVariable *ParallelLoopGeneratorKMP::createSourceLocation() {
+  const std::string LocName = ".loc.dummy";
+  GlobalVariable *SourceLocDummy = M->getGlobalVariable(LocName);
+
+  if (SourceLocDummy == nullptr) {
+    const std::string StructName = "struct.ident_t";
+    StructType *IdentTy = M->getTypeByName(StructName);
+
+    // If the ident_t StructType is not available, declare it.
+    // in LLVM-IR: ident_t = type { i32, i32, i32, i32, i8* }
+    if (!IdentTy) {
+      Type *LocMembers[] = {Builder.getInt32Ty(), Builder.getInt32Ty(),
+                            Builder.getInt32Ty(), Builder.getInt32Ty(),
+                            Builder.getInt8PtrTy()};
+
+      IdentTy =
+          StructType::create(M->getContext(), LocMembers, StructName, false);
+    }
+
+    const auto ArrayType =
+        llvm::ArrayType::get(Builder.getInt8Ty(), /* Length */ 23);
+
+    // Global Variable Definitions
+    GlobalVariable *StrVar = new GlobalVariable(
+        *M, ArrayType, true, GlobalValue::PrivateLinkage, 0, ".str.ident");
+    StrVar->setAlignment(1);
+
+    SourceLocDummy = new GlobalVariable(
+        *M, IdentTy, true, GlobalValue::PrivateLinkage, nullptr, LocName);
+    SourceLocDummy->setAlignment(8);
+
+    // Constant Definitions
+    Constant *InitStr = ConstantDataArray::getString(
+        M->getContext(), "Source location dummy.", true);
+
+    Constant *StrPtr = static_cast<Constant *>(Builder.CreateInBoundsGEP(
+        ArrayType, StrVar, {Builder.getInt32(0), Builder.getInt32(0)}));
+
+    Constant *LocInitStruct = ConstantStruct::get(
+        IdentTy, {Builder.getInt32(0), Builder.getInt32(0), Builder.getInt32(0),
+                  Builder.getInt32(0), StrPtr});
+
+    // Initialize variables
+    StrVar->setInitializer(InitStr);
+    SourceLocDummy->setInitializer(LocInitStruct);
+  }
+
+  return SourceLocDummy;
+}
+
+bool ParallelLoopGeneratorKMP::is64BitArch() {
+  return (LongType->getIntegerBitWidth() == 64);
+}
+
+OMPGeneralSchedulingType ParallelLoopGeneratorKMP::getSchedType(
+    int ChunkSize, OMPGeneralSchedulingType Scheduling) const {
+  if (ChunkSize == 0 && Scheduling == OMPGeneralSchedulingType::StaticChunked)
+    return OMPGeneralSchedulingType::StaticNonChunked;
+
+  return Scheduling;
+}
diff --git a/stable/lib/CodeGen/ManagedMemoryRewrite.cpp b/stable/lib/CodeGen/ManagedMemoryRewrite.cpp
index e14da1d..8492b5f 100644
--- a/stable/lib/CodeGen/ManagedMemoryRewrite.cpp
+++ b/stable/lib/CodeGen/ManagedMemoryRewrite.cpp
@@ -1,9 +1,8 @@
 //===---- ManagedMemoryRewrite.cpp - Rewrite global & malloc'd memory -----===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,35 +15,18 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "polly/CodeGen/CodeGeneration.h"
-#include "polly/CodeGen/IslAst.h"
-#include "polly/CodeGen/IslNodeBuilder.h"
+#include "polly/CodeGen/IRBuilder.h"
 #include "polly/CodeGen/PPCGCodeGeneration.h"
-#include "polly/CodeGen/Utils.h"
 #include "polly/DependenceInfo.h"
 #include "polly/LinkAllPasses.h"
 #include "polly/Options.h"
 #include "polly/ScopDetection.h"
-#include "polly/ScopInfo.h"
-#include "polly/Support/SCEVValidator.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/BasicAliasAnalysis.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/Analysis/CaptureTracking.h"
-#include "llvm/Analysis/GlobalsModRef.h"
-#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
-#include "llvm/Analysis/TargetLibraryInfo.h"
-#include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/IR/LegacyPassManager.h"
-#include "llvm/IR/Verifier.h"
-#include "llvm/IRReader/IRReader.h"
-#include "llvm/Linker/Linker.h"
-#include "llvm/Support/TargetRegistry.h"
-#include "llvm/Support/TargetSelect.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Transforms/IPO/PassManagerBuilder.h"
-#include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 
+using namespace polly;
+
 static cl::opt<bool> RewriteAllocas(
     "polly-acc-rewrite-allocas",
     cl::desc(
@@ -311,7 +293,8 @@
   PollyIRBuilder Builder(M->getContext());
   Builder.SetInsertPoint(Alloca);
 
-  Value *MallocManagedFn = getOrCreatePollyMallocManaged(*Alloca->getModule());
+  Function *MallocManagedFn =
+      getOrCreatePollyMallocManaged(*Alloca->getModule());
   const uint64_t Size =
       DL.getTypeAllocSize(Alloca->getType()->getElementType());
   Value *SizeVal = Builder.getInt64(Size);
@@ -331,7 +314,7 @@
       continue;
     Builder.SetInsertPoint(Return);
 
-    Value *FreeManagedFn = getOrCreatePollyFreeManaged(*M);
+    Function *FreeManagedFn = getOrCreatePollyFreeManaged(*M);
     Builder.CreateCall(FreeManagedFn, {RawManagedMem});
   }
 }
diff --git a/stable/lib/CodeGen/PPCGCodeGeneration.cpp b/stable/lib/CodeGen/PPCGCodeGeneration.cpp
index 47beb1c..2516b33 100644
--- a/stable/lib/CodeGen/PPCGCodeGeneration.cpp
+++ b/stable/lib/CodeGen/PPCGCodeGeneration.cpp
@@ -1,9 +1,8 @@
 //===------ PPCGCodeGeneration.cpp - Polly Accelerator Code Generation. ---===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -25,30 +24,22 @@
 #include "polly/ScopInfo.h"
 #include "polly/Support/SCEVValidator.h"
 #include "llvm/ADT/PostOrderIterator.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/BasicAliasAnalysis.h"
-#include "llvm/Analysis/GlobalsModRef.h"
-#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
-#include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
-#include "llvm/Support/TargetSelect.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
-
 #include "isl/union_map.h"
 
 extern "C" {
 #include "ppcg/cuda.h"
 #include "ppcg/gpu.h"
-#include "ppcg/gpu_print.h"
 #include "ppcg/ppcg.h"
-#include "ppcg/schedule.h"
 }
 
 #include "llvm/Support/Debug.h"
diff --git a/stable/lib/CodeGen/PerfMonitor.cpp b/stable/lib/CodeGen/PerfMonitor.cpp
index 9cc99de..d9419e9 100644
--- a/stable/lib/CodeGen/PerfMonitor.cpp
+++ b/stable/lib/CodeGen/PerfMonitor.cpp
@@ -1,9 +1,8 @@
 //===------ PerfMonitor.cpp - Generate a run-time performance monitor. -======//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/lib/CodeGen/RuntimeDebugBuilder.cpp b/stable/lib/CodeGen/RuntimeDebugBuilder.cpp
index dbfeae2..29cba08 100644
--- a/stable/lib/CodeGen/RuntimeDebugBuilder.cpp
+++ b/stable/lib/CodeGen/RuntimeDebugBuilder.cpp
@@ -1,9 +1,8 @@
 //===--- RuntimeDebugBuilder.cpp - Helper to insert prints into LLVM-IR ---===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -12,7 +11,6 @@
 #include "polly/CodeGen/RuntimeDebugBuilder.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Support/Debug.h"
 #include <string>
 #include <vector>
 
diff --git a/stable/lib/CodeGen/Utils.cpp b/stable/lib/CodeGen/Utils.cpp
index 4d595fb..3afb2e5 100644
--- a/stable/lib/CodeGen/Utils.cpp
+++ b/stable/lib/CodeGen/Utils.cpp
@@ -1,9 +1,8 @@
 //===--- Utils.cpp - Utility functions for the code generation --*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,7 +15,6 @@
 #include "polly/ScopInfo.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/RegionInfo.h"
-#include "llvm/Support/Debug.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
 using namespace llvm;
diff --git a/stable/lib/Exchange/JSONExporter.cpp b/stable/lib/Exchange/JSONExporter.cpp
index 4197539..b9cb568 100644
--- a/stable/lib/Exchange/JSONExporter.cpp
+++ b/stable/lib/Exchange/JSONExporter.cpp
@@ -1,9 +1,8 @@
 //===-- JSONExporter.cpp  - Export Scops as JSON  -------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -19,18 +18,14 @@
 #include "polly/ScopPass.h"
 #include "polly/Support/ScopLocation.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/RegionInfo.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/raw_ostream.h"
-#include "isl/constraint.h"
 #include "isl/map.h"
-#include "isl/printer.h"
 #include "isl/set.h"
-#include "isl/union_map.h"
 #include <memory>
 #include <string>
 #include <system_error>
diff --git a/stable/lib/Polly.cpp b/stable/lib/Polly.cpp
index 95903ab..e6bae93 100644
--- a/stable/lib/Polly.cpp
+++ b/stable/lib/Polly.cpp
@@ -1,16 +1,15 @@
 //===---------- Polly.cpp - Initialize the Polly Module -------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
 //===----------------------------------------------------------------------===//
 
 #include "polly/RegisterPasses.h"
-#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/PassRegistry.h"
 
 namespace {
 
diff --git a/stable/lib/Support/DumpModulePass.cpp b/stable/lib/Support/DumpModulePass.cpp
index bb581f3..615fd75 100644
--- a/stable/lib/Support/DumpModulePass.cpp
+++ b/stable/lib/Support/DumpModulePass.cpp
@@ -1,9 +1,8 @@
 //===------ DumpModulePass.cpp ----------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -12,16 +11,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/Support/DumpModulePass.h"
-
-#include "polly/Options.h"
-#include "llvm/IR/LegacyPassManagers.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ToolOutputFile.h"
-#include <string.h>
+
 #define DEBUG_TYPE "polly-dump-module"
 
 using namespace llvm;
diff --git a/stable/lib/Support/GICHelper.cpp b/stable/lib/Support/GICHelper.cpp
index ae3d80d..1230b48 100644
--- a/stable/lib/Support/GICHelper.cpp
+++ b/stable/lib/Support/GICHelper.cpp
@@ -1,27 +1,18 @@
 //===- GmpConv.cpp - Recreate LLVM IR from the Scop.  ---------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
 // Functions for converting between gmp objects and llvm::APInt.
 //
 //===----------------------------------------------------------------------===//
-#include "polly/Support/GICHelper.h"
-#include "llvm/IR/Value.h"
-#include "isl/aff.h"
-#include "isl/map.h"
-#include "isl/schedule.h"
-#include "isl/set.h"
-#include "isl/space.h"
-#include "isl/union_map.h"
-#include "isl/union_set.h"
-#include "isl/val.h"
 
-#include <climits>
+#include "polly/Support/GICHelper.h"
+#include "llvm/ADT/APInt.h"
+#include "isl/val.h"
 
 using namespace llvm;
 
diff --git a/stable/lib/Support/ISLTools.cpp b/stable/lib/Support/ISLTools.cpp
index bbc4b07..2559262 100644
--- a/stable/lib/Support/ISLTools.cpp
+++ b/stable/lib/Support/ISLTools.cpp
@@ -1,9 +1,8 @@
 //===------ ISLTools.cpp ----------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -13,7 +12,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/Support/ISLTools.h"
-#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <vector>
 
 using namespace polly;
 
@@ -719,7 +720,7 @@
   }
 
   // Sort the polyhedra.
-  llvm::sort(BSets.begin(), BSets.end(), orderComparer);
+  llvm::sort(BSets, orderComparer);
 
   // Print the polyhedra.
   bool First = true;
diff --git a/stable/lib/Support/RegisterPasses.cpp b/stable/lib/Support/RegisterPasses.cpp
index 975ec57..1349bdc 100644
--- a/stable/lib/Support/RegisterPasses.cpp
+++ b/stable/lib/Support/RegisterPasses.cpp
@@ -1,9 +1,8 @@
 //===------ RegisterPasses.cpp - Add the Polly Passes to default passes  --===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -24,15 +23,11 @@
 #include "polly/CodeGen/CodeGeneration.h"
 #include "polly/CodeGen/CodegenCleanup.h"
 #include "polly/CodeGen/IslAst.h"
-#include "polly/CodeGen/PPCGCodeGeneration.h"
 #include "polly/CodePreparation.h"
-#include "polly/DeLICM.h"
 #include "polly/DependenceInfo.h"
-#include "polly/FlattenSchedule.h"
 #include "polly/ForwardOpTree.h"
 #include "polly/JSONExporter.h"
 #include "polly/LinkAllPasses.h"
-#include "polly/Options.h"
 #include "polly/PolyhedralInfo.h"
 #include "polly/ScopDetection.h"
 #include "polly/ScopInfo.h"
@@ -46,8 +41,6 @@
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/Vectorize.h"
 
 using namespace llvm;
 using namespace polly;
@@ -350,12 +343,9 @@
     PM.add(polly::createPruneUnprofitablePass());
 
 #ifdef GPU_CODEGEN
-  if (Target == TARGET_HYBRID) {
+  if (Target == TARGET_HYBRID)
     PM.add(
         polly::createPPCGCodeGenerationPass(GPUArchChoice, GPURuntimeChoice));
-    PM.add(polly::createManagedMemoryRewritePassPass(GPUArchChoice,
-                                                     GPURuntimeChoice));
-  }
 #endif
   if (Target == TARGET_CPU || Target == TARGET_HYBRID)
     switch (Optimizer) {
@@ -389,6 +379,12 @@
   }
 #endif
 
+#ifdef GPU_CODEGEN
+  if (Target == TARGET_HYBRID)
+    PM.add(polly::createManagedMemoryRewritePassPass(GPUArchChoice,
+                                                     GPURuntimeChoice));
+#endif
+
   // FIXME: This dummy ModulePass keeps some programs from miscompiling,
   // probably some not correctly preserved analyses. It acts as a barrier to
   // force all analysis results to be recomputed.
diff --git a/stable/lib/Support/SCEVAffinator.cpp b/stable/lib/Support/SCEVAffinator.cpp
index d00d6d6..85e39e3 100644
--- a/stable/lib/Support/SCEVAffinator.cpp
+++ b/stable/lib/Support/SCEVAffinator.cpp
@@ -1,9 +1,8 @@
 //===--------- SCEVAffinator.cpp  - Create Scops from LLVM IR -------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,7 +15,6 @@
 #include "polly/ScopInfo.h"
 #include "polly/Support/GICHelper.h"
 #include "polly/Support/SCEVValidator.h"
-#include "polly/Support/ScopHelper.h"
 #include "isl/aff.h"
 #include "isl/local_space.h"
 #include "isl/set.h"
diff --git a/stable/lib/Support/SCEVValidator.cpp b/stable/lib/Support/SCEVValidator.cpp
index 6732f4b..84e9b87 100644
--- a/stable/lib/Support/SCEVValidator.cpp
+++ b/stable/lib/Support/SCEVValidator.cpp
@@ -1,6 +1,6 @@
 
 #include "polly/Support/SCEVValidator.h"
-#include "polly/ScopInfo.h"
+#include "polly/ScopDetection.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
diff --git a/stable/lib/Support/ScopHelper.cpp b/stable/lib/Support/ScopHelper.cpp
index fedb7b0..8c730c4 100644
--- a/stable/lib/Support/ScopHelper.cpp
+++ b/stable/lib/Support/ScopHelper.cpp
@@ -1,9 +1,8 @@
 //===- ScopHelper.cpp - Some Helper Functions for Scop.  ------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,13 +16,9 @@
 #include "polly/Support/SCEVValidator.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/RegionInfo.h"
-#include "llvm/Analysis/RegionInfoImpl.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionExpander.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
-#include "llvm/IR/CFG.h"
-#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/Support/Debug.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
 using namespace llvm;
diff --git a/stable/lib/Support/ScopLocation.cpp b/stable/lib/Support/ScopLocation.cpp
index a4b3dec..1b5e82e 100644
--- a/stable/lib/Support/ScopLocation.cpp
+++ b/stable/lib/Support/ScopLocation.cpp
@@ -1,9 +1,8 @@
 //=== ScopLocation.cpp - Debug location for ScopDetection ----- -*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -13,9 +12,7 @@
 //
 #include "polly/Support/ScopLocation.h"
 #include "llvm/Analysis/RegionInfo.h"
-#include "llvm/IR/BasicBlock.h"
-#include "llvm/IR/DebugInfo.h"
-#include "llvm/IR/DebugLoc.h"
+#include "llvm/IR/DebugInfoMetadata.h"
 
 using namespace llvm;
 
diff --git a/stable/lib/Support/VirtualInstruction.cpp b/stable/lib/Support/VirtualInstruction.cpp
index f779368..be055ac 100644
--- a/stable/lib/Support/VirtualInstruction.cpp
+++ b/stable/lib/Support/VirtualInstruction.cpp
@@ -1,9 +1,8 @@
 //===------ VirtualInstruction.cpp ------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -13,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/Support/VirtualInstruction.h"
-#include "polly/Support/SCEVValidator.h"
 
 using namespace polly;
 using namespace llvm;
diff --git a/stable/lib/Transform/Canonicalization.cpp b/stable/lib/Transform/Canonicalization.cpp
index 58e4914..8945f1f 100644
--- a/stable/lib/Transform/Canonicalization.cpp
+++ b/stable/lib/Transform/Canonicalization.cpp
@@ -1,9 +1,8 @@
 //===---- Canonicalization.cpp - Run canonicalization passes --------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,6 +15,7 @@
 #include "polly/Canonicalization.h"
 #include "polly/LinkAllPasses.h"
 #include "polly/Options.h"
+#include "llvm/IR/LegacyPassManager.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
 #include "llvm/Transforms/Scalar.h"
diff --git a/stable/lib/Transform/CodePreparation.cpp b/stable/lib/Transform/CodePreparation.cpp
index 299c141..a445d72 100644
--- a/stable/lib/Transform/CodePreparation.cpp
+++ b/stable/lib/Transform/CodePreparation.cpp
@@ -1,9 +1,8 @@
 //===---- CodePreparation.cpp - Code preparation for Scop Detection -------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -18,13 +17,11 @@
 
 #include "polly/CodePreparation.h"
 #include "polly/LinkAllPasses.h"
-#include "polly/ScopDetection.h"
 #include "polly/Support/ScopHelper.h"
 #include "llvm/Analysis/DominanceFrontier.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
-#include "llvm/Transforms/Utils/Local.h"
 
 using namespace llvm;
 using namespace polly;
diff --git a/stable/lib/Transform/DeLICM.cpp b/stable/lib/Transform/DeLICM.cpp
index fde99a2..b229d60 100644
--- a/stable/lib/Transform/DeLICM.cpp
+++ b/stable/lib/Transform/DeLICM.cpp
@@ -1,9 +1,8 @@
 //===------ DeLICM.cpp -----------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,13 +15,16 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/DeLICM.h"
+#include "polly/LinkAllPasses.h"
 #include "polly/Options.h"
 #include "polly/ScopInfo.h"
 #include "polly/ScopPass.h"
+#include "polly/Support/GICHelper.h"
 #include "polly/Support/ISLOStream.h"
 #include "polly/Support/ISLTools.h"
 #include "polly/ZoneAlgo.h"
 #include "llvm/ADT/Statistic.h"
+
 #define DEBUG_TYPE "polly-delicm"
 
 using namespace polly;
diff --git a/stable/lib/Transform/DeadCodeElimination.cpp b/stable/lib/Transform/DeadCodeElimination.cpp
index 1a029b4..cc8923c 100644
--- a/stable/lib/Transform/DeadCodeElimination.cpp
+++ b/stable/lib/Transform/DeadCodeElimination.cpp
@@ -1,9 +1,8 @@
 //===- DeadCodeElimination.cpp - Eliminate dead iteration  ----------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -37,12 +36,7 @@
 #include "polly/Options.h"
 #include "polly/ScopInfo.h"
 #include "llvm/Support/CommandLine.h"
-#include "isl/flow.h"
 #include "isl/isl-noexceptions.h"
-#include "isl/map.h"
-#include "isl/set.h"
-#include "isl/union_map.h"
-#include "isl/union_set.h"
 
 using namespace llvm;
 using namespace polly;
diff --git a/stable/lib/Transform/FlattenAlgo.cpp b/stable/lib/Transform/FlattenAlgo.cpp
index 5632b14..c7d02c1 100644
--- a/stable/lib/Transform/FlattenAlgo.cpp
+++ b/stable/lib/Transform/FlattenAlgo.cpp
@@ -1,9 +1,8 @@
 //===------ FlattenAlgo.cpp ------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/lib/Transform/FlattenSchedule.cpp b/stable/lib/Transform/FlattenSchedule.cpp
index 52ff0b7..fc065af 100644
--- a/stable/lib/Transform/FlattenSchedule.cpp
+++ b/stable/lib/Transform/FlattenSchedule.cpp
@@ -1,9 +1,8 @@
 //===------ FlattenSchedule.cpp --------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/lib/Transform/ForwardOpTree.cpp b/stable/lib/Transform/ForwardOpTree.cpp
index f49b673..ad31673 100644
--- a/stable/lib/Transform/ForwardOpTree.cpp
+++ b/stable/lib/Transform/ForwardOpTree.cpp
@@ -1,9 +1,8 @@
 //===- ForwardOpTree.h ------------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -29,7 +28,6 @@
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Value.h"
-#include "llvm/Pass.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
diff --git a/stable/lib/Transform/MaximalStaticExpansion.cpp b/stable/lib/Transform/MaximalStaticExpansion.cpp
index 2157db2..a9e1c50 100644
--- a/stable/lib/Transform/MaximalStaticExpansion.cpp
+++ b/stable/lib/Transform/MaximalStaticExpansion.cpp
@@ -1,9 +1,8 @@
 //===- MaximalStaticExpansion.cpp -----------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -16,12 +15,10 @@
 #include "polly/LinkAllPasses.h"
 #include "polly/ScopInfo.h"
 #include "polly/ScopPass.h"
-#include "polly/Support/GICHelper.h"
 #include "polly/Support/ISLTools.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
-#include "llvm/Pass.h"
 #include "isl/isl-noexceptions.h"
 #include "isl/union_map.h"
 #include <cassert>
diff --git a/stable/lib/Transform/RewriteByReferenceParameters.cpp b/stable/lib/Transform/RewriteByReferenceParameters.cpp
index 1b9f852..494280e 100644
--- a/stable/lib/Transform/RewriteByReferenceParameters.cpp
+++ b/stable/lib/Transform/RewriteByReferenceParameters.cpp
@@ -1,9 +1,8 @@
 //===------ RewriteByReferenceParameters.cpp --------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -17,7 +16,7 @@
 #include "polly/LinkAllPasses.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
-#include "llvm/IR/PassManager.h"
+#include "llvm/Pass.h"
 
 #define DEBUG_TYPE "polly-rewrite-byref-params"
 
diff --git a/stable/lib/Transform/ScheduleOptimizer.cpp b/stable/lib/Transform/ScheduleOptimizer.cpp
index fb3e4b3..5554154 100644
--- a/stable/lib/Transform/ScheduleOptimizer.cpp
+++ b/stable/lib/Transform/ScheduleOptimizer.cpp
@@ -1,9 +1,8 @@
 //===- Schedule.cpp - Calculate an optimized schedule ---------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -54,23 +53,18 @@
 #include "polly/ScopInfo.h"
 #include "polly/ScopPass.h"
 #include "polly/Simplify.h"
-#include "polly/Support/GICHelper.h"
 #include "polly/Support/ISLOStream.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/IR/Function.h"
-#include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
-#include "isl/constraint.h"
 #include "isl/ctx.h"
-#include "isl/map.h"
 #include "isl/options.h"
 #include "isl/printer.h"
 #include "isl/schedule.h"
 #include "isl/schedule_node.h"
-#include "isl/space.h"
 #include "isl/union_map.h"
 #include "isl/union_set.h"
 #include <algorithm>
diff --git a/stable/lib/Transform/ScopInliner.cpp b/stable/lib/Transform/ScopInliner.cpp
index 4aadb6a..7aaa367 100644
--- a/stable/lib/Transform/ScopInliner.cpp
+++ b/stable/lib/Transform/ScopInliner.cpp
@@ -1,9 +1,8 @@
 //===---- ScopInliner.cpp - Polyhedral based inliner ----------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-/// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -15,10 +14,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/LinkAllPasses.h"
-#include "polly/RegisterPasses.h"
 #include "polly/ScopDetection.h"
 #include "llvm/Analysis/CallGraphSCCPass.h"
-#include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
diff --git a/stable/lib/Transform/Simplify.cpp b/stable/lib/Transform/Simplify.cpp
index 8b0a695..d58aa0b 100644
--- a/stable/lib/Transform/Simplify.cpp
+++ b/stable/lib/Transform/Simplify.cpp
@@ -1,9 +1,8 @@
 //===------ Simplify.cpp ----------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/lib/Transform/ZoneAlgo.cpp b/stable/lib/Transform/ZoneAlgo.cpp
index f5109a6..6802615 100644
--- a/stable/lib/Transform/ZoneAlgo.cpp
+++ b/stable/lib/Transform/ZoneAlgo.cpp
@@ -1,9 +1,8 @@
 //===------ ZoneAlgo.cpp ----------------------------------------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
diff --git a/stable/test/Isl/CodeGen/OpenMP/reference-argument-from-non-affine-region.ll b/stable/test/Isl/CodeGen/OpenMP/reference-argument-from-non-affine-region.ll
index ce30395..28461ef 100644
--- a/stable/test/Isl/CodeGen/OpenMP/reference-argument-from-non-affine-region.ll
+++ b/stable/test/Isl/CodeGen/OpenMP/reference-argument-from-non-affine-region.ll
@@ -1,10 +1,25 @@
 ; RUN: opt %loadPolly -polly-parallel \
-; RUN: -polly-parallel-force -polly-codegen -S -verify-dom-info < %s \
+; RUN: -polly-parallel-force -polly-codegen \
+; RUN: -S -verify-dom-info < %s \
 ; RUN: | FileCheck %s -check-prefix=IR
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; RUN: opt %loadPolly -polly-parallel \
+; RUN: -polly-parallel-force -polly-codegen -polly-scheduling=runtime \
+; RUN: -S -verify-dom-info < %s \
+; RUN: | FileCheck %s -check-prefix=IR
+
+; RUN: opt %loadPolly -polly-parallel \
+; RUN: -polly-parallel-force -polly-codegen -polly-omp-backend=LLVM \
+; RUN: -S -verify-dom-info < %s \
+; RUN: | FileCheck %s -check-prefix=LIBOMP-IR
 
 ; IR: @GOMP_parallel_loop_runtime_start
 
+; LIBOMP-IR: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call
+; LIBOMP-IR: call void @__kmpc_dispatch_init_{{[4|8]}}
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
 @longLimit = external global [9 x [23 x i32]], align 16
 @shortLimit = external global [9 x [14 x i32]], align 16
 
diff --git a/stable/test/Isl/CodeGen/OpenMP/single_loop.ll b/stable/test/Isl/CodeGen/OpenMP/single_loop.ll
index 6aeda25..6de65bd 100644
--- a/stable/test/Isl/CodeGen/OpenMP/single_loop.ll
+++ b/stable/test/Isl/CodeGen/OpenMP/single_loop.ll
@@ -4,9 +4,14 @@
 ; RUN: opt %loadPolly -polly-parallel -polly-parallel-force -polly-import-jscop -polly-ast -analyze < %s | FileCheck %s -check-prefix=AST-STRIDE4
 ; RUN: opt %loadPolly -polly-parallel -polly-parallel-force -polly-import-jscop -polly-codegen -S < %s | FileCheck %s -check-prefix=IR-STRIDE4
 
+; RUN: opt %loadPolly -polly-parallel -polly-parallel-force -polly-codegen -polly-omp-backend=LLVM -polly-scheduling=static -polly-scheduling-chunksize=43 -S -verify-dom-info < %s | FileCheck %s -check-prefix=LIBOMP-IR
+; RUN: opt %loadPolly -polly-parallel -polly-parallel-force -polly-codegen -polly-omp-backend=LLVM -polly-scheduling=dynamic -S -verify-dom-info < %s | FileCheck %s -check-prefix=LIBOMP-IR-DYNAMIC
+; RUN: opt %loadPolly -polly-parallel -polly-parallel-force -polly-codegen -polly-omp-backend=LLVM -polly-scheduling=dynamic -polly-scheduling-chunksize=4 -S -verify-dom-info < %s | FileCheck %s -check-prefix=LIBOMP-IR-DYNAMIC-FOUR
+; RUN: opt %loadPolly -polly-parallel -polly-parallel-force -polly-import-jscop -polly-codegen -polly-omp-backend=LLVM -S < %s | FileCheck %s -check-prefix=LIBOMP-IR-STRIDE4
+
 ; This extensive test case tests the creation of the full set of OpenMP calls
 ; as well as the subfunction creation using a trivial loop as example.
-
+;
 ; #define N 1024
 ; float A[N];
 ;
@@ -83,6 +88,90 @@
 ; IR-STRIDE4:  %polly.indvar_next = add nsw i64 %polly.indvar, 4
 ; IR-STRIDE4   %polly.adjust_ub = sub i64 %polly.par.UBAdjusted, 4
 
+; LIBOMP-IR: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+
+; LIBOMP-IR-LABEL: single_parallel_loop()
+; LIBOMP-IR-NEXT: entry
+; LIBOMP-IR-NEXT:   %polly.par.userContext = alloca
+
+; LIBOMP-IR-LABEL: polly.parallel.for:
+; LIBOMP-IR-NEXT:   %polly.par.userContext1 = bitcast {}* %polly.par.userContext to i8*
+; LIBOMP-IR-NEXT:   call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @.loc.dummy, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i64, i8*)* @single_parallel_loop_polly_subfn to void (i32*, i32*, ...)*), i64 0, i64 1024, i64 1, i8* %polly.par.userContext1)
+; LIBOMP-IR-NEXT:   br label %polly.exiting
+
+; LIBOMP-IR: define internal void @single_parallel_loop_polly_subfn(i32* %polly.kmpc.global_tid, i32* %polly.kmpc.bound_tid, i64 %polly.kmpc.lb, i64 %polly.kmpc.ub, i64 %polly.kmpc.inc, i8* %polly.kmpc.shared)
+; LIBOMP-IR-LABEL: polly.par.setup:
+; LIBOMP-IR-NEXT:   %polly.par.LBPtr = alloca i64
+; LIBOMP-IR-NEXT:   %polly.par.UBPtr = alloca i64
+; LIBOMP-IR-NEXT:   %polly.par.lastIterPtr = alloca i32
+; LIBOMP-IR-NEXT:   %polly.par.StridePtr = alloca i64
+; LIBOMP-IR-NEXT:   %polly.par.userContext = bitcast i8* %polly.kmpc.shared
+; LIBOMP-IR-NEXT:   %polly.par.global_tid = load i32, i32* %polly.kmpc.global_tid
+; LIBOMP-IR-NEXT:   store i64 %polly.kmpc.lb, i64* %polly.par.LBPtr
+; LIBOMP-IR-NEXT:   store i64 %polly.kmpc.ub, i64* %polly.par.UBPtr
+; LIBOMP-IR-NEXT:   store i32 0, i32* %polly.par.lastIterPtr
+; LIBOMP-IR-NEXT:   store i64 %polly.kmpc.inc, i64* %polly.par.StridePtr
+; LIBOMP-IR-NEXT:   %polly.indvar.UBAdjusted = add i64 %polly.kmpc.ub, -1
+; LIBOMP-IR-NEXT:   call void @__kmpc_for_static_init_{{[4|8]}}(%struct.ident_t* @.loc.dummy{{[.0-9]*}}, i32 %polly.par.global_tid, i32 33, i32* %polly.par.lastIterPtr, i64* %polly.par.LBPtr, i64* %polly.par.UBPtr, i64* %polly.par.StridePtr, i64 1, i64 43)
+; LIBOMP-IR-NEXT:   %polly.indvar.LB = load i64, i64* %polly.par.LBPtr
+; LIBOMP-IR-NEXT:   %polly.indvar.UB = load i64, i64* %polly.par.UBPtr
+; LIBOMP-IR-NEXT:   %polly.adjustedUBOutOfBounds = icmp slt i64 %polly.indvar.UB, %polly.indvar.UBAdjusted
+; LIBOMP-IR-NEXT:   %{{[0-9]+}} = select i1 %polly.adjustedUBOutOfBounds, i64 %polly.indvar.UB, i64 %polly.indvar.UBAdjusted
+; LIBOMP-IR-NEXT:   store i64 %{{[0-9]+}}, i64* %polly.par.UBPtr
+; LIBOMP-IR-NEXT:   %polly.hasIteration = icmp sle i64 %polly.indvar.LB, %{{[0-9]+}}
+; LIBOMP-IR:   br i1 %polly.hasIteration, label %polly.par.loadIVBounds, label %polly.par.exit
+
+; LIBOMP-IR-LABEL: polly.par.exit:
+; LIBOMP-IR-NEXT:   call void @__kmpc_for_static_fini(%struct.ident_t* @.loc.dummy, i32 %polly.par.global_tid)
+; LIBOMP-IR-NEXT:   ret void
+
+; LIBOMP-IR-LABEL: polly.par.checkNext:
+; LIBOMP-IR-NEXT:   br label %polly.par.exit
+
+; LIBOMP-IR-LABEL: polly.par.loadIVBounds:
+; LIBOMP-IR-NEXT:   br label %polly.loop_preheader
+
+; LIBOMP-IR-LABEL: polly.loop_exit:
+; LIBOMP-IR-NEXT:   br label %polly.par.checkNext
+
+; LIBOMP-IR-LABEL: polly.loop_header:
+; LIBOMP-IR-NEXT:   %polly.indvar = phi i64 [ %polly.indvar.LB, %polly.loop_preheader ], [ %polly.indvar_next, %polly.stmt.S ]
+; LIBOMP-IR-NEXT:   br label %polly.stmt.S
+
+; LIBOMP-IR-LABEL: polly.stmt.S:
+; LIBOMP-IR-NEXT:   %[[gep:[._a-zA-Z0-9]*]] = getelementptr [1024 x float], [1024 x float]* {{.*}}, i64 0, i64 %polly.indvar
+; LIBOMP-IR-NEXT:   store float 1.000000e+00, float* %[[gep]]
+; LIBOMP-IR-NEXT:   %polly.indvar_next = add nsw i64 %polly.indvar, %polly.kmpc.inc
+; LIBOMP-IR-NEXT:   %polly.loop_cond = icmp sle i64 %polly.indvar_next, %{{[0-9]+}}
+; LIBOMP-IR-NEXT:   br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
+
+; LIBOMP-IR-LABEL: polly.loop_preheader:
+; LIBOMP-IR-NEXT:   br label %polly.loop_header
+
+; LIBOMP-IR: attributes #1 = { "polly.skip.fn" }
+
+; LIBOMP-IR-DYNAMIC:   call void @__kmpc_dispatch_init_{{[4|8]}}(%struct.ident_t* @.loc.dummy, i32 %polly.par.global_tid, i32 35, i64 %polly.kmpc.lb, i64 %polly.indvar.UBAdjusted, i64 %polly.kmpc.inc, i64 1)
+; LIBOMP-IR-DYNAMIC-NEXT:   %{{[0-9]+}} = call i32 @__kmpc_dispatch_next_{{[4|8]}}(%struct.ident_t* @.loc.dummy, i32 %polly.par.global_tid, i32* %polly.par.lastIterPtr, i64* %polly.par.LBPtr, i64* %polly.par.UBPtr, i64* %polly.par.StridePtr)
+; LIBOMP-IR-DYNAMIC-NEXT:   %polly.hasIteration = icmp eq i32 %{{[0-9]+}}, 1
+; LIBOMP-IR-DYNAMIC-NEXT:   br i1 %polly.hasIteration, label %polly.par.loadIVBounds, label %polly.par.exit
+
+; LIBOMP-IR-DYNAMIC-LABEL: polly.par.exit:
+; LIBOMP-IR-DYNAMIC-NEXT:   ret void
+
+; LIBOMP-IR-DYNAMIC-LABEL: polly.par.checkNext:
+; LIBOMP-IR-DYNAMIC-NEXT:   %{{[0-9]+}} = call i32 @__kmpc_dispatch_next_{{[4|8]}}(%struct.ident_t* @.loc.dummy, i32 %polly.par.global_tid, i32* %polly.par.lastIterPtr, i64* %polly.par.LBPtr, i64* %polly.par.UBPtr, i64* %polly.par.StridePtr)
+; LIBOMP-IR-DYNAMIC-NEXT:   %polly.hasWork = icmp eq i32 %{{[0-9]+}}, 1
+; LIBOMP-IR-DYNAMIC-NEXT:   br i1 %polly.hasWork, label %polly.par.loadIVBounds, label %polly.par.exit
+
+; LIBOMP-IR-DYNAMIC-LABEL: polly.par.loadIVBounds:
+; LIBOMP-IR-DYNAMIC-NEXT:   %polly.indvar.LB = load i64, i64* %polly.par.LBPtr
+; LIBOMP-IR-DYNAMIC-NEXT:   %polly.indvar.UB = load i64, i64* %polly.par.UBPtr
+; LIBOMP-IR-DYNAMIC-NEXT:   br label %polly.loop_preheader
+
+; LIBOMP-IR-DYNAMIC-FOUR:   call void @__kmpc_dispatch_init_{{[4|8]}}(%struct.ident_t* @.loc.dummy, i32 %polly.par.global_tid, i32 35, i64 %polly.kmpc.lb, i64 %polly.indvar.UBAdjusted, i64 %polly.kmpc.inc, i64 4)
+
+; LIBOMP-IR-STRIDE4:     call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @.loc.dummy, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i64, i8*)* @single_parallel_loop_polly_subfn to void (i32*, i32*, ...)*), i64 0, i64 1024, i64 4, i8* %polly.par.userContext1)
+
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 
 @A = common global [1024 x float] zeroinitializer, align 16
diff --git a/stable/test/Isl/CodeGen/OpenMP/single_loop_with_param.ll b/stable/test/Isl/CodeGen/OpenMP/single_loop_with_param.ll
index f518319..4c3bc0f 100644
--- a/stable/test/Isl/CodeGen/OpenMP/single_loop_with_param.ll
+++ b/stable/test/Isl/CodeGen/OpenMP/single_loop_with_param.ll
@@ -1,7 +1,21 @@
 ; RUN: opt %loadPolly -polly-parallel \
-; RUN: -polly-parallel-force -polly-codegen -S -verify-dom-info < %s \
+; RUN: -polly-parallel-force -polly-codegen \
+; RUN: -S -verify-dom-info < %s \
 ; RUN: | FileCheck %s -check-prefix=IR
 
+; RUN: opt %loadPolly -polly-parallel \
+; RUN: -polly-parallel-force -polly-codegen -polly-omp-backend=LLVM \
+; RUN: -S -verify-dom-info < %s \
+; RUN: | FileCheck %s -check-prefix=LIBOMP-IR
+
+; RUN: opt %loadPolly -polly-parallel \
+; RUN: -polly-parallel-force -polly-codegen -polly-omp-backend=LLVM \
+; RUN: -polly-scheduling=static \
+; RUN: -S -verify-dom-info < %s \
+; RUN: | FileCheck %s -check-prefix=LIBOMP-STATIC-IR
+
+; Ensure the scalars are initialized before the OpenMP code is launched.
+;
 ; #define N 1024
 ; float A[N];
 ;
@@ -9,16 +23,24 @@
 ;   for (long i = 0; i < N; i++)
 ;     A[i] = alpha;
 ; }
-
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
-
-; Ensure the scalars are initialized before the OpenMP code is launched.
+;
 
 ; IR-LABEL: polly.start:
 ; IR-NEXT:    store float %alpha, float* %alpha.s2a
 
 ; IR: GOMP_parallel_loop_runtime_start
 
+; LIBOMP-IR-LABEL: polly.start:
+; LIBOMP-IR-NEXT:    store float %alpha, float* %alpha.s2a
+
+; LIBOMP-IR: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call
+; LIBOMP-IR: call void @__kmpc_dispatch_init_{{[4|8]}}
+
+; LIBOMP-STATIC-IR: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call
+; LIBOMP-STATIC-IR: call void @__kmpc_for_static_init_{{[4|8]}}
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+
 @A = common global [1024 x float] zeroinitializer, align 16
 
 define void @single_parallel_loop(float %alpha) nounwind {
diff --git a/stable/test/Isl/CodeGen/openmp_limit_threads.ll b/stable/test/Isl/CodeGen/openmp_limit_threads.ll
index 82b9f8d..b3c2f3f 100644
--- a/stable/test/Isl/CodeGen/openmp_limit_threads.ll
+++ b/stable/test/Isl/CodeGen/openmp_limit_threads.ll
@@ -1,20 +1,31 @@
 ; RUN: opt %loadPolly -polly-codegen -polly-parallel -S < %s | FileCheck %s --check-prefix=AUTO
 ; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-num-threads=1 -S < %s | FileCheck %s --check-prefix=ONE
 ; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-num-threads=4 -S < %s | FileCheck %s --check-prefix=FOUR
+
+; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-omp-backend=LLVM -S < %s | FileCheck %s --check-prefix=LIBOMP-AUTO
+; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-omp-backend=LLVM -polly-num-threads=1 -S < %s | FileCheck %s --check-prefix=LIBOMP-ONE
+; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-omp-backend=LLVM -polly-num-threads=4 -S < %s | FileCheck %s --check-prefix=LIBOMP-FOUR
+
+; Ensure that the provided thread numbers are forwarded to the OpenMP calls.
 ;
-; AUTO: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 0, i64 0, i64 1024, i64 1)
-; ONE: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 1, i64 0, i64 1024, i64 1)
-; FOUR: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @jd_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 4, i64 0, i64 1024, i64 1)
-;
-;    void jd(int *A) {
+;    void storePosition(int *A) {
 ;      for (int i = 0; i < 1024; i++)
 ;        for (int j = 0; j < 1024; j++)
 ;          A[i + j * 1024] = 0;
 ;    }
-;
+
+; AUTO: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @storePosition_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 0, i64 0, i64 1024, i64 1)
+; ONE: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @storePosition_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 1, i64 0, i64 1024, i64 1)
+; FOUR: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @storePosition_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 4, i64 0, i64 1024, i64 1)
+
+; In automatic mode, no threads are pushed explicitly.
+; LIBOMP-AUTO-NOT: call void @__kmpc_push_num_threads
+; LIBOMP-ONE: call void @__kmpc_push_num_threads(%struct.ident_t* @.loc.dummy{{[.0-9]*}}, i32 %{{[0-9]+}}, i32 1)
+; LIBOMP-FOUR: call void @__kmpc_push_num_threads(%struct.ident_t* @.loc.dummy{{[.0-9]*}}, i32 %{{[0-9]+}}, i32 4)
+
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
-define void @jd(i32* %A) {
+define void @storePosition(i32* %A) {
 entry:
   br label %for.cond
 
diff --git a/stable/tools/GPURuntime/GPUJIT.c b/stable/tools/GPURuntime/GPUJIT.c
index 25c5d6b..4de9626 100644
--- a/stable/tools/GPURuntime/GPUJIT.c
+++ b/stable/tools/GPURuntime/GPUJIT.c
@@ -1,9 +1,9 @@
 /******************** GPUJIT.c - GPUJIT Execution Engine **********************/
 /*                                                                            */
-/*                     The LLVM Compiler Infrastructure                       */
-/*                                                                            */
-/* This file is dual licensed under the MIT and the University of Illinois    */
-/* Open Source License. See LICENSE.TXT for details.                          */
+/* Part of the LLVM Project, under the Apache License v2.0 with LLVM          */
+/* Exceptions.                                                                */
+/* See https://llvm.org/LICENSE.txt for license information.                  */
+/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    */
 /*                                                                            */
 /******************************************************************************/
 /*                                                                            */
diff --git a/stable/tools/GPURuntime/GPUJIT.h b/stable/tools/GPURuntime/GPUJIT.h
index fd52ec3..768e097 100644
--- a/stable/tools/GPURuntime/GPUJIT.h
+++ b/stable/tools/GPURuntime/GPUJIT.h
@@ -1,9 +1,9 @@
 /******************************************************************************/
 /*                                                                            */
-/*                     The LLVM Compiler Infrastructure                       */
-/*                                                                            */
-/* This file is dual licensed under the MIT and the University of Illinois    */
-/* Open Source License. See LICENSE.TXT for details.                          */
+/* Part of the LLVM Project, under the Apache License v2.0 with LLVM          */
+/* Exceptions.                                                                */
+/* See https://llvm.org/LICENSE.txt for license information.                  */
+/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    */
 /*                                                                            */
 /******************************************************************************/
 /*                                                                            */
diff --git a/stable/tools/GPURuntime/LICENSE.TXT b/stable/tools/GPURuntime/LICENSE.TXT
index b9e3080..a556c3a 100644
--- a/stable/tools/GPURuntime/LICENSE.TXT
+++ b/stable/tools/GPURuntime/LICENSE.TXT
@@ -1,5 +1,240 @@
 ==============================================================================
-GPURuntime License
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+    1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+    2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+    3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+    4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+    5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+    6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+    7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+    8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+    9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+    END OF TERMS AND CONDITIONS
+
+    APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+    Copyright [yyyy] [name of copyright owner]
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+   `LICENSE` file at the top containing the specific license and restrictions
+   which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+   file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
 ==============================================================================
 
 The GPURuntime library is dual licensed under both the University of Illinois
diff --git a/stable/unittests/DeLICM/DeLICMTest.cpp b/stable/unittests/DeLICM/DeLICMTest.cpp
index bac2366..3e6b6f0 100644
--- a/stable/unittests/DeLICM/DeLICMTest.cpp
+++ b/stable/unittests/DeLICM/DeLICMTest.cpp
@@ -1,9 +1,8 @@
 //===- DeLICMTest.cpp ----------------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/stable/unittests/Flatten/FlattenTest.cpp b/stable/unittests/Flatten/FlattenTest.cpp
index b141d28..6668403 100644
--- a/stable/unittests/Flatten/FlattenTest.cpp
+++ b/stable/unittests/Flatten/FlattenTest.cpp
@@ -1,9 +1,8 @@
 //===- FlattenTest.cpp ----------------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/stable/unittests/Isl/IslTest.cpp b/stable/unittests/Isl/IslTest.cpp
index 984264e..d319c64 100644
--- a/stable/unittests/Isl/IslTest.cpp
+++ b/stable/unittests/Isl/IslTest.cpp
@@ -1,9 +1,8 @@
 //===- IslTest.cpp ----------------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/stable/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp b/stable/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp
index d23766d..b7fed0b 100644
--- a/stable/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp
+++ b/stable/unittests/ScheduleOptimizer/ScheduleOptimizerTest.cpp
@@ -1,9 +1,8 @@
 //===- ScheduleOptimizerTest.cpp ------------------------------------------===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/stable/www/get_started.html b/stable/www/get_started.html
index 5d2caba..5d3e004 100644
--- a/stable/www/get_started.html
+++ b/stable/www/get_started.html
@@ -33,20 +33,14 @@
 <h2> Manual </h2>
 <h3 id="source"> Get the code </h3>
 
-<p><b>Warning:</b> Polly/LLVM/clang need to be checked out at the same time.</p>
-
 <pre>
-git clone http://llvm.org/git/llvm.git llvm_git
-git clone http://llvm.org/git/polly.git llvm_git/tools/polly
-
-# Also build the matching clang-version (optional)
-git clone http://llvm.org/git/clang.git llvm_git/tools/clang
+git clone http://github.com/llvm/llvm-project.git llvm_git
 </pre>
 <h3 id="build">Build Polly</h3>
 
 <pre>
 mkdir llvm_build && cd llvm_build
-cmake ../llvm_git && make
+cmake -DLLVM_ENABLE_PROJECTS='polly;clang' ../llvm_git/llvm && make
 </pre>
 
 <h3> Test Polly</h3>
@@ -59,7 +53,7 @@
 build. To configure Polly to use a pre-built LLVM, set the
 <code>-DCMAKE_PREFIX_PATH</code> option:
 
-<pre>cmake -DCMAKE_PREFIX_PATH=${LLVM_PREFIX}/lib/cmake/llvm</pre>
+<pre>cmake -DCMAKE_PREFIX_PATH=${LLVM_PREFIX}/lib/cmake/llvm ../llvm_git/polly</pre>
 
 To run unittests, however, you need to have the LLVM source directory around.
 Polly will use the <code>llvm-config</code> of the LLVM you're building against
diff --git a/stable/www/menu.html.incl b/stable/www/menu.html.incl
index da2bca6..07afd7b 100644
--- a/stable/www/menu.html.incl
+++ b/stable/www/menu.html.incl
@@ -34,7 +34,7 @@
     <a href="http://lab.llvm.org:8080/coverage/coverage-reports/polly/index.html">Code Coverage</a>
     <a href="http://llvm.org/reports/scan-build/">Static analysis</a>
     <a href="/doxygen/">Doxygen</a>
-    <a href="https://github.com/llvm-mirror/polly">Source @ GitHub</a>
+    <a href="https://github.com/llvm/llvm-project/tree/master/polly">Source @ GitHub</a>
   </div>
 
   <div class="submenu">
diff --git a/stable/www/todo.html b/stable/www/todo.html
index 8aa45c9..3624dc3 100644
--- a/stable/www/todo.html
+++ b/stable/www/todo.html
@@ -413,12 +413,6 @@
 
 </td></tr>
 <tr>
-<th align="left"> Git mirror
-</th><td class="done" align="center">
-git://llvm.org/git/polly.git
-</td><td> Tobias
-</td></tr>
-<tr>
 <th align="left"> Commit mails
 </th><td class="done" align="center">
 llvm-commits@lists.llvm.org