Apply include-what-you-use #include removal suggestions. NFC.

This removes unused includes (and forward declarations) as
suggested by include-what-you-use. If a transitive include of a removed
include is required to compile a file, I added the required header (or
forward declaration if suggested by include-what-you-use).

This should reduce compilation time and reduce the number of iterative
recompilations when a header was changed.

git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@357209 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/polly/Canonicalization.h b/include/polly/Canonicalization.h
index 28f5e2d..763f2df 100644
--- a/include/polly/Canonicalization.h
+++ b/include/polly/Canonicalization.h
@@ -9,7 +9,11 @@
 #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/include/polly/CodeGen/BlockGenerators.h b/include/polly/CodeGen/BlockGenerators.h
index 6cb41e4..f2c52c8 100644
--- a/include/polly/CodeGen/BlockGenerators.h
+++ b/include/polly/CodeGen/BlockGenerators.h
@@ -16,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/include/polly/CodeGen/CodeGeneration.h b/include/polly/CodeGen/CodeGeneration.h
index 02b77d7..b32f312 100644
--- a/include/polly/CodeGen/CodeGeneration.h
+++ b/include/polly/CodeGen/CodeGeneration.h
@@ -9,20 +9,12 @@
 #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/include/polly/CodeGen/IRBuilder.h b/include/polly/CodeGen/IRBuilder.h
index 2649068..8033ffa 100644
--- a/include/polly/CodeGen/IRBuilder.h
+++ b/include/polly/CodeGen/IRBuilder.h
@@ -15,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/include/polly/CodeGen/IslAst.h b/include/polly/CodeGen/IslAst.h
index 89d8aa5..1a842b8 100644
--- a/include/polly/CodeGen/IslAst.h
+++ b/include/polly/CodeGen/IslAst.h
@@ -21,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/include/polly/CodeGen/IslExprBuilder.h b/include/polly/CodeGen/IslExprBuilder.h
index 9e3764a..fe727cd 100644
--- a/include/polly/CodeGen/IslExprBuilder.h
+++ b/include/polly/CodeGen/IslExprBuilder.h
@@ -13,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/include/polly/CodeGen/IslNodeBuilder.h b/include/polly/CodeGen/IslNodeBuilder.h
index 935922d..47bec72 100644
--- a/include/polly/CodeGen/IslNodeBuilder.h
+++ b/include/polly/CodeGen/IslNodeBuilder.h
@@ -17,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/include/polly/CodeGen/LoopGenerators.h b/include/polly/CodeGen/LoopGenerators.h
index 39ff3a7..152f816 100644
--- a/include/polly/CodeGen/LoopGenerators.h
+++ b/include/polly/CodeGen/LoopGenerators.h
@@ -15,15 +15,7 @@
 
 #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;
diff --git a/include/polly/CodeGen/LoopGeneratorsGOMP.h b/include/polly/CodeGen/LoopGeneratorsGOMP.h
index 641d0dd..083be75 100644
--- a/include/polly/CodeGen/LoopGeneratorsGOMP.h
+++ b/include/polly/CodeGen/LoopGeneratorsGOMP.h
@@ -16,15 +16,7 @@
 #include "polly/CodeGen/IRBuilder.h"
 #include "polly/CodeGen/LoopGenerators.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;
diff --git a/include/polly/CodeGen/LoopGeneratorsKMP.h b/include/polly/CodeGen/LoopGeneratorsKMP.h
index 9adcd56..d9a6916 100644
--- a/include/polly/CodeGen/LoopGeneratorsKMP.h
+++ b/include/polly/CodeGen/LoopGeneratorsKMP.h
@@ -16,15 +16,7 @@
 #include "polly/CodeGen/IRBuilder.h"
 #include "polly/CodeGen/LoopGenerators.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;
diff --git a/include/polly/CodeGen/PerfMonitor.h b/include/polly/CodeGen/PerfMonitor.h
index 0f7b0fd..81aa4c7 100644
--- a/include/polly/CodeGen/PerfMonitor.h
+++ b/include/polly/CodeGen/PerfMonitor.h
@@ -11,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/include/polly/DeLICM.h b/include/polly/DeLICM.h
index e5e9c5c..7ef382f 100644
--- a/include/polly/DeLICM.h
+++ b/include/polly/DeLICM.h
@@ -17,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/include/polly/DependenceInfo.h b/include/polly/DependenceInfo.h
index 6198fbf..d66be81 100644
--- a/include/polly/DependenceInfo.h
+++ b/include/polly/DependenceInfo.h
@@ -26,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
@@ -313,7 +302,6 @@
 } // namespace polly
 
 namespace llvm {
-class PassRegistry;
 void initializeDependenceInfoPass(llvm::PassRegistry &);
 void initializeDependenceInfoWrapperPassPass(llvm::PassRegistry &);
 } // namespace llvm
diff --git a/include/polly/FlattenAlgo.h b/include/polly/FlattenAlgo.h
index ce4a938..6fdca8f 100644
--- a/include/polly/FlattenAlgo.h
+++ b/include/polly/FlattenAlgo.h
@@ -14,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/include/polly/LinkAllPasses.h b/include/polly/LinkAllPasses.h
index 09bbf9b..ed05f83 100644
--- a/include/polly/LinkAllPasses.h
+++ b/include/polly/LinkAllPasses.h
@@ -24,9 +24,7 @@
 
 namespace llvm {
 class Pass;
-class PassInfo;
 class PassRegistry;
-class RegionPass;
 } // namespace llvm
 
 namespace polly {
diff --git a/include/polly/PolyhedralInfo.h b/include/polly/PolyhedralInfo.h
index 46893d1..cec288d 100644
--- a/include/polly/PolyhedralInfo.h
+++ b/include/polly/PolyhedralInfo.h
@@ -17,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/include/polly/RegisterPasses.h b/include/polly/RegisterPasses.h
index 9a0ae04..2126db9 100644
--- a/include/polly/RegisterPasses.h
+++ b/include/polly/RegisterPasses.h
@@ -13,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/include/polly/ScopBuilder.h b/include/polly/ScopBuilder.h
index 5f23cdb..54d48be 100644
--- a/include/polly/ScopBuilder.h
+++ b/include/polly/ScopBuilder.h
@@ -20,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/include/polly/ScopDetection.h b/include/polly/ScopDetection.h
index 292816c..a174b4b 100644
--- a/include/polly/ScopDetection.h
+++ b/include/polly/ScopDetection.h
@@ -48,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/include/polly/ScopDetectionDiagnostic.h b/include/polly/ScopDetectionDiagnostic.h
index 4db784c..6824615 100644
--- a/include/polly/ScopDetectionDiagnostic.h
+++ b/include/polly/ScopDetectionDiagnostic.h
@@ -20,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;
 
@@ -37,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/include/polly/ScopInfo.h b/include/polly/ScopInfo.h
index 98db37b..5f48f64 100644
--- a/include/polly/ScopInfo.h
+++ b/include/polly/ScopInfo.h
@@ -19,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/include/polly/Support/GICHelper.h b/include/polly/Support/GICHelper.h
index 5442c08..ca8abe4 100644
--- a/include/polly/Support/GICHelper.h
+++ b/include/polly/Support/GICHelper.h
@@ -16,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/include/polly/Support/ISLTools.h b/include/polly/Support/ISLTools.h
index 230145f..fab0dae 100644
--- a/include/polly/Support/ISLTools.h
+++ b/include/polly/Support/ISLTools.h
@@ -14,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/include/polly/Support/SCEVAffinator.h b/include/polly/Support/SCEVAffinator.h
index c15ae56..4aad9a6 100644
--- a/include/polly/Support/SCEVAffinator.h
+++ b/include/polly/Support/SCEVAffinator.h
@@ -13,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/include/polly/Support/SCEVValidator.h b/include/polly/Support/SCEVValidator.h
index 23d40e8..a341dc0 100644
--- a/include/polly/Support/SCEVValidator.h
+++ b/include/polly/Support/SCEVValidator.h
@@ -12,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/include/polly/Support/ScopHelper.h b/include/polly/Support/ScopHelper.h
index 0d26027..02c669a 100644
--- a/include/polly/Support/ScopHelper.h
+++ b/include/polly/Support/ScopHelper.h
@@ -13,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;
@@ -30,7 +27,6 @@
 class Pass;
 class DominatorTree;
 class RegionInfo;
-class GetElementPtrInst;
 } // namespace llvm
 
 namespace polly {
diff --git a/lib/Analysis/DependenceInfo.cpp b/lib/Analysis/DependenceInfo.cpp
index eaceaf0..173c292 100644
--- a/lib/Analysis/DependenceInfo.cpp
+++ b/lib/Analysis/DependenceInfo.cpp
@@ -26,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/lib/Analysis/PolyhedralInfo.cpp b/lib/Analysis/PolyhedralInfo.cpp
index d734d9e..2b5ed6f 100644
--- a/lib/Analysis/PolyhedralInfo.cpp
+++ b/lib/Analysis/PolyhedralInfo.cpp
@@ -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/lib/Analysis/PruneUnprofitable.cpp b/lib/Analysis/PruneUnprofitable.cpp
index 008c5f9..f2780a3 100644
--- a/lib/Analysis/PruneUnprofitable.cpp
+++ b/lib/Analysis/PruneUnprofitable.cpp
@@ -16,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/lib/Analysis/ScopBuilder.cpp b/lib/Analysis/ScopBuilder.cpp
index 6b7e073..3c44429 100644
--- a/lib/Analysis/ScopBuilder.cpp
+++ b/lib/Analysis/ScopBuilder.cpp
@@ -16,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"
@@ -36,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/lib/Analysis/ScopDetection.cpp b/lib/Analysis/ScopDetection.cpp
index 905f37e..25732b7 100644
--- a/lib/Analysis/ScopDetection.cpp
+++ b/lib/Analysis/ScopDetection.cpp
@@ -50,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"
@@ -76,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/lib/Analysis/ScopInfo.cpp b/lib/Analysis/ScopInfo.cpp
index 30c759d..f7e7898 100644
--- a/lib/Analysis/ScopInfo.cpp
+++ b/lib/Analysis/ScopInfo.cpp
@@ -29,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"
@@ -50,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;
diff --git a/lib/Analysis/ScopPass.cpp b/lib/Analysis/ScopPass.cpp
index 5898286..6e29998 100644
--- a/lib/Analysis/ScopPass.cpp
+++ b/lib/Analysis/ScopPass.cpp
@@ -12,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/lib/CodeGen/BlockGenerators.cpp b/lib/CodeGen/BlockGenerators.cpp
index 4990db8..389c8ac 100644
--- a/lib/CodeGen/BlockGenerators.cpp
+++ b/lib/CodeGen/BlockGenerators.cpp
@@ -13,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/lib/CodeGen/CodeGeneration.cpp b/lib/CodeGen/CodeGeneration.cpp
index af6a8db..784b7d8 100644
--- a/lib/CodeGen/CodeGeneration.cpp
+++ b/lib/CodeGen/CodeGeneration.cpp
@@ -27,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/lib/CodeGen/CodegenCleanup.cpp b/lib/CodeGen/CodegenCleanup.cpp
index 885bd9d..b1cf935 100644
--- a/lib/CodeGen/CodegenCleanup.cpp
+++ b/lib/CodeGen/CodegenCleanup.cpp
@@ -12,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/lib/CodeGen/IRBuilder.cpp b/lib/CodeGen/IRBuilder.cpp
index f93cf21..435be74 100644
--- a/lib/CodeGen/IRBuilder.cpp
+++ b/lib/CodeGen/IRBuilder.cpp
@@ -16,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/lib/CodeGen/IslAst.cpp b/lib/CodeGen/IslAst.cpp
index b228547..8ccbeda 100644
--- a/lib/CodeGen/IslAst.cpp
+++ b/lib/CodeGen/IslAst.cpp
@@ -37,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"
@@ -46,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"
@@ -54,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/lib/CodeGen/IslExprBuilder.cpp b/lib/CodeGen/IslExprBuilder.cpp
index 51b507a..c8e2984 100644
--- a/lib/CodeGen/IslExprBuilder.cpp
+++ b/lib/CodeGen/IslExprBuilder.cpp
@@ -13,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/lib/CodeGen/IslNodeBuilder.cpp b/lib/CodeGen/IslNodeBuilder.cpp
index 06a646f..492944c 100644
--- a/lib/CodeGen/IslNodeBuilder.cpp
+++ b/lib/CodeGen/IslNodeBuilder.cpp
@@ -19,10 +19,8 @@
 #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"
diff --git a/lib/CodeGen/LoopGeneratorsGOMP.cpp b/lib/CodeGen/LoopGeneratorsGOMP.cpp
index 0a16a87..9c93af9 100644
--- a/lib/CodeGen/LoopGeneratorsGOMP.cpp
+++ b/lib/CodeGen/LoopGeneratorsGOMP.cpp
@@ -11,13 +11,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/CodeGen/LoopGeneratorsGOMP.h"
-#include "polly/ScopDetection.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
 using namespace llvm;
 using namespace polly;
diff --git a/lib/CodeGen/LoopGeneratorsKMP.cpp b/lib/CodeGen/LoopGeneratorsKMP.cpp
index 653b211..d2ebdbc 100644
--- a/lib/CodeGen/LoopGeneratorsKMP.cpp
+++ b/lib/CodeGen/LoopGeneratorsKMP.cpp
@@ -11,14 +11,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/CodeGen/LoopGeneratorsKMP.h"
-#include "polly/Options.h"
-#include "polly/ScopDetection.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
 using namespace llvm;
 using namespace polly;
diff --git a/lib/CodeGen/ManagedMemoryRewrite.cpp b/lib/CodeGen/ManagedMemoryRewrite.cpp
index 8065eb8..8492b5f 100644
--- a/lib/CodeGen/ManagedMemoryRewrite.cpp
+++ b/lib/CodeGen/ManagedMemoryRewrite.cpp
@@ -15,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(
diff --git a/lib/CodeGen/PPCGCodeGeneration.cpp b/lib/CodeGen/PPCGCodeGeneration.cpp
index 2ed60b2..2516b33 100644
--- a/lib/CodeGen/PPCGCodeGeneration.cpp
+++ b/lib/CodeGen/PPCGCodeGeneration.cpp
@@ -24,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/lib/CodeGen/RuntimeDebugBuilder.cpp b/lib/CodeGen/RuntimeDebugBuilder.cpp
index 847c4a0..29cba08 100644
--- a/lib/CodeGen/RuntimeDebugBuilder.cpp
+++ b/lib/CodeGen/RuntimeDebugBuilder.cpp
@@ -11,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/lib/CodeGen/Utils.cpp b/lib/CodeGen/Utils.cpp
index 96f8c05..3afb2e5 100644
--- a/lib/CodeGen/Utils.cpp
+++ b/lib/CodeGen/Utils.cpp
@@ -15,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/lib/Exchange/JSONExporter.cpp b/lib/Exchange/JSONExporter.cpp
index c7c9b95..b9cb568 100644
--- a/lib/Exchange/JSONExporter.cpp
+++ b/lib/Exchange/JSONExporter.cpp
@@ -18,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/lib/Polly.cpp b/lib/Polly.cpp
index 6c539e9..e6bae93 100644
--- a/lib/Polly.cpp
+++ b/lib/Polly.cpp
@@ -9,7 +9,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/RegisterPasses.h"
-#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/PassRegistry.h"
 
 namespace {
 
diff --git a/lib/Support/DumpModulePass.cpp b/lib/Support/DumpModulePass.cpp
index 7a812b4..615fd75 100644
--- a/lib/Support/DumpModulePass.cpp
+++ b/lib/Support/DumpModulePass.cpp
@@ -11,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/lib/Support/GICHelper.cpp b/lib/Support/GICHelper.cpp
index 2495692..1230b48 100644
--- a/lib/Support/GICHelper.cpp
+++ b/lib/Support/GICHelper.cpp
@@ -9,18 +9,10 @@
 // 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/lib/Support/ISLTools.cpp b/lib/Support/ISLTools.cpp
index f7a5c10..2559262 100644
--- a/lib/Support/ISLTools.cpp
+++ b/lib/Support/ISLTools.cpp
@@ -12,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;
 
diff --git a/lib/Support/RegisterPasses.cpp b/lib/Support/RegisterPasses.cpp
index 676756d..1349bdc 100644
--- a/lib/Support/RegisterPasses.cpp
+++ b/lib/Support/RegisterPasses.cpp
@@ -23,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"
@@ -45,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;
diff --git a/lib/Support/SCEVAffinator.cpp b/lib/Support/SCEVAffinator.cpp
index c49204a..85e39e3 100644
--- a/lib/Support/SCEVAffinator.cpp
+++ b/lib/Support/SCEVAffinator.cpp
@@ -15,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/lib/Support/SCEVValidator.cpp b/lib/Support/SCEVValidator.cpp
index 6732f4b..84e9b87 100644
--- a/lib/Support/SCEVValidator.cpp
+++ b/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/lib/Support/ScopHelper.cpp b/lib/Support/ScopHelper.cpp
index aeeddfe..8c730c4 100644
--- a/lib/Support/ScopHelper.cpp
+++ b/lib/Support/ScopHelper.cpp
@@ -16,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/lib/Support/ScopLocation.cpp b/lib/Support/ScopLocation.cpp
index 3f8caf5..1b5e82e 100644
--- a/lib/Support/ScopLocation.cpp
+++ b/lib/Support/ScopLocation.cpp
@@ -12,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/lib/Support/VirtualInstruction.cpp b/lib/Support/VirtualInstruction.cpp
index 7d8697d..be055ac 100644
--- a/lib/Support/VirtualInstruction.cpp
+++ b/lib/Support/VirtualInstruction.cpp
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/Support/VirtualInstruction.h"
-#include "polly/Support/SCEVValidator.h"
 
 using namespace polly;
 using namespace llvm;
diff --git a/lib/Transform/Canonicalization.cpp b/lib/Transform/Canonicalization.cpp
index 31e3340..8945f1f 100644
--- a/lib/Transform/Canonicalization.cpp
+++ b/lib/Transform/Canonicalization.cpp
@@ -15,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/lib/Transform/CodePreparation.cpp b/lib/Transform/CodePreparation.cpp
index 1fb9473..a445d72 100644
--- a/lib/Transform/CodePreparation.cpp
+++ b/lib/Transform/CodePreparation.cpp
@@ -17,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/lib/Transform/DeLICM.cpp b/lib/Transform/DeLICM.cpp
index ebebc60..b229d60 100644
--- a/lib/Transform/DeLICM.cpp
+++ b/lib/Transform/DeLICM.cpp
@@ -15,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/lib/Transform/DeadCodeElimination.cpp b/lib/Transform/DeadCodeElimination.cpp
index 7a7fcad..cc8923c 100644
--- a/lib/Transform/DeadCodeElimination.cpp
+++ b/lib/Transform/DeadCodeElimination.cpp
@@ -36,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/lib/Transform/ForwardOpTree.cpp b/lib/Transform/ForwardOpTree.cpp
index 4aa4d42..ad31673 100644
--- a/lib/Transform/ForwardOpTree.cpp
+++ b/lib/Transform/ForwardOpTree.cpp
@@ -28,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/lib/Transform/MaximalStaticExpansion.cpp b/lib/Transform/MaximalStaticExpansion.cpp
index 7fcd022..a9e1c50 100644
--- a/lib/Transform/MaximalStaticExpansion.cpp
+++ b/lib/Transform/MaximalStaticExpansion.cpp
@@ -15,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/lib/Transform/RewriteByReferenceParameters.cpp b/lib/Transform/RewriteByReferenceParameters.cpp
index 16cf56a..494280e 100644
--- a/lib/Transform/RewriteByReferenceParameters.cpp
+++ b/lib/Transform/RewriteByReferenceParameters.cpp
@@ -16,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/lib/Transform/ScheduleOptimizer.cpp b/lib/Transform/ScheduleOptimizer.cpp
index fbcfcec..5554154 100644
--- a/lib/Transform/ScheduleOptimizer.cpp
+++ b/lib/Transform/ScheduleOptimizer.cpp
@@ -53,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/lib/Transform/ScopInliner.cpp b/lib/Transform/ScopInliner.cpp
index 76e43bd..7aaa367 100644
--- a/lib/Transform/ScopInliner.cpp
+++ b/lib/Transform/ScopInliner.cpp
@@ -14,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"