aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/include/llvm/Transforms
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/include/llvm/Transforms
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/Transforms')
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Coroutines.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroCleanup.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroEarly.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroElide.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroSplit.h10
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/HelloNew/HelloWorld.h68
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO.h24
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/AlwaysInliner.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/Annotation2Metadata.h82
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/Attributor.h1200
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/BlockExtractor.h72
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/IROutliner.h738
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/Inliner.h14
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/LoopExtractor.h86
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/LowerTypeTests.h14
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/OpenMPOpt.h20
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleContextTracker.h326
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfile.h10
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfileProbe.h316
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/StripSymbols.h116
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/IPO/WholeProgramDevirt.h6
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/InstCombine/InstCombiner.h1078
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation.h10
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/AddressSanitizer.h4
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/BoundsChecking.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h86
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/GCOVProfiler.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h38
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemProfiler.h124
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemorySanitizer.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/ObjCARC.h36
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar.h98
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h6
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/AnnotationRemarks.h74
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/ConstraintElimination.h70
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/DCE.h12
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/GVN.h24
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/IndVarSimplify.h8
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/InferAddressSpaces.h76
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/JumpThreading.h74
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopFlatten.h86
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h26
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopInterchange.h70
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopPassManager.h522
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopReroll.h76
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopRotation.h6
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopUnrollPass.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopVersioningLICM.h72
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerAtomic.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h6
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h14
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/MemCpyOptimizer.h36
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/NaryReassociate.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/Reg2Mem.h76
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/SROA.h6
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h80
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h76
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/SimplifyCFG.h4
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h70
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Scalar/StructurizeCFG.h62
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h236
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h8
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h86
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h124
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h62
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h62
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h48
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h102
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h4
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h144
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h26
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h74
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h210
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h74
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h38
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h940
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h176
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h46
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h2
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h72
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h74
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h20
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h66
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h114
-rw-r--r--contrib/libs/llvm12/include/llvm/Transforms/Vectorize/SLPVectorizer.h8
89 files changed, 4527 insertions, 4527 deletions
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines.h b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines.h
index 2dbf762461..e0cc7db8cd 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines.h
@@ -30,7 +30,7 @@ void addCoroutinePassesToExtensionPoints(PassManagerBuilder &Builder);
Pass *createCoroEarlyLegacyPass();
/// Split up coroutines into multiple functions driving their state machines.
-Pass *createCoroSplitLegacyPass(bool ReuseFrameSlot = false);
+Pass *createCoroSplitLegacyPass(bool ReuseFrameSlot = false);
/// Analyze coroutines use sites, devirtualize resume/destroy calls and elide
/// heap allocation for coroutine frame where possible.
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroCleanup.h b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroCleanup.h
index a7f525fe9d..c7031cf032 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroCleanup.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroCleanup.h
@@ -29,7 +29,7 @@ class Function;
struct CoroCleanupPass : PassInfoMixin<CoroCleanupPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
} // end namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroEarly.h b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroEarly.h
index 6d6e4907c8..fe343cd386 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroEarly.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroEarly.h
@@ -32,7 +32,7 @@ class Function;
struct CoroEarlyPass : PassInfoMixin<CoroEarlyPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
} // end namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroElide.h b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroElide.h
index af75801fc8..cc469fa2c8 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroElide.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroElide.h
@@ -31,7 +31,7 @@ class Function;
struct CoroElidePass : PassInfoMixin<CoroElidePass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
} // end namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroSplit.h b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroSplit.h
index ed26d9bb64..c5268f2ef6 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroSplit.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Coroutines/CoroSplit.h
@@ -29,13 +29,13 @@
namespace llvm {
struct CoroSplitPass : PassInfoMixin<CoroSplitPass> {
- CoroSplitPass(bool ReuseFrameSlot = false) : ReuseFrameSlot(ReuseFrameSlot) {}
-
+ CoroSplitPass(bool ReuseFrameSlot = false) : ReuseFrameSlot(ReuseFrameSlot) {}
+
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
- static bool isRequired() { return true; }
-
- bool ReuseFrameSlot;
+ static bool isRequired() { return true; }
+
+ bool ReuseFrameSlot;
};
} // end namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/HelloNew/HelloWorld.h b/contrib/libs/llvm12/include/llvm/Transforms/HelloNew/HelloWorld.h
index c25f3ccfb6..7421f01864 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/HelloNew/HelloWorld.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/HelloNew/HelloWorld.h
@@ -1,34 +1,34 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===-- HelloWorld.h - Example Transformations ------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_HELLONEW_HELLOWORLD_H
-#define LLVM_TRANSFORMS_HELLONEW_HELLOWORLD_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_HELLONEW_HELLOWORLD_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===-- HelloWorld.h - Example Transformations ------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_HELLONEW_HELLOWORLD_H
+#define LLVM_TRANSFORMS_HELLONEW_HELLOWORLD_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_HELLONEW_HELLOWORLD_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO.h
index c270acfe87..79b0313aea 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO.h
@@ -38,13 +38,13 @@ class raw_ostream;
//===----------------------------------------------------------------------===//
//
-// This pass adds !annotation metadata to entries in the
-// @llvm.global.annotations global constant.
-//
-ModulePass *createAnnotation2MetadataLegacyPass();
-
-//===----------------------------------------------------------------------===//
-//
+// This pass adds !annotation metadata to entries in the
+// @llvm.global.annotations global constant.
+//
+ModulePass *createAnnotation2MetadataLegacyPass();
+
+//===----------------------------------------------------------------------===//
+//
// These functions removes symbols from functions and modules. If OnlyDebugInfo
// is true, only debugging information is removed from the module.
//
@@ -223,11 +223,11 @@ ModulePass *createMergeFunctionsPass();
ModulePass *createHotColdSplittingPass();
//===----------------------------------------------------------------------===//
-/// createIROutlinerPass - This pass finds similar code regions and factors
-/// those regions out into functions.
-ModulePass *createIROutlinerPass();
-
-//===----------------------------------------------------------------------===//
+/// createIROutlinerPass - This pass finds similar code regions and factors
+/// those regions out into functions.
+ModulePass *createIROutlinerPass();
+
+//===----------------------------------------------------------------------===//
/// createPartialInliningPass - This pass inlines parts of functions.
///
ModulePass *createPartialInliningPass();
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/AlwaysInliner.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/AlwaysInliner.h
index 4a9764b855..06ae0fecb4 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/AlwaysInliner.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/AlwaysInliner.h
@@ -41,7 +41,7 @@ public:
: InsertLifetime(InsertLifetime) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
/// Create a legacy pass manager instance of a pass to inline and remove
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/Annotation2Metadata.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/Annotation2Metadata.h
index 198d4cfc2c..17740ca383 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/Annotation2Metadata.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/Annotation2Metadata.h
@@ -1,41 +1,41 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- Annotation2Metadata.h - Add !annotation metadata. --------*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-// New pass manager pass to convert @llvm.global.annotations to !annotation
-// metadata.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_IPO_ANNOTATION2METADATA_H
-#define LLVM_TRANSFORMS_IPO_ANNOTATION2METADATA_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class Module;
-
-/// Pass to convert @llvm.global.annotations to !annotation metadata.
-struct Annotation2MetadataPass : public PassInfoMixin<Annotation2MetadataPass> {
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_IPO_SCCP_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- Annotation2Metadata.h - Add !annotation metadata. --------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// New pass manager pass to convert @llvm.global.annotations to !annotation
+// metadata.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_ANNOTATION2METADATA_H
+#define LLVM_TRANSFORMS_IPO_ANNOTATION2METADATA_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class Module;
+
+/// Pass to convert @llvm.global.annotations to !annotation metadata.
+struct Annotation2MetadataPass : public PassInfoMixin<Annotation2MetadataPass> {
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_IPO_SCCP_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/Attributor.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/Attributor.h
index fd82945466..96681071db 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/Attributor.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/Attributor.h
@@ -104,10 +104,10 @@
#ifndef LLVM_TRANSFORMS_IPO_ATTRIBUTOR_H
#define LLVM_TRANSFORMS_IPO_ATTRIBUTOR_H
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/MapVector.h"
-#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/AssumeBundleQueries.h"
#include "llvm/Analysis/CFG.h"
@@ -121,27 +121,27 @@
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Allocator.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/TimeProfiler.h"
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
namespace llvm {
-struct AADepGraphNode;
-struct AADepGraph;
+struct AADepGraphNode;
+struct AADepGraph;
struct Attributor;
struct AbstractAttribute;
struct InformationCache;
struct AAIsDead;
-class AAManager;
-class AAResults;
+class AAManager;
+class AAResults;
class Function;
-/// The value passed to the line option that defines the maximal initialization
-/// chain length.
-extern unsigned MaxInitializationChainLength;
-
+/// The value passed to the line option that defines the maximal initialization
+/// chain length.
+extern unsigned MaxInitializationChainLength;
+
///{
enum class ChangeStatus {
CHANGED,
@@ -157,74 +157,74 @@ enum class DepClassTy {
};
///}
-/// The data structure for the nodes of a dependency graph
-struct AADepGraphNode {
-public:
- virtual ~AADepGraphNode(){};
- using DepTy = PointerIntPair<AADepGraphNode *, 1>;
-
-protected:
- /// Set of dependency graph nodes which should be updated if this one
- /// is updated. The bit encodes if it is optional.
- TinyPtrVector<DepTy> Deps;
-
- static AADepGraphNode *DepGetVal(DepTy &DT) { return DT.getPointer(); }
- static AbstractAttribute *DepGetValAA(DepTy &DT) {
- return cast<AbstractAttribute>(DT.getPointer());
- }
-
- operator AbstractAttribute *() { return cast<AbstractAttribute>(this); }
-
-public:
- using iterator =
- mapped_iterator<TinyPtrVector<DepTy>::iterator, decltype(&DepGetVal)>;
- using aaiterator =
- mapped_iterator<TinyPtrVector<DepTy>::iterator, decltype(&DepGetValAA)>;
-
- aaiterator begin() { return aaiterator(Deps.begin(), &DepGetValAA); }
- aaiterator end() { return aaiterator(Deps.end(), &DepGetValAA); }
- iterator child_begin() { return iterator(Deps.begin(), &DepGetVal); }
- iterator child_end() { return iterator(Deps.end(), &DepGetVal); }
-
- virtual void print(raw_ostream &OS) const { OS << "AADepNode Impl\n"; }
- TinyPtrVector<DepTy> &getDeps() { return Deps; }
-
- friend struct Attributor;
- friend struct AADepGraph;
-};
-
-/// The data structure for the dependency graph
-///
-/// Note that in this graph if there is an edge from A to B (A -> B),
-/// then it means that B depends on A, and when the state of A is
-/// updated, node B should also be updated
-struct AADepGraph {
- AADepGraph() {}
- ~AADepGraph() {}
-
- using DepTy = AADepGraphNode::DepTy;
- static AADepGraphNode *DepGetVal(DepTy &DT) { return DT.getPointer(); }
- using iterator =
- mapped_iterator<TinyPtrVector<DepTy>::iterator, decltype(&DepGetVal)>;
-
- /// There is no root node for the dependency graph. But the SCCIterator
- /// requires a single entry point, so we maintain a fake("synthetic") root
- /// node that depends on every node.
- AADepGraphNode SyntheticRoot;
- AADepGraphNode *GetEntryNode() { return &SyntheticRoot; }
-
- iterator begin() { return SyntheticRoot.child_begin(); }
- iterator end() { return SyntheticRoot.child_end(); }
-
- void viewGraph();
-
- /// Dump graph to file
- void dumpGraph();
-
- /// Print dependency graph
- void print();
-};
-
+/// The data structure for the nodes of a dependency graph
+struct AADepGraphNode {
+public:
+ virtual ~AADepGraphNode(){};
+ using DepTy = PointerIntPair<AADepGraphNode *, 1>;
+
+protected:
+ /// Set of dependency graph nodes which should be updated if this one
+ /// is updated. The bit encodes if it is optional.
+ TinyPtrVector<DepTy> Deps;
+
+ static AADepGraphNode *DepGetVal(DepTy &DT) { return DT.getPointer(); }
+ static AbstractAttribute *DepGetValAA(DepTy &DT) {
+ return cast<AbstractAttribute>(DT.getPointer());
+ }
+
+ operator AbstractAttribute *() { return cast<AbstractAttribute>(this); }
+
+public:
+ using iterator =
+ mapped_iterator<TinyPtrVector<DepTy>::iterator, decltype(&DepGetVal)>;
+ using aaiterator =
+ mapped_iterator<TinyPtrVector<DepTy>::iterator, decltype(&DepGetValAA)>;
+
+ aaiterator begin() { return aaiterator(Deps.begin(), &DepGetValAA); }
+ aaiterator end() { return aaiterator(Deps.end(), &DepGetValAA); }
+ iterator child_begin() { return iterator(Deps.begin(), &DepGetVal); }
+ iterator child_end() { return iterator(Deps.end(), &DepGetVal); }
+
+ virtual void print(raw_ostream &OS) const { OS << "AADepNode Impl\n"; }
+ TinyPtrVector<DepTy> &getDeps() { return Deps; }
+
+ friend struct Attributor;
+ friend struct AADepGraph;
+};
+
+/// The data structure for the dependency graph
+///
+/// Note that in this graph if there is an edge from A to B (A -> B),
+/// then it means that B depends on A, and when the state of A is
+/// updated, node B should also be updated
+struct AADepGraph {
+ AADepGraph() {}
+ ~AADepGraph() {}
+
+ using DepTy = AADepGraphNode::DepTy;
+ static AADepGraphNode *DepGetVal(DepTy &DT) { return DT.getPointer(); }
+ using iterator =
+ mapped_iterator<TinyPtrVector<DepTy>::iterator, decltype(&DepGetVal)>;
+
+ /// There is no root node for the dependency graph. But the SCCIterator
+ /// requires a single entry point, so we maintain a fake("synthetic") root
+ /// node that depends on every node.
+ AADepGraphNode SyntheticRoot;
+ AADepGraphNode *GetEntryNode() { return &SyntheticRoot; }
+
+ iterator begin() { return SyntheticRoot.child_begin(); }
+ iterator end() { return SyntheticRoot.child_end(); }
+
+ void viewGraph();
+
+ /// Dump graph to file
+ void dumpGraph();
+
+ /// Print dependency graph
+ void print();
+};
+
/// Helper to describe and deal with positions in the LLVM-IR.
///
/// A position in the IR is described by an anchor value and an "offset" that
@@ -344,14 +344,14 @@ struct IRPosition {
/// Return the associated function, if any.
Function *getAssociatedFunction() const {
- if (auto *CB = dyn_cast<CallBase>(&getAnchorValue())) {
- // We reuse the logic that associates callback calles to arguments of a
- // call site here to identify the callback callee as the associated
- // function.
- if (Argument *Arg = getAssociatedArgument())
- return Arg->getParent();
+ if (auto *CB = dyn_cast<CallBase>(&getAnchorValue())) {
+ // We reuse the logic that associates callback calles to arguments of a
+ // call site here to identify the callback callee as the associated
+ // function.
+ if (Argument *Arg = getAssociatedArgument())
+ return Arg->getParent();
return CB->getCalledFunction();
- }
+ }
return getAnchorScope();
}
@@ -399,11 +399,11 @@ struct IRPosition {
/// Return the value this abstract attribute is associated with.
Value &getAssociatedValue() const {
- if (getCallSiteArgNo() < 0 || isa<Argument>(&getAnchorValue()))
+ if (getCallSiteArgNo() < 0 || isa<Argument>(&getAnchorValue()))
return getAnchorValue();
assert(isa<CallBase>(&getAnchorValue()) && "Expected a call base!");
- return *cast<CallBase>(&getAnchorValue())
- ->getArgOperand(getCallSiteArgNo());
+ return *cast<CallBase>(&getAnchorValue())
+ ->getArgOperand(getCallSiteArgNo());
}
/// Return the type this abstract attribute is associated with.
@@ -413,24 +413,24 @@ struct IRPosition {
return getAssociatedValue().getType();
}
- /// Return the callee argument number of the associated value if it is an
- /// argument or call site argument, otherwise a negative value. In contrast to
- /// `getCallSiteArgNo` this method will always return the "argument number"
- /// from the perspective of the callee. This may not the same as the call site
- /// if this is a callback call.
- int getCalleeArgNo() const {
- return getArgNo(/* CallbackCalleeArgIfApplicable */ true);
- }
-
- /// Return the call site argument number of the associated value if it is an
- /// argument or call site argument, otherwise a negative value. In contrast to
- /// `getCalleArgNo` this method will always return the "operand number" from
- /// the perspective of the call site. This may not the same as the callee
- /// perspective if this is a callback call.
- int getCallSiteArgNo() const {
- return getArgNo(/* CallbackCalleeArgIfApplicable */ false);
- }
-
+ /// Return the callee argument number of the associated value if it is an
+ /// argument or call site argument, otherwise a negative value. In contrast to
+ /// `getCallSiteArgNo` this method will always return the "argument number"
+ /// from the perspective of the callee. This may not the same as the call site
+ /// if this is a callback call.
+ int getCalleeArgNo() const {
+ return getArgNo(/* CallbackCalleeArgIfApplicable */ true);
+ }
+
+ /// Return the call site argument number of the associated value if it is an
+ /// argument or call site argument, otherwise a negative value. In contrast to
+ /// `getCalleArgNo` this method will always return the "operand number" from
+ /// the perspective of the call site. This may not the same as the callee
+ /// perspective if this is a callback call.
+ int getCallSiteArgNo() const {
+ return getArgNo(/* CallbackCalleeArgIfApplicable */ false);
+ }
+
/// Return the index in the attribute list for this position.
unsigned getAttrIdx() const {
switch (getPositionKind()) {
@@ -445,7 +445,7 @@ struct IRPosition {
return AttributeList::ReturnIndex;
case IRPosition::IRP_ARGUMENT:
case IRPosition::IRP_CALL_SITE_ARGUMENT:
- return getCallSiteArgNo() + AttributeList::FirstArgIndex;
+ return getCallSiteArgNo() + AttributeList::FirstArgIndex;
}
llvm_unreachable(
"There is no attribute index for a floating or invalid position!");
@@ -530,17 +530,17 @@ struct IRPosition {
}
}
- /// Return true if the position is an argument or call site argument.
- bool isArgumentPosition() const {
- switch (getPositionKind()) {
- case IRPosition::IRP_ARGUMENT:
- case IRPosition::IRP_CALL_SITE_ARGUMENT:
- return true;
- default:
- return false;
- }
- }
-
+ /// Return true if the position is an argument or call site argument.
+ bool isArgumentPosition() const {
+ switch (getPositionKind()) {
+ case IRPosition::IRP_ARGUMENT:
+ case IRPosition::IRP_CALL_SITE_ARGUMENT:
+ return true;
+ default:
+ return false;
+ }
+ }
+
/// Special DenseMap key values.
///
///{
@@ -587,25 +587,25 @@ private:
verify();
}
- /// Return the callee argument number of the associated value if it is an
- /// argument or call site argument. See also `getCalleeArgNo` and
- /// `getCallSiteArgNo`.
- int getArgNo(bool CallbackCalleeArgIfApplicable) const {
- if (CallbackCalleeArgIfApplicable)
- if (Argument *Arg = getAssociatedArgument())
- return Arg->getArgNo();
- switch (getPositionKind()) {
- case IRPosition::IRP_ARGUMENT:
- return cast<Argument>(getAsValuePtr())->getArgNo();
- case IRPosition::IRP_CALL_SITE_ARGUMENT: {
- Use &U = *getAsUsePtr();
- return cast<CallBase>(U.getUser())->getArgOperandNo(&U);
- }
- default:
- return -1;
- }
- }
-
+ /// Return the callee argument number of the associated value if it is an
+ /// argument or call site argument. See also `getCalleeArgNo` and
+ /// `getCallSiteArgNo`.
+ int getArgNo(bool CallbackCalleeArgIfApplicable) const {
+ if (CallbackCalleeArgIfApplicable)
+ if (Argument *Arg = getAssociatedArgument())
+ return Arg->getArgNo();
+ switch (getPositionKind()) {
+ case IRPosition::IRP_ARGUMENT:
+ return cast<Argument>(getAsValuePtr())->getArgNo();
+ case IRPosition::IRP_CALL_SITE_ARGUMENT: {
+ Use &U = *getAsUsePtr();
+ return cast<CallBase>(U.getUser())->getArgOperandNo(&U);
+ }
+ default:
+ return -1;
+ }
+ }
+
/// IRPosition for the use \p U. The position kind \p PK needs to be
/// IRP_CALL_SITE_ARGUMENT, the anchor value is the user, the associated value
/// the used value.
@@ -769,10 +769,10 @@ struct InformationCache {
[&](const Function &F) {
return AG.getAnalysis<PostDominatorTreeAnalysis>(F);
}),
- AG(AG), CGSCC(CGSCC) {
- if (CGSCC)
- initializeModuleSlice(*CGSCC);
- }
+ AG(AG), CGSCC(CGSCC) {
+ if (CGSCC)
+ initializeModuleSlice(*CGSCC);
+ }
~InformationCache() {
// The FunctionInfo objects are allocated via a BumpPtrAllocator, we call
@@ -781,68 +781,68 @@ struct InformationCache {
It.getSecond()->~FunctionInfo();
}
- /// Apply \p CB to all uses of \p F. If \p LookThroughConstantExprUses is
- /// true, constant expression users are not given to \p CB but their uses are
- /// traversed transitively.
- template <typename CBTy>
- static void foreachUse(Function &F, CBTy CB,
- bool LookThroughConstantExprUses = true) {
- SmallVector<Use *, 8> Worklist(make_pointer_range(F.uses()));
-
- for (unsigned Idx = 0; Idx < Worklist.size(); ++Idx) {
- Use &U = *Worklist[Idx];
-
- // Allow use in constant bitcasts and simply look through them.
- if (LookThroughConstantExprUses && isa<ConstantExpr>(U.getUser())) {
- for (Use &CEU : cast<ConstantExpr>(U.getUser())->uses())
- Worklist.push_back(&CEU);
- continue;
- }
-
- CB(U);
- }
- }
-
- /// Initialize the ModuleSlice member based on \p SCC. ModuleSlices contains
- /// (a subset of) all functions that we can look at during this SCC traversal.
- /// This includes functions (transitively) called from the SCC and the
- /// (transitive) callers of SCC functions. We also can look at a function if
- /// there is a "reference edge", i.a., if the function somehow uses (!=calls)
- /// a function in the SCC or a caller of a function in the SCC.
- void initializeModuleSlice(SetVector<Function *> &SCC) {
- ModuleSlice.insert(SCC.begin(), SCC.end());
-
- SmallPtrSet<Function *, 16> Seen;
- SmallVector<Function *, 16> Worklist(SCC.begin(), SCC.end());
- while (!Worklist.empty()) {
- Function *F = Worklist.pop_back_val();
- ModuleSlice.insert(F);
-
- for (Instruction &I : instructions(*F))
- if (auto *CB = dyn_cast<CallBase>(&I))
- if (Function *Callee = CB->getCalledFunction())
- if (Seen.insert(Callee).second)
- Worklist.push_back(Callee);
- }
-
- Seen.clear();
- Worklist.append(SCC.begin(), SCC.end());
- while (!Worklist.empty()) {
- Function *F = Worklist.pop_back_val();
- ModuleSlice.insert(F);
-
- // Traverse all transitive uses.
- foreachUse(*F, [&](Use &U) {
- if (auto *UsrI = dyn_cast<Instruction>(U.getUser()))
- if (Seen.insert(UsrI->getFunction()).second)
- Worklist.push_back(UsrI->getFunction());
- });
- }
- }
-
- /// The slice of the module we are allowed to look at.
- SmallPtrSet<Function *, 8> ModuleSlice;
-
+ /// Apply \p CB to all uses of \p F. If \p LookThroughConstantExprUses is
+ /// true, constant expression users are not given to \p CB but their uses are
+ /// traversed transitively.
+ template <typename CBTy>
+ static void foreachUse(Function &F, CBTy CB,
+ bool LookThroughConstantExprUses = true) {
+ SmallVector<Use *, 8> Worklist(make_pointer_range(F.uses()));
+
+ for (unsigned Idx = 0; Idx < Worklist.size(); ++Idx) {
+ Use &U = *Worklist[Idx];
+
+ // Allow use in constant bitcasts and simply look through them.
+ if (LookThroughConstantExprUses && isa<ConstantExpr>(U.getUser())) {
+ for (Use &CEU : cast<ConstantExpr>(U.getUser())->uses())
+ Worklist.push_back(&CEU);
+ continue;
+ }
+
+ CB(U);
+ }
+ }
+
+ /// Initialize the ModuleSlice member based on \p SCC. ModuleSlices contains
+ /// (a subset of) all functions that we can look at during this SCC traversal.
+ /// This includes functions (transitively) called from the SCC and the
+ /// (transitive) callers of SCC functions. We also can look at a function if
+ /// there is a "reference edge", i.a., if the function somehow uses (!=calls)
+ /// a function in the SCC or a caller of a function in the SCC.
+ void initializeModuleSlice(SetVector<Function *> &SCC) {
+ ModuleSlice.insert(SCC.begin(), SCC.end());
+
+ SmallPtrSet<Function *, 16> Seen;
+ SmallVector<Function *, 16> Worklist(SCC.begin(), SCC.end());
+ while (!Worklist.empty()) {
+ Function *F = Worklist.pop_back_val();
+ ModuleSlice.insert(F);
+
+ for (Instruction &I : instructions(*F))
+ if (auto *CB = dyn_cast<CallBase>(&I))
+ if (Function *Callee = CB->getCalledFunction())
+ if (Seen.insert(Callee).second)
+ Worklist.push_back(Callee);
+ }
+
+ Seen.clear();
+ Worklist.append(SCC.begin(), SCC.end());
+ while (!Worklist.empty()) {
+ Function *F = Worklist.pop_back_val();
+ ModuleSlice.insert(F);
+
+ // Traverse all transitive uses.
+ foreachUse(*F, [&](Use &U) {
+ if (auto *UsrI = dyn_cast<Instruction>(U.getUser()))
+ if (Seen.insert(UsrI->getFunction()).second)
+ Worklist.push_back(UsrI->getFunction());
+ });
+ }
+ }
+
+ /// The slice of the module we are allowed to look at.
+ SmallPtrSet<Function *, 8> ModuleSlice;
+
/// A vector type to hold instructions.
using InstructionVectorTy = SmallVector<Instruction *, 8>;
@@ -871,7 +871,7 @@ struct InformationCache {
}
/// Return AliasAnalysis Result for function \p F.
- AAResults *getAAResultsForFunction(const Function &F);
+ AAResults *getAAResultsForFunction(const Function &F);
/// Return true if \p Arg is involved in a must-tail call, thus the argument
/// of the caller or callee.
@@ -899,26 +899,26 @@ struct InformationCache {
/// Return the map conaining all the knowledge we have from `llvm.assume`s.
const RetainedKnowledgeMap &getKnowledgeMap() const { return KnowledgeMap; }
- /// Return if \p To is potentially reachable form \p From or not
- /// If the same query was answered, return cached result
- bool getPotentiallyReachable(const Instruction &From, const Instruction &To) {
- auto KeyPair = std::make_pair(&From, &To);
- auto Iter = PotentiallyReachableMap.find(KeyPair);
- if (Iter != PotentiallyReachableMap.end())
- return Iter->second;
- const Function &F = *From.getFunction();
- bool Result = isPotentiallyReachable(
- &From, &To, nullptr, AG.getAnalysis<DominatorTreeAnalysis>(F),
- AG.getAnalysis<LoopAnalysis>(F));
- PotentiallyReachableMap.insert(std::make_pair(KeyPair, Result));
- return Result;
- }
-
- /// Check whether \p F is part of module slice.
- bool isInModuleSlice(const Function &F) {
- return ModuleSlice.count(const_cast<Function *>(&F));
- }
-
+ /// Return if \p To is potentially reachable form \p From or not
+ /// If the same query was answered, return cached result
+ bool getPotentiallyReachable(const Instruction &From, const Instruction &To) {
+ auto KeyPair = std::make_pair(&From, &To);
+ auto Iter = PotentiallyReachableMap.find(KeyPair);
+ if (Iter != PotentiallyReachableMap.end())
+ return Iter->second;
+ const Function &F = *From.getFunction();
+ bool Result = isPotentiallyReachable(
+ &From, &To, nullptr, AG.getAnalysis<DominatorTreeAnalysis>(F),
+ AG.getAnalysis<LoopAnalysis>(F));
+ PotentiallyReachableMap.insert(std::make_pair(KeyPair, Result));
+ return Result;
+ }
+
+ /// Check whether \p F is part of module slice.
+ bool isInModuleSlice(const Function &F) {
+ return ModuleSlice.count(const_cast<Function *>(&F));
+ }
+
private:
struct FunctionInfo {
~FunctionInfo();
@@ -978,10 +978,10 @@ private:
/// Set of inlineable functions
SmallPtrSet<const Function *, 8> InlineableFunctions;
- /// A map for caching results of queries for isPotentiallyReachable
- DenseMap<std::pair<const Instruction *, const Instruction *>, bool>
- PotentiallyReachableMap;
-
+ /// A map for caching results of queries for isPotentiallyReachable
+ DenseMap<std::pair<const Instruction *, const Instruction *>, bool>
+ PotentiallyReachableMap;
+
/// Give the Attributor access to the members so
/// Attributor::identifyDefaultAbstractAttributes(...) can initialize them.
friend struct Attributor;
@@ -1084,7 +1084,7 @@ struct Attributor {
/// attribute. Using this after Attributor started running is restricted to
/// only the Attributor itself. Initial seeding of AAs can be done via this
/// function.
- /// NOTE: ForceUpdate is ignored in any stage other than the update stage.
+ /// NOTE: ForceUpdate is ignored in any stage other than the update stage.
template <typename AAType>
const AAType &getOrCreateAAFor(const IRPosition &IRP,
const AbstractAttribute *QueryingAA = nullptr,
@@ -1092,7 +1092,7 @@ struct Attributor {
DepClassTy DepClass = DepClassTy::OPTIONAL,
bool ForceUpdate = false) {
if (AAType *AAPtr = lookupAAFor<AAType>(IRP, QueryingAA, TrackDependence)) {
- if (ForceUpdate && Phase == AttributorPhase::UPDATE)
+ if (ForceUpdate && Phase == AttributorPhase::UPDATE)
updateAA(*AAPtr);
return *AAPtr;
}
@@ -1102,7 +1102,7 @@ struct Attributor {
auto &AA = AAType::createForPosition(IRP, *this);
// If we are currenty seeding attributes, enforce seeding rules.
- if (Phase == AttributorPhase::SEEDING && !shouldSeedAttribute(AA)) {
+ if (Phase == AttributorPhase::SEEDING && !shouldSeedAttribute(AA)) {
AA.getState().indicatePessimisticFixpoint();
return AA;
}
@@ -1116,9 +1116,9 @@ struct Attributor {
Invalidate |= FnScope->hasFnAttribute(Attribute::Naked) ||
FnScope->hasFnAttribute(Attribute::OptimizeNone);
- // Avoid too many nested initializations to prevent a stack overflow.
- Invalidate |= InitializationChainLength > MaxInitializationChainLength;
-
+ // Avoid too many nested initializations to prevent a stack overflow.
+ Invalidate |= InitializationChainLength > MaxInitializationChainLength;
+
// Bootstrap the new attribute with an initial update to propagate
// information, e.g., function -> call site. If it is not on a given
// Allowed we will not perform updates at all.
@@ -1127,39 +1127,39 @@ struct Attributor {
return AA;
}
- {
- TimeTraceScope TimeScope(AA.getName() + "::initialize");
- ++InitializationChainLength;
- AA.initialize(*this);
- --InitializationChainLength;
- }
-
- // Initialize and update is allowed for code outside of the current function
- // set, but only if it is part of module slice we are allowed to look at.
- // Only exception is AAIsDeadFunction whose initialization is prevented
- // directly, since we don't to compute it twice.
+ {
+ TimeTraceScope TimeScope(AA.getName() + "::initialize");
+ ++InitializationChainLength;
+ AA.initialize(*this);
+ --InitializationChainLength;
+ }
+
+ // Initialize and update is allowed for code outside of the current function
+ // set, but only if it is part of module slice we are allowed to look at.
+ // Only exception is AAIsDeadFunction whose initialization is prevented
+ // directly, since we don't to compute it twice.
if (FnScope && !Functions.count(const_cast<Function *>(FnScope))) {
- if (!getInfoCache().isInModuleSlice(*FnScope)) {
- AA.getState().indicatePessimisticFixpoint();
- return AA;
- }
- }
-
- // If this is queried in the manifest stage, we force the AA to indicate
- // pessimistic fixpoint immediately.
- if (Phase == AttributorPhase::MANIFEST) {
+ if (!getInfoCache().isInModuleSlice(*FnScope)) {
+ AA.getState().indicatePessimisticFixpoint();
+ return AA;
+ }
+ }
+
+ // If this is queried in the manifest stage, we force the AA to indicate
+ // pessimistic fixpoint immediately.
+ if (Phase == AttributorPhase::MANIFEST) {
AA.getState().indicatePessimisticFixpoint();
return AA;
}
// Allow seeded attributes to declare dependencies.
// Remember the seeding state.
- AttributorPhase OldPhase = Phase;
- Phase = AttributorPhase::UPDATE;
+ AttributorPhase OldPhase = Phase;
+ Phase = AttributorPhase::UPDATE;
updateAA(AA);
- Phase = OldPhase;
+ Phase = OldPhase;
if (TrackDependence && AA.getState().isValidState())
recordDependence(AA, const_cast<AbstractAttribute &>(*QueryingAA),
@@ -1228,11 +1228,11 @@ struct Attributor {
assert(!AAPtr && "Attribute already in map!");
AAPtr = &AA;
- // Register AA with the synthetic root only before the manifest stage.
- if (Phase == AttributorPhase::SEEDING || Phase == AttributorPhase::UPDATE)
- DG.SyntheticRoot.Deps.push_back(
- AADepGraphNode::DepTy(&AA, unsigned(DepClassTy::REQUIRED)));
-
+ // Register AA with the synthetic root only before the manifest stage.
+ if (Phase == AttributorPhase::SEEDING || Phase == AttributorPhase::UPDATE)
+ DG.SyntheticRoot.Deps.push_back(
+ AADepGraphNode::DepTy(&AA, unsigned(DepClassTy::REQUIRED)));
+
return AA;
}
@@ -1541,22 +1541,22 @@ struct Attributor {
bool checkForAllReadWriteInstructions(function_ref<bool(Instruction &)> Pred,
AbstractAttribute &QueryingAA);
- /// Create a shallow wrapper for \p F such that \p F has internal linkage
- /// afterwards. It also sets the original \p F 's name to anonymous
- ///
- /// A wrapper is a function with the same type (and attributes) as \p F
- /// that will only call \p F and return the result, if any.
- ///
- /// Assuming the declaration of looks like:
- /// rty F(aty0 arg0, ..., atyN argN);
- ///
- /// The wrapper will then look as follows:
- /// rty wrapper(aty0 arg0, ..., atyN argN) {
- /// return F(arg0, ..., argN);
- /// }
- ///
- static void createShallowWrapper(Function &F);
-
+ /// Create a shallow wrapper for \p F such that \p F has internal linkage
+ /// afterwards. It also sets the original \p F 's name to anonymous
+ ///
+ /// A wrapper is a function with the same type (and attributes) as \p F
+ /// that will only call \p F and return the result, if any.
+ ///
+ /// Assuming the declaration of looks like:
+ /// rty F(aty0 arg0, ..., atyN argN);
+ ///
+ /// The wrapper will then look as follows:
+ /// rty wrapper(aty0 arg0, ..., atyN argN) {
+ /// return F(arg0, ..., argN);
+ /// }
+ ///
+ static void createShallowWrapper(Function &F);
+
/// Return the data layout associated with the anchor scope.
const DataLayout &getDataLayout() const { return InfoCache.DL; }
@@ -1580,10 +1580,10 @@ private:
/// Rewrites function signitures and updates the call graph.
ChangeStatus cleanupIR();
- /// Identify internal functions that are effectively dead, thus not reachable
- /// from a live entry point. The functions are added to ToBeDeletedFunctions.
- void identifyDeadInternalFunctions();
-
+ /// Identify internal functions that are effectively dead, thus not reachable
+ /// from a live entry point. The functions are added to ToBeDeletedFunctions.
+ void identifyDeadInternalFunctions();
+
/// Run `::update` on \p AA and track the dependences queried while doing so.
/// Also adjust the state if we know further updates are not necessary.
ChangeStatus updateAA(AbstractAttribute &AA);
@@ -1635,9 +1635,9 @@ private:
/// Helper to update an underlying call graph.
CallGraphUpdater &CGUpdater;
- /// Abstract Attribute dependency graph
- AADepGraph DG;
-
+ /// Abstract Attribute dependency graph
+ AADepGraph DG;
+
/// Set of functions for which we modified the content such that it might
/// impact the call graph.
SmallPtrSet<Function *, 8> CGModifiedFunctions;
@@ -1676,18 +1676,18 @@ private:
/// Invoke instructions with at least a single dead successor block.
SmallVector<WeakVH, 16> InvokeWithDeadSuccessor;
- /// A flag that indicates which stage of the process we are in. Initially, the
- /// phase is SEEDING. Phase is changed in `Attributor::run()`
- enum class AttributorPhase {
- SEEDING,
- UPDATE,
- MANIFEST,
- CLEANUP,
- } Phase = AttributorPhase::SEEDING;
-
- /// The current initialization chain length. Tracked to avoid stack overflows.
- unsigned InitializationChainLength = 0;
-
+ /// A flag that indicates which stage of the process we are in. Initially, the
+ /// phase is SEEDING. Phase is changed in `Attributor::run()`
+ enum class AttributorPhase {
+ SEEDING,
+ UPDATE,
+ MANIFEST,
+ CLEANUP,
+ } Phase = AttributorPhase::SEEDING;
+
+ /// The current initialization chain length. Tracked to avoid stack overflows.
+ unsigned InitializationChainLength = 0;
+
/// Functions, blocks, and instructions we delete after manifest is done.
///
///{
@@ -1695,8 +1695,8 @@ private:
SmallPtrSet<BasicBlock *, 8> ToBeDeletedBlocks;
SmallDenseSet<WeakVH, 8> ToBeDeletedInsts;
///}
-
- friend AADepGraph;
+
+ friend AADepGraph;
};
/// An interface to query the internal state of an abstract attribute.
@@ -2175,7 +2175,7 @@ struct StateWrapper : public BaseType, public StateTy {
StateType &getState() override { return *this; }
/// See AbstractAttribute::getState(...).
- const StateType &getState() const override { return *this; }
+ const StateType &getState() const override { return *this; }
};
/// Helper class that provides common functionality to manifest IR attributes.
@@ -2269,7 +2269,7 @@ struct IRAttribute : public BaseType {
/// both directions will be added in the future.
/// NOTE: The mechanics of adding a new "concrete" abstract attribute are
/// described in the file comment.
-struct AbstractAttribute : public IRPosition, public AADepGraphNode {
+struct AbstractAttribute : public IRPosition, public AADepGraphNode {
using StateType = AbstractState;
AbstractAttribute(const IRPosition &IRP) : IRPosition(IRP) {}
@@ -2277,14 +2277,14 @@ struct AbstractAttribute : public IRPosition, public AADepGraphNode {
/// Virtual destructor.
virtual ~AbstractAttribute() {}
- /// This function is used to identify if an \p DGN is of type
- /// AbstractAttribute so that the dyn_cast and cast can use such information
- /// to cast an AADepGraphNode to an AbstractAttribute.
- ///
- /// We eagerly return true here because all AADepGraphNodes except for the
- /// Synthethis Node are of type AbstractAttribute
- static bool classof(const AADepGraphNode *DGN) { return true; }
-
+ /// This function is used to identify if an \p DGN is of type
+ /// AbstractAttribute so that the dyn_cast and cast can use such information
+ /// to cast an AADepGraphNode to an AbstractAttribute.
+ ///
+ /// We eagerly return true here because all AADepGraphNodes except for the
+ /// Synthethis Node are of type AbstractAttribute
+ static bool classof(const AADepGraphNode *DGN) { return true; }
+
/// Initialize the state with the information in the Attributor \p A.
///
/// This function is called by the Attributor once all abstract attributes
@@ -2305,8 +2305,8 @@ struct AbstractAttribute : public IRPosition, public AADepGraphNode {
/// Helper functions, for debug purposes only.
///{
- void print(raw_ostream &OS) const override;
- virtual void printWithDeps(raw_ostream &OS) const;
+ void print(raw_ostream &OS) const override;
+ virtual void printWithDeps(raw_ostream &OS) const;
void dump() const { print(dbgs()); }
/// This function should return the "summarized" assumed state as string.
@@ -2635,17 +2635,17 @@ struct AAReachability : public StateWrapper<BooleanState, AbstractAttribute> {
/// Returns true if 'From' instruction is assumed to reach, 'To' instruction.
/// Users should provide two positions they are interested in, and the class
/// determines (and caches) reachability.
- bool isAssumedReachable(Attributor &A, const Instruction &From,
- const Instruction &To) const {
- return A.getInfoCache().getPotentiallyReachable(From, To);
+ bool isAssumedReachable(Attributor &A, const Instruction &From,
+ const Instruction &To) const {
+ return A.getInfoCache().getPotentiallyReachable(From, To);
}
/// Returns true if 'From' instruction is known to reach, 'To' instruction.
/// Users should provide two positions they are interested in, and the class
/// determines (and caches) reachability.
- bool isKnownReachable(Attributor &A, const Instruction &From,
- const Instruction &To) const {
- return A.getInfoCache().getPotentiallyReachable(From, To);
+ bool isKnownReachable(Attributor &A, const Instruction &From,
+ const Instruction &To) const {
+ return A.getInfoCache().getPotentiallyReachable(From, To);
}
/// Create an abstract attribute view for the position \p IRP.
@@ -2808,12 +2808,12 @@ public:
return F.hasPersonalityFn() && !canSimplifyInvokeNoUnwind(&F);
}
- /// Return if the edge from \p From BB to \p To BB is assumed dead.
- /// This is specifically useful in AAReachability.
- virtual bool isEdgeDead(const BasicBlock *From, const BasicBlock *To) const {
- return false;
- }
-
+ /// Return if the edge from \p From BB to \p To BB is assumed dead.
+ /// This is specifically useful in AAReachability.
+ virtual bool isEdgeDead(const BasicBlock *From, const BasicBlock *To) const {
+ return false;
+ }
+
/// See AbstractAttribute::getName()
const std::string getName() const override { return "AAIsDead"; }
@@ -3470,7 +3470,7 @@ struct AAValueConstantRange
/// See AbstractAttribute::getState(...).
IntegerRangeState &getState() override { return *this; }
- const IntegerRangeState &getState() const override { return *this; }
+ const IntegerRangeState &getState() const override { return *this; }
/// Create an abstract attribute view for the position \p IRP.
static AAValueConstantRange &createForPosition(const IRPosition &IRP,
@@ -3518,279 +3518,279 @@ struct AAValueConstantRange
static const char ID;
};
-/// A class for a set state.
-/// The assumed boolean state indicates whether the corresponding set is full
-/// set or not. If the assumed state is false, this is the worst state. The
-/// worst state (invalid state) of set of potential values is when the set
-/// contains every possible value (i.e. we cannot in any way limit the value
-/// that the target position can take). That never happens naturally, we only
-/// force it. As for the conditions under which we force it, see
-/// AAPotentialValues.
-template <typename MemberTy, typename KeyInfo = DenseMapInfo<MemberTy>>
-struct PotentialValuesState : AbstractState {
- using SetTy = DenseSet<MemberTy, KeyInfo>;
-
- PotentialValuesState() : IsValidState(true), UndefIsContained(false) {}
-
- PotentialValuesState(bool IsValid)
- : IsValidState(IsValid), UndefIsContained(false) {}
-
- /// See AbstractState::isValidState(...)
- bool isValidState() const override { return IsValidState.isValidState(); }
-
- /// See AbstractState::isAtFixpoint(...)
- bool isAtFixpoint() const override { return IsValidState.isAtFixpoint(); }
-
- /// See AbstractState::indicatePessimisticFixpoint(...)
- ChangeStatus indicatePessimisticFixpoint() override {
- return IsValidState.indicatePessimisticFixpoint();
- }
-
- /// See AbstractState::indicateOptimisticFixpoint(...)
- ChangeStatus indicateOptimisticFixpoint() override {
- return IsValidState.indicateOptimisticFixpoint();
- }
-
- /// Return the assumed state
- PotentialValuesState &getAssumed() { return *this; }
- const PotentialValuesState &getAssumed() const { return *this; }
-
- /// Return this set. We should check whether this set is valid or not by
- /// isValidState() before calling this function.
- const SetTy &getAssumedSet() const {
- assert(isValidState() && "This set shoud not be used when it is invalid!");
- return Set;
- }
-
- /// Returns whether this state contains an undef value or not.
- bool undefIsContained() const {
- assert(isValidState() && "This flag shoud not be used when it is invalid!");
- return UndefIsContained;
- }
-
- bool operator==(const PotentialValuesState &RHS) const {
- if (isValidState() != RHS.isValidState())
- return false;
- if (!isValidState() && !RHS.isValidState())
- return true;
- if (undefIsContained() != RHS.undefIsContained())
- return false;
- return Set == RHS.getAssumedSet();
- }
-
- /// Maximum number of potential values to be tracked.
- /// This is set by -attributor-max-potential-values command line option
- static unsigned MaxPotentialValues;
-
- /// Return empty set as the best state of potential values.
- static PotentialValuesState getBestState() {
- return PotentialValuesState(true);
- }
-
- static PotentialValuesState getBestState(PotentialValuesState &PVS) {
- return getBestState();
- }
-
- /// Return full set as the worst state of potential values.
- static PotentialValuesState getWorstState() {
- return PotentialValuesState(false);
- }
-
- /// Union assumed set with the passed value.
- void unionAssumed(const MemberTy &C) { insert(C); }
-
- /// Union assumed set with assumed set of the passed state \p PVS.
- void unionAssumed(const PotentialValuesState &PVS) { unionWith(PVS); }
-
- /// Union assumed set with an undef value.
- void unionAssumedWithUndef() { unionWithUndef(); }
-
- /// "Clamp" this state with \p PVS.
- PotentialValuesState operator^=(const PotentialValuesState &PVS) {
- IsValidState ^= PVS.IsValidState;
- unionAssumed(PVS);
- return *this;
- }
-
- PotentialValuesState operator&=(const PotentialValuesState &PVS) {
- IsValidState &= PVS.IsValidState;
- unionAssumed(PVS);
- return *this;
- }
-
-private:
- /// Check the size of this set, and invalidate when the size is no
- /// less than \p MaxPotentialValues threshold.
- void checkAndInvalidate() {
- if (Set.size() >= MaxPotentialValues)
- indicatePessimisticFixpoint();
- }
-
- /// If this state contains both undef and not undef, we can reduce
- /// undef to the not undef value.
- void reduceUndefValue() { UndefIsContained = UndefIsContained & Set.empty(); }
-
- /// Insert an element into this set.
- void insert(const MemberTy &C) {
- if (!isValidState())
- return;
- Set.insert(C);
- checkAndInvalidate();
- }
-
- /// Take union with R.
- void unionWith(const PotentialValuesState &R) {
- /// If this is a full set, do nothing.;
- if (!isValidState())
- return;
- /// If R is full set, change L to a full set.
- if (!R.isValidState()) {
- indicatePessimisticFixpoint();
- return;
- }
- for (const MemberTy &C : R.Set)
- Set.insert(C);
- UndefIsContained |= R.undefIsContained();
- reduceUndefValue();
- checkAndInvalidate();
- }
-
- /// Take union with an undef value.
- void unionWithUndef() {
- UndefIsContained = true;
- reduceUndefValue();
- }
-
- /// Take intersection with R.
- void intersectWith(const PotentialValuesState &R) {
- /// If R is a full set, do nothing.
- if (!R.isValidState())
- return;
- /// If this is a full set, change this to R.
- if (!isValidState()) {
- *this = R;
- return;
- }
- SetTy IntersectSet;
- for (const MemberTy &C : Set) {
- if (R.Set.count(C))
- IntersectSet.insert(C);
- }
- Set = IntersectSet;
- UndefIsContained &= R.undefIsContained();
- reduceUndefValue();
- }
-
- /// A helper state which indicate whether this state is valid or not.
- BooleanState IsValidState;
-
- /// Container for potential values
- SetTy Set;
-
- /// Flag for undef value
- bool UndefIsContained;
-};
-
-using PotentialConstantIntValuesState = PotentialValuesState<APInt>;
-
-raw_ostream &operator<<(raw_ostream &OS,
- const PotentialConstantIntValuesState &R);
-
-/// An abstract interface for potential values analysis.
-///
-/// This AA collects potential values for each IR position.
-/// An assumed set of potential values is initialized with the empty set (the
-/// best state) and it will grow monotonically as we find more potential values
-/// for this position.
-/// The set might be forced to the worst state, that is, to contain every
-/// possible value for this position in 2 cases.
-/// 1. We surpassed the \p MaxPotentialValues threshold. This includes the
-/// case that this position is affected (e.g. because of an operation) by a
-/// Value that is in the worst state.
-/// 2. We tried to initialize on a Value that we cannot handle (e.g. an
-/// operator we do not currently handle).
-///
-/// TODO: Support values other than constant integers.
-struct AAPotentialValues
- : public StateWrapper<PotentialConstantIntValuesState, AbstractAttribute> {
- using Base = StateWrapper<PotentialConstantIntValuesState, AbstractAttribute>;
- AAPotentialValues(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
-
- /// See AbstractAttribute::getState(...).
- PotentialConstantIntValuesState &getState() override { return *this; }
- const PotentialConstantIntValuesState &getState() const override {
- return *this;
- }
-
- /// Create an abstract attribute view for the position \p IRP.
- static AAPotentialValues &createForPosition(const IRPosition &IRP,
- Attributor &A);
-
- /// Return assumed constant for the associated value
- Optional<ConstantInt *>
- getAssumedConstantInt(Attributor &A,
- const Instruction *CtxI = nullptr) const {
- if (!isValidState())
- return nullptr;
- if (getAssumedSet().size() == 1)
- return cast<ConstantInt>(ConstantInt::get(getAssociatedValue().getType(),
- *(getAssumedSet().begin())));
- if (getAssumedSet().size() == 0) {
- if (undefIsContained())
- return cast<ConstantInt>(
- ConstantInt::get(getAssociatedValue().getType(), 0));
- return llvm::None;
- }
-
- return nullptr;
- }
-
- /// See AbstractAttribute::getName()
- const std::string getName() const override { return "AAPotentialValues"; }
-
- /// See AbstractAttribute::getIdAddr()
- const char *getIdAddr() const override { return &ID; }
-
- /// This function should return true if the type of the \p AA is
- /// AAPotentialValues
- static bool classof(const AbstractAttribute *AA) {
- return (AA->getIdAddr() == &ID);
- }
-
- /// Unique ID (due to the unique address)
- static const char ID;
-};
-
-/// An abstract interface for all noundef attributes.
-struct AANoUndef
- : public IRAttribute<Attribute::NoUndef,
- StateWrapper<BooleanState, AbstractAttribute>> {
- AANoUndef(const IRPosition &IRP, Attributor &A) : IRAttribute(IRP) {}
-
- /// Return true if we assume that the underlying value is noundef.
- bool isAssumedNoUndef() const { return getAssumed(); }
-
- /// Return true if we know that underlying value is noundef.
- bool isKnownNoUndef() const { return getKnown(); }
-
- /// Create an abstract attribute view for the position \p IRP.
- static AANoUndef &createForPosition(const IRPosition &IRP, Attributor &A);
-
- /// See AbstractAttribute::getName()
- const std::string getName() const override { return "AANoUndef"; }
-
- /// See AbstractAttribute::getIdAddr()
- const char *getIdAddr() const override { return &ID; }
-
- /// This function should return true if the type of the \p AA is AANoUndef
- static bool classof(const AbstractAttribute *AA) {
- return (AA->getIdAddr() == &ID);
- }
-
- /// Unique ID (due to the unique address)
- static const char ID;
-};
-
+/// A class for a set state.
+/// The assumed boolean state indicates whether the corresponding set is full
+/// set or not. If the assumed state is false, this is the worst state. The
+/// worst state (invalid state) of set of potential values is when the set
+/// contains every possible value (i.e. we cannot in any way limit the value
+/// that the target position can take). That never happens naturally, we only
+/// force it. As for the conditions under which we force it, see
+/// AAPotentialValues.
+template <typename MemberTy, typename KeyInfo = DenseMapInfo<MemberTy>>
+struct PotentialValuesState : AbstractState {
+ using SetTy = DenseSet<MemberTy, KeyInfo>;
+
+ PotentialValuesState() : IsValidState(true), UndefIsContained(false) {}
+
+ PotentialValuesState(bool IsValid)
+ : IsValidState(IsValid), UndefIsContained(false) {}
+
+ /// See AbstractState::isValidState(...)
+ bool isValidState() const override { return IsValidState.isValidState(); }
+
+ /// See AbstractState::isAtFixpoint(...)
+ bool isAtFixpoint() const override { return IsValidState.isAtFixpoint(); }
+
+ /// See AbstractState::indicatePessimisticFixpoint(...)
+ ChangeStatus indicatePessimisticFixpoint() override {
+ return IsValidState.indicatePessimisticFixpoint();
+ }
+
+ /// See AbstractState::indicateOptimisticFixpoint(...)
+ ChangeStatus indicateOptimisticFixpoint() override {
+ return IsValidState.indicateOptimisticFixpoint();
+ }
+
+ /// Return the assumed state
+ PotentialValuesState &getAssumed() { return *this; }
+ const PotentialValuesState &getAssumed() const { return *this; }
+
+ /// Return this set. We should check whether this set is valid or not by
+ /// isValidState() before calling this function.
+ const SetTy &getAssumedSet() const {
+ assert(isValidState() && "This set shoud not be used when it is invalid!");
+ return Set;
+ }
+
+ /// Returns whether this state contains an undef value or not.
+ bool undefIsContained() const {
+ assert(isValidState() && "This flag shoud not be used when it is invalid!");
+ return UndefIsContained;
+ }
+
+ bool operator==(const PotentialValuesState &RHS) const {
+ if (isValidState() != RHS.isValidState())
+ return false;
+ if (!isValidState() && !RHS.isValidState())
+ return true;
+ if (undefIsContained() != RHS.undefIsContained())
+ return false;
+ return Set == RHS.getAssumedSet();
+ }
+
+ /// Maximum number of potential values to be tracked.
+ /// This is set by -attributor-max-potential-values command line option
+ static unsigned MaxPotentialValues;
+
+ /// Return empty set as the best state of potential values.
+ static PotentialValuesState getBestState() {
+ return PotentialValuesState(true);
+ }
+
+ static PotentialValuesState getBestState(PotentialValuesState &PVS) {
+ return getBestState();
+ }
+
+ /// Return full set as the worst state of potential values.
+ static PotentialValuesState getWorstState() {
+ return PotentialValuesState(false);
+ }
+
+ /// Union assumed set with the passed value.
+ void unionAssumed(const MemberTy &C) { insert(C); }
+
+ /// Union assumed set with assumed set of the passed state \p PVS.
+ void unionAssumed(const PotentialValuesState &PVS) { unionWith(PVS); }
+
+ /// Union assumed set with an undef value.
+ void unionAssumedWithUndef() { unionWithUndef(); }
+
+ /// "Clamp" this state with \p PVS.
+ PotentialValuesState operator^=(const PotentialValuesState &PVS) {
+ IsValidState ^= PVS.IsValidState;
+ unionAssumed(PVS);
+ return *this;
+ }
+
+ PotentialValuesState operator&=(const PotentialValuesState &PVS) {
+ IsValidState &= PVS.IsValidState;
+ unionAssumed(PVS);
+ return *this;
+ }
+
+private:
+ /// Check the size of this set, and invalidate when the size is no
+ /// less than \p MaxPotentialValues threshold.
+ void checkAndInvalidate() {
+ if (Set.size() >= MaxPotentialValues)
+ indicatePessimisticFixpoint();
+ }
+
+ /// If this state contains both undef and not undef, we can reduce
+ /// undef to the not undef value.
+ void reduceUndefValue() { UndefIsContained = UndefIsContained & Set.empty(); }
+
+ /// Insert an element into this set.
+ void insert(const MemberTy &C) {
+ if (!isValidState())
+ return;
+ Set.insert(C);
+ checkAndInvalidate();
+ }
+
+ /// Take union with R.
+ void unionWith(const PotentialValuesState &R) {
+ /// If this is a full set, do nothing.;
+ if (!isValidState())
+ return;
+ /// If R is full set, change L to a full set.
+ if (!R.isValidState()) {
+ indicatePessimisticFixpoint();
+ return;
+ }
+ for (const MemberTy &C : R.Set)
+ Set.insert(C);
+ UndefIsContained |= R.undefIsContained();
+ reduceUndefValue();
+ checkAndInvalidate();
+ }
+
+ /// Take union with an undef value.
+ void unionWithUndef() {
+ UndefIsContained = true;
+ reduceUndefValue();
+ }
+
+ /// Take intersection with R.
+ void intersectWith(const PotentialValuesState &R) {
+ /// If R is a full set, do nothing.
+ if (!R.isValidState())
+ return;
+ /// If this is a full set, change this to R.
+ if (!isValidState()) {
+ *this = R;
+ return;
+ }
+ SetTy IntersectSet;
+ for (const MemberTy &C : Set) {
+ if (R.Set.count(C))
+ IntersectSet.insert(C);
+ }
+ Set = IntersectSet;
+ UndefIsContained &= R.undefIsContained();
+ reduceUndefValue();
+ }
+
+ /// A helper state which indicate whether this state is valid or not.
+ BooleanState IsValidState;
+
+ /// Container for potential values
+ SetTy Set;
+
+ /// Flag for undef value
+ bool UndefIsContained;
+};
+
+using PotentialConstantIntValuesState = PotentialValuesState<APInt>;
+
+raw_ostream &operator<<(raw_ostream &OS,
+ const PotentialConstantIntValuesState &R);
+
+/// An abstract interface for potential values analysis.
+///
+/// This AA collects potential values for each IR position.
+/// An assumed set of potential values is initialized with the empty set (the
+/// best state) and it will grow monotonically as we find more potential values
+/// for this position.
+/// The set might be forced to the worst state, that is, to contain every
+/// possible value for this position in 2 cases.
+/// 1. We surpassed the \p MaxPotentialValues threshold. This includes the
+/// case that this position is affected (e.g. because of an operation) by a
+/// Value that is in the worst state.
+/// 2. We tried to initialize on a Value that we cannot handle (e.g. an
+/// operator we do not currently handle).
+///
+/// TODO: Support values other than constant integers.
+struct AAPotentialValues
+ : public StateWrapper<PotentialConstantIntValuesState, AbstractAttribute> {
+ using Base = StateWrapper<PotentialConstantIntValuesState, AbstractAttribute>;
+ AAPotentialValues(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
+
+ /// See AbstractAttribute::getState(...).
+ PotentialConstantIntValuesState &getState() override { return *this; }
+ const PotentialConstantIntValuesState &getState() const override {
+ return *this;
+ }
+
+ /// Create an abstract attribute view for the position \p IRP.
+ static AAPotentialValues &createForPosition(const IRPosition &IRP,
+ Attributor &A);
+
+ /// Return assumed constant for the associated value
+ Optional<ConstantInt *>
+ getAssumedConstantInt(Attributor &A,
+ const Instruction *CtxI = nullptr) const {
+ if (!isValidState())
+ return nullptr;
+ if (getAssumedSet().size() == 1)
+ return cast<ConstantInt>(ConstantInt::get(getAssociatedValue().getType(),
+ *(getAssumedSet().begin())));
+ if (getAssumedSet().size() == 0) {
+ if (undefIsContained())
+ return cast<ConstantInt>(
+ ConstantInt::get(getAssociatedValue().getType(), 0));
+ return llvm::None;
+ }
+
+ return nullptr;
+ }
+
+ /// See AbstractAttribute::getName()
+ const std::string getName() const override { return "AAPotentialValues"; }
+
+ /// See AbstractAttribute::getIdAddr()
+ const char *getIdAddr() const override { return &ID; }
+
+ /// This function should return true if the type of the \p AA is
+ /// AAPotentialValues
+ static bool classof(const AbstractAttribute *AA) {
+ return (AA->getIdAddr() == &ID);
+ }
+
+ /// Unique ID (due to the unique address)
+ static const char ID;
+};
+
+/// An abstract interface for all noundef attributes.
+struct AANoUndef
+ : public IRAttribute<Attribute::NoUndef,
+ StateWrapper<BooleanState, AbstractAttribute>> {
+ AANoUndef(const IRPosition &IRP, Attributor &A) : IRAttribute(IRP) {}
+
+ /// Return true if we assume that the underlying value is noundef.
+ bool isAssumedNoUndef() const { return getAssumed(); }
+
+ /// Return true if we know that underlying value is noundef.
+ bool isKnownNoUndef() const { return getKnown(); }
+
+ /// Create an abstract attribute view for the position \p IRP.
+ static AANoUndef &createForPosition(const IRPosition &IRP, Attributor &A);
+
+ /// See AbstractAttribute::getName()
+ const std::string getName() const override { return "AANoUndef"; }
+
+ /// See AbstractAttribute::getIdAddr()
+ const char *getIdAddr() const override { return &ID; }
+
+ /// This function should return true if the type of the \p AA is AANoUndef
+ static bool classof(const AbstractAttribute *AA) {
+ return (AA->getIdAddr() == &ID);
+ }
+
+ /// Unique ID (due to the unique address)
+ static const char ID;
+};
+
/// Run options, used by the pass manager.
enum AttributorRunOption {
NONE = 0,
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/BlockExtractor.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/BlockExtractor.h
index 937c1cbb39..10ac54d79d 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/BlockExtractor.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/BlockExtractor.h
@@ -1,36 +1,36 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- BlockExtractor.h - Extracts blocks into their own functions --------===//
-//
-// 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 pass extracts the specified basic blocks from the module into their
-// own functions.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_IPO_BLOCKEXTRACTOR_H
-#define LLVM_TRANSFORMS_IPO_BLOCKEXTRACTOR_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-struct BlockExtractorPass : PassInfoMixin<BlockExtractorPass> {
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_IPO_BLOCKEXTRACTOR_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- BlockExtractor.h - Extracts blocks into their own functions --------===//
+//
+// 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 pass extracts the specified basic blocks from the module into their
+// own functions.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_BLOCKEXTRACTOR_H
+#define LLVM_TRANSFORMS_IPO_BLOCKEXTRACTOR_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+struct BlockExtractorPass : PassInfoMixin<BlockExtractorPass> {
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_IPO_BLOCKEXTRACTOR_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/IROutliner.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/IROutliner.h
index bb1f1beb5a..0b90589079 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/IROutliner.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/IROutliner.h
@@ -1,369 +1,369 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- IROutliner.h - Extract similar IR regions into functions ------------==//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// \file
-// The interface file for the IROutliner which is used by the IROutliner Pass.
-//
-// The outliner uses the IRSimilarityIdentifier to identify the similar regions
-// of code. It evaluates each set of IRSimilarityCandidates with an estimate of
-// whether it will provide code size reduction. Each region is extracted using
-// the code extractor. These extracted functions are consolidated into a single
-// function and called from the extracted call site.
-//
-// For example:
-// \code
-// %1 = add i32 %a, %b
-// %2 = add i32 %b, %a
-// %3 = add i32 %b, %a
-// %4 = add i32 %a, %b
-// \endcode
-// would become function
-// \code
-// define internal void outlined_ir_function(i32 %0, i32 %1) {
-// %1 = add i32 %0, %1
-// %2 = add i32 %1, %0
-// ret void
-// }
-// \endcode
-// with calls:
-// \code
-// call void outlined_ir_function(i32 %a, i32 %b)
-// call void outlined_ir_function(i32 %b, i32 %a)
-// \endcode
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_IPO_IROUTLINER_H
-#define LLVM_TRANSFORMS_IPO_IROUTLINER_H
-
-#include "llvm/Analysis/IRSimilarityIdentifier.h"
-#include "llvm/IR/PassManager.h"
-#include "llvm/IR/ValueMap.h"
-#include "llvm/Support/InstructionCost.h"
-#include "llvm/Transforms/Utils/CodeExtractor.h"
-#include <set>
-
-struct OutlinableGroup;
-
-namespace llvm {
-using namespace IRSimilarity;
-
-class Module;
-class TargetTransformInfo;
-class OptimizationRemarkEmitter;
-
-/// The OutlinableRegion holds all the information for a specific region, or
-/// sequence of instructions. This includes what values need to be hoisted to
-/// arguments from the extracted function, inputs and outputs to the region, and
-/// mapping from the extracted function arguments to overall function arguments.
-struct OutlinableRegion {
- /// Describes the region of code.
- IRSimilarityCandidate *Candidate;
-
- /// If this region is outlined, the front and back IRInstructionData could
- /// potentially become invalidated if the only new instruction is a call.
- /// This ensures that we replace in the instruction in the IRInstructionData.
- IRInstructionData *NewFront = nullptr;
- IRInstructionData *NewBack = nullptr;
-
- /// The number of extracted inputs from the CodeExtractor.
- unsigned NumExtractedInputs;
-
- /// The corresponding BasicBlock with the appropriate stores for this
- /// OutlinableRegion in the overall function.
- unsigned OutputBlockNum;
-
- /// Mapping the extracted argument number to the argument number in the
- /// overall function. Since there will be inputs, such as elevated constants
- /// that are not the same in each region in a SimilarityGroup, or values that
- /// cannot be sunk into the extracted section in every region, we must keep
- /// track of which extracted argument maps to which overall argument.
- DenseMap<unsigned, unsigned> ExtractedArgToAgg;
- DenseMap<unsigned, unsigned> AggArgToExtracted;
-
- /// Mapping of the argument number in the deduplicated function
- /// to a given constant, which is used when creating the arguments to the call
- /// to the newly created deduplicated function. This is handled separately
- /// since the CodeExtractor does not recognize constants.
- DenseMap<unsigned, Constant *> AggArgToConstant;
-
- /// The global value numbers that are used as outputs for this section. Once
- /// extracted, each output will be stored to an output register. This
- /// documents the global value numbers that are used in this pattern.
- SmallVector<unsigned, 4> GVNStores;
-
- /// Used to create an outlined function.
- CodeExtractor *CE = nullptr;
-
- /// The call site of the extracted region.
- CallInst *Call = nullptr;
-
- /// The function for the extracted region.
- Function *ExtractedFunction = nullptr;
-
- /// Flag for whether we have split out the IRSimilarityCanidate. That is,
- /// make the region contained the IRSimilarityCandidate its own BasicBlock.
- bool CandidateSplit = false;
-
- /// Flag for whether we should not consider this region for extraction.
- bool IgnoreRegion = false;
-
- /// The BasicBlock that is before the start of the region BasicBlock,
- /// only defined when the region has been split.
- BasicBlock *PrevBB = nullptr;
-
- /// The BasicBlock that contains the starting instruction of the region.
- BasicBlock *StartBB = nullptr;
-
- /// The BasicBlock that contains the ending instruction of the region.
- BasicBlock *EndBB = nullptr;
-
- /// The BasicBlock that is after the start of the region BasicBlock,
- /// only defined when the region has been split.
- BasicBlock *FollowBB = nullptr;
-
- /// The Outlinable Group that contains this region and structurally similar
- /// regions to this region.
- OutlinableGroup *Parent = nullptr;
-
- OutlinableRegion(IRSimilarityCandidate &C, OutlinableGroup &Group)
- : Candidate(&C), Parent(&Group) {
- StartBB = C.getStartBB();
- EndBB = C.getEndBB();
- }
-
- /// For the contained region, split the parent BasicBlock at the starting and
- /// ending instructions of the contained IRSimilarityCandidate.
- void splitCandidate();
-
- /// For the contained region, reattach the BasicBlock at the starting and
- /// ending instructions of the contained IRSimilarityCandidate, or if the
- /// function has been extracted, the start and end of the BasicBlock
- /// containing the called function.
- void reattachCandidate();
-
- /// Get the size of the code removed from the region.
- ///
- /// \param [in] TTI - The TargetTransformInfo for the parent function.
- /// \returns the code size of the region
- InstructionCost getBenefit(TargetTransformInfo &TTI);
-};
-
-/// This class is a pass that identifies similarity in a Module, extracts
-/// instances of the similarity, and then consolidating the similar regions
-/// in an effort to reduce code size. It uses the IRSimilarityIdentifier pass
-/// to identify the similar regions of code, and then extracts the similar
-/// sections into a single function. See the above for an example as to
-/// how code is extracted and consolidated into a single function.
-class IROutliner {
-public:
- IROutliner(function_ref<TargetTransformInfo &(Function &)> GTTI,
- function_ref<IRSimilarityIdentifier &(Module &)> GIRSI,
- function_ref<OptimizationRemarkEmitter &(Function &)> GORE)
- : getTTI(GTTI), getIRSI(GIRSI), getORE(GORE) {}
- bool run(Module &M);
-
-private:
- /// Find repeated similar code sequences in \p M and outline them into new
- /// Functions.
- ///
- /// \param [in] M - The module to outline from.
- /// \returns The number of Functions created.
- unsigned doOutline(Module &M);
-
- /// Remove all the IRSimilarityCandidates from \p CandidateVec that have
- /// instructions contained in a previously outlined region and put the
- /// remaining regions in \p CurrentGroup.
- ///
- /// \param [in] CandidateVec - List of similarity candidates for regions with
- /// the same similarity structure.
- /// \param [in,out] CurrentGroup - Contains the potential sections to
- /// be outlined.
- void
- pruneIncompatibleRegions(std::vector<IRSimilarityCandidate> &CandidateVec,
- OutlinableGroup &CurrentGroup);
-
- /// Create the function based on the overall types found in the current
- /// regions being outlined.
- ///
- /// \param M - The module to outline from.
- /// \param [in,out] CG - The OutlinableGroup for the regions to be outlined.
- /// \param [in] FunctionNameSuffix - How many functions have we previously
- /// created.
- /// \returns the newly created function.
- Function *createFunction(Module &M, OutlinableGroup &CG,
- unsigned FunctionNameSuffix);
-
- /// Identify the needed extracted inputs in a section, and add to the overall
- /// function if needed.
- ///
- /// \param [in] M - The module to outline from.
- /// \param [in,out] Region - The region to be extracted.
- /// \param [in] NotSame - The global value numbers of the Values in the region
- /// that do not have the same Constant in each strucutrally similar region.
- void findAddInputsOutputs(Module &M, OutlinableRegion &Region,
- DenseSet<unsigned> &NotSame);
-
- /// Find the number of instructions that will be removed by extracting the
- /// OutlinableRegions in \p CurrentGroup.
- ///
- /// \param [in] CurrentGroup - The collection of OutlinableRegions to be
- /// analyzed.
- /// \returns the number of outlined instructions across all regions.
- InstructionCost findBenefitFromAllRegions(OutlinableGroup &CurrentGroup);
-
- /// Find the number of instructions that will be added by reloading arguments.
- ///
- /// \param [in] CurrentGroup - The collection of OutlinableRegions to be
- /// analyzed.
- /// \returns the number of added reload instructions across all regions.
- InstructionCost findCostOutputReloads(OutlinableGroup &CurrentGroup);
-
- /// Find the cost and the benefit of \p CurrentGroup and save it back to
- /// \p CurrentGroup.
- ///
- /// \param [in] M - The module being analyzed
- /// \param [in,out] CurrentGroup - The overall outlined section
- void findCostBenefit(Module &M, OutlinableGroup &CurrentGroup);
-
- /// Update the output mapping based on the load instruction, and the outputs
- /// of the extracted function.
- ///
- /// \param Region - The region extracted
- /// \param Outputs - The outputs from the extracted function.
- /// \param LI - The load instruction used to update the mapping.
- void updateOutputMapping(OutlinableRegion &Region,
- ArrayRef<Value *> Outputs, LoadInst *LI);
-
- /// Extract \p Region into its own function.
- ///
- /// \param [in] Region - The region to be extracted into its own function.
- /// \returns True if it was successfully outlined.
- bool extractSection(OutlinableRegion &Region);
-
- /// For the similarities found, and the extracted sections, create a single
- /// outlined function with appropriate output blocks as necessary.
- ///
- /// \param [in] M - The module to outline from
- /// \param [in] CurrentGroup - The set of extracted sections to consolidate.
- /// \param [in,out] FuncsToRemove - List of functions to remove from the
- /// module after outlining is completed.
- /// \param [in,out] OutlinedFunctionNum - the number of new outlined
- /// functions.
- void deduplicateExtractedSections(Module &M, OutlinableGroup &CurrentGroup,
- std::vector<Function *> &FuncsToRemove,
- unsigned &OutlinedFunctionNum);
-
- /// If true, enables us to outline from functions that have LinkOnceFromODR
- /// linkages.
- bool OutlineFromLinkODRs = false;
-
- /// If false, we do not worry if the cost is greater than the benefit. This
- /// is for debugging and testing, so that we can test small cases to ensure
- /// that the outlining is being done correctly.
- bool CostModel = true;
-
- /// The set of outlined Instructions, identified by their location in the
- /// sequential ordering of instructions in a Module.
- DenseSet<unsigned> Outlined;
-
- /// TargetTransformInfo lambda for target specific information.
- function_ref<TargetTransformInfo &(Function &)> getTTI;
-
- /// A mapping from newly created reloaded output values to the original value.
- /// If an value is replace by an output from an outlined region, this maps
- /// that Value, back to its original Value.
- DenseMap<Value *, Value *> OutputMappings;
-
- /// IRSimilarityIdentifier lambda to retrieve IRSimilarityIdentifier.
- function_ref<IRSimilarityIdentifier &(Module &)> getIRSI;
-
- /// The optimization remark emitter for the pass.
- function_ref<OptimizationRemarkEmitter &(Function &)> getORE;
-
- /// The memory allocator used to allocate the CodeExtractors.
- SpecificBumpPtrAllocator<CodeExtractor> ExtractorAllocator;
-
- /// The memory allocator used to allocate the OutlinableRegions.
- SpecificBumpPtrAllocator<OutlinableRegion> RegionAllocator;
-
- /// The memory allocator used to allocate new IRInstructionData.
- SpecificBumpPtrAllocator<IRInstructionData> InstDataAllocator;
-
- /// Custom InstVisitor to classify different instructions for whether it can
- /// be analyzed for similarity. This is needed as there may be instruction we
- /// can identify as having similarity, but are more complicated to outline.
- struct InstructionAllowed : public InstVisitor<InstructionAllowed, bool> {
- InstructionAllowed() {}
-
- // TODO: Determine a scheme to resolve when the label is similar enough.
- bool visitBranchInst(BranchInst &BI) { return false; }
- // TODO: Determine a scheme to resolve when the labels are similar enough.
- bool visitPHINode(PHINode &PN) { return false; }
- // TODO: Handle allocas.
- bool visitAllocaInst(AllocaInst &AI) { return false; }
- // VAArg instructions are not allowed since this could cause difficulty when
- // differentiating between different sets of variable instructions in
- // the deduplicated outlined regions.
- bool visitVAArgInst(VAArgInst &VI) { return false; }
- // We exclude all exception handling cases since they are so context
- // dependent.
- bool visitLandingPadInst(LandingPadInst &LPI) { return false; }
- bool visitFuncletPadInst(FuncletPadInst &FPI) { return false; }
- // DebugInfo should be included in the regions, but should not be
- // analyzed for similarity as it has no bearing on the outcome of the
- // program.
- bool visitDbgInfoIntrinsic(DbgInfoIntrinsic &DII) { return true; }
- // TODO: Handle specific intrinsics individually from those that can be
- // handled.
- bool IntrinsicInst(IntrinsicInst &II) { return false; }
- // We only handle CallInsts that are not indirect, since we cannot guarantee
- // that they have a name in these cases.
- bool visitCallInst(CallInst &CI) {
- Function *F = CI.getCalledFunction();
- if (!F || CI.isIndirectCall() || !F->hasName())
- return false;
- return true;
- }
- // TODO: Handle FreezeInsts. Since a frozen value could be frozen inside
- // the outlined region, and then returned as an output, this will have to be
- // handled differently.
- bool visitFreezeInst(FreezeInst &CI) { return false; }
- // TODO: We do not current handle similarity that changes the control flow.
- bool visitInvokeInst(InvokeInst &II) { return false; }
- // TODO: We do not current handle similarity that changes the control flow.
- bool visitCallBrInst(CallBrInst &CBI) { return false; }
- // TODO: Handle interblock similarity.
- bool visitTerminator(Instruction &I) { return false; }
- bool visitInstruction(Instruction &I) { return true; }
- };
-
- /// A InstVisitor used to exclude certain instructions from being outlined.
- InstructionAllowed InstructionClassifier;
-};
-
-/// Pass to outline similar regions.
-class IROutlinerPass : public PassInfoMixin<IROutlinerPass> {
-public:
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_IPO_IROUTLINER_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- IROutliner.h - Extract similar IR regions into functions ------------==//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// \file
+// The interface file for the IROutliner which is used by the IROutliner Pass.
+//
+// The outliner uses the IRSimilarityIdentifier to identify the similar regions
+// of code. It evaluates each set of IRSimilarityCandidates with an estimate of
+// whether it will provide code size reduction. Each region is extracted using
+// the code extractor. These extracted functions are consolidated into a single
+// function and called from the extracted call site.
+//
+// For example:
+// \code
+// %1 = add i32 %a, %b
+// %2 = add i32 %b, %a
+// %3 = add i32 %b, %a
+// %4 = add i32 %a, %b
+// \endcode
+// would become function
+// \code
+// define internal void outlined_ir_function(i32 %0, i32 %1) {
+// %1 = add i32 %0, %1
+// %2 = add i32 %1, %0
+// ret void
+// }
+// \endcode
+// with calls:
+// \code
+// call void outlined_ir_function(i32 %a, i32 %b)
+// call void outlined_ir_function(i32 %b, i32 %a)
+// \endcode
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_IROUTLINER_H
+#define LLVM_TRANSFORMS_IPO_IROUTLINER_H
+
+#include "llvm/Analysis/IRSimilarityIdentifier.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/IR/ValueMap.h"
+#include "llvm/Support/InstructionCost.h"
+#include "llvm/Transforms/Utils/CodeExtractor.h"
+#include <set>
+
+struct OutlinableGroup;
+
+namespace llvm {
+using namespace IRSimilarity;
+
+class Module;
+class TargetTransformInfo;
+class OptimizationRemarkEmitter;
+
+/// The OutlinableRegion holds all the information for a specific region, or
+/// sequence of instructions. This includes what values need to be hoisted to
+/// arguments from the extracted function, inputs and outputs to the region, and
+/// mapping from the extracted function arguments to overall function arguments.
+struct OutlinableRegion {
+ /// Describes the region of code.
+ IRSimilarityCandidate *Candidate;
+
+ /// If this region is outlined, the front and back IRInstructionData could
+ /// potentially become invalidated if the only new instruction is a call.
+ /// This ensures that we replace in the instruction in the IRInstructionData.
+ IRInstructionData *NewFront = nullptr;
+ IRInstructionData *NewBack = nullptr;
+
+ /// The number of extracted inputs from the CodeExtractor.
+ unsigned NumExtractedInputs;
+
+ /// The corresponding BasicBlock with the appropriate stores for this
+ /// OutlinableRegion in the overall function.
+ unsigned OutputBlockNum;
+
+ /// Mapping the extracted argument number to the argument number in the
+ /// overall function. Since there will be inputs, such as elevated constants
+ /// that are not the same in each region in a SimilarityGroup, or values that
+ /// cannot be sunk into the extracted section in every region, we must keep
+ /// track of which extracted argument maps to which overall argument.
+ DenseMap<unsigned, unsigned> ExtractedArgToAgg;
+ DenseMap<unsigned, unsigned> AggArgToExtracted;
+
+ /// Mapping of the argument number in the deduplicated function
+ /// to a given constant, which is used when creating the arguments to the call
+ /// to the newly created deduplicated function. This is handled separately
+ /// since the CodeExtractor does not recognize constants.
+ DenseMap<unsigned, Constant *> AggArgToConstant;
+
+ /// The global value numbers that are used as outputs for this section. Once
+ /// extracted, each output will be stored to an output register. This
+ /// documents the global value numbers that are used in this pattern.
+ SmallVector<unsigned, 4> GVNStores;
+
+ /// Used to create an outlined function.
+ CodeExtractor *CE = nullptr;
+
+ /// The call site of the extracted region.
+ CallInst *Call = nullptr;
+
+ /// The function for the extracted region.
+ Function *ExtractedFunction = nullptr;
+
+ /// Flag for whether we have split out the IRSimilarityCanidate. That is,
+ /// make the region contained the IRSimilarityCandidate its own BasicBlock.
+ bool CandidateSplit = false;
+
+ /// Flag for whether we should not consider this region for extraction.
+ bool IgnoreRegion = false;
+
+ /// The BasicBlock that is before the start of the region BasicBlock,
+ /// only defined when the region has been split.
+ BasicBlock *PrevBB = nullptr;
+
+ /// The BasicBlock that contains the starting instruction of the region.
+ BasicBlock *StartBB = nullptr;
+
+ /// The BasicBlock that contains the ending instruction of the region.
+ BasicBlock *EndBB = nullptr;
+
+ /// The BasicBlock that is after the start of the region BasicBlock,
+ /// only defined when the region has been split.
+ BasicBlock *FollowBB = nullptr;
+
+ /// The Outlinable Group that contains this region and structurally similar
+ /// regions to this region.
+ OutlinableGroup *Parent = nullptr;
+
+ OutlinableRegion(IRSimilarityCandidate &C, OutlinableGroup &Group)
+ : Candidate(&C), Parent(&Group) {
+ StartBB = C.getStartBB();
+ EndBB = C.getEndBB();
+ }
+
+ /// For the contained region, split the parent BasicBlock at the starting and
+ /// ending instructions of the contained IRSimilarityCandidate.
+ void splitCandidate();
+
+ /// For the contained region, reattach the BasicBlock at the starting and
+ /// ending instructions of the contained IRSimilarityCandidate, or if the
+ /// function has been extracted, the start and end of the BasicBlock
+ /// containing the called function.
+ void reattachCandidate();
+
+ /// Get the size of the code removed from the region.
+ ///
+ /// \param [in] TTI - The TargetTransformInfo for the parent function.
+ /// \returns the code size of the region
+ InstructionCost getBenefit(TargetTransformInfo &TTI);
+};
+
+/// This class is a pass that identifies similarity in a Module, extracts
+/// instances of the similarity, and then consolidating the similar regions
+/// in an effort to reduce code size. It uses the IRSimilarityIdentifier pass
+/// to identify the similar regions of code, and then extracts the similar
+/// sections into a single function. See the above for an example as to
+/// how code is extracted and consolidated into a single function.
+class IROutliner {
+public:
+ IROutliner(function_ref<TargetTransformInfo &(Function &)> GTTI,
+ function_ref<IRSimilarityIdentifier &(Module &)> GIRSI,
+ function_ref<OptimizationRemarkEmitter &(Function &)> GORE)
+ : getTTI(GTTI), getIRSI(GIRSI), getORE(GORE) {}
+ bool run(Module &M);
+
+private:
+ /// Find repeated similar code sequences in \p M and outline them into new
+ /// Functions.
+ ///
+ /// \param [in] M - The module to outline from.
+ /// \returns The number of Functions created.
+ unsigned doOutline(Module &M);
+
+ /// Remove all the IRSimilarityCandidates from \p CandidateVec that have
+ /// instructions contained in a previously outlined region and put the
+ /// remaining regions in \p CurrentGroup.
+ ///
+ /// \param [in] CandidateVec - List of similarity candidates for regions with
+ /// the same similarity structure.
+ /// \param [in,out] CurrentGroup - Contains the potential sections to
+ /// be outlined.
+ void
+ pruneIncompatibleRegions(std::vector<IRSimilarityCandidate> &CandidateVec,
+ OutlinableGroup &CurrentGroup);
+
+ /// Create the function based on the overall types found in the current
+ /// regions being outlined.
+ ///
+ /// \param M - The module to outline from.
+ /// \param [in,out] CG - The OutlinableGroup for the regions to be outlined.
+ /// \param [in] FunctionNameSuffix - How many functions have we previously
+ /// created.
+ /// \returns the newly created function.
+ Function *createFunction(Module &M, OutlinableGroup &CG,
+ unsigned FunctionNameSuffix);
+
+ /// Identify the needed extracted inputs in a section, and add to the overall
+ /// function if needed.
+ ///
+ /// \param [in] M - The module to outline from.
+ /// \param [in,out] Region - The region to be extracted.
+ /// \param [in] NotSame - The global value numbers of the Values in the region
+ /// that do not have the same Constant in each strucutrally similar region.
+ void findAddInputsOutputs(Module &M, OutlinableRegion &Region,
+ DenseSet<unsigned> &NotSame);
+
+ /// Find the number of instructions that will be removed by extracting the
+ /// OutlinableRegions in \p CurrentGroup.
+ ///
+ /// \param [in] CurrentGroup - The collection of OutlinableRegions to be
+ /// analyzed.
+ /// \returns the number of outlined instructions across all regions.
+ InstructionCost findBenefitFromAllRegions(OutlinableGroup &CurrentGroup);
+
+ /// Find the number of instructions that will be added by reloading arguments.
+ ///
+ /// \param [in] CurrentGroup - The collection of OutlinableRegions to be
+ /// analyzed.
+ /// \returns the number of added reload instructions across all regions.
+ InstructionCost findCostOutputReloads(OutlinableGroup &CurrentGroup);
+
+ /// Find the cost and the benefit of \p CurrentGroup and save it back to
+ /// \p CurrentGroup.
+ ///
+ /// \param [in] M - The module being analyzed
+ /// \param [in,out] CurrentGroup - The overall outlined section
+ void findCostBenefit(Module &M, OutlinableGroup &CurrentGroup);
+
+ /// Update the output mapping based on the load instruction, and the outputs
+ /// of the extracted function.
+ ///
+ /// \param Region - The region extracted
+ /// \param Outputs - The outputs from the extracted function.
+ /// \param LI - The load instruction used to update the mapping.
+ void updateOutputMapping(OutlinableRegion &Region,
+ ArrayRef<Value *> Outputs, LoadInst *LI);
+
+ /// Extract \p Region into its own function.
+ ///
+ /// \param [in] Region - The region to be extracted into its own function.
+ /// \returns True if it was successfully outlined.
+ bool extractSection(OutlinableRegion &Region);
+
+ /// For the similarities found, and the extracted sections, create a single
+ /// outlined function with appropriate output blocks as necessary.
+ ///
+ /// \param [in] M - The module to outline from
+ /// \param [in] CurrentGroup - The set of extracted sections to consolidate.
+ /// \param [in,out] FuncsToRemove - List of functions to remove from the
+ /// module after outlining is completed.
+ /// \param [in,out] OutlinedFunctionNum - the number of new outlined
+ /// functions.
+ void deduplicateExtractedSections(Module &M, OutlinableGroup &CurrentGroup,
+ std::vector<Function *> &FuncsToRemove,
+ unsigned &OutlinedFunctionNum);
+
+ /// If true, enables us to outline from functions that have LinkOnceFromODR
+ /// linkages.
+ bool OutlineFromLinkODRs = false;
+
+ /// If false, we do not worry if the cost is greater than the benefit. This
+ /// is for debugging and testing, so that we can test small cases to ensure
+ /// that the outlining is being done correctly.
+ bool CostModel = true;
+
+ /// The set of outlined Instructions, identified by their location in the
+ /// sequential ordering of instructions in a Module.
+ DenseSet<unsigned> Outlined;
+
+ /// TargetTransformInfo lambda for target specific information.
+ function_ref<TargetTransformInfo &(Function &)> getTTI;
+
+ /// A mapping from newly created reloaded output values to the original value.
+ /// If an value is replace by an output from an outlined region, this maps
+ /// that Value, back to its original Value.
+ DenseMap<Value *, Value *> OutputMappings;
+
+ /// IRSimilarityIdentifier lambda to retrieve IRSimilarityIdentifier.
+ function_ref<IRSimilarityIdentifier &(Module &)> getIRSI;
+
+ /// The optimization remark emitter for the pass.
+ function_ref<OptimizationRemarkEmitter &(Function &)> getORE;
+
+ /// The memory allocator used to allocate the CodeExtractors.
+ SpecificBumpPtrAllocator<CodeExtractor> ExtractorAllocator;
+
+ /// The memory allocator used to allocate the OutlinableRegions.
+ SpecificBumpPtrAllocator<OutlinableRegion> RegionAllocator;
+
+ /// The memory allocator used to allocate new IRInstructionData.
+ SpecificBumpPtrAllocator<IRInstructionData> InstDataAllocator;
+
+ /// Custom InstVisitor to classify different instructions for whether it can
+ /// be analyzed for similarity. This is needed as there may be instruction we
+ /// can identify as having similarity, but are more complicated to outline.
+ struct InstructionAllowed : public InstVisitor<InstructionAllowed, bool> {
+ InstructionAllowed() {}
+
+ // TODO: Determine a scheme to resolve when the label is similar enough.
+ bool visitBranchInst(BranchInst &BI) { return false; }
+ // TODO: Determine a scheme to resolve when the labels are similar enough.
+ bool visitPHINode(PHINode &PN) { return false; }
+ // TODO: Handle allocas.
+ bool visitAllocaInst(AllocaInst &AI) { return false; }
+ // VAArg instructions are not allowed since this could cause difficulty when
+ // differentiating between different sets of variable instructions in
+ // the deduplicated outlined regions.
+ bool visitVAArgInst(VAArgInst &VI) { return false; }
+ // We exclude all exception handling cases since they are so context
+ // dependent.
+ bool visitLandingPadInst(LandingPadInst &LPI) { return false; }
+ bool visitFuncletPadInst(FuncletPadInst &FPI) { return false; }
+ // DebugInfo should be included in the regions, but should not be
+ // analyzed for similarity as it has no bearing on the outcome of the
+ // program.
+ bool visitDbgInfoIntrinsic(DbgInfoIntrinsic &DII) { return true; }
+ // TODO: Handle specific intrinsics individually from those that can be
+ // handled.
+ bool IntrinsicInst(IntrinsicInst &II) { return false; }
+ // We only handle CallInsts that are not indirect, since we cannot guarantee
+ // that they have a name in these cases.
+ bool visitCallInst(CallInst &CI) {
+ Function *F = CI.getCalledFunction();
+ if (!F || CI.isIndirectCall() || !F->hasName())
+ return false;
+ return true;
+ }
+ // TODO: Handle FreezeInsts. Since a frozen value could be frozen inside
+ // the outlined region, and then returned as an output, this will have to be
+ // handled differently.
+ bool visitFreezeInst(FreezeInst &CI) { return false; }
+ // TODO: We do not current handle similarity that changes the control flow.
+ bool visitInvokeInst(InvokeInst &II) { return false; }
+ // TODO: We do not current handle similarity that changes the control flow.
+ bool visitCallBrInst(CallBrInst &CBI) { return false; }
+ // TODO: Handle interblock similarity.
+ bool visitTerminator(Instruction &I) { return false; }
+ bool visitInstruction(Instruction &I) { return true; }
+ };
+
+ /// A InstVisitor used to exclude certain instructions from being outlined.
+ InstructionAllowed InstructionClassifier;
+};
+
+/// Pass to outline similar regions.
+class IROutlinerPass : public PassInfoMixin<IROutlinerPass> {
+public:
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_IPO_IROUTLINER_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/Inliner.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/Inliner.h
index a5b5934b73..2430425c60 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/Inliner.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/Inliner.h
@@ -21,8 +21,8 @@
#include "llvm/Analysis/InlineAdvisor.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LazyCallGraph.h"
-#include "llvm/Analysis/ReplayInlineAdvisor.h"
-#include "llvm/Analysis/Utils/ImportedFunctionsInliningStatistics.h"
+#include "llvm/Analysis/ReplayInlineAdvisor.h"
+#include "llvm/Analysis/Utils/ImportedFunctionsInliningStatistics.h"
#include "llvm/IR/PassManager.h"
#include <utility>
@@ -104,8 +104,8 @@ protected:
/// passes be composed to achieve the same end result.
class InlinerPass : public PassInfoMixin<InlinerPass> {
public:
- InlinerPass(bool OnlyMandatory = false) : OnlyMandatory(OnlyMandatory) {}
- InlinerPass(InlinerPass &&Arg) = default;
+ InlinerPass(bool OnlyMandatory = false) : OnlyMandatory(OnlyMandatory) {}
+ InlinerPass(InlinerPass &&Arg) = default;
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
@@ -113,8 +113,8 @@ public:
private:
InlineAdvisor &getAdvisor(const ModuleAnalysisManagerCGSCCProxy::Result &MAM,
FunctionAnalysisManager &FAM, Module &M);
- std::unique_ptr<InlineAdvisor> OwnedAdvisor;
- const bool OnlyMandatory;
+ std::unique_ptr<InlineAdvisor> OwnedAdvisor;
+ const bool OnlyMandatory;
};
/// Module pass, wrapping the inliner pass. This works in conjunction with the
@@ -127,7 +127,7 @@ class ModuleInlinerWrapperPass
public:
ModuleInlinerWrapperPass(
InlineParams Params = getInlineParams(), bool Debugging = false,
- bool MandatoryFirst = true,
+ bool MandatoryFirst = true,
InliningAdvisorMode Mode = InliningAdvisorMode::Default,
unsigned MaxDevirtIterations = 0);
ModuleInlinerWrapperPass(ModuleInlinerWrapperPass &&Arg) = default;
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/LoopExtractor.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/LoopExtractor.h
index 3b721a1279..ede8250980 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/LoopExtractor.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/LoopExtractor.h
@@ -1,43 +1,43 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- LoopExtractor.h - Extract each loop into a new function ------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// A pass wrapper around the ExtractLoop() scalar transformation to extract each
-// top-level loop into its own new function. If the loop is the ONLY loop in a
-// given function, it is not touched. This is a pass most useful for debugging
-// via bugpoint.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_IPO_LOOPEXTRACTOR_H
-#define LLVM_TRANSFORMS_IPO_LOOPEXTRACTOR_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-struct LoopExtractorPass : public PassInfoMixin<LoopExtractorPass> {
- LoopExtractorPass(unsigned NumLoops = ~0) : NumLoops(NumLoops) {}
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-private:
- unsigned NumLoops;
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_IPO_LOOPEXTRACTOR_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- LoopExtractor.h - Extract each loop into a new function ------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// A pass wrapper around the ExtractLoop() scalar transformation to extract each
+// top-level loop into its own new function. If the loop is the ONLY loop in a
+// given function, it is not touched. This is a pass most useful for debugging
+// via bugpoint.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_LOOPEXTRACTOR_H
+#define LLVM_TRANSFORMS_IPO_LOOPEXTRACTOR_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+struct LoopExtractorPass : public PassInfoMixin<LoopExtractorPass> {
+ LoopExtractorPass(unsigned NumLoops = ~0) : NumLoops(NumLoops) {}
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+
+private:
+ unsigned NumLoops;
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_IPO_LOOPEXTRACTOR_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/LowerTypeTests.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/LowerTypeTests.h
index 8ad2193588..40761ef91e 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/LowerTypeTests.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/LowerTypeTests.h
@@ -205,14 +205,14 @@ bool isJumpTableCanonical(Function *F);
} // end namespace lowertypetests
class LowerTypeTestsPass : public PassInfoMixin<LowerTypeTestsPass> {
- bool UseCommandLine = false;
-
- ModuleSummaryIndex *ExportSummary = nullptr;
- const ModuleSummaryIndex *ImportSummary = nullptr;
- bool DropTypeTests = true;
-
+ bool UseCommandLine = false;
+
+ ModuleSummaryIndex *ExportSummary = nullptr;
+ const ModuleSummaryIndex *ImportSummary = nullptr;
+ bool DropTypeTests = true;
+
public:
- LowerTypeTestsPass() : UseCommandLine(true) {}
+ LowerTypeTestsPass() : UseCommandLine(true) {}
LowerTypeTestsPass(ModuleSummaryIndex *ExportSummary,
const ModuleSummaryIndex *ImportSummary,
bool DropTypeTests = false)
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/OpenMPOpt.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/OpenMPOpt.h
index 76aff7eb6f..4e8071e60c 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/OpenMPOpt.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/OpenMPOpt.h
@@ -40,11 +40,11 @@ struct OpenMPInModule {
bool isKnown() { return Value != OpenMP::UNKNOWN; }
operator bool() { return Value != OpenMP::NOT_FOUND; }
- /// Does this function \p F contain any OpenMP runtime calls?
- bool containsOMPRuntimeCalls(Function *F) const {
- return FuncsWithOMPRuntimeCalls.contains(F);
- }
-
+ /// Does this function \p F contain any OpenMP runtime calls?
+ bool containsOMPRuntimeCalls(Function *F) const {
+ return FuncsWithOMPRuntimeCalls.contains(F);
+ }
+
/// Return the known kernels (=GPU entry points) in the module.
SmallPtrSetImpl<Kernel> &getKernels() { return Kernels; }
@@ -54,11 +54,11 @@ struct OpenMPInModule {
private:
enum class OpenMP { FOUND, NOT_FOUND, UNKNOWN } Value = OpenMP::UNKNOWN;
- friend bool containsOpenMP(Module &M, OpenMPInModule &OMPInModule);
-
- /// In which functions are OpenMP runtime calls present?
- SmallPtrSet<Function *, 32> FuncsWithOMPRuntimeCalls;
-
+ friend bool containsOpenMP(Module &M, OpenMPInModule &OMPInModule);
+
+ /// In which functions are OpenMP runtime calls present?
+ SmallPtrSet<Function *, 32> FuncsWithOMPRuntimeCalls;
+
/// Collection of known kernels (=GPU entry points) in the module.
SmallPtrSet<Kernel, 8> Kernels;
};
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleContextTracker.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleContextTracker.h
index e5f5e5b737..11328fb5ac 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleContextTracker.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleContextTracker.h
@@ -1,163 +1,163 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- Transforms/IPO/SampleContextTracker.h --------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-/// \file
-/// This file provides the interface for context-sensitive profile tracker used
-/// by CSSPGO.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
-#define LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
-
-#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Analysis/CallGraph.h"
-#include "llvm/IR/DebugInfoMetadata.h"
-#include "llvm/IR/Instructions.h"
-#include "llvm/ProfileData/SampleProf.h"
-#include <list>
-#include <map>
-#include <vector>
-
-using namespace llvm;
-using namespace sampleprof;
-
-namespace llvm {
-
-// Internal trie tree representation used for tracking context tree and sample
-// profiles. The path from root node to a given node represents the context of
-// that nodes' profile.
-class ContextTrieNode {
-public:
- ContextTrieNode(ContextTrieNode *Parent = nullptr,
- StringRef FName = StringRef(),
- FunctionSamples *FSamples = nullptr,
- LineLocation CallLoc = {0, 0})
- : ParentContext(Parent), FuncName(FName), FuncSamples(FSamples),
- CallSiteLoc(CallLoc){};
- ContextTrieNode *getChildContext(const LineLocation &CallSite,
- StringRef CalleeName);
- ContextTrieNode *getHottestChildContext(const LineLocation &CallSite);
- ContextTrieNode *getOrCreateChildContext(const LineLocation &CallSite,
- StringRef CalleeName,
- bool AllowCreate = true);
-
- ContextTrieNode &moveToChildContext(const LineLocation &CallSite,
- ContextTrieNode &&NodeToMove,
- StringRef ContextStrToRemove,
- bool DeleteNode = true);
- void removeChildContext(const LineLocation &CallSite, StringRef CalleeName);
- std::map<uint32_t, ContextTrieNode> &getAllChildContext();
- const StringRef getFuncName() const;
- FunctionSamples *getFunctionSamples() const;
- void setFunctionSamples(FunctionSamples *FSamples);
- LineLocation getCallSiteLoc() const;
- ContextTrieNode *getParentContext() const;
- void setParentContext(ContextTrieNode *Parent);
- void dump();
-
-private:
- static uint32_t nodeHash(StringRef ChildName, const LineLocation &Callsite);
-
- // Map line+discriminator location to child context
- std::map<uint32_t, ContextTrieNode> AllChildContext;
-
- // Link to parent context node
- ContextTrieNode *ParentContext;
-
- // Function name for current context
- StringRef FuncName;
-
- // Function Samples for current context
- FunctionSamples *FuncSamples;
-
- // Callsite location in parent context
- LineLocation CallSiteLoc;
-};
-
-// Profile tracker that manages profiles and its associated context. It
-// provides interfaces used by sample profile loader to query context profile or
-// base profile for given function or location; it also manages context tree
-// manipulation that is needed to accommodate inline decisions so we have
-// accurate post-inline profile for functions. Internally context profiles
-// are organized in a trie, with each node representing profile for specific
-// calling context and the context is identified by path from root to the node.
-class SampleContextTracker {
-public:
- using ContextSamplesTy = SmallSet<FunctionSamples *, 16>;
-
- SampleContextTracker(StringMap<FunctionSamples> &Profiles);
- // Query context profile for a specific callee with given name at a given
- // call-site. The full context is identified by location of call instruction.
- FunctionSamples *getCalleeContextSamplesFor(const CallBase &Inst,
- StringRef CalleeName);
- // Get samples for indirect call targets for call site at given location.
- std::vector<const FunctionSamples *>
- getIndirectCalleeContextSamplesFor(const DILocation *DIL);
- // Query context profile for a given location. The full context
- // is identified by input DILocation.
- FunctionSamples *getContextSamplesFor(const DILocation *DIL);
- // Query context profile for a given sample contxt of a function.
- FunctionSamples *getContextSamplesFor(const SampleContext &Context);
- // Get all context profile for given function.
- ContextSamplesTy &getAllContextSamplesFor(const Function &Func);
- ContextSamplesTy &getAllContextSamplesFor(StringRef Name);
- // Query base profile for a given function. A base profile is a merged view
- // of all context profiles for contexts that are not inlined.
- FunctionSamples *getBaseSamplesFor(const Function &Func,
- bool MergeContext = true);
- // Query base profile for a given function by name.
- FunctionSamples *getBaseSamplesFor(StringRef Name, bool MergeContext);
- // Mark a context profile as inlined when function is inlined.
- // This makes sure that inlined context profile will be excluded in
- // function's base profile.
- void markContextSamplesInlined(const FunctionSamples *InlinedSamples);
- void promoteMergeContextSamplesTree(const Instruction &Inst,
- StringRef CalleeName);
- void addCallGraphEdges(CallGraph &CG, StringMap<Function *> &SymbolMap);
- // Dump the internal context profile trie.
- void dump();
-
-private:
- ContextTrieNode *getContextFor(const DILocation *DIL);
- ContextTrieNode *getContextFor(const SampleContext &Context);
- ContextTrieNode *getCalleeContextFor(const DILocation *DIL,
- StringRef CalleeName);
- ContextTrieNode *getOrCreateContextPath(const SampleContext &Context,
- bool AllowCreate);
- ContextTrieNode *getTopLevelContextNode(StringRef FName);
- ContextTrieNode &addTopLevelContextNode(StringRef FName);
- ContextTrieNode &promoteMergeContextSamplesTree(ContextTrieNode &NodeToPromo);
- void mergeContextNode(ContextTrieNode &FromNode, ContextTrieNode &ToNode,
- StringRef ContextStrToRemove);
- ContextTrieNode &promoteMergeContextSamplesTree(ContextTrieNode &FromNode,
- ContextTrieNode &ToNodeParent,
- StringRef ContextStrToRemove);
-
- // Map from function name to context profiles (excluding base profile)
- StringMap<ContextSamplesTy> FuncToCtxtProfileSet;
-
- // Root node for context trie tree
- ContextTrieNode RootContext;
-};
-
-} // end namespace llvm
-#endif // LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- Transforms/IPO/SampleContextTracker.h --------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// This file provides the interface for context-sensitive profile tracker used
+/// by CSSPGO.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
+#define LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
+
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/CallGraph.h"
+#include "llvm/IR/DebugInfoMetadata.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/ProfileData/SampleProf.h"
+#include <list>
+#include <map>
+#include <vector>
+
+using namespace llvm;
+using namespace sampleprof;
+
+namespace llvm {
+
+// Internal trie tree representation used for tracking context tree and sample
+// profiles. The path from root node to a given node represents the context of
+// that nodes' profile.
+class ContextTrieNode {
+public:
+ ContextTrieNode(ContextTrieNode *Parent = nullptr,
+ StringRef FName = StringRef(),
+ FunctionSamples *FSamples = nullptr,
+ LineLocation CallLoc = {0, 0})
+ : ParentContext(Parent), FuncName(FName), FuncSamples(FSamples),
+ CallSiteLoc(CallLoc){};
+ ContextTrieNode *getChildContext(const LineLocation &CallSite,
+ StringRef CalleeName);
+ ContextTrieNode *getHottestChildContext(const LineLocation &CallSite);
+ ContextTrieNode *getOrCreateChildContext(const LineLocation &CallSite,
+ StringRef CalleeName,
+ bool AllowCreate = true);
+
+ ContextTrieNode &moveToChildContext(const LineLocation &CallSite,
+ ContextTrieNode &&NodeToMove,
+ StringRef ContextStrToRemove,
+ bool DeleteNode = true);
+ void removeChildContext(const LineLocation &CallSite, StringRef CalleeName);
+ std::map<uint32_t, ContextTrieNode> &getAllChildContext();
+ const StringRef getFuncName() const;
+ FunctionSamples *getFunctionSamples() const;
+ void setFunctionSamples(FunctionSamples *FSamples);
+ LineLocation getCallSiteLoc() const;
+ ContextTrieNode *getParentContext() const;
+ void setParentContext(ContextTrieNode *Parent);
+ void dump();
+
+private:
+ static uint32_t nodeHash(StringRef ChildName, const LineLocation &Callsite);
+
+ // Map line+discriminator location to child context
+ std::map<uint32_t, ContextTrieNode> AllChildContext;
+
+ // Link to parent context node
+ ContextTrieNode *ParentContext;
+
+ // Function name for current context
+ StringRef FuncName;
+
+ // Function Samples for current context
+ FunctionSamples *FuncSamples;
+
+ // Callsite location in parent context
+ LineLocation CallSiteLoc;
+};
+
+// Profile tracker that manages profiles and its associated context. It
+// provides interfaces used by sample profile loader to query context profile or
+// base profile for given function or location; it also manages context tree
+// manipulation that is needed to accommodate inline decisions so we have
+// accurate post-inline profile for functions. Internally context profiles
+// are organized in a trie, with each node representing profile for specific
+// calling context and the context is identified by path from root to the node.
+class SampleContextTracker {
+public:
+ using ContextSamplesTy = SmallSet<FunctionSamples *, 16>;
+
+ SampleContextTracker(StringMap<FunctionSamples> &Profiles);
+ // Query context profile for a specific callee with given name at a given
+ // call-site. The full context is identified by location of call instruction.
+ FunctionSamples *getCalleeContextSamplesFor(const CallBase &Inst,
+ StringRef CalleeName);
+ // Get samples for indirect call targets for call site at given location.
+ std::vector<const FunctionSamples *>
+ getIndirectCalleeContextSamplesFor(const DILocation *DIL);
+ // Query context profile for a given location. The full context
+ // is identified by input DILocation.
+ FunctionSamples *getContextSamplesFor(const DILocation *DIL);
+ // Query context profile for a given sample contxt of a function.
+ FunctionSamples *getContextSamplesFor(const SampleContext &Context);
+ // Get all context profile for given function.
+ ContextSamplesTy &getAllContextSamplesFor(const Function &Func);
+ ContextSamplesTy &getAllContextSamplesFor(StringRef Name);
+ // Query base profile for a given function. A base profile is a merged view
+ // of all context profiles for contexts that are not inlined.
+ FunctionSamples *getBaseSamplesFor(const Function &Func,
+ bool MergeContext = true);
+ // Query base profile for a given function by name.
+ FunctionSamples *getBaseSamplesFor(StringRef Name, bool MergeContext);
+ // Mark a context profile as inlined when function is inlined.
+ // This makes sure that inlined context profile will be excluded in
+ // function's base profile.
+ void markContextSamplesInlined(const FunctionSamples *InlinedSamples);
+ void promoteMergeContextSamplesTree(const Instruction &Inst,
+ StringRef CalleeName);
+ void addCallGraphEdges(CallGraph &CG, StringMap<Function *> &SymbolMap);
+ // Dump the internal context profile trie.
+ void dump();
+
+private:
+ ContextTrieNode *getContextFor(const DILocation *DIL);
+ ContextTrieNode *getContextFor(const SampleContext &Context);
+ ContextTrieNode *getCalleeContextFor(const DILocation *DIL,
+ StringRef CalleeName);
+ ContextTrieNode *getOrCreateContextPath(const SampleContext &Context,
+ bool AllowCreate);
+ ContextTrieNode *getTopLevelContextNode(StringRef FName);
+ ContextTrieNode &addTopLevelContextNode(StringRef FName);
+ ContextTrieNode &promoteMergeContextSamplesTree(ContextTrieNode &NodeToPromo);
+ void mergeContextNode(ContextTrieNode &FromNode, ContextTrieNode &ToNode,
+ StringRef ContextStrToRemove);
+ ContextTrieNode &promoteMergeContextSamplesTree(ContextTrieNode &FromNode,
+ ContextTrieNode &ToNodeParent,
+ StringRef ContextStrToRemove);
+
+ // Map from function name to context profiles (excluding base profile)
+ StringMap<ContextSamplesTy> FuncToCtxtProfileSet;
+
+ // Root node for context trie tree
+ ContextTrieNode RootContext;
+};
+
+} // end namespace llvm
+#endif // LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfile.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfile.h
index be24fac675..9cc502eba6 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfile.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfile.h
@@ -31,18 +31,18 @@ class Module;
/// The sample profiler data loader pass.
class SampleProfileLoaderPass : public PassInfoMixin<SampleProfileLoaderPass> {
public:
- SampleProfileLoaderPass(
- std::string File = "", std::string RemappingFile = "",
- ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None)
+ SampleProfileLoaderPass(
+ std::string File = "", std::string RemappingFile = "",
+ ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None)
: ProfileFileName(File), ProfileRemappingFileName(RemappingFile),
- LTOPhase(LTOPhase) {}
+ LTOPhase(LTOPhase) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
private:
std::string ProfileFileName;
std::string ProfileRemappingFileName;
- ThinOrFullLTOPhase LTOPhase;
+ ThinOrFullLTOPhase LTOPhase;
};
} // end namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfileProbe.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfileProbe.h
index 55d7546fe7..7163fe38c0 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfileProbe.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/SampleProfileProbe.h
@@ -1,158 +1,158 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- Transforms/IPO/SampleProfileProbe.h ----------*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-/// \file
-/// This file provides the interface for the pseudo probe implementation for
-/// AutoFDO.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_IPO_SAMPLEPROFILEPROBE_H
-#define LLVM_TRANSFORMS_IPO_SAMPLEPROFILEPROBE_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/Analysis/CallGraphSCCPass.h"
-#include "llvm/Analysis/LazyCallGraph.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/IR/PassInstrumentation.h"
-#include "llvm/IR/PassManager.h"
-#include "llvm/IR/PseudoProbe.h"
-#include "llvm/ProfileData/SampleProf.h"
-#include "llvm/Target/TargetMachine.h"
-#include <unordered_map>
-
-namespace llvm {
-
-class Module;
-
-using namespace sampleprof;
-using BlockIdMap = std::unordered_map<BasicBlock *, uint32_t>;
-using InstructionIdMap = std::unordered_map<Instruction *, uint32_t>;
-using ProbeFactorMap = std::unordered_map<uint64_t, float>;
-using FuncProbeFactorMap = StringMap<ProbeFactorMap>;
-
-enum class PseudoProbeReservedId { Invalid = 0, Last = Invalid };
-
-class PseudoProbeDescriptor {
- uint64_t FunctionGUID;
- uint64_t FunctionHash;
-
-public:
- PseudoProbeDescriptor(uint64_t GUID, uint64_t Hash)
- : FunctionGUID(GUID), FunctionHash(Hash) {}
- uint64_t getFunctionGUID() const { return FunctionGUID; }
- uint64_t getFunctionHash() const { return FunctionHash; }
-};
-
-// A pseudo probe verifier that can be run after each IR passes to detect the
-// violation of updating probe factors. In principle, the sum of distribution
-// factor for a probe should be identical before and after a pass. For a
-// function pass, the factor sum for a probe would be typically 100%.
-class PseudoProbeVerifier {
-public:
- void registerCallbacks(PassInstrumentationCallbacks &PIC);
-
- // Implementation of pass instrumentation callbacks for new pass manager.
- void runAfterPass(StringRef PassID, Any IR);
-
-private:
- // Allow a little bias due the rounding to integral factors.
- constexpr static float DistributionFactorVariance = 0.02f;
- // Distribution factors from last pass.
- FuncProbeFactorMap FunctionProbeFactors;
-
- void collectProbeFactors(const BasicBlock *BB, ProbeFactorMap &ProbeFactors);
- void runAfterPass(const Module *M);
- void runAfterPass(const LazyCallGraph::SCC *C);
- void runAfterPass(const Function *F);
- void runAfterPass(const Loop *L);
- bool shouldVerifyFunction(const Function *F);
- void verifyProbeFactors(const Function *F,
- const ProbeFactorMap &ProbeFactors);
-};
-
-// This class serves sample counts correlation for SampleProfileLoader by
-// analyzing pseudo probes and their function descriptors injected by
-// SampleProfileProber.
-class PseudoProbeManager {
- DenseMap<uint64_t, PseudoProbeDescriptor> GUIDToProbeDescMap;
-
- const PseudoProbeDescriptor *getDesc(const Function &F) const;
-
-public:
- PseudoProbeManager(const Module &M);
- bool moduleIsProbed(const Module &M) const;
- bool profileIsValid(const Function &F, const FunctionSamples &Samples) const;
-};
-
-/// Sample profile pseudo prober.
-///
-/// Insert pseudo probes for block sampling and value sampling.
-class SampleProfileProber {
-public:
- // Give an empty module id when the prober is not used for instrumentation.
- SampleProfileProber(Function &F, const std::string &CurModuleUniqueId);
- void instrumentOneFunc(Function &F, TargetMachine *TM);
-
-private:
- Function *getFunction() const { return F; }
- uint64_t getFunctionHash() const { return FunctionHash; }
- uint32_t getBlockId(const BasicBlock *BB) const;
- uint32_t getCallsiteId(const Instruction *Call) const;
- void computeCFGHash();
- void computeProbeIdForBlocks();
- void computeProbeIdForCallsites();
-
- Function *F;
-
- /// The current module ID that is used to name a static object as a comdat
- /// group.
- std::string CurModuleUniqueId;
-
- /// A CFG hash code used to identify a function code changes.
- uint64_t FunctionHash;
-
- /// Map basic blocks to the their pseudo probe ids.
- BlockIdMap BlockProbeIds;
-
- /// Map indirect calls to the their pseudo probe ids.
- InstructionIdMap CallProbeIds;
-
- /// The ID of the last probe, Can be used to number a new probe.
- uint32_t LastProbeId;
-};
-
-class SampleProfileProbePass : public PassInfoMixin<SampleProfileProbePass> {
- TargetMachine *TM;
-
-public:
- SampleProfileProbePass(TargetMachine *TM) : TM(TM) {}
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-class PseudoProbeUpdatePass : public PassInfoMixin<PseudoProbeUpdatePass> {
- void runOnFunction(Function &F, FunctionAnalysisManager &FAM);
-
-public:
- PseudoProbeUpdatePass() {}
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-} // end namespace llvm
-#endif // LLVM_TRANSFORMS_IPO_SAMPLEPROFILEPROBE_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- Transforms/IPO/SampleProfileProbe.h ----------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// This file provides the interface for the pseudo probe implementation for
+/// AutoFDO.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_SAMPLEPROFILEPROBE_H
+#define LLVM_TRANSFORMS_IPO_SAMPLEPROFILEPROBE_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/Analysis/CallGraphSCCPass.h"
+#include "llvm/Analysis/LazyCallGraph.h"
+#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/IR/PassInstrumentation.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PseudoProbe.h"
+#include "llvm/ProfileData/SampleProf.h"
+#include "llvm/Target/TargetMachine.h"
+#include <unordered_map>
+
+namespace llvm {
+
+class Module;
+
+using namespace sampleprof;
+using BlockIdMap = std::unordered_map<BasicBlock *, uint32_t>;
+using InstructionIdMap = std::unordered_map<Instruction *, uint32_t>;
+using ProbeFactorMap = std::unordered_map<uint64_t, float>;
+using FuncProbeFactorMap = StringMap<ProbeFactorMap>;
+
+enum class PseudoProbeReservedId { Invalid = 0, Last = Invalid };
+
+class PseudoProbeDescriptor {
+ uint64_t FunctionGUID;
+ uint64_t FunctionHash;
+
+public:
+ PseudoProbeDescriptor(uint64_t GUID, uint64_t Hash)
+ : FunctionGUID(GUID), FunctionHash(Hash) {}
+ uint64_t getFunctionGUID() const { return FunctionGUID; }
+ uint64_t getFunctionHash() const { return FunctionHash; }
+};
+
+// A pseudo probe verifier that can be run after each IR passes to detect the
+// violation of updating probe factors. In principle, the sum of distribution
+// factor for a probe should be identical before and after a pass. For a
+// function pass, the factor sum for a probe would be typically 100%.
+class PseudoProbeVerifier {
+public:
+ void registerCallbacks(PassInstrumentationCallbacks &PIC);
+
+ // Implementation of pass instrumentation callbacks for new pass manager.
+ void runAfterPass(StringRef PassID, Any IR);
+
+private:
+ // Allow a little bias due the rounding to integral factors.
+ constexpr static float DistributionFactorVariance = 0.02f;
+ // Distribution factors from last pass.
+ FuncProbeFactorMap FunctionProbeFactors;
+
+ void collectProbeFactors(const BasicBlock *BB, ProbeFactorMap &ProbeFactors);
+ void runAfterPass(const Module *M);
+ void runAfterPass(const LazyCallGraph::SCC *C);
+ void runAfterPass(const Function *F);
+ void runAfterPass(const Loop *L);
+ bool shouldVerifyFunction(const Function *F);
+ void verifyProbeFactors(const Function *F,
+ const ProbeFactorMap &ProbeFactors);
+};
+
+// This class serves sample counts correlation for SampleProfileLoader by
+// analyzing pseudo probes and their function descriptors injected by
+// SampleProfileProber.
+class PseudoProbeManager {
+ DenseMap<uint64_t, PseudoProbeDescriptor> GUIDToProbeDescMap;
+
+ const PseudoProbeDescriptor *getDesc(const Function &F) const;
+
+public:
+ PseudoProbeManager(const Module &M);
+ bool moduleIsProbed(const Module &M) const;
+ bool profileIsValid(const Function &F, const FunctionSamples &Samples) const;
+};
+
+/// Sample profile pseudo prober.
+///
+/// Insert pseudo probes for block sampling and value sampling.
+class SampleProfileProber {
+public:
+ // Give an empty module id when the prober is not used for instrumentation.
+ SampleProfileProber(Function &F, const std::string &CurModuleUniqueId);
+ void instrumentOneFunc(Function &F, TargetMachine *TM);
+
+private:
+ Function *getFunction() const { return F; }
+ uint64_t getFunctionHash() const { return FunctionHash; }
+ uint32_t getBlockId(const BasicBlock *BB) const;
+ uint32_t getCallsiteId(const Instruction *Call) const;
+ void computeCFGHash();
+ void computeProbeIdForBlocks();
+ void computeProbeIdForCallsites();
+
+ Function *F;
+
+ /// The current module ID that is used to name a static object as a comdat
+ /// group.
+ std::string CurModuleUniqueId;
+
+ /// A CFG hash code used to identify a function code changes.
+ uint64_t FunctionHash;
+
+ /// Map basic blocks to the their pseudo probe ids.
+ BlockIdMap BlockProbeIds;
+
+ /// Map indirect calls to the their pseudo probe ids.
+ InstructionIdMap CallProbeIds;
+
+ /// The ID of the last probe, Can be used to number a new probe.
+ uint32_t LastProbeId;
+};
+
+class SampleProfileProbePass : public PassInfoMixin<SampleProfileProbePass> {
+ TargetMachine *TM;
+
+public:
+ SampleProfileProbePass(TargetMachine *TM) : TM(TM) {}
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+class PseudoProbeUpdatePass : public PassInfoMixin<PseudoProbeUpdatePass> {
+ void runOnFunction(Function &F, FunctionAnalysisManager &FAM);
+
+public:
+ PseudoProbeUpdatePass() {}
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // end namespace llvm
+#endif // LLVM_TRANSFORMS_IPO_SAMPLEPROFILEPROBE_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/StripSymbols.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/StripSymbols.h
index 21ce7b836f..83829c1fa8 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/StripSymbols.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/StripSymbols.h
@@ -1,58 +1,58 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- StripSymbols.h - Strip symbols and debug info from a module --------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// The StripSymbols transformation implements code stripping. Specifically, it
-// can delete:
-//
-// * names for virtual registers
-// * symbols for internal globals and functions
-// * debug information
-//
-// Note that this transformation makes code much less readable, so it should
-// only be used in situations where the 'strip' utility would be used, such as
-// reducing code size or making it harder to reverse engineer code.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_IPO_STRIPSYMBOLS_H
-#define LLVM_TRANSFORMS_IPO_STRIPSYMBOLS_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-struct StripSymbolsPass : PassInfoMixin<StripSymbolsPass> {
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-struct StripNonDebugSymbolsPass : PassInfoMixin<StripNonDebugSymbolsPass> {
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-struct StripDebugDeclarePass : PassInfoMixin<StripDebugDeclarePass> {
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-struct StripDeadDebugInfoPass : PassInfoMixin<StripDeadDebugInfoPass> {
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_IPO_STRIPSYMBOLS_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- StripSymbols.h - Strip symbols and debug info from a module --------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// The StripSymbols transformation implements code stripping. Specifically, it
+// can delete:
+//
+// * names for virtual registers
+// * symbols for internal globals and functions
+// * debug information
+//
+// Note that this transformation makes code much less readable, so it should
+// only be used in situations where the 'strip' utility would be used, such as
+// reducing code size or making it harder to reverse engineer code.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_STRIPSYMBOLS_H
+#define LLVM_TRANSFORMS_IPO_STRIPSYMBOLS_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+struct StripSymbolsPass : PassInfoMixin<StripSymbolsPass> {
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+struct StripNonDebugSymbolsPass : PassInfoMixin<StripNonDebugSymbolsPass> {
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+struct StripDebugDeclarePass : PassInfoMixin<StripDebugDeclarePass> {
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+struct StripDeadDebugInfoPass : PassInfoMixin<StripDeadDebugInfoPass> {
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_IPO_STRIPSYMBOLS_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/IPO/WholeProgramDevirt.h b/contrib/libs/llvm12/include/llvm/Transforms/IPO/WholeProgramDevirt.h
index 0e0cc1fd16..135d78a1d3 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/IPO/WholeProgramDevirt.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/IPO/WholeProgramDevirt.h
@@ -230,9 +230,9 @@ void setAfterReturnValues(MutableArrayRef<VirtualCallTarget> Targets,
struct WholeProgramDevirtPass : public PassInfoMixin<WholeProgramDevirtPass> {
ModuleSummaryIndex *ExportSummary;
const ModuleSummaryIndex *ImportSummary;
- bool UseCommandLine = false;
- WholeProgramDevirtPass()
- : ExportSummary(nullptr), ImportSummary(nullptr), UseCommandLine(true) {}
+ bool UseCommandLine = false;
+ WholeProgramDevirtPass()
+ : ExportSummary(nullptr), ImportSummary(nullptr), UseCommandLine(true) {}
WholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary,
const ModuleSummaryIndex *ImportSummary)
: ExportSummary(ExportSummary), ImportSummary(ImportSummary) {
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/InstCombine/InstCombiner.h b/contrib/libs/llvm12/include/llvm/Transforms/InstCombine/InstCombiner.h
index eff73fb86c..430bc69af6 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/InstCombine/InstCombiner.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/InstCombine/InstCombiner.h
@@ -1,539 +1,539 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- InstCombiner.h - InstCombine implementation --------------*- 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
-//
-//===----------------------------------------------------------------------===//
-/// \file
-///
-/// This file provides the interface for the instcombine pass implementation.
-/// The interface is used for generic transformations in this folder and
-/// target specific combinations in the targets.
-/// The visitor implementation is in \c InstCombinerImpl in
-/// \c InstCombineInternal.h.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINER_H
-#define LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINER_H
-
-#include "llvm/Analysis/InstructionSimplify.h"
-#include "llvm/Analysis/TargetFolder.h"
-#include "llvm/Analysis/ValueTracking.h"
-#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/PatternMatch.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/KnownBits.h"
-#include "llvm/Transforms/InstCombine/InstCombineWorklist.h"
-#include <cassert>
-
-#define DEBUG_TYPE "instcombine"
-
-namespace llvm {
-
-class AAResults;
-class AssumptionCache;
-class ProfileSummaryInfo;
-class TargetLibraryInfo;
-class TargetTransformInfo;
-
-/// The core instruction combiner logic.
-///
-/// This class provides both the logic to recursively visit instructions and
-/// combine them.
-class LLVM_LIBRARY_VISIBILITY InstCombiner {
- /// Only used to call target specific inst combining.
- TargetTransformInfo &TTI;
-
-public:
- /// Maximum size of array considered when transforming.
- uint64_t MaxArraySizeForCombine = 0;
-
- /// An IRBuilder that automatically inserts new instructions into the
- /// worklist.
- using BuilderTy = IRBuilder<TargetFolder, IRBuilderCallbackInserter>;
- BuilderTy &Builder;
-
-protected:
- /// A worklist of the instructions that need to be simplified.
- InstCombineWorklist &Worklist;
-
- // Mode in which we are running the combiner.
- const bool MinimizeSize;
-
- AAResults *AA;
-
- // Required analyses.
- AssumptionCache &AC;
- TargetLibraryInfo &TLI;
- DominatorTree &DT;
- const DataLayout &DL;
- const SimplifyQuery SQ;
- OptimizationRemarkEmitter &ORE;
- BlockFrequencyInfo *BFI;
- ProfileSummaryInfo *PSI;
-
- // Optional analyses. When non-null, these can both be used to do better
- // combining and will be updated to reflect any changes.
- LoopInfo *LI;
-
- bool MadeIRChange = false;
-
-public:
- InstCombiner(InstCombineWorklist &Worklist, BuilderTy &Builder,
- bool MinimizeSize, AAResults *AA, AssumptionCache &AC,
- TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
- DominatorTree &DT, OptimizationRemarkEmitter &ORE,
- BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI,
- const DataLayout &DL, LoopInfo *LI)
- : TTI(TTI), Builder(Builder), Worklist(Worklist),
- MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
- SQ(DL, &TLI, &DT, &AC), ORE(ORE), BFI(BFI), PSI(PSI), LI(LI) {}
-
- virtual ~InstCombiner() {}
-
- /// Return the source operand of a potentially bitcasted value while
- /// optionally checking if it has one use. If there is no bitcast or the one
- /// use check is not met, return the input value itself.
- static Value *peekThroughBitcast(Value *V, bool OneUseOnly = false) {
- if (auto *BitCast = dyn_cast<BitCastInst>(V))
- if (!OneUseOnly || BitCast->hasOneUse())
- return BitCast->getOperand(0);
-
- // V is not a bitcast or V has more than one use and OneUseOnly is true.
- return V;
- }
-
- /// Assign a complexity or rank value to LLVM Values. This is used to reduce
- /// the amount of pattern matching needed for compares and commutative
- /// instructions. For example, if we have:
- /// icmp ugt X, Constant
- /// or
- /// xor (add X, Constant), cast Z
- ///
- /// We do not have to consider the commuted variants of these patterns because
- /// canonicalization based on complexity guarantees the above ordering.
- ///
- /// This routine maps IR values to various complexity ranks:
- /// 0 -> undef
- /// 1 -> Constants
- /// 2 -> Other non-instructions
- /// 3 -> Arguments
- /// 4 -> Cast and (f)neg/not instructions
- /// 5 -> Other instructions
- static unsigned getComplexity(Value *V) {
- if (isa<Instruction>(V)) {
- if (isa<CastInst>(V) || match(V, m_Neg(PatternMatch::m_Value())) ||
- match(V, m_Not(PatternMatch::m_Value())) ||
- match(V, m_FNeg(PatternMatch::m_Value())))
- return 4;
- return 5;
- }
- if (isa<Argument>(V))
- return 3;
- return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
- }
-
- /// Predicate canonicalization reduces the number of patterns that need to be
- /// matched by other transforms. For example, we may swap the operands of a
- /// conditional branch or select to create a compare with a canonical
- /// (inverted) predicate which is then more likely to be matched with other
- /// values.
- static bool isCanonicalPredicate(CmpInst::Predicate Pred) {
- switch (Pred) {
- case CmpInst::ICMP_NE:
- case CmpInst::ICMP_ULE:
- case CmpInst::ICMP_SLE:
- case CmpInst::ICMP_UGE:
- case CmpInst::ICMP_SGE:
- // TODO: There are 16 FCMP predicates. Should others be (not) canonical?
- case CmpInst::FCMP_ONE:
- case CmpInst::FCMP_OLE:
- case CmpInst::FCMP_OGE:
- return false;
- default:
- return true;
- }
- }
-
- /// Given an exploded icmp instruction, return true if the comparison only
- /// checks the sign bit. If it only checks the sign bit, set TrueIfSigned if
- /// the result of the comparison is true when the input value is signed.
- static bool isSignBitCheck(ICmpInst::Predicate Pred, const APInt &RHS,
- bool &TrueIfSigned) {
- switch (Pred) {
- case ICmpInst::ICMP_SLT: // True if LHS s< 0
- TrueIfSigned = true;
- return RHS.isNullValue();
- case ICmpInst::ICMP_SLE: // True if LHS s<= -1
- TrueIfSigned = true;
- return RHS.isAllOnesValue();
- case ICmpInst::ICMP_SGT: // True if LHS s> -1
- TrueIfSigned = false;
- return RHS.isAllOnesValue();
- case ICmpInst::ICMP_SGE: // True if LHS s>= 0
- TrueIfSigned = false;
- return RHS.isNullValue();
- case ICmpInst::ICMP_UGT:
- // True if LHS u> RHS and RHS == sign-bit-mask - 1
- TrueIfSigned = true;
- return RHS.isMaxSignedValue();
- case ICmpInst::ICMP_UGE:
- // True if LHS u>= RHS and RHS == sign-bit-mask (2^7, 2^15, 2^31, etc)
- TrueIfSigned = true;
- return RHS.isMinSignedValue();
- case ICmpInst::ICMP_ULT:
- // True if LHS u< RHS and RHS == sign-bit-mask (2^7, 2^15, 2^31, etc)
- TrueIfSigned = false;
- return RHS.isMinSignedValue();
- case ICmpInst::ICMP_ULE:
- // True if LHS u<= RHS and RHS == sign-bit-mask - 1
- TrueIfSigned = false;
- return RHS.isMaxSignedValue();
- default:
- return false;
- }
- }
-
- /// Add one to a Constant
- static Constant *AddOne(Constant *C) {
- return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
- }
-
- /// Subtract one from a Constant
- static Constant *SubOne(Constant *C) {
- return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1));
- }
-
- llvm::Optional<std::pair<
- CmpInst::Predicate,
- Constant *>> static getFlippedStrictnessPredicateAndConstant(CmpInst::
- Predicate
- Pred,
- Constant *C);
-
- static bool shouldAvoidAbsorbingNotIntoSelect(const SelectInst &SI) {
- // a ? b : false and a ? true : b are the canonical form of logical and/or.
- // This includes !a ? b : false and !a ? true : b. Absorbing the not into
- // the select by swapping operands would break recognition of this pattern
- // in other analyses, so don't do that.
- return match(&SI, PatternMatch::m_LogicalAnd(PatternMatch::m_Value(),
- PatternMatch::m_Value())) ||
- match(&SI, PatternMatch::m_LogicalOr(PatternMatch::m_Value(),
- PatternMatch::m_Value()));
- }
-
- /// Return true if the specified value is free to invert (apply ~ to).
- /// This happens in cases where the ~ can be eliminated. If WillInvertAllUses
- /// is true, work under the assumption that the caller intends to remove all
- /// uses of V and only keep uses of ~V.
- ///
- /// See also: canFreelyInvertAllUsersOf()
- static bool isFreeToInvert(Value *V, bool WillInvertAllUses) {
- // ~(~(X)) -> X.
- if (match(V, m_Not(PatternMatch::m_Value())))
- return true;
-
- // Constants can be considered to be not'ed values.
- if (match(V, PatternMatch::m_AnyIntegralConstant()))
- return true;
-
- // Compares can be inverted if all of their uses are being modified to use
- // the ~V.
- if (isa<CmpInst>(V))
- return WillInvertAllUses;
-
- // If `V` is of the form `A + Constant` then `-1 - V` can be folded into
- // `(-1 - Constant) - A` if we are willing to invert all of the uses.
- if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V))
- if (BO->getOpcode() == Instruction::Add ||
- BO->getOpcode() == Instruction::Sub)
- if (isa<Constant>(BO->getOperand(0)) ||
- isa<Constant>(BO->getOperand(1)))
- return WillInvertAllUses;
-
- // Selects with invertible operands are freely invertible
- if (match(V,
- m_Select(PatternMatch::m_Value(), m_Not(PatternMatch::m_Value()),
- m_Not(PatternMatch::m_Value()))))
- return WillInvertAllUses;
-
- return false;
- }
-
- /// Given i1 V, can every user of V be freely adapted if V is changed to !V ?
- /// InstCombine's freelyInvertAllUsersOf() must be kept in sync with this fn.
- ///
- /// See also: isFreeToInvert()
- static bool canFreelyInvertAllUsersOf(Value *V, Value *IgnoredUser) {
- // Look at every user of V.
- for (Use &U : V->uses()) {
- if (U.getUser() == IgnoredUser)
- continue; // Don't consider this user.
-
- auto *I = cast<Instruction>(U.getUser());
- switch (I->getOpcode()) {
- case Instruction::Select:
- if (U.getOperandNo() != 0) // Only if the value is used as select cond.
- return false;
- if (shouldAvoidAbsorbingNotIntoSelect(*cast<SelectInst>(I)))
- return false;
- break;
- case Instruction::Br:
- assert(U.getOperandNo() == 0 && "Must be branching on that value.");
- break; // Free to invert by swapping true/false values/destinations.
- case Instruction::Xor: // Can invert 'xor' if it's a 'not', by ignoring
- // it.
- if (!match(I, m_Not(PatternMatch::m_Value())))
- return false; // Not a 'not'.
- break;
- default:
- return false; // Don't know, likely not freely invertible.
- }
- // So far all users were free to invert...
- }
- return true; // Can freely invert all users!
- }
-
- /// Some binary operators require special handling to avoid poison and
- /// undefined behavior. If a constant vector has undef elements, replace those
- /// undefs with identity constants if possible because those are always safe
- /// to execute. If no identity constant exists, replace undef with some other
- /// safe constant.
- static Constant *
- getSafeVectorConstantForBinop(BinaryOperator::BinaryOps Opcode, Constant *In,
- bool IsRHSConstant) {
- auto *InVTy = cast<FixedVectorType>(In->getType());
-
- Type *EltTy = InVTy->getElementType();
- auto *SafeC = ConstantExpr::getBinOpIdentity(Opcode, EltTy, IsRHSConstant);
- if (!SafeC) {
- // TODO: Should this be available as a constant utility function? It is
- // similar to getBinOpAbsorber().
- if (IsRHSConstant) {
- switch (Opcode) {
- case Instruction::SRem: // X % 1 = 0
- case Instruction::URem: // X %u 1 = 0
- SafeC = ConstantInt::get(EltTy, 1);
- break;
- case Instruction::FRem: // X % 1.0 (doesn't simplify, but it is safe)
- SafeC = ConstantFP::get(EltTy, 1.0);
- break;
- default:
- llvm_unreachable(
- "Only rem opcodes have no identity constant for RHS");
- }
- } else {
- switch (Opcode) {
- case Instruction::Shl: // 0 << X = 0
- case Instruction::LShr: // 0 >>u X = 0
- case Instruction::AShr: // 0 >> X = 0
- case Instruction::SDiv: // 0 / X = 0
- case Instruction::UDiv: // 0 /u X = 0
- case Instruction::SRem: // 0 % X = 0
- case Instruction::URem: // 0 %u X = 0
- case Instruction::Sub: // 0 - X (doesn't simplify, but it is safe)
- case Instruction::FSub: // 0.0 - X (doesn't simplify, but it is safe)
- case Instruction::FDiv: // 0.0 / X (doesn't simplify, but it is safe)
- case Instruction::FRem: // 0.0 % X = 0
- SafeC = Constant::getNullValue(EltTy);
- break;
- default:
- llvm_unreachable("Expected to find identity constant for opcode");
- }
- }
- }
- assert(SafeC && "Must have safe constant for binop");
- unsigned NumElts = InVTy->getNumElements();
- SmallVector<Constant *, 16> Out(NumElts);
- for (unsigned i = 0; i != NumElts; ++i) {
- Constant *C = In->getAggregateElement(i);
- Out[i] = isa<UndefValue>(C) ? SafeC : C;
- }
- return ConstantVector::get(Out);
- }
-
- /// Create and insert the idiom we use to indicate a block is unreachable
- /// without having to rewrite the CFG from within InstCombine.
- static void CreateNonTerminatorUnreachable(Instruction *InsertAt) {
- auto &Ctx = InsertAt->getContext();
- new StoreInst(ConstantInt::getTrue(Ctx),
- UndefValue::get(Type::getInt1PtrTy(Ctx)), InsertAt);
- }
-
- void addToWorklist(Instruction *I) { Worklist.push(I); }
-
- AssumptionCache &getAssumptionCache() const { return AC; }
- TargetLibraryInfo &getTargetLibraryInfo() const { return TLI; }
- DominatorTree &getDominatorTree() const { return DT; }
- const DataLayout &getDataLayout() const { return DL; }
- const SimplifyQuery &getSimplifyQuery() const { return SQ; }
- OptimizationRemarkEmitter &getOptimizationRemarkEmitter() const {
- return ORE;
- }
- BlockFrequencyInfo *getBlockFrequencyInfo() const { return BFI; }
- ProfileSummaryInfo *getProfileSummaryInfo() const { return PSI; }
- LoopInfo *getLoopInfo() const { return LI; }
-
- // Call target specific combiners
- Optional<Instruction *> targetInstCombineIntrinsic(IntrinsicInst &II);
- Optional<Value *>
- targetSimplifyDemandedUseBitsIntrinsic(IntrinsicInst &II, APInt DemandedMask,
- KnownBits &Known,
- bool &KnownBitsComputed);
- Optional<Value *> targetSimplifyDemandedVectorEltsIntrinsic(
- IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
- APInt &UndefElts2, APInt &UndefElts3,
- std::function<void(Instruction *, unsigned, APInt, APInt &)>
- SimplifyAndSetOp);
-
- /// Inserts an instruction \p New before instruction \p Old
- ///
- /// Also adds the new instruction to the worklist and returns \p New so that
- /// it is suitable for use as the return from the visitation patterns.
- Instruction *InsertNewInstBefore(Instruction *New, Instruction &Old) {
- assert(New && !New->getParent() &&
- "New instruction already inserted into a basic block!");
- BasicBlock *BB = Old.getParent();
- BB->getInstList().insert(Old.getIterator(), New); // Insert inst
- Worklist.push(New);
- return New;
- }
-
- /// Same as InsertNewInstBefore, but also sets the debug loc.
- Instruction *InsertNewInstWith(Instruction *New, Instruction &Old) {
- New->setDebugLoc(Old.getDebugLoc());
- return InsertNewInstBefore(New, Old);
- }
-
- /// A combiner-aware RAUW-like routine.
- ///
- /// This method is to be used when an instruction is found to be dead,
- /// replaceable with another preexisting expression. Here we add all uses of
- /// I to the worklist, replace all uses of I with the new value, then return
- /// I, so that the inst combiner will know that I was modified.
- Instruction *replaceInstUsesWith(Instruction &I, Value *V) {
- // If there are no uses to replace, then we return nullptr to indicate that
- // no changes were made to the program.
- if (I.use_empty())
- return nullptr;
-
- Worklist.pushUsersToWorkList(I); // Add all modified instrs to worklist.
-
- // If we are replacing the instruction with itself, this must be in a
- // segment of unreachable code, so just clobber the instruction.
- if (&I == V)
- V = UndefValue::get(I.getType());
-
- LLVM_DEBUG(dbgs() << "IC: Replacing " << I << "\n"
- << " with " << *V << '\n');
-
- I.replaceAllUsesWith(V);
- return &I;
- }
-
- /// Replace operand of instruction and add old operand to the worklist.
- Instruction *replaceOperand(Instruction &I, unsigned OpNum, Value *V) {
- Worklist.addValue(I.getOperand(OpNum));
- I.setOperand(OpNum, V);
- return &I;
- }
-
- /// Replace use and add the previously used value to the worklist.
- void replaceUse(Use &U, Value *NewValue) {
- Worklist.addValue(U);
- U = NewValue;
- }
-
- /// Combiner aware instruction erasure.
- ///
- /// When dealing with an instruction that has side effects or produces a void
- /// value, we can't rely on DCE to delete the instruction. Instead, visit
- /// methods should return the value returned by this function.
- virtual Instruction *eraseInstFromFunction(Instruction &I) = 0;
-
- void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth,
- const Instruction *CxtI) const {
- llvm::computeKnownBits(V, Known, DL, Depth, &AC, CxtI, &DT);
- }
-
- KnownBits computeKnownBits(const Value *V, unsigned Depth,
- const Instruction *CxtI) const {
- return llvm::computeKnownBits(V, DL, Depth, &AC, CxtI, &DT);
- }
-
- bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero = false,
- unsigned Depth = 0,
- const Instruction *CxtI = nullptr) {
- return llvm::isKnownToBeAPowerOfTwo(V, DL, OrZero, Depth, &AC, CxtI, &DT);
- }
-
- bool MaskedValueIsZero(const Value *V, const APInt &Mask, unsigned Depth = 0,
- const Instruction *CxtI = nullptr) const {
- return llvm::MaskedValueIsZero(V, Mask, DL, Depth, &AC, CxtI, &DT);
- }
-
- unsigned ComputeNumSignBits(const Value *Op, unsigned Depth = 0,
- const Instruction *CxtI = nullptr) const {
- return llvm::ComputeNumSignBits(Op, DL, Depth, &AC, CxtI, &DT);
- }
-
- OverflowResult computeOverflowForUnsignedMul(const Value *LHS,
- const Value *RHS,
- const Instruction *CxtI) const {
- return llvm::computeOverflowForUnsignedMul(LHS, RHS, DL, &AC, CxtI, &DT);
- }
-
- OverflowResult computeOverflowForSignedMul(const Value *LHS, const Value *RHS,
- const Instruction *CxtI) const {
- return llvm::computeOverflowForSignedMul(LHS, RHS, DL, &AC, CxtI, &DT);
- }
-
- OverflowResult computeOverflowForUnsignedAdd(const Value *LHS,
- const Value *RHS,
- const Instruction *CxtI) const {
- return llvm::computeOverflowForUnsignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
- }
-
- OverflowResult computeOverflowForSignedAdd(const Value *LHS, const Value *RHS,
- const Instruction *CxtI) const {
- return llvm::computeOverflowForSignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
- }
-
- OverflowResult computeOverflowForUnsignedSub(const Value *LHS,
- const Value *RHS,
- const Instruction *CxtI) const {
- return llvm::computeOverflowForUnsignedSub(LHS, RHS, DL, &AC, CxtI, &DT);
- }
-
- OverflowResult computeOverflowForSignedSub(const Value *LHS, const Value *RHS,
- const Instruction *CxtI) const {
- return llvm::computeOverflowForSignedSub(LHS, RHS, DL, &AC, CxtI, &DT);
- }
-
- virtual bool SimplifyDemandedBits(Instruction *I, unsigned OpNo,
- const APInt &DemandedMask, KnownBits &Known,
- unsigned Depth = 0) = 0;
- virtual Value *
- SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, APInt &UndefElts,
- unsigned Depth = 0,
- bool AllowMultipleUsers = false) = 0;
-};
-
-} // namespace llvm
-
-#undef DEBUG_TYPE
-
-#endif
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- InstCombiner.h - InstCombine implementation --------------*- 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
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file provides the interface for the instcombine pass implementation.
+/// The interface is used for generic transformations in this folder and
+/// target specific combinations in the targets.
+/// The visitor implementation is in \c InstCombinerImpl in
+/// \c InstCombineInternal.h.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINER_H
+#define LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINER_H
+
+#include "llvm/Analysis/InstructionSimplify.h"
+#include "llvm/Analysis/TargetFolder.h"
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/PatternMatch.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/KnownBits.h"
+#include "llvm/Transforms/InstCombine/InstCombineWorklist.h"
+#include <cassert>
+
+#define DEBUG_TYPE "instcombine"
+
+namespace llvm {
+
+class AAResults;
+class AssumptionCache;
+class ProfileSummaryInfo;
+class TargetLibraryInfo;
+class TargetTransformInfo;
+
+/// The core instruction combiner logic.
+///
+/// This class provides both the logic to recursively visit instructions and
+/// combine them.
+class LLVM_LIBRARY_VISIBILITY InstCombiner {
+ /// Only used to call target specific inst combining.
+ TargetTransformInfo &TTI;
+
+public:
+ /// Maximum size of array considered when transforming.
+ uint64_t MaxArraySizeForCombine = 0;
+
+ /// An IRBuilder that automatically inserts new instructions into the
+ /// worklist.
+ using BuilderTy = IRBuilder<TargetFolder, IRBuilderCallbackInserter>;
+ BuilderTy &Builder;
+
+protected:
+ /// A worklist of the instructions that need to be simplified.
+ InstCombineWorklist &Worklist;
+
+ // Mode in which we are running the combiner.
+ const bool MinimizeSize;
+
+ AAResults *AA;
+
+ // Required analyses.
+ AssumptionCache &AC;
+ TargetLibraryInfo &TLI;
+ DominatorTree &DT;
+ const DataLayout &DL;
+ const SimplifyQuery SQ;
+ OptimizationRemarkEmitter &ORE;
+ BlockFrequencyInfo *BFI;
+ ProfileSummaryInfo *PSI;
+
+ // Optional analyses. When non-null, these can both be used to do better
+ // combining and will be updated to reflect any changes.
+ LoopInfo *LI;
+
+ bool MadeIRChange = false;
+
+public:
+ InstCombiner(InstCombineWorklist &Worklist, BuilderTy &Builder,
+ bool MinimizeSize, AAResults *AA, AssumptionCache &AC,
+ TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
+ DominatorTree &DT, OptimizationRemarkEmitter &ORE,
+ BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI,
+ const DataLayout &DL, LoopInfo *LI)
+ : TTI(TTI), Builder(Builder), Worklist(Worklist),
+ MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
+ SQ(DL, &TLI, &DT, &AC), ORE(ORE), BFI(BFI), PSI(PSI), LI(LI) {}
+
+ virtual ~InstCombiner() {}
+
+ /// Return the source operand of a potentially bitcasted value while
+ /// optionally checking if it has one use. If there is no bitcast or the one
+ /// use check is not met, return the input value itself.
+ static Value *peekThroughBitcast(Value *V, bool OneUseOnly = false) {
+ if (auto *BitCast = dyn_cast<BitCastInst>(V))
+ if (!OneUseOnly || BitCast->hasOneUse())
+ return BitCast->getOperand(0);
+
+ // V is not a bitcast or V has more than one use and OneUseOnly is true.
+ return V;
+ }
+
+ /// Assign a complexity or rank value to LLVM Values. This is used to reduce
+ /// the amount of pattern matching needed for compares and commutative
+ /// instructions. For example, if we have:
+ /// icmp ugt X, Constant
+ /// or
+ /// xor (add X, Constant), cast Z
+ ///
+ /// We do not have to consider the commuted variants of these patterns because
+ /// canonicalization based on complexity guarantees the above ordering.
+ ///
+ /// This routine maps IR values to various complexity ranks:
+ /// 0 -> undef
+ /// 1 -> Constants
+ /// 2 -> Other non-instructions
+ /// 3 -> Arguments
+ /// 4 -> Cast and (f)neg/not instructions
+ /// 5 -> Other instructions
+ static unsigned getComplexity(Value *V) {
+ if (isa<Instruction>(V)) {
+ if (isa<CastInst>(V) || match(V, m_Neg(PatternMatch::m_Value())) ||
+ match(V, m_Not(PatternMatch::m_Value())) ||
+ match(V, m_FNeg(PatternMatch::m_Value())))
+ return 4;
+ return 5;
+ }
+ if (isa<Argument>(V))
+ return 3;
+ return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
+ }
+
+ /// Predicate canonicalization reduces the number of patterns that need to be
+ /// matched by other transforms. For example, we may swap the operands of a
+ /// conditional branch or select to create a compare with a canonical
+ /// (inverted) predicate which is then more likely to be matched with other
+ /// values.
+ static bool isCanonicalPredicate(CmpInst::Predicate Pred) {
+ switch (Pred) {
+ case CmpInst::ICMP_NE:
+ case CmpInst::ICMP_ULE:
+ case CmpInst::ICMP_SLE:
+ case CmpInst::ICMP_UGE:
+ case CmpInst::ICMP_SGE:
+ // TODO: There are 16 FCMP predicates. Should others be (not) canonical?
+ case CmpInst::FCMP_ONE:
+ case CmpInst::FCMP_OLE:
+ case CmpInst::FCMP_OGE:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ /// Given an exploded icmp instruction, return true if the comparison only
+ /// checks the sign bit. If it only checks the sign bit, set TrueIfSigned if
+ /// the result of the comparison is true when the input value is signed.
+ static bool isSignBitCheck(ICmpInst::Predicate Pred, const APInt &RHS,
+ bool &TrueIfSigned) {
+ switch (Pred) {
+ case ICmpInst::ICMP_SLT: // True if LHS s< 0
+ TrueIfSigned = true;
+ return RHS.isNullValue();
+ case ICmpInst::ICMP_SLE: // True if LHS s<= -1
+ TrueIfSigned = true;
+ return RHS.isAllOnesValue();
+ case ICmpInst::ICMP_SGT: // True if LHS s> -1
+ TrueIfSigned = false;
+ return RHS.isAllOnesValue();
+ case ICmpInst::ICMP_SGE: // True if LHS s>= 0
+ TrueIfSigned = false;
+ return RHS.isNullValue();
+ case ICmpInst::ICMP_UGT:
+ // True if LHS u> RHS and RHS == sign-bit-mask - 1
+ TrueIfSigned = true;
+ return RHS.isMaxSignedValue();
+ case ICmpInst::ICMP_UGE:
+ // True if LHS u>= RHS and RHS == sign-bit-mask (2^7, 2^15, 2^31, etc)
+ TrueIfSigned = true;
+ return RHS.isMinSignedValue();
+ case ICmpInst::ICMP_ULT:
+ // True if LHS u< RHS and RHS == sign-bit-mask (2^7, 2^15, 2^31, etc)
+ TrueIfSigned = false;
+ return RHS.isMinSignedValue();
+ case ICmpInst::ICMP_ULE:
+ // True if LHS u<= RHS and RHS == sign-bit-mask - 1
+ TrueIfSigned = false;
+ return RHS.isMaxSignedValue();
+ default:
+ return false;
+ }
+ }
+
+ /// Add one to a Constant
+ static Constant *AddOne(Constant *C) {
+ return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
+ }
+
+ /// Subtract one from a Constant
+ static Constant *SubOne(Constant *C) {
+ return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1));
+ }
+
+ llvm::Optional<std::pair<
+ CmpInst::Predicate,
+ Constant *>> static getFlippedStrictnessPredicateAndConstant(CmpInst::
+ Predicate
+ Pred,
+ Constant *C);
+
+ static bool shouldAvoidAbsorbingNotIntoSelect(const SelectInst &SI) {
+ // a ? b : false and a ? true : b are the canonical form of logical and/or.
+ // This includes !a ? b : false and !a ? true : b. Absorbing the not into
+ // the select by swapping operands would break recognition of this pattern
+ // in other analyses, so don't do that.
+ return match(&SI, PatternMatch::m_LogicalAnd(PatternMatch::m_Value(),
+ PatternMatch::m_Value())) ||
+ match(&SI, PatternMatch::m_LogicalOr(PatternMatch::m_Value(),
+ PatternMatch::m_Value()));
+ }
+
+ /// Return true if the specified value is free to invert (apply ~ to).
+ /// This happens in cases where the ~ can be eliminated. If WillInvertAllUses
+ /// is true, work under the assumption that the caller intends to remove all
+ /// uses of V and only keep uses of ~V.
+ ///
+ /// See also: canFreelyInvertAllUsersOf()
+ static bool isFreeToInvert(Value *V, bool WillInvertAllUses) {
+ // ~(~(X)) -> X.
+ if (match(V, m_Not(PatternMatch::m_Value())))
+ return true;
+
+ // Constants can be considered to be not'ed values.
+ if (match(V, PatternMatch::m_AnyIntegralConstant()))
+ return true;
+
+ // Compares can be inverted if all of their uses are being modified to use
+ // the ~V.
+ if (isa<CmpInst>(V))
+ return WillInvertAllUses;
+
+ // If `V` is of the form `A + Constant` then `-1 - V` can be folded into
+ // `(-1 - Constant) - A` if we are willing to invert all of the uses.
+ if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V))
+ if (BO->getOpcode() == Instruction::Add ||
+ BO->getOpcode() == Instruction::Sub)
+ if (isa<Constant>(BO->getOperand(0)) ||
+ isa<Constant>(BO->getOperand(1)))
+ return WillInvertAllUses;
+
+ // Selects with invertible operands are freely invertible
+ if (match(V,
+ m_Select(PatternMatch::m_Value(), m_Not(PatternMatch::m_Value()),
+ m_Not(PatternMatch::m_Value()))))
+ return WillInvertAllUses;
+
+ return false;
+ }
+
+ /// Given i1 V, can every user of V be freely adapted if V is changed to !V ?
+ /// InstCombine's freelyInvertAllUsersOf() must be kept in sync with this fn.
+ ///
+ /// See also: isFreeToInvert()
+ static bool canFreelyInvertAllUsersOf(Value *V, Value *IgnoredUser) {
+ // Look at every user of V.
+ for (Use &U : V->uses()) {
+ if (U.getUser() == IgnoredUser)
+ continue; // Don't consider this user.
+
+ auto *I = cast<Instruction>(U.getUser());
+ switch (I->getOpcode()) {
+ case Instruction::Select:
+ if (U.getOperandNo() != 0) // Only if the value is used as select cond.
+ return false;
+ if (shouldAvoidAbsorbingNotIntoSelect(*cast<SelectInst>(I)))
+ return false;
+ break;
+ case Instruction::Br:
+ assert(U.getOperandNo() == 0 && "Must be branching on that value.");
+ break; // Free to invert by swapping true/false values/destinations.
+ case Instruction::Xor: // Can invert 'xor' if it's a 'not', by ignoring
+ // it.
+ if (!match(I, m_Not(PatternMatch::m_Value())))
+ return false; // Not a 'not'.
+ break;
+ default:
+ return false; // Don't know, likely not freely invertible.
+ }
+ // So far all users were free to invert...
+ }
+ return true; // Can freely invert all users!
+ }
+
+ /// Some binary operators require special handling to avoid poison and
+ /// undefined behavior. If a constant vector has undef elements, replace those
+ /// undefs with identity constants if possible because those are always safe
+ /// to execute. If no identity constant exists, replace undef with some other
+ /// safe constant.
+ static Constant *
+ getSafeVectorConstantForBinop(BinaryOperator::BinaryOps Opcode, Constant *In,
+ bool IsRHSConstant) {
+ auto *InVTy = cast<FixedVectorType>(In->getType());
+
+ Type *EltTy = InVTy->getElementType();
+ auto *SafeC = ConstantExpr::getBinOpIdentity(Opcode, EltTy, IsRHSConstant);
+ if (!SafeC) {
+ // TODO: Should this be available as a constant utility function? It is
+ // similar to getBinOpAbsorber().
+ if (IsRHSConstant) {
+ switch (Opcode) {
+ case Instruction::SRem: // X % 1 = 0
+ case Instruction::URem: // X %u 1 = 0
+ SafeC = ConstantInt::get(EltTy, 1);
+ break;
+ case Instruction::FRem: // X % 1.0 (doesn't simplify, but it is safe)
+ SafeC = ConstantFP::get(EltTy, 1.0);
+ break;
+ default:
+ llvm_unreachable(
+ "Only rem opcodes have no identity constant for RHS");
+ }
+ } else {
+ switch (Opcode) {
+ case Instruction::Shl: // 0 << X = 0
+ case Instruction::LShr: // 0 >>u X = 0
+ case Instruction::AShr: // 0 >> X = 0
+ case Instruction::SDiv: // 0 / X = 0
+ case Instruction::UDiv: // 0 /u X = 0
+ case Instruction::SRem: // 0 % X = 0
+ case Instruction::URem: // 0 %u X = 0
+ case Instruction::Sub: // 0 - X (doesn't simplify, but it is safe)
+ case Instruction::FSub: // 0.0 - X (doesn't simplify, but it is safe)
+ case Instruction::FDiv: // 0.0 / X (doesn't simplify, but it is safe)
+ case Instruction::FRem: // 0.0 % X = 0
+ SafeC = Constant::getNullValue(EltTy);
+ break;
+ default:
+ llvm_unreachable("Expected to find identity constant for opcode");
+ }
+ }
+ }
+ assert(SafeC && "Must have safe constant for binop");
+ unsigned NumElts = InVTy->getNumElements();
+ SmallVector<Constant *, 16> Out(NumElts);
+ for (unsigned i = 0; i != NumElts; ++i) {
+ Constant *C = In->getAggregateElement(i);
+ Out[i] = isa<UndefValue>(C) ? SafeC : C;
+ }
+ return ConstantVector::get(Out);
+ }
+
+ /// Create and insert the idiom we use to indicate a block is unreachable
+ /// without having to rewrite the CFG from within InstCombine.
+ static void CreateNonTerminatorUnreachable(Instruction *InsertAt) {
+ auto &Ctx = InsertAt->getContext();
+ new StoreInst(ConstantInt::getTrue(Ctx),
+ UndefValue::get(Type::getInt1PtrTy(Ctx)), InsertAt);
+ }
+
+ void addToWorklist(Instruction *I) { Worklist.push(I); }
+
+ AssumptionCache &getAssumptionCache() const { return AC; }
+ TargetLibraryInfo &getTargetLibraryInfo() const { return TLI; }
+ DominatorTree &getDominatorTree() const { return DT; }
+ const DataLayout &getDataLayout() const { return DL; }
+ const SimplifyQuery &getSimplifyQuery() const { return SQ; }
+ OptimizationRemarkEmitter &getOptimizationRemarkEmitter() const {
+ return ORE;
+ }
+ BlockFrequencyInfo *getBlockFrequencyInfo() const { return BFI; }
+ ProfileSummaryInfo *getProfileSummaryInfo() const { return PSI; }
+ LoopInfo *getLoopInfo() const { return LI; }
+
+ // Call target specific combiners
+ Optional<Instruction *> targetInstCombineIntrinsic(IntrinsicInst &II);
+ Optional<Value *>
+ targetSimplifyDemandedUseBitsIntrinsic(IntrinsicInst &II, APInt DemandedMask,
+ KnownBits &Known,
+ bool &KnownBitsComputed);
+ Optional<Value *> targetSimplifyDemandedVectorEltsIntrinsic(
+ IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
+ APInt &UndefElts2, APInt &UndefElts3,
+ std::function<void(Instruction *, unsigned, APInt, APInt &)>
+ SimplifyAndSetOp);
+
+ /// Inserts an instruction \p New before instruction \p Old
+ ///
+ /// Also adds the new instruction to the worklist and returns \p New so that
+ /// it is suitable for use as the return from the visitation patterns.
+ Instruction *InsertNewInstBefore(Instruction *New, Instruction &Old) {
+ assert(New && !New->getParent() &&
+ "New instruction already inserted into a basic block!");
+ BasicBlock *BB = Old.getParent();
+ BB->getInstList().insert(Old.getIterator(), New); // Insert inst
+ Worklist.push(New);
+ return New;
+ }
+
+ /// Same as InsertNewInstBefore, but also sets the debug loc.
+ Instruction *InsertNewInstWith(Instruction *New, Instruction &Old) {
+ New->setDebugLoc(Old.getDebugLoc());
+ return InsertNewInstBefore(New, Old);
+ }
+
+ /// A combiner-aware RAUW-like routine.
+ ///
+ /// This method is to be used when an instruction is found to be dead,
+ /// replaceable with another preexisting expression. Here we add all uses of
+ /// I to the worklist, replace all uses of I with the new value, then return
+ /// I, so that the inst combiner will know that I was modified.
+ Instruction *replaceInstUsesWith(Instruction &I, Value *V) {
+ // If there are no uses to replace, then we return nullptr to indicate that
+ // no changes were made to the program.
+ if (I.use_empty())
+ return nullptr;
+
+ Worklist.pushUsersToWorkList(I); // Add all modified instrs to worklist.
+
+ // If we are replacing the instruction with itself, this must be in a
+ // segment of unreachable code, so just clobber the instruction.
+ if (&I == V)
+ V = UndefValue::get(I.getType());
+
+ LLVM_DEBUG(dbgs() << "IC: Replacing " << I << "\n"
+ << " with " << *V << '\n');
+
+ I.replaceAllUsesWith(V);
+ return &I;
+ }
+
+ /// Replace operand of instruction and add old operand to the worklist.
+ Instruction *replaceOperand(Instruction &I, unsigned OpNum, Value *V) {
+ Worklist.addValue(I.getOperand(OpNum));
+ I.setOperand(OpNum, V);
+ return &I;
+ }
+
+ /// Replace use and add the previously used value to the worklist.
+ void replaceUse(Use &U, Value *NewValue) {
+ Worklist.addValue(U);
+ U = NewValue;
+ }
+
+ /// Combiner aware instruction erasure.
+ ///
+ /// When dealing with an instruction that has side effects or produces a void
+ /// value, we can't rely on DCE to delete the instruction. Instead, visit
+ /// methods should return the value returned by this function.
+ virtual Instruction *eraseInstFromFunction(Instruction &I) = 0;
+
+ void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth,
+ const Instruction *CxtI) const {
+ llvm::computeKnownBits(V, Known, DL, Depth, &AC, CxtI, &DT);
+ }
+
+ KnownBits computeKnownBits(const Value *V, unsigned Depth,
+ const Instruction *CxtI) const {
+ return llvm::computeKnownBits(V, DL, Depth, &AC, CxtI, &DT);
+ }
+
+ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero = false,
+ unsigned Depth = 0,
+ const Instruction *CxtI = nullptr) {
+ return llvm::isKnownToBeAPowerOfTwo(V, DL, OrZero, Depth, &AC, CxtI, &DT);
+ }
+
+ bool MaskedValueIsZero(const Value *V, const APInt &Mask, unsigned Depth = 0,
+ const Instruction *CxtI = nullptr) const {
+ return llvm::MaskedValueIsZero(V, Mask, DL, Depth, &AC, CxtI, &DT);
+ }
+
+ unsigned ComputeNumSignBits(const Value *Op, unsigned Depth = 0,
+ const Instruction *CxtI = nullptr) const {
+ return llvm::ComputeNumSignBits(Op, DL, Depth, &AC, CxtI, &DT);
+ }
+
+ OverflowResult computeOverflowForUnsignedMul(const Value *LHS,
+ const Value *RHS,
+ const Instruction *CxtI) const {
+ return llvm::computeOverflowForUnsignedMul(LHS, RHS, DL, &AC, CxtI, &DT);
+ }
+
+ OverflowResult computeOverflowForSignedMul(const Value *LHS, const Value *RHS,
+ const Instruction *CxtI) const {
+ return llvm::computeOverflowForSignedMul(LHS, RHS, DL, &AC, CxtI, &DT);
+ }
+
+ OverflowResult computeOverflowForUnsignedAdd(const Value *LHS,
+ const Value *RHS,
+ const Instruction *CxtI) const {
+ return llvm::computeOverflowForUnsignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
+ }
+
+ OverflowResult computeOverflowForSignedAdd(const Value *LHS, const Value *RHS,
+ const Instruction *CxtI) const {
+ return llvm::computeOverflowForSignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
+ }
+
+ OverflowResult computeOverflowForUnsignedSub(const Value *LHS,
+ const Value *RHS,
+ const Instruction *CxtI) const {
+ return llvm::computeOverflowForUnsignedSub(LHS, RHS, DL, &AC, CxtI, &DT);
+ }
+
+ OverflowResult computeOverflowForSignedSub(const Value *LHS, const Value *RHS,
+ const Instruction *CxtI) const {
+ return llvm::computeOverflowForSignedSub(LHS, RHS, DL, &AC, CxtI, &DT);
+ }
+
+ virtual bool SimplifyDemandedBits(Instruction *I, unsigned OpNo,
+ const APInt &DemandedMask, KnownBits &Known,
+ unsigned Depth = 0) = 0;
+ virtual Value *
+ SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, APInt &UndefElts,
+ unsigned Depth = 0,
+ bool AllowMultipleUsers = false) = 0;
+};
+
+} // namespace llvm
+
+#undef DEBUG_TYPE
+
+#endif
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation.h
index 1a0a209ce9..8809cb1ec1 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation.h
@@ -73,9 +73,9 @@ struct GCOVOptions {
// Add the 'noredzone' attribute to added runtime library calls.
bool NoRedZone;
- // Use atomic profile counter increments.
- bool Atomic = false;
-
+ // Use atomic profile counter increments.
+ bool Atomic = false;
+
// Regexes separated by a semi-colon to filter the files to instrument.
std::string Filter;
@@ -153,8 +153,8 @@ ModulePass *createInstrProfilingLegacyPass(
ModulePass *createInstrOrderFilePass();
// Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
-ModulePass *createDataFlowSanitizerLegacyPassPass(
- const std::vector<std::string> &ABIListFiles = std::vector<std::string>());
+ModulePass *createDataFlowSanitizerLegacyPassPass(
+ const std::vector<std::string> &ABIListFiles = std::vector<std::string>());
// Options for sanitizer coverage instrumentation.
struct SanitizerCoverageOptions {
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/AddressSanitizer.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index cd14ac66f5..46cbf49956 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -109,7 +109,7 @@ public:
bool Recover = false,
bool UseAfterScope = false);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
private:
bool CompileKernel;
@@ -130,7 +130,7 @@ public:
bool UseGlobalGC = true,
bool UseOdrIndicator = false);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
private:
bool CompileKernel;
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/BoundsChecking.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/BoundsChecking.h
index bb4d634cde..4661ea7779 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/BoundsChecking.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/BoundsChecking.h
@@ -24,7 +24,7 @@ namespace llvm {
/// stores, and other memory intrinsics.
struct BoundsCheckingPass : PassInfoMixin<BoundsCheckingPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
index 38aa2d560b..b732dae51c 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
@@ -1,43 +1,43 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- DataFlowSanitizer.h - dynamic data flow analysis -------------------===//
-//
-// 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 LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZER_H
-#define LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZER_H
-
-#include "llvm/IR/Module.h"
-#include "llvm/IR/PassManager.h"
-#include <string>
-#include <vector>
-
-namespace llvm {
-
-class DataFlowSanitizerPass : public PassInfoMixin<DataFlowSanitizerPass> {
-private:
- std::vector<std::string> ABIListFiles;
-
-public:
- DataFlowSanitizerPass(
- const std::vector<std::string> &ABIListFiles = std::vector<std::string>())
- : ABIListFiles(ABIListFiles) {}
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
- static bool isRequired() { return true; }
-};
-
-} // namespace llvm
-
-#endif
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- DataFlowSanitizer.h - dynamic data flow analysis -------------------===//
+//
+// 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 LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZER_H
+#define LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZER_H
+
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include <string>
+#include <vector>
+
+namespace llvm {
+
+class DataFlowSanitizerPass : public PassInfoMixin<DataFlowSanitizerPass> {
+private:
+ std::vector<std::string> ABIListFiles;
+
+public:
+ DataFlowSanitizerPass(
+ const std::vector<std::string> &ABIListFiles = std::vector<std::string>())
+ : ABIListFiles(ABIListFiles) {}
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+ static bool isRequired() { return true; }
+};
+
+} // namespace llvm
+
+#endif
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/GCOVProfiler.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
index 78024a30a3..70b3eea60b 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
@@ -33,7 +33,7 @@ private:
GCOVOptions GCOVOpts;
};
-} // namespace llvm
+} // namespace llvm
#endif
#ifdef __GNUC__
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
index 585b6b84f0..a7011f14a5 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
@@ -34,7 +34,7 @@ public:
explicit HWAddressSanitizerPass(bool CompileKernel = false,
bool Recover = false);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
private:
bool CompileKernel;
@@ -44,24 +44,24 @@ private:
FunctionPass *createHWAddressSanitizerLegacyPassPass(bool CompileKernel = false,
bool Recover = false);
-namespace HWASanAccessInfo {
-
-// Bit field positions for the accessinfo parameter to
-// llvm.hwasan.check.memaccess. Shared between the pass and the backend. Bits
-// 0-15 are also used by the runtime.
-enum {
- AccessSizeShift = 0, // 4 bits
- IsWriteShift = 4,
- RecoverShift = 5,
- MatchAllShift = 16, // 8 bits
- HasMatchAllShift = 24,
- CompileKernelShift = 25,
-};
-
-enum { RuntimeMask = 0xffff };
-
-} // namespace HWASanAccessInfo
-
+namespace HWASanAccessInfo {
+
+// Bit field positions for the accessinfo parameter to
+// llvm.hwasan.check.memaccess. Shared between the pass and the backend. Bits
+// 0-15 are also used by the runtime.
+enum {
+ AccessSizeShift = 0, // 4 bits
+ IsWriteShift = 4,
+ RecoverShift = 5,
+ MatchAllShift = 16, // 8 bits
+ HasMatchAllShift = 24,
+ CompileKernelShift = 25,
+};
+
+enum { RuntimeMask = 0xffff };
+
+} // namespace HWASanAccessInfo
+
} // namespace llvm
#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemProfiler.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemProfiler.h
index 4be1152817..86547e02f0 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemProfiler.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemProfiler.h
@@ -1,62 +1,62 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===--------- Definition of the MemProfiler class --------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file declares the MemProfiler class.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H
-#define LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H
-
-#include "llvm/IR/Function.h"
-#include "llvm/IR/Module.h"
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-/// Public interface to the memory profiler pass for instrumenting code to
-/// profile memory accesses.
-///
-/// The profiler itself is a function pass that works by inserting various
-/// calls to the MemProfiler runtime library functions. The runtime library
-/// essentially replaces malloc() and free() with custom implementations that
-/// record data about the allocations.
-class MemProfilerPass : public PassInfoMixin<MemProfilerPass> {
-public:
- explicit MemProfilerPass();
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
-};
-
-/// Public interface to the memory profiler module pass for instrumenting code
-/// to profile memory allocations and accesses.
-class ModuleMemProfilerPass : public PassInfoMixin<ModuleMemProfilerPass> {
-public:
- explicit ModuleMemProfilerPass();
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
- static bool isRequired() { return true; }
-};
-
-// Insert MemProfiler instrumentation
-FunctionPass *createMemProfilerFunctionPass();
-ModulePass *createModuleMemProfilerLegacyPassPass();
-
-} // namespace llvm
-
-#endif
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===--------- Definition of the MemProfiler class --------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the MemProfiler class.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H
+#define LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H
+
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+/// Public interface to the memory profiler pass for instrumenting code to
+/// profile memory accesses.
+///
+/// The profiler itself is a function pass that works by inserting various
+/// calls to the MemProfiler runtime library functions. The runtime library
+/// essentially replaces malloc() and free() with custom implementations that
+/// record data about the allocations.
+class MemProfilerPass : public PassInfoMixin<MemProfilerPass> {
+public:
+ explicit MemProfilerPass();
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+ static bool isRequired() { return true; }
+};
+
+/// Public interface to the memory profiler module pass for instrumenting code
+/// to profile memory allocations and accesses.
+class ModuleMemProfilerPass : public PassInfoMixin<ModuleMemProfilerPass> {
+public:
+ explicit ModuleMemProfilerPass();
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+ static bool isRequired() { return true; }
+};
+
+// Insert MemProfiler instrumentation
+FunctionPass *createMemProfilerFunctionPass();
+ModulePass *createModuleMemProfilerLegacyPassPass();
+
+} // namespace llvm
+
+#endif
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemorySanitizer.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
index 85748cb221..d6d96b89b1 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
@@ -48,7 +48,7 @@ struct MemorySanitizerPass : public PassInfoMixin<MemorySanitizerPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
private:
MemorySanitizerOptions Options;
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
index 69610fc22c..76494514af 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
@@ -53,7 +53,7 @@ public:
*vfs::getRealFileSystem());
}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
private:
SanitizerCoverageOptions Options;
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
index 898a08b238..a2e2d99692 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
@@ -35,7 +35,7 @@ FunctionPass *createThreadSanitizerLegacyPassPass();
struct ThreadSanitizerPass : public PassInfoMixin<ThreadSanitizerPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/ObjCARC.h b/contrib/libs/llvm12/include/llvm/Transforms/ObjCARC.h
index 456ca448ff..1de1f773f5 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/ObjCARC.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/ObjCARC.h
@@ -21,8 +21,8 @@
#ifndef LLVM_TRANSFORMS_OBJCARC_H
#define LLVM_TRANSFORMS_OBJCARC_H
-#include "llvm/IR/PassManager.h"
-
+#include "llvm/IR/PassManager.h"
+
namespace llvm {
class Pass;
@@ -51,22 +51,22 @@ Pass *createObjCARCContractPass();
//
Pass *createObjCARCOptPass();
-struct ObjCARCOptPass : public PassInfoMixin<ObjCARCOptPass> {
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
-struct ObjCARCContractPass : public PassInfoMixin<ObjCARCContractPass> {
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
-struct ObjCARCAPElimPass : public PassInfoMixin<ObjCARCAPElimPass> {
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-struct ObjCARCExpandPass : public PassInfoMixin<ObjCARCExpandPass> {
- PreservedAnalyses run(Function &M, FunctionAnalysisManager &AM);
-};
-
+struct ObjCARCOptPass : public PassInfoMixin<ObjCARCOptPass> {
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+struct ObjCARCContractPass : public PassInfoMixin<ObjCARCContractPass> {
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+struct ObjCARCAPElimPass : public PassInfoMixin<ObjCARCAPElimPass> {
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+struct ObjCARCExpandPass : public PassInfoMixin<ObjCARCExpandPass> {
+ PreservedAnalyses run(Function &M, FunctionAnalysisManager &AM);
+};
+
} // End llvm namespace
#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar.h
index dcafc13c49..7cf295b2e8 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar.h
@@ -21,7 +21,7 @@
#ifndef LLVM_TRANSFORMS_SCALAR_H
#define LLVM_TRANSFORMS_SCALAR_H
-#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
+#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
#include <functional>
namespace llvm {
@@ -40,15 +40,15 @@ FunctionPass *createAlignmentFromAssumptionsPass();
//===----------------------------------------------------------------------===//
//
-// AnnotationRemarks - Emit remarks for !annotation metadata.
+// AnnotationRemarks - Emit remarks for !annotation metadata.
//
-FunctionPass *createAnnotationRemarksLegacyPass();
+FunctionPass *createAnnotationRemarksLegacyPass();
//===----------------------------------------------------------------------===//
//
-// SCCP - Sparse conditional constant propagation.
+// SCCP - Sparse conditional constant propagation.
//
-FunctionPass *createSCCPPass();
+FunctionPass *createSCCPPass();
//===----------------------------------------------------------------------===//
//
@@ -164,12 +164,12 @@ Pass *createLoopInterchangePass();
//===----------------------------------------------------------------------===//
//
-// LoopFlatten - This pass flattens nested loops into a single loop.
-//
-FunctionPass *createLoopFlattenPass();
-
-//===----------------------------------------------------------------------===//
-//
+// LoopFlatten - This pass flattens nested loops into a single loop.
+//
+FunctionPass *createLoopFlattenPass();
+
+//===----------------------------------------------------------------------===//
+//
// LoopStrengthReduce - This pass is strength reduces GEP instructions that use
// a loop's canonical induction variable as one of their indices.
//
@@ -197,8 +197,8 @@ Pass *createLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
int Count = -1, int AllowPartial = -1,
int Runtime = -1, int UpperBound = -1,
int AllowPeeling = -1);
-// Create an unrolling pass for full unrolling that uses exact trip count only
-// and also does peeling.
+// Create an unrolling pass for full unrolling that uses exact trip count only
+// and also does peeling.
Pass *createSimpleLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
bool ForgetAllSCEV = false);
@@ -218,7 +218,7 @@ Pass *createLoopRerollPass();
//
// LoopRotate - This pass is a simple loop rotating pass.
//
-Pass *createLoopRotatePass(int MaxHeaderSize = -1, bool PrepareForLTO = false);
+Pass *createLoopRotatePass(int MaxHeaderSize = -1, bool PrepareForLTO = false);
//===----------------------------------------------------------------------===//
//
@@ -253,12 +253,12 @@ FunctionPass *createReassociatePass();
//===----------------------------------------------------------------------===//
//
// JumpThreading - Thread control through mult-pred/multi-succ blocks where some
-// preds always go to some succ. If FreezeSelectCond is true, unfold the
-// condition of a select that unfolds to branch. Thresholds other than minus one
-// override the internal BB duplication default threshold.
+// preds always go to some succ. If FreezeSelectCond is true, unfold the
+// condition of a select that unfolds to branch. Thresholds other than minus one
+// override the internal BB duplication default threshold.
//
-FunctionPass *createJumpThreadingPass(bool FreezeSelectCond = false,
- int Threshold = -1);
+FunctionPass *createJumpThreadingPass(bool FreezeSelectCond = false,
+ int Threshold = -1);
//===----------------------------------------------------------------------===//
//
@@ -266,7 +266,7 @@ FunctionPass *createJumpThreadingPass(bool FreezeSelectCond = false,
// simplify terminator instructions, convert switches to lookup tables, etc.
//
FunctionPass *createCFGSimplificationPass(
- SimplifyCFGOptions Options = SimplifyCFGOptions(),
+ SimplifyCFGOptions Options = SimplifyCFGOptions(),
std::function<bool(const Function &)> Ftor = nullptr);
//===----------------------------------------------------------------------===//
@@ -355,13 +355,13 @@ FunctionPass *createConstantHoistingPass();
//===----------------------------------------------------------------------===//
//
-// ConstraintElimination - This pass eliminates conditions based on found
-// constraints.
-//
-FunctionPass *createConstraintEliminationPass();
-
-//===----------------------------------------------------------------------===//
-//
+// ConstraintElimination - This pass eliminates conditions based on found
+// constraints.
+//
+FunctionPass *createConstraintEliminationPass();
+
+//===----------------------------------------------------------------------===//
+//
// Sink - Code Sinking
//
FunctionPass *createSinkingPass();
@@ -386,13 +386,13 @@ Pass *createLowerMatrixIntrinsicsPass();
//===----------------------------------------------------------------------===//
//
-// LowerMatrixIntrinsicsMinimal - Lower matrix intrinsics to vector operations
-// (lightweight, does not require extra analysis)
-//
-Pass *createLowerMatrixIntrinsicsMinimalPass();
-
-//===----------------------------------------------------------------------===//
-//
+// LowerMatrixIntrinsicsMinimal - Lower matrix intrinsics to vector operations
+// (lightweight, does not require extra analysis)
+//
+Pass *createLowerMatrixIntrinsicsMinimalPass();
+
+//===----------------------------------------------------------------------===//
+//
// LowerWidenableCondition - Lower widenable condition to i1 true.
//
Pass *createLowerWidenableConditionPass();
@@ -546,21 +546,21 @@ Pass *createLoopSimplifyCFGPass();
// transformations.
//
Pass *createWarnMissedTransformationsPass();
-
-//===----------------------------------------------------------------------===//
-//
-// This pass does instruction simplification on each
-// instruction in a function.
-//
-FunctionPass *createInstSimplifyLegacyPass();
-
-
-//===----------------------------------------------------------------------===//
-//
-// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather
-// and scatter intrinsics with scalar code when target doesn't support them.
-//
-FunctionPass *createScalarizeMaskedMemIntrinLegacyPass();
+
+//===----------------------------------------------------------------------===//
+//
+// This pass does instruction simplification on each
+// instruction in a function.
+//
+FunctionPass *createInstSimplifyLegacyPass();
+
+
+//===----------------------------------------------------------------------===//
+//
+// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather
+// and scatter intrinsics with scalar code when target doesn't support them.
+//
+FunctionPass *createScalarizeMaskedMemIntrinLegacyPass();
} // End llvm namespace
#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
index 0a2c890d61..805cabbb03 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
@@ -44,9 +44,9 @@ struct AlignmentFromAssumptionsPass
ScalarEvolution *SE = nullptr;
DominatorTree *DT = nullptr;
- bool extractAlignmentInfo(CallInst *I, unsigned Idx, Value *&AAPtr,
- const SCEV *&AlignSCEV, const SCEV *&OffSCEV);
- bool processAssumption(CallInst *I, unsigned Idx);
+ bool extractAlignmentInfo(CallInst *I, unsigned Idx, Value *&AAPtr,
+ const SCEV *&AlignSCEV, const SCEV *&OffSCEV);
+ bool processAssumption(CallInst *I, unsigned Idx);
};
}
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AnnotationRemarks.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AnnotationRemarks.h
index 408ac969b2..78a4812cb8 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AnnotationRemarks.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/AnnotationRemarks.h
@@ -1,37 +1,37 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- AnnotationRemarks.cpp - Emit remarks for !annotation MD --*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-// \file
-// This file defines AnnotationRemarksPass for the new pass manager.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_SCALAR_ANNOTATION_REMARKS_H
-#define LLVM_TRANSFORMS_SCALAR_ANNOTATION_REMARKS_H
-
-#include "llvm/IR/Function.h"
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-struct AnnotationRemarksPass : public PassInfoMixin<AnnotationRemarksPass> {
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_ANNOTATION_REMARKS_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- AnnotationRemarks.cpp - Emit remarks for !annotation MD --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// \file
+// This file defines AnnotationRemarksPass for the new pass manager.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_SCALAR_ANNOTATION_REMARKS_H
+#define LLVM_TRANSFORMS_SCALAR_ANNOTATION_REMARKS_H
+
+#include "llvm/IR/Function.h"
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+struct AnnotationRemarksPass : public PassInfoMixin<AnnotationRemarksPass> {
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_ANNOTATION_REMARKS_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ConstraintElimination.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ConstraintElimination.h
index aabe7a8cda..f353d384e7 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ConstraintElimination.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ConstraintElimination.h
@@ -1,35 +1,35 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- ConstraintElimination.h - Constraint elimination pass ----*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_SCALAR_CONSTRAINTELIMINATION_H
-#define LLVM_TRANSFORMS_SCALAR_CONSTRAINTELIMINATION_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class ConstraintEliminationPass
- : public PassInfoMixin<ConstraintEliminationPass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_CONSTRAINTELIMINATION_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- ConstraintElimination.h - Constraint elimination pass ----*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_SCALAR_CONSTRAINTELIMINATION_H
+#define LLVM_TRANSFORMS_SCALAR_CONSTRAINTELIMINATION_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class ConstraintEliminationPass
+ : public PassInfoMixin<ConstraintEliminationPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_CONSTRAINTELIMINATION_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/DCE.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/DCE.h
index d624328b36..344ebe68f9 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/DCE.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/DCE.h
@@ -30,12 +30,12 @@ class DCEPass : public PassInfoMixin<DCEPass> {
public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
-
-class RedundantDbgInstEliminationPass
- : public PassInfoMixin<RedundantDbgInstEliminationPass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
+
+class RedundantDbgInstEliminationPass
+ : public PassInfoMixin<RedundantDbgInstEliminationPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
}
#endif // LLVM_TRANSFORMS_SCALAR_DCE_H
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/GVN.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/GVN.h
index 8a41b18799..c2906dc22f 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/GVN.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/GVN.h
@@ -53,8 +53,8 @@ class FunctionPass;
class IntrinsicInst;
class LoadInst;
class LoopInfo;
-class MemorySSA;
-class MemorySSAUpdater;
+class MemorySSA;
+class MemorySSAUpdater;
class OptimizationRemarkEmitter;
class PHINode;
class TargetLibraryInfo;
@@ -80,7 +80,7 @@ struct GVNOptions {
Optional<bool> AllowPRE = None;
Optional<bool> AllowLoadPRE = None;
Optional<bool> AllowLoadInLoopPRE = None;
- Optional<bool> AllowLoadPRESplitBackedge = None;
+ Optional<bool> AllowLoadPRESplitBackedge = None;
Optional<bool> AllowMemDep = None;
GVNOptions() = default;
@@ -102,12 +102,12 @@ struct GVNOptions {
return *this;
}
- /// Enables or disables PRE of loads in GVN.
- GVNOptions &setLoadPRESplitBackedge(bool LoadPRESplitBackedge) {
- AllowLoadPRESplitBackedge = LoadPRESplitBackedge;
- return *this;
- }
-
+ /// Enables or disables PRE of loads in GVN.
+ GVNOptions &setLoadPRESplitBackedge(bool LoadPRESplitBackedge) {
+ AllowLoadPRESplitBackedge = LoadPRESplitBackedge;
+ return *this;
+ }
+
/// Enables or disables use of MemDepAnalysis.
GVNOptions &setMemDep(bool MemDep) {
AllowMemDep = MemDep;
@@ -144,7 +144,7 @@ public:
bool isPREEnabled() const;
bool isLoadPREEnabled() const;
bool isLoadInLoopPREEnabled() const;
- bool isLoadPRESplitBackedgeEnabled() const;
+ bool isLoadPRESplitBackedgeEnabled() const;
bool isMemDepEnabled() const;
/// This class holds the mapping between values and value numbers. It is used
@@ -227,7 +227,7 @@ private:
OptimizationRemarkEmitter *ORE = nullptr;
ImplicitControlFlowTracking *ICF = nullptr;
LoopInfo *LI = nullptr;
- MemorySSAUpdater *MSSAU = nullptr;
+ MemorySSAUpdater *MSSAU = nullptr;
ValueTable VN;
@@ -263,7 +263,7 @@ private:
bool runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
const TargetLibraryInfo &RunTLI, AAResults &RunAA,
MemoryDependenceResults *RunMD, LoopInfo *LI,
- OptimizationRemarkEmitter *ORE, MemorySSA *MSSA = nullptr);
+ OptimizationRemarkEmitter *ORE, MemorySSA *MSSA = nullptr);
/// Push a new Value to the LeaderTable onto the list for its value number.
void addToLeaderTable(uint32_t N, Value *V, const BasicBlock *BB) {
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/IndVarSimplify.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/IndVarSimplify.h
index cd5cb68c0e..885487f548 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/IndVarSimplify.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/IndVarSimplify.h
@@ -30,11 +30,11 @@ class Loop;
class LPMUpdater;
class IndVarSimplifyPass : public PassInfoMixin<IndVarSimplifyPass> {
- /// Perform IV widening during the pass.
- bool WidenIndVars;
-
+ /// Perform IV widening during the pass.
+ bool WidenIndVars;
+
public:
- IndVarSimplifyPass(bool WidenIndVars = true) : WidenIndVars(WidenIndVars) {}
+ IndVarSimplifyPass(bool WidenIndVars = true) : WidenIndVars(WidenIndVars) {}
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);
};
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/InferAddressSpaces.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/InferAddressSpaces.h
index 1132195c13..4d4a62e0c5 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/InferAddressSpaces.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/InferAddressSpaces.h
@@ -1,38 +1,38 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- InferAddressSpace.h - ----------------------------------------------===//
-//
-// 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 LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
-#define LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-struct InferAddressSpacesPass : PassInfoMixin<InferAddressSpacesPass> {
- InferAddressSpacesPass();
- InferAddressSpacesPass(unsigned AddressSpace);
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-private:
- unsigned FlatAddrSpace = 0;
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- InferAddressSpace.h - ----------------------------------------------===//
+//
+// 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 LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
+#define LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+struct InferAddressSpacesPass : PassInfoMixin<InferAddressSpacesPass> {
+ InferAddressSpacesPass();
+ InferAddressSpacesPass(unsigned AddressSpace);
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+private:
+ unsigned FlatAddrSpace = 0;
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/JumpThreading.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/JumpThreading.h
index f24333c390..4d977dcd43 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/JumpThreading.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/JumpThreading.h
@@ -35,7 +35,7 @@
namespace llvm {
-class AAResults;
+class AAResults;
class BasicBlock;
class BinaryOperator;
class BranchInst;
@@ -48,8 +48,8 @@ class IntrinsicInst;
class LazyValueInfo;
class LoadInst;
class PHINode;
-class SelectInst;
-class SwitchInst;
+class SelectInst;
+class SwitchInst;
class TargetLibraryInfo;
class Value;
@@ -86,7 +86,7 @@ enum ConstantPreference { WantInteger, WantBlockAddress };
class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
TargetLibraryInfo *TLI;
LazyValueInfo *LVI;
- AAResults *AA;
+ AAResults *AA;
DomTreeUpdater *DTU;
std::unique_ptr<BlockFrequencyInfo> BFI;
std::unique_ptr<BranchProbabilityInfo> BPI;
@@ -100,16 +100,16 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
unsigned BBDupThreshold;
unsigned DefaultBBDupThreshold;
- bool InsertFreezeWhenUnfoldingSelect;
+ bool InsertFreezeWhenUnfoldingSelect;
public:
- JumpThreadingPass(bool InsertFreezeWhenUnfoldingSelect = false, int T = -1);
+ JumpThreadingPass(bool InsertFreezeWhenUnfoldingSelect = false, int T = -1);
// Glue for old PM.
- bool runImpl(Function &F, TargetLibraryInfo *TLI, LazyValueInfo *LVI,
- AAResults *AA, DomTreeUpdater *DTU, bool HasProfileData,
- std::unique_ptr<BlockFrequencyInfo> BFI,
- std::unique_ptr<BranchProbabilityInfo> BPI);
+ bool runImpl(Function &F, TargetLibraryInfo *TLI, LazyValueInfo *LVI,
+ AAResults *AA, DomTreeUpdater *DTU, bool HasProfileData,
+ std::unique_ptr<BlockFrequencyInfo> BFI,
+ std::unique_ptr<BranchProbabilityInfo> BPI);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
@@ -118,65 +118,65 @@ public:
BPI.reset();
}
- void findLoopHeaders(Function &F);
- bool processBlock(BasicBlock *BB);
- bool maybeMergeBasicBlockIntoOnlyPred(BasicBlock *BB);
- void updateSSA(BasicBlock *BB, BasicBlock *NewBB,
+ void findLoopHeaders(Function &F);
+ bool processBlock(BasicBlock *BB);
+ bool maybeMergeBasicBlockIntoOnlyPred(BasicBlock *BB);
+ void updateSSA(BasicBlock *BB, BasicBlock *NewBB,
DenseMap<Instruction *, Value *> &ValueMapping);
- DenseMap<Instruction *, Value *> cloneInstructions(BasicBlock::iterator BI,
+ DenseMap<Instruction *, Value *> cloneInstructions(BasicBlock::iterator BI,
BasicBlock::iterator BE,
BasicBlock *NewBB,
BasicBlock *PredBB);
- bool tryThreadEdge(BasicBlock *BB,
+ bool tryThreadEdge(BasicBlock *BB,
const SmallVectorImpl<BasicBlock *> &PredBBs,
BasicBlock *SuccBB);
- void threadEdge(BasicBlock *BB, const SmallVectorImpl<BasicBlock *> &PredBBs,
+ void threadEdge(BasicBlock *BB, const SmallVectorImpl<BasicBlock *> &PredBBs,
BasicBlock *SuccBB);
- bool duplicateCondBranchOnPHIIntoPred(
+ bool duplicateCondBranchOnPHIIntoPred(
BasicBlock *BB, const SmallVectorImpl<BasicBlock *> &PredBBs);
- bool computeValueKnownInPredecessorsImpl(
+ bool computeValueKnownInPredecessorsImpl(
Value *V, BasicBlock *BB, jumpthreading::PredValueInfo &Result,
jumpthreading::ConstantPreference Preference,
DenseSet<Value *> &RecursionSet, Instruction *CxtI = nullptr);
bool
- computeValueKnownInPredecessors(Value *V, BasicBlock *BB,
+ computeValueKnownInPredecessors(Value *V, BasicBlock *BB,
jumpthreading::PredValueInfo &Result,
jumpthreading::ConstantPreference Preference,
Instruction *CxtI = nullptr) {
DenseSet<Value *> RecursionSet;
- return computeValueKnownInPredecessorsImpl(V, BB, Result, Preference,
+ return computeValueKnownInPredecessorsImpl(V, BB, Result, Preference,
RecursionSet, CxtI);
}
- Constant *evaluateOnPredecessorEdge(BasicBlock *BB, BasicBlock *PredPredBB,
+ Constant *evaluateOnPredecessorEdge(BasicBlock *BB, BasicBlock *PredPredBB,
Value *cond);
- bool maybethreadThroughTwoBasicBlocks(BasicBlock *BB, Value *Cond);
- void threadThroughTwoBasicBlocks(BasicBlock *PredPredBB, BasicBlock *PredBB,
+ bool maybethreadThroughTwoBasicBlocks(BasicBlock *BB, Value *Cond);
+ void threadThroughTwoBasicBlocks(BasicBlock *PredPredBB, BasicBlock *PredBB,
BasicBlock *BB, BasicBlock *SuccBB);
- bool processThreadableEdges(Value *Cond, BasicBlock *BB,
+ bool processThreadableEdges(Value *Cond, BasicBlock *BB,
jumpthreading::ConstantPreference Preference,
Instruction *CxtI = nullptr);
- bool processBranchOnPHI(PHINode *PN);
- bool processBranchOnXOR(BinaryOperator *BO);
- bool processImpliedCondition(BasicBlock *BB);
+ bool processBranchOnPHI(PHINode *PN);
+ bool processBranchOnXOR(BinaryOperator *BO);
+ bool processImpliedCondition(BasicBlock *BB);
- bool simplifyPartiallyRedundantLoad(LoadInst *LI);
- void unfoldSelectInstr(BasicBlock *Pred, BasicBlock *BB, SelectInst *SI,
+ bool simplifyPartiallyRedundantLoad(LoadInst *LI);
+ void unfoldSelectInstr(BasicBlock *Pred, BasicBlock *BB, SelectInst *SI,
PHINode *SIUse, unsigned Idx);
- bool tryToUnfoldSelect(CmpInst *CondCmp, BasicBlock *BB);
- bool tryToUnfoldSelect(SwitchInst *SI, BasicBlock *BB);
- bool tryToUnfoldSelectInCurrBB(BasicBlock *BB);
+ bool tryToUnfoldSelect(CmpInst *CondCmp, BasicBlock *BB);
+ bool tryToUnfoldSelect(SwitchInst *SI, BasicBlock *BB);
+ bool tryToUnfoldSelectInCurrBB(BasicBlock *BB);
- bool processGuards(BasicBlock *BB);
- bool threadGuard(BasicBlock *BB, IntrinsicInst *Guard, BranchInst *BI);
+ bool processGuards(BasicBlock *BB);
+ bool threadGuard(BasicBlock *BB, IntrinsicInst *Guard, BranchInst *BI);
private:
- BasicBlock *splitBlockPreds(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,
+ BasicBlock *splitBlockPreds(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,
const char *Suffix);
- void updateBlockFreqAndEdgeWeight(BasicBlock *PredBB, BasicBlock *BB,
+ void updateBlockFreqAndEdgeWeight(BasicBlock *PredBB, BasicBlock *BB,
BasicBlock *NewBB, BasicBlock *SuccBB);
/// Check if the block has profile metadata for its outgoing edges.
bool doesBlockHaveProfileData(BasicBlock *BB);
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopFlatten.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopFlatten.h
index 10ab54e1dc..94c153da09 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopFlatten.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopFlatten.h
@@ -1,43 +1,43 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- LoopFlatten.h - Loop Flatten ---------------- -----------*- 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 provides the interface for the Loop Flatten Pass.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_SCALAR_LOOPFLATTEN_H
-#define LLVM_TRANSFORMS_SCALAR_LOOPFLATTEN_H
-
-#include "llvm/Analysis/LoopAnalysisManager.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Scalar/LoopPassManager.h"
-
-namespace llvm {
-
-class LoopFlattenPass : public PassInfoMixin<LoopFlattenPass> {
-public:
- LoopFlattenPass() = default;
-
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_LOOPFLATTEN_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- LoopFlatten.h - Loop Flatten ---------------- -----------*- 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 provides the interface for the Loop Flatten Pass.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_SCALAR_LOOPFLATTEN_H
+#define LLVM_TRANSFORMS_SCALAR_LOOPFLATTEN_H
+
+#include "llvm/Analysis/LoopAnalysisManager.h"
+#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Scalar/LoopPassManager.h"
+
+namespace llvm {
+
+class LoopFlattenPass : public PassInfoMixin<LoopFlattenPass> {
+public:
+ LoopFlattenPass() = default;
+
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_LOOPFLATTEN_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
index 3affa35521..33a39a0820 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
@@ -30,19 +30,19 @@ namespace llvm {
class Loop;
class LPMUpdater;
-/// Options to disable Loop Idiom Recognize, which can be shared with other
-/// passes.
-struct DisableLIRP {
- /// When true, the entire pass is disabled.
- static bool All;
-
- /// When true, Memset is disabled.
- static bool Memset;
-
- /// When true, Memcpy is disabled.
- static bool Memcpy;
-};
-
+/// Options to disable Loop Idiom Recognize, which can be shared with other
+/// passes.
+struct DisableLIRP {
+ /// When true, the entire pass is disabled.
+ static bool All;
+
+ /// When true, Memset is disabled.
+ static bool Memset;
+
+ /// When true, Memcpy is disabled.
+ static bool Memcpy;
+};
+
/// Performs Loop Idiom Recognize Pass.
class LoopIdiomRecognizePass : public PassInfoMixin<LoopIdiomRecognizePass> {
public:
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopInterchange.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopInterchange.h
index 94c3f00d17..61b9808304 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopInterchange.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopInterchange.h
@@ -1,35 +1,35 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- LoopInterchange.h - Loop interchange pass --------------------------===//
-//
-// 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 LLVM_TRANSFORMS_SCALAR_LOOPINTERCHANGE_H
-#define LLVM_TRANSFORMS_SCALAR_LOOPINTERCHANGE_H
-
-#include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Scalar/LoopPassManager.h"
-
-namespace llvm {
-
-struct LoopInterchangePass : public PassInfoMixin<LoopInterchangePass> {
- PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR, LPMUpdater &U);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_LOOPINTERCHANGE_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- LoopInterchange.h - Loop interchange pass --------------------------===//
+//
+// 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 LLVM_TRANSFORMS_SCALAR_LOOPINTERCHANGE_H
+#define LLVM_TRANSFORMS_SCALAR_LOOPINTERCHANGE_H
+
+#include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Scalar/LoopPassManager.h"
+
+namespace llvm {
+
+struct LoopInterchangePass : public PassInfoMixin<LoopInterchangePass> {
+ PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR, LPMUpdater &U);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_LOOPINTERCHANGE_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopPassManager.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopPassManager.h
index c268c9c097..30d26eab5e 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -46,161 +46,161 @@
#include "llvm/ADT/PriorityWorklist.h"
#include "llvm/Analysis/LoopAnalysisManager.h"
#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/LoopNestAnalysis.h"
+#include "llvm/Analysis/LoopNestAnalysis.h"
#include "llvm/IR/Dominators.h"
-#include "llvm/IR/PassInstrumentation.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Transforms/Utils/LCSSA.h"
#include "llvm/Transforms/Utils/LoopSimplify.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
-#include <memory>
+#include <memory>
namespace llvm {
// Forward declarations of an update tracking API used in the pass manager.
class LPMUpdater;
-namespace {
-
-template <typename PassT>
-using HasRunOnLoopT = decltype(std::declval<PassT>().run(
- std::declval<Loop &>(), std::declval<LoopAnalysisManager &>(),
- std::declval<LoopStandardAnalysisResults &>(),
- std::declval<LPMUpdater &>()));
-
-} // namespace
-
+namespace {
+
+template <typename PassT>
+using HasRunOnLoopT = decltype(std::declval<PassT>().run(
+ std::declval<Loop &>(), std::declval<LoopAnalysisManager &>(),
+ std::declval<LoopStandardAnalysisResults &>(),
+ std::declval<LPMUpdater &>()));
+
+} // namespace
+
// Explicit specialization and instantiation declarations for the pass manager.
// See the comments on the definition of the specialization for details on how
// it differs from the primary template.
template <>
-class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
- LPMUpdater &>
- : public PassInfoMixin<
- PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
- LPMUpdater &>> {
-public:
- /// Construct a pass manager.
- ///
- /// If \p DebugLogging is true, we'll log our progress to llvm::dbgs().
- explicit PassManager(bool DebugLogging = false)
- : DebugLogging(DebugLogging) {}
-
- // FIXME: These are equivalent to the default move constructor/move
- // assignment. However, using = default triggers linker errors due to the
- // explicit instantiations below. Find a way to use the default and remove the
- // duplicated code here.
- PassManager(PassManager &&Arg)
- : IsLoopNestPass(std::move(Arg.IsLoopNestPass)),
- LoopPasses(std::move(Arg.LoopPasses)),
- LoopNestPasses(std::move(Arg.LoopNestPasses)),
- DebugLogging(std::move(Arg.DebugLogging)) {}
-
- PassManager &operator=(PassManager &&RHS) {
- IsLoopNestPass = std::move(RHS.IsLoopNestPass);
- LoopPasses = std::move(RHS.LoopPasses);
- LoopNestPasses = std::move(RHS.LoopNestPasses);
- DebugLogging = std::move(RHS.DebugLogging);
- return *this;
- }
-
- PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR, LPMUpdater &U);
-
- /// Add either a loop pass or a loop-nest pass to the pass manager. Append \p
- /// Pass to the list of loop passes if it has a dedicated \fn run() method for
- /// loops and to the list of loop-nest passes if the \fn run() method is for
- /// loop-nests instead. Also append whether \p Pass is loop-nest pass or not
- /// to the end of \var IsLoopNestPass so we can easily identify the types of
- /// passes in the pass manager later.
- template <typename PassT>
- std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
- addPass(PassT Pass) {
- using LoopPassModelT =
- detail::PassModel<Loop, PassT, PreservedAnalyses, LoopAnalysisManager,
- LoopStandardAnalysisResults &, LPMUpdater &>;
- IsLoopNestPass.push_back(false);
- LoopPasses.emplace_back(new LoopPassModelT(std::move(Pass)));
- }
-
- template <typename PassT>
- std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
- addPass(PassT Pass) {
- using LoopNestPassModelT =
- detail::PassModel<LoopNest, PassT, PreservedAnalyses,
- LoopAnalysisManager, LoopStandardAnalysisResults &,
- LPMUpdater &>;
- IsLoopNestPass.push_back(true);
- LoopNestPasses.emplace_back(new LoopNestPassModelT(std::move(Pass)));
- }
-
- // Specializations of `addPass` for `RepeatedPass`. These are necessary since
- // `RepeatedPass` has a templated `run` method that will result in incorrect
- // detection of `HasRunOnLoopT`.
- template <typename PassT>
- std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> Pass) {
- using RepeatedLoopPassModelT =
- detail::PassModel<Loop, RepeatedPass<PassT>, PreservedAnalyses,
- LoopAnalysisManager, LoopStandardAnalysisResults &,
- LPMUpdater &>;
- IsLoopNestPass.push_back(false);
- LoopPasses.emplace_back(new RepeatedLoopPassModelT(std::move(Pass)));
- }
-
- template <typename PassT>
- std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> Pass) {
- using RepeatedLoopNestPassModelT =
- detail::PassModel<LoopNest, RepeatedPass<PassT>, PreservedAnalyses,
- LoopAnalysisManager, LoopStandardAnalysisResults &,
- LPMUpdater &>;
- IsLoopNestPass.push_back(true);
- LoopNestPasses.emplace_back(
- new RepeatedLoopNestPassModelT(std::move(Pass)));
- }
-
- bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
-
- static bool isRequired() { return true; }
-
- size_t getNumLoopPasses() const { return LoopPasses.size(); }
- size_t getNumLoopNestPasses() const { return LoopNestPasses.size(); }
-
-protected:
- using LoopPassConceptT =
- detail::PassConcept<Loop, LoopAnalysisManager,
- LoopStandardAnalysisResults &, LPMUpdater &>;
- using LoopNestPassConceptT =
- detail::PassConcept<LoopNest, LoopAnalysisManager,
- LoopStandardAnalysisResults &, LPMUpdater &>;
-
- // BitVector that identifies whether the passes are loop passes or loop-nest
- // passes (true for loop-nest passes).
- BitVector IsLoopNestPass;
- std::vector<std::unique_ptr<LoopPassConceptT>> LoopPasses;
- std::vector<std::unique_ptr<LoopNestPassConceptT>> LoopNestPasses;
-
- /// Flag indicating whether we should do debug logging.
- bool DebugLogging;
-
- /// Run either a loop pass or a loop-nest pass. Returns `None` if
- /// PassInstrumentation's BeforePass returns false. Otherwise, returns the
- /// preserved analyses of the pass.
- template <typename IRUnitT, typename PassT>
- Optional<PreservedAnalyses>
- runSinglePass(IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR, LPMUpdater &U,
- PassInstrumentation &PI);
-
- PreservedAnalyses runWithLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR,
- LPMUpdater &U);
- PreservedAnalyses runWithoutLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR,
- LPMUpdater &U);
-};
-
+class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
+ LPMUpdater &>
+ : public PassInfoMixin<
+ PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
+ LPMUpdater &>> {
+public:
+ /// Construct a pass manager.
+ ///
+ /// If \p DebugLogging is true, we'll log our progress to llvm::dbgs().
+ explicit PassManager(bool DebugLogging = false)
+ : DebugLogging(DebugLogging) {}
+
+ // FIXME: These are equivalent to the default move constructor/move
+ // assignment. However, using = default triggers linker errors due to the
+ // explicit instantiations below. Find a way to use the default and remove the
+ // duplicated code here.
+ PassManager(PassManager &&Arg)
+ : IsLoopNestPass(std::move(Arg.IsLoopNestPass)),
+ LoopPasses(std::move(Arg.LoopPasses)),
+ LoopNestPasses(std::move(Arg.LoopNestPasses)),
+ DebugLogging(std::move(Arg.DebugLogging)) {}
+
+ PassManager &operator=(PassManager &&RHS) {
+ IsLoopNestPass = std::move(RHS.IsLoopNestPass);
+ LoopPasses = std::move(RHS.LoopPasses);
+ LoopNestPasses = std::move(RHS.LoopNestPasses);
+ DebugLogging = std::move(RHS.DebugLogging);
+ return *this;
+ }
+
+ PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR, LPMUpdater &U);
+
+ /// Add either a loop pass or a loop-nest pass to the pass manager. Append \p
+ /// Pass to the list of loop passes if it has a dedicated \fn run() method for
+ /// loops and to the list of loop-nest passes if the \fn run() method is for
+ /// loop-nests instead. Also append whether \p Pass is loop-nest pass or not
+ /// to the end of \var IsLoopNestPass so we can easily identify the types of
+ /// passes in the pass manager later.
+ template <typename PassT>
+ std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(PassT Pass) {
+ using LoopPassModelT =
+ detail::PassModel<Loop, PassT, PreservedAnalyses, LoopAnalysisManager,
+ LoopStandardAnalysisResults &, LPMUpdater &>;
+ IsLoopNestPass.push_back(false);
+ LoopPasses.emplace_back(new LoopPassModelT(std::move(Pass)));
+ }
+
+ template <typename PassT>
+ std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(PassT Pass) {
+ using LoopNestPassModelT =
+ detail::PassModel<LoopNest, PassT, PreservedAnalyses,
+ LoopAnalysisManager, LoopStandardAnalysisResults &,
+ LPMUpdater &>;
+ IsLoopNestPass.push_back(true);
+ LoopNestPasses.emplace_back(new LoopNestPassModelT(std::move(Pass)));
+ }
+
+ // Specializations of `addPass` for `RepeatedPass`. These are necessary since
+ // `RepeatedPass` has a templated `run` method that will result in incorrect
+ // detection of `HasRunOnLoopT`.
+ template <typename PassT>
+ std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(RepeatedPass<PassT> Pass) {
+ using RepeatedLoopPassModelT =
+ detail::PassModel<Loop, RepeatedPass<PassT>, PreservedAnalyses,
+ LoopAnalysisManager, LoopStandardAnalysisResults &,
+ LPMUpdater &>;
+ IsLoopNestPass.push_back(false);
+ LoopPasses.emplace_back(new RepeatedLoopPassModelT(std::move(Pass)));
+ }
+
+ template <typename PassT>
+ std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(RepeatedPass<PassT> Pass) {
+ using RepeatedLoopNestPassModelT =
+ detail::PassModel<LoopNest, RepeatedPass<PassT>, PreservedAnalyses,
+ LoopAnalysisManager, LoopStandardAnalysisResults &,
+ LPMUpdater &>;
+ IsLoopNestPass.push_back(true);
+ LoopNestPasses.emplace_back(
+ new RepeatedLoopNestPassModelT(std::move(Pass)));
+ }
+
+ bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
+
+ static bool isRequired() { return true; }
+
+ size_t getNumLoopPasses() const { return LoopPasses.size(); }
+ size_t getNumLoopNestPasses() const { return LoopNestPasses.size(); }
+
+protected:
+ using LoopPassConceptT =
+ detail::PassConcept<Loop, LoopAnalysisManager,
+ LoopStandardAnalysisResults &, LPMUpdater &>;
+ using LoopNestPassConceptT =
+ detail::PassConcept<LoopNest, LoopAnalysisManager,
+ LoopStandardAnalysisResults &, LPMUpdater &>;
+
+ // BitVector that identifies whether the passes are loop passes or loop-nest
+ // passes (true for loop-nest passes).
+ BitVector IsLoopNestPass;
+ std::vector<std::unique_ptr<LoopPassConceptT>> LoopPasses;
+ std::vector<std::unique_ptr<LoopNestPassConceptT>> LoopNestPasses;
+
+ /// Flag indicating whether we should do debug logging.
+ bool DebugLogging;
+
+ /// Run either a loop pass or a loop-nest pass. Returns `None` if
+ /// PassInstrumentation's BeforePass returns false. Otherwise, returns the
+ /// preserved analyses of the pass.
+ template <typename IRUnitT, typename PassT>
+ Optional<PreservedAnalyses>
+ runSinglePass(IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR, LPMUpdater &U,
+ PassInstrumentation &PI);
+
+ PreservedAnalyses runWithLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR,
+ LPMUpdater &U);
+ PreservedAnalyses runWithoutLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR,
+ LPMUpdater &U);
+};
+
/// The Loop pass manager.
///
/// See the documentation for the PassManager template for details. It runs
@@ -232,7 +232,7 @@ using RequireAnalysisLoopPass =
RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &>;
-class FunctionToLoopPassAdaptor;
+class FunctionToLoopPassAdaptor;
/// This class provides an interface for updating the loop pass manager based
/// on mutations to the loop nest.
@@ -240,13 +240,13 @@ class FunctionToLoopPassAdaptor;
/// A reference to an instance of this class is passed as an argument to each
/// Loop pass, and Loop passes should use it to update LPM infrastructure if
/// they modify the loop nest structure.
-///
-/// \c LPMUpdater comes with two modes: the loop mode and the loop-nest mode. In
-/// loop mode, all the loops in the function will be pushed into the worklist
-/// and when new loops are added to the pipeline, their subloops are also
-/// inserted recursively. On the other hand, in loop-nest mode, only top-level
-/// loops are contained in the worklist and the addition of new (top-level)
-/// loops will not trigger the addition of their subloops.
+///
+/// \c LPMUpdater comes with two modes: the loop mode and the loop-nest mode. In
+/// loop mode, all the loops in the function will be pushed into the worklist
+/// and when new loops are added to the pipeline, their subloops are also
+/// inserted recursively. On the other hand, in loop-nest mode, only top-level
+/// loops are contained in the worklist and the addition of new (top-level)
+/// loops will not trigger the addition of their subloops.
class LPMUpdater {
public:
/// This can be queried by loop passes which run other loop passes (like pass
@@ -268,8 +268,8 @@ public:
/// state, this routine will mark that the current loop should be skipped by
/// the rest of the pass management infrastructure.
void markLoopAsDeleted(Loop &L, llvm::StringRef Name) {
- assert((!LoopNestMode || L.isOutermost()) &&
- "L should be a top-level loop in loop-nest mode.");
+ assert((!LoopNestMode || L.isOutermost()) &&
+ "L should be a top-level loop in loop-nest mode.");
LAM.clear(L, Name);
assert((&L == CurrentL || CurrentL->contains(&L)) &&
"Cannot delete a loop outside of the "
@@ -285,8 +285,8 @@ public:
/// loops within them will be visited in postorder as usual for the loop pass
/// manager.
void addChildLoops(ArrayRef<Loop *> NewChildLoops) {
- assert(!LoopNestMode &&
- "Child loops should not be pushed in loop-nest mode.");
+ assert(!LoopNestMode &&
+ "Child loops should not be pushed in loop-nest mode.");
// Insert ourselves back into the worklist first, as this loop should be
// revisited after all the children have been processed.
Worklist.insert(CurrentL);
@@ -318,10 +318,10 @@ public:
"All of the new loops must be siblings of the current loop!");
#endif
- if (LoopNestMode)
- Worklist.insert(NewSibLoops);
- else
- appendLoopsToWorklist(NewSibLoops, Worklist);
+ if (LoopNestMode)
+ Worklist.insert(NewSibLoops);
+ else
+ appendLoopsToWorklist(NewSibLoops, Worklist);
// No need to skip the current loop or revisit it, as sibling loops
// shouldn't impact anything.
@@ -341,7 +341,7 @@ public:
}
private:
- friend class llvm::FunctionToLoopPassAdaptor;
+ friend class llvm::FunctionToLoopPassAdaptor;
/// The \c FunctionToLoopPassAdaptor's worklist of loops to process.
SmallPriorityWorklist<Loop *, 4> &Worklist;
@@ -351,7 +351,7 @@ private:
Loop *CurrentL;
bool SkipCurrentLoop;
- const bool LoopNestMode;
+ const bool LoopNestMode;
#ifndef NDEBUG
// In debug builds we also track the parent loop to implement asserts even in
@@ -360,33 +360,33 @@ private:
#endif
LPMUpdater(SmallPriorityWorklist<Loop *, 4> &Worklist,
- LoopAnalysisManager &LAM, bool LoopNestMode = false)
- : Worklist(Worklist), LAM(LAM), LoopNestMode(LoopNestMode) {}
+ LoopAnalysisManager &LAM, bool LoopNestMode = false)
+ : Worklist(Worklist), LAM(LAM), LoopNestMode(LoopNestMode) {}
};
-template <typename IRUnitT, typename PassT>
-Optional<PreservedAnalyses> LoopPassManager::runSinglePass(
- IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR, LPMUpdater &U, PassInstrumentation &PI) {
- // Check the PassInstrumentation's BeforePass callbacks before running the
- // pass, skip its execution completely if asked to (callback returns false).
- if (!PI.runBeforePass<IRUnitT>(*Pass, IR))
- return None;
-
- PreservedAnalyses PA;
- {
- TimeTraceScope TimeScope(Pass->name(), IR.getName());
- PA = Pass->run(IR, AM, AR, U);
- }
-
- // do not pass deleted Loop into the instrumentation
- if (U.skipCurrentLoop())
- PI.runAfterPassInvalidated<IRUnitT>(*Pass, PA);
- else
- PI.runAfterPass<IRUnitT>(*Pass, IR, PA);
- return PA;
-}
-
+template <typename IRUnitT, typename PassT>
+Optional<PreservedAnalyses> LoopPassManager::runSinglePass(
+ IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR, LPMUpdater &U, PassInstrumentation &PI) {
+ // Check the PassInstrumentation's BeforePass callbacks before running the
+ // pass, skip its execution completely if asked to (callback returns false).
+ if (!PI.runBeforePass<IRUnitT>(*Pass, IR))
+ return None;
+
+ PreservedAnalyses PA;
+ {
+ TimeTraceScope TimeScope(Pass->name(), IR.getName());
+ PA = Pass->run(IR, AM, AR, U);
+ }
+
+ // do not pass deleted Loop into the instrumentation
+ if (U.skipCurrentLoop())
+ PI.runAfterPassInvalidated<IRUnitT>(*Pass, PA);
+ else
+ PI.runAfterPass<IRUnitT>(*Pass, IR, PA);
+ return PA;
+}
+
/// Adaptor that maps from a function to its loops.
///
/// Designed to allow composition of a LoopPass(Manager) and a
@@ -394,109 +394,109 @@ Optional<PreservedAnalyses> LoopPassManager::runSinglePass(
/// FunctionAnalysisManager it will run the \c LoopAnalysisManagerFunctionProxy
/// analysis prior to running the loop passes over the function to enable a \c
/// LoopAnalysisManager to be used within this run safely.
-///
-/// The adaptor comes with two modes: the loop mode and the loop-nest mode, and
-/// the worklist updater lived inside will be in the same mode as the adaptor
-/// (refer to the documentation of \c LPMUpdater for more detailed explanation).
-/// Specifically, in loop mode, all loops in the funciton will be pushed into
-/// the worklist and processed by \p Pass, while only top-level loops are
-/// processed in loop-nest mode. Please refer to the various specializations of
-/// \fn createLoopFunctionToLoopPassAdaptor to see when loop mode and loop-nest
-/// mode are used.
+///
+/// The adaptor comes with two modes: the loop mode and the loop-nest mode, and
+/// the worklist updater lived inside will be in the same mode as the adaptor
+/// (refer to the documentation of \c LPMUpdater for more detailed explanation).
+/// Specifically, in loop mode, all loops in the funciton will be pushed into
+/// the worklist and processed by \p Pass, while only top-level loops are
+/// processed in loop-nest mode. Please refer to the various specializations of
+/// \fn createLoopFunctionToLoopPassAdaptor to see when loop mode and loop-nest
+/// mode are used.
class FunctionToLoopPassAdaptor
- : public PassInfoMixin<FunctionToLoopPassAdaptor> {
+ : public PassInfoMixin<FunctionToLoopPassAdaptor> {
public:
- using PassConceptT =
- detail::PassConcept<Loop, LoopAnalysisManager,
- LoopStandardAnalysisResults &, LPMUpdater &>;
-
- explicit FunctionToLoopPassAdaptor(std::unique_ptr<PassConceptT> Pass,
- bool UseMemorySSA = false,
- bool UseBlockFrequencyInfo = false,
- bool DebugLogging = false,
- bool LoopNestMode = false)
+ using PassConceptT =
+ detail::PassConcept<Loop, LoopAnalysisManager,
+ LoopStandardAnalysisResults &, LPMUpdater &>;
+
+ explicit FunctionToLoopPassAdaptor(std::unique_ptr<PassConceptT> Pass,
+ bool UseMemorySSA = false,
+ bool UseBlockFrequencyInfo = false,
+ bool DebugLogging = false,
+ bool LoopNestMode = false)
: Pass(std::move(Pass)), LoopCanonicalizationFPM(DebugLogging),
- UseMemorySSA(UseMemorySSA),
- UseBlockFrequencyInfo(UseBlockFrequencyInfo),
- LoopNestMode(LoopNestMode) {
+ UseMemorySSA(UseMemorySSA),
+ UseBlockFrequencyInfo(UseBlockFrequencyInfo),
+ LoopNestMode(LoopNestMode) {
LoopCanonicalizationFPM.addPass(LoopSimplifyPass());
LoopCanonicalizationFPM.addPass(LCSSAPass());
}
/// Runs the loop passes across every loop in the function.
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
- bool isLoopNestMode() const { return LoopNestMode; }
+ bool isLoopNestMode() const { return LoopNestMode; }
private:
- std::unique_ptr<PassConceptT> Pass;
+ std::unique_ptr<PassConceptT> Pass;
FunctionPassManager LoopCanonicalizationFPM;
bool UseMemorySSA = false;
- bool UseBlockFrequencyInfo = false;
- const bool LoopNestMode;
+ bool UseBlockFrequencyInfo = false;
+ const bool LoopNestMode;
};
/// A function to deduce a loop pass type and wrap it in the templated
/// adaptor.
-///
-/// If \p Pass is a loop pass, the returned adaptor will be in loop mode.
+///
+/// If \p Pass is a loop pass, the returned adaptor will be in loop mode.
template <typename LoopPassT>
-inline std::enable_if_t<is_detected<HasRunOnLoopT, LoopPassT>::value,
- FunctionToLoopPassAdaptor>
+inline std::enable_if_t<is_detected<HasRunOnLoopT, LoopPassT>::value,
+ FunctionToLoopPassAdaptor>
createFunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA = false,
- bool UseBlockFrequencyInfo = false,
+ bool UseBlockFrequencyInfo = false,
+ bool DebugLogging = false) {
+ using PassModelT =
+ detail::PassModel<Loop, LoopPassT, PreservedAnalyses, LoopAnalysisManager,
+ LoopStandardAnalysisResults &, LPMUpdater &>;
+ return FunctionToLoopPassAdaptor(
+ std::make_unique<PassModelT>(std::move(Pass)), UseMemorySSA,
+ UseBlockFrequencyInfo, DebugLogging, false);
+}
+
+/// If \p Pass is a loop-nest pass, \p Pass will first be wrapped into a
+/// \c LoopPassManager and the returned adaptor will be in loop-nest mode.
+template <typename LoopNestPassT>
+inline std::enable_if_t<!is_detected<HasRunOnLoopT, LoopNestPassT>::value,
+ FunctionToLoopPassAdaptor>
+createFunctionToLoopPassAdaptor(LoopNestPassT Pass, bool UseMemorySSA = false,
+ bool UseBlockFrequencyInfo = false,
bool DebugLogging = false) {
- using PassModelT =
- detail::PassModel<Loop, LoopPassT, PreservedAnalyses, LoopAnalysisManager,
- LoopStandardAnalysisResults &, LPMUpdater &>;
- return FunctionToLoopPassAdaptor(
- std::make_unique<PassModelT>(std::move(Pass)), UseMemorySSA,
- UseBlockFrequencyInfo, DebugLogging, false);
+ LoopPassManager LPM(DebugLogging);
+ LPM.addPass(std::move(Pass));
+ using PassModelT =
+ detail::PassModel<Loop, LoopPassManager, PreservedAnalyses,
+ LoopAnalysisManager, LoopStandardAnalysisResults &,
+ LPMUpdater &>;
+ return FunctionToLoopPassAdaptor(std::make_unique<PassModelT>(std::move(LPM)),
+ UseMemorySSA, UseBlockFrequencyInfo,
+ DebugLogging, true);
+}
+
+/// If \p Pass is an instance of \c LoopPassManager, the returned adaptor will
+/// be in loop-nest mode if the pass manager contains only loop-nest passes.
+template <>
+inline FunctionToLoopPassAdaptor
+createFunctionToLoopPassAdaptor<LoopPassManager>(LoopPassManager LPM,
+ bool UseMemorySSA,
+ bool UseBlockFrequencyInfo,
+ bool DebugLogging) {
+ // Check if LPM contains any loop pass and if it does not, returns an adaptor
+ // in loop-nest mode.
+ using PassModelT =
+ detail::PassModel<Loop, LoopPassManager, PreservedAnalyses,
+ LoopAnalysisManager, LoopStandardAnalysisResults &,
+ LPMUpdater &>;
+ bool LoopNestMode = (LPM.getNumLoopPasses() == 0);
+ return FunctionToLoopPassAdaptor(std::make_unique<PassModelT>(std::move(LPM)),
+ UseMemorySSA, UseBlockFrequencyInfo,
+ DebugLogging, LoopNestMode);
}
-/// If \p Pass is a loop-nest pass, \p Pass will first be wrapped into a
-/// \c LoopPassManager and the returned adaptor will be in loop-nest mode.
-template <typename LoopNestPassT>
-inline std::enable_if_t<!is_detected<HasRunOnLoopT, LoopNestPassT>::value,
- FunctionToLoopPassAdaptor>
-createFunctionToLoopPassAdaptor(LoopNestPassT Pass, bool UseMemorySSA = false,
- bool UseBlockFrequencyInfo = false,
- bool DebugLogging = false) {
- LoopPassManager LPM(DebugLogging);
- LPM.addPass(std::move(Pass));
- using PassModelT =
- detail::PassModel<Loop, LoopPassManager, PreservedAnalyses,
- LoopAnalysisManager, LoopStandardAnalysisResults &,
- LPMUpdater &>;
- return FunctionToLoopPassAdaptor(std::make_unique<PassModelT>(std::move(LPM)),
- UseMemorySSA, UseBlockFrequencyInfo,
- DebugLogging, true);
-}
-
-/// If \p Pass is an instance of \c LoopPassManager, the returned adaptor will
-/// be in loop-nest mode if the pass manager contains only loop-nest passes.
-template <>
-inline FunctionToLoopPassAdaptor
-createFunctionToLoopPassAdaptor<LoopPassManager>(LoopPassManager LPM,
- bool UseMemorySSA,
- bool UseBlockFrequencyInfo,
- bool DebugLogging) {
- // Check if LPM contains any loop pass and if it does not, returns an adaptor
- // in loop-nest mode.
- using PassModelT =
- detail::PassModel<Loop, LoopPassManager, PreservedAnalyses,
- LoopAnalysisManager, LoopStandardAnalysisResults &,
- LPMUpdater &>;
- bool LoopNestMode = (LPM.getNumLoopPasses() == 0);
- return FunctionToLoopPassAdaptor(std::make_unique<PassModelT>(std::move(LPM)),
- UseMemorySSA, UseBlockFrequencyInfo,
- DebugLogging, LoopNestMode);
-}
-
/// Pass for printing a loop's contents as textual IR.
class PrintLoopPass : public PassInfoMixin<PrintLoopPass> {
raw_ostream &OS;
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopReroll.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopReroll.h
index 53929a90a1..d4674af374 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopReroll.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopReroll.h
@@ -1,38 +1,38 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- LoopReroll.h - Loop rerolling pass ---------------------------------===//
-//
-// 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 LLVM_TRANSFORMS_SCALAR_LOOPREROLL_H
-#define LLVM_TRANSFORMS_SCALAR_LOOPREROLL_H
-
-#include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Scalar/LoopPassManager.h"
-
-namespace llvm {
-
-class Function;
-
-class LoopRerollPass : public PassInfoMixin<LoopRerollPass> {
-public:
- PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR, LPMUpdater &U);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_LOOPREROLL_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- LoopReroll.h - Loop rerolling pass ---------------------------------===//
+//
+// 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 LLVM_TRANSFORMS_SCALAR_LOOPREROLL_H
+#define LLVM_TRANSFORMS_SCALAR_LOOPREROLL_H
+
+#include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Scalar/LoopPassManager.h"
+
+namespace llvm {
+
+class Function;
+
+class LoopRerollPass : public PassInfoMixin<LoopRerollPass> {
+public:
+ PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR, LPMUpdater &U);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_LOOPREROLL_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopRotation.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopRotation.h
index 36eb74558a..907bf22274 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopRotation.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopRotation.h
@@ -29,14 +29,14 @@ namespace llvm {
/// A simple loop rotation transformation.
class LoopRotatePass : public PassInfoMixin<LoopRotatePass> {
public:
- LoopRotatePass(bool EnableHeaderDuplication = true,
- bool PrepareForLTO = false);
+ LoopRotatePass(bool EnableHeaderDuplication = true,
+ bool PrepareForLTO = false);
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);
private:
const bool EnableHeaderDuplication;
- const bool PrepareForLTO;
+ const bool PrepareForLTO;
};
}
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopUnrollPass.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopUnrollPass.h
index 9ba3f0ed28..d6c45889ef 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopUnrollPass.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopUnrollPass.h
@@ -29,7 +29,7 @@ class Function;
class Loop;
class LPMUpdater;
-/// Loop unroll pass that only does full loop unrolling and peeling.
+/// Loop unroll pass that only does full loop unrolling and peeling.
class LoopFullUnrollPass : public PassInfoMixin<LoopFullUnrollPass> {
const int OptLevel;
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopVersioningLICM.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopVersioningLICM.h
index c554baddb9..1e16fabbe3 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopVersioningLICM.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LoopVersioningLICM.h
@@ -1,36 +1,36 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- LoopVersioningLICM.h - LICM Loop Versioning ------------------------===//
-//
-// 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 LLVM_TRANSFORMS_SCALAR_LOOPVERSIONINGLICM_H
-#define LLVM_TRANSFORMS_SCALAR_LOOPVERSIONINGLICM_H
-
-#include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Scalar/LoopPassManager.h"
-
-namespace llvm {
-
-class LoopVersioningLICMPass : public PassInfoMixin<LoopVersioningLICMPass> {
-public:
- PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &LAR, LPMUpdater &U);
-};
-
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_LOOPVERSIONINGLICM_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- LoopVersioningLICM.h - LICM Loop Versioning ------------------------===//
+//
+// 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 LLVM_TRANSFORMS_SCALAR_LOOPVERSIONINGLICM_H
+#define LLVM_TRANSFORMS_SCALAR_LOOPVERSIONINGLICM_H
+
+#include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Scalar/LoopPassManager.h"
+
+namespace llvm {
+
+class LoopVersioningLICMPass : public PassInfoMixin<LoopVersioningLICMPass> {
+public:
+ PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &LAR, LPMUpdater &U);
+};
+
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_LOOPVERSIONINGLICM_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerAtomic.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerAtomic.h
index 6e98c10455..351afc1018 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerAtomic.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerAtomic.h
@@ -29,7 +29,7 @@ namespace llvm {
class LowerAtomicPass : public PassInfoMixin<LowerAtomicPass> {
public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
}
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
index bf63ebe46e..c862c7fa33 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
@@ -24,7 +24,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/CommandLine.h"
namespace llvm {
@@ -39,8 +39,8 @@ struct LowerExpectIntrinsicPass : PassInfoMixin<LowerExpectIntrinsicPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
};
-extern cl::opt<uint32_t> LikelyBranchWeight;
-extern cl::opt<uint32_t> UnlikelyBranchWeight;
+extern cl::opt<uint32_t> LikelyBranchWeight;
+extern cl::opt<uint32_t> UnlikelyBranchWeight;
}
#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
index d2bbcc508b..58bcd51171 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
@@ -23,14 +23,14 @@
#include "llvm/IR/PassManager.h"
namespace llvm {
-class LowerMatrixIntrinsicsPass
- : public PassInfoMixin<LowerMatrixIntrinsicsPass> {
- bool Minimal;
-
-public:
- LowerMatrixIntrinsicsPass(bool Minimal = false) : Minimal(Minimal) {}
+class LowerMatrixIntrinsicsPass
+ : public PassInfoMixin<LowerMatrixIntrinsicsPass> {
+ bool Minimal;
+
+public:
+ LowerMatrixIntrinsicsPass(bool Minimal = false) : Minimal(Minimal) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
- static bool isRequired() { return true; }
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/MemCpyOptimizer.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
index 470e105c41..5615f3375c 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
@@ -28,19 +28,19 @@
namespace llvm {
-class AAResults;
+class AAResults;
class AssumptionCache;
-class CallBase;
+class CallBase;
class CallInst;
class DominatorTree;
class Function;
class Instruction;
-class LoadInst;
+class LoadInst;
class MemCpyInst;
class MemMoveInst;
class MemoryDependenceResults;
-class MemorySSA;
-class MemorySSAUpdater;
+class MemorySSA;
+class MemorySSAUpdater;
class MemSetInst;
class StoreInst;
class TargetLibraryInfo;
@@ -49,11 +49,11 @@ class Value;
class MemCpyOptPass : public PassInfoMixin<MemCpyOptPass> {
MemoryDependenceResults *MD = nullptr;
TargetLibraryInfo *TLI = nullptr;
- AAResults *AA = nullptr;
- AssumptionCache *AC = nullptr;
- DominatorTree *DT = nullptr;
- MemorySSA *MSSA = nullptr;
- MemorySSAUpdater *MSSAU = nullptr;
+ AAResults *AA = nullptr;
+ AssumptionCache *AC = nullptr;
+ DominatorTree *DT = nullptr;
+ MemorySSA *MSSA = nullptr;
+ MemorySSAUpdater *MSSAU = nullptr;
public:
MemCpyOptPass() = default;
@@ -61,9 +61,9 @@ public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
// Glue for the old PM.
- bool runImpl(Function &F, MemoryDependenceResults *MD, TargetLibraryInfo *TLI,
- AAResults *AA, AssumptionCache *AC, DominatorTree *DT,
- MemorySSA *MSSA);
+ bool runImpl(Function &F, MemoryDependenceResults *MD, TargetLibraryInfo *TLI,
+ AAResults *AA, AssumptionCache *AC, DominatorTree *DT,
+ MemorySSA *MSSA);
private:
// Helper functions
@@ -71,18 +71,18 @@ private:
bool processMemSet(MemSetInst *SI, BasicBlock::iterator &BBI);
bool processMemCpy(MemCpyInst *M, BasicBlock::iterator &BBI);
bool processMemMove(MemMoveInst *M);
- bool performCallSlotOptzn(Instruction *cpyLoad, Instruction *cpyStore,
- Value *cpyDst, Value *cpySrc, uint64_t cpyLen,
- Align cpyAlign, CallInst *C);
+ bool performCallSlotOptzn(Instruction *cpyLoad, Instruction *cpyStore,
+ Value *cpyDst, Value *cpySrc, uint64_t cpyLen,
+ Align cpyAlign, CallInst *C);
bool processMemCpyMemCpyDependence(MemCpyInst *M, MemCpyInst *MDep);
bool processMemSetMemCpyDependence(MemCpyInst *MemCpy, MemSetInst *MemSet);
bool performMemCpyToMemSetOptzn(MemCpyInst *MemCpy, MemSetInst *MemSet);
bool processByValArgument(CallBase &CB, unsigned ArgNo);
Instruction *tryMergingIntoMemset(Instruction *I, Value *StartPtr,
Value *ByteVal);
- bool moveUp(StoreInst *SI, Instruction *P, const LoadInst *LI);
+ bool moveUp(StoreInst *SI, Instruction *P, const LoadInst *LI);
- void eraseInstruction(Instruction *I);
+ void eraseInstruction(Instruction *I);
bool iterateOnFunction(Function &F);
};
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/NaryReassociate.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/NaryReassociate.h
index a91076c0c9..06a9cdc04b 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/NaryReassociate.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/NaryReassociate.h
@@ -121,7 +121,7 @@ private:
bool doOneIteration(Function &F);
// Reassociates I for better CSE.
- Instruction *tryReassociate(Instruction *I, const SCEV *&OrigSCEV);
+ Instruction *tryReassociate(Instruction *I, const SCEV *&OrigSCEV);
// Reassociate GEP for better CSE.
Instruction *tryReassociateGEP(GetElementPtrInst *GEP);
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/Reg2Mem.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/Reg2Mem.h
index 78ee91f0f8..d2a5d8cb85 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/Reg2Mem.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/Reg2Mem.h
@@ -1,38 +1,38 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- Reg2Mem.h - Convert registers to allocas -----------------*- 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 provides the interface for the RegToMem Pass.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_SCALAR_REG2MEM_H
-#define LLVM_TRANSFORMS_SCALAR_REG2MEM_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class RegToMemPass : public PassInfoMixin<RegToMemPass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_REG2MEM_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- Reg2Mem.h - Convert registers to allocas -----------------*- 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 provides the interface for the RegToMem Pass.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_SCALAR_REG2MEM_H
+#define LLVM_TRANSFORMS_SCALAR_REG2MEM_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class RegToMemPass : public PassInfoMixin<RegToMemPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_REG2MEM_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SROA.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SROA.h
index 25471d0157..9f369eaf77 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SROA.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SROA.h
@@ -25,7 +25,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/PassManager.h"
-#include "llvm/IR/ValueHandle.h"
+#include "llvm/IR/ValueHandle.h"
#include <vector>
namespace llvm {
@@ -85,8 +85,8 @@ class SROA : public PassInfoMixin<SROA> {
/// A collection of instructions to delete.
/// We try to batch deletions to simplify code and make things a bit more
- /// efficient. We also make sure there is no dangling pointers.
- SmallVector<WeakVH, 8> DeadInsts;
+ /// efficient. We also make sure there is no dangling pointers.
+ SmallVector<WeakVH, 8> DeadInsts;
/// Post-promotion worklist.
///
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h
index dbdfa7502d..89f08f823d 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h
@@ -1,40 +1,40 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- ScalarizeMaskedMemIntrin.h - Scalarize unsupported masked mem ----===//
-// instrinsics
-//
-// 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 pass replaces masked memory intrinsics - when unsupported by the target
-// - with a chain of basic blocks, that deal with the elements one-by-one if the
-// appropriate mask bit is set.
-//
-//===----------------------------------------------------------------------===//
-//
-#ifndef LLVM_TRANSFORMS_SCALAR_SCALARIZE_MASKED_MEMINTRIN_H
-#define LLVM_TRANSFORMS_SCALAR_SCALARIZE_MASKED_MEMINTRIN_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-struct ScalarizeMaskedMemIntrinPass
- : public PassInfoMixin<ScalarizeMaskedMemIntrinPass> {
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-} // end namespace llvm
-
-#endif
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- ScalarizeMaskedMemIntrin.h - Scalarize unsupported masked mem ----===//
+// instrinsics
+//
+// 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 pass replaces masked memory intrinsics - when unsupported by the target
+// - with a chain of basic blocks, that deal with the elements one-by-one if the
+// appropriate mask bit is set.
+//
+//===----------------------------------------------------------------------===//
+//
+#ifndef LLVM_TRANSFORMS_SCALAR_SCALARIZE_MASKED_MEMINTRIN_H
+#define LLVM_TRANSFORMS_SCALAR_SCALARIZE_MASKED_MEMINTRIN_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+struct ScalarizeMaskedMemIntrinPass
+ : public PassInfoMixin<ScalarizeMaskedMemIntrinPass> {
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+} // end namespace llvm
+
+#endif
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h
index 219d4f2354..258501eda8 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h
@@ -1,38 +1,38 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- SeparateConstOffsetFromGEP.h ---------------------------------------===//
-//
-// 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 LLVM_TRANSFORMS_SCALAR_SEPARATECONSTOFFSETFROMGEP_H
-#define LLVM_TRANSFORMS_SCALAR_SEPARATECONSTOFFSETFROMGEP_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class SeparateConstOffsetFromGEPPass
- : public PassInfoMixin<SeparateConstOffsetFromGEPPass> {
- bool LowerGEP;
-
-public:
- SeparateConstOffsetFromGEPPass(bool LowerGEP = false) : LowerGEP(LowerGEP) {}
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_SEPARATECONSTOFFSETFROMGEP_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- SeparateConstOffsetFromGEP.h ---------------------------------------===//
+//
+// 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 LLVM_TRANSFORMS_SCALAR_SEPARATECONSTOFFSETFROMGEP_H
+#define LLVM_TRANSFORMS_SCALAR_SEPARATECONSTOFFSETFROMGEP_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class SeparateConstOffsetFromGEPPass
+ : public PassInfoMixin<SeparateConstOffsetFromGEPPass> {
+ bool LowerGEP;
+
+public:
+ SeparateConstOffsetFromGEPPass(bool LowerGEP = false) : LowerGEP(LowerGEP) {}
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_SEPARATECONSTOFFSETFROMGEP_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SimplifyCFG.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SimplifyCFG.h
index 3e50d4b808..d87a05c3ac 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SimplifyCFG.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/SimplifyCFG.h
@@ -23,7 +23,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
+#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
namespace llvm {
@@ -41,7 +41,7 @@ public:
/// rather than optimal IR. That is, by default we bypass transformations that
/// are likely to improve performance but make analysis for other passes more
/// difficult.
- SimplifyCFGPass();
+ SimplifyCFGPass();
/// Construct a pass with optional optimizations.
SimplifyCFGPass(const SimplifyCFGOptions &PassOptions);
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h
index 4418930cce..628f029de0 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h
@@ -1,35 +1,35 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- StraightLineStrengthReduce.h - -----------------------------------===//
-//
-// 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 LLVM_TRANSFORMS_SCALAR_STRAIGHTLINESTRENGTHREDUCE_H
-#define LLVM_TRANSFORMS_SCALAR_STRAIGHTLINESTRENGTHREDUCE_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class StraightLineStrengthReducePass
- : public PassInfoMixin<StraightLineStrengthReducePass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_STRAIGHTLINESTRENGTHREDUCE_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- StraightLineStrengthReduce.h - -----------------------------------===//
+//
+// 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 LLVM_TRANSFORMS_SCALAR_STRAIGHTLINESTRENGTHREDUCE_H
+#define LLVM_TRANSFORMS_SCALAR_STRAIGHTLINESTRENGTHREDUCE_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class StraightLineStrengthReducePass
+ : public PassInfoMixin<StraightLineStrengthReducePass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_STRAIGHTLINESTRENGTHREDUCE_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StructurizeCFG.h b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StructurizeCFG.h
index 4435610177..b36082a59c 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StructurizeCFG.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Scalar/StructurizeCFG.h
@@ -1,31 +1,31 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- StructurizeCFG.h ---------------------------------------------------===//
-//
-// 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 LLVM_TRANSFORMS_SCALAR_STRUCTURIZECFG_H
-#define LLVM_TRANSFORMS_SCALAR_STRUCTURIZECFG_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-struct StructurizeCFGPass : PassInfoMixin<StructurizeCFGPass> {
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_SCALAR_STRUCTURIZECFG_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- StructurizeCFG.h ---------------------------------------------------===//
+//
+// 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 LLVM_TRANSFORMS_SCALAR_STRUCTURIZECFG_H
+#define LLVM_TRANSFORMS_SCALAR_STRUCTURIZECFG_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+struct StructurizeCFGPass : PassInfoMixin<StructurizeCFGPass> {
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_STRUCTURIZECFG_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils.h
index 4d1704538a..9937638f2f 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils.h
@@ -124,7 +124,7 @@ extern char &LoopSimplifyID;
/// This function returns a new pass that downgrades the debug info in the
/// module to line tables only.
-ModulePass *createStripNonLineTableDebugLegacyPass();
+ModulePass *createStripNonLineTableDebugLegacyPass();
//===----------------------------------------------------------------------===//
//
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h
index 2b7016b7e6..17376fd660 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -81,7 +81,7 @@ bool EliminateUnreachableBlocks(Function &F, DomTreeUpdater *DTU = nullptr,
/// in it, fold them away. This handles the case when all entries to the PHI
/// nodes in a block are guaranteed equal, such as when the block has exactly
/// one predecessor.
-bool FoldSingleEntryPHINodes(BasicBlock *BB,
+bool FoldSingleEntryPHINodes(BasicBlock *BB,
MemoryDependenceResults *MemDep = nullptr);
/// Examine each PHI in the given block and delete it if it is dead. Also
@@ -203,8 +203,8 @@ struct CriticalEdgeSplittingOptions {
/// to.
BasicBlock *SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
const CriticalEdgeSplittingOptions &Options =
- CriticalEdgeSplittingOptions(),
- const Twine &BBName = "");
+ CriticalEdgeSplittingOptions(),
+ const Twine &BBName = "");
inline BasicBlock *
SplitCriticalEdge(BasicBlock *BB, succ_iterator SI,
@@ -252,50 +252,72 @@ unsigned SplitAllCriticalEdges(Function &F,
const CriticalEdgeSplittingOptions &Options =
CriticalEdgeSplittingOptions());
-/// Split the edge connecting the specified blocks, and return the newly created
-/// basic block between \p From and \p To.
+/// Split the edge connecting the specified blocks, and return the newly created
+/// basic block between \p From and \p To.
BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
- MemorySSAUpdater *MSSAU = nullptr,
- const Twine &BBName = "");
-
-/// Split the specified block at the specified instruction.
-///
-/// If \p Before is true, splitBlockBefore handles the block
-/// splitting. Otherwise, execution proceeds as described below.
-///
-/// Everything before \p SplitPt stays in \p Old and everything starting with \p
-/// SplitPt moves to a new block. The two blocks are joined by an unconditional
-/// branch. The new block with name \p BBName is returned.
-///
-/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
-BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT,
- LoopInfo *LI = nullptr,
- MemorySSAUpdater *MSSAU = nullptr,
- const Twine &BBName = "", bool Before = false);
-
-/// Split the specified block at the specified instruction.
-///
-/// If \p Before is true, splitBlockBefore handles the block
-/// splitting. Otherwise, execution proceeds as described below.
-///
-/// Everything before \p SplitPt stays in \p Old and everything starting with \p
-/// SplitPt moves to a new block. The two blocks are joined by an unconditional
-/// branch. The new block with name \p BBName is returned.
+ MemorySSAUpdater *MSSAU = nullptr,
+ const Twine &BBName = "");
+
+/// Split the specified block at the specified instruction.
+///
+/// If \p Before is true, splitBlockBefore handles the block
+/// splitting. Otherwise, execution proceeds as described below.
+///
+/// Everything before \p SplitPt stays in \p Old and everything starting with \p
+/// SplitPt moves to a new block. The two blocks are joined by an unconditional
+/// branch. The new block with name \p BBName is returned.
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT,
+ LoopInfo *LI = nullptr,
+ MemorySSAUpdater *MSSAU = nullptr,
+ const Twine &BBName = "", bool Before = false);
+
+/// Split the specified block at the specified instruction.
+///
+/// If \p Before is true, splitBlockBefore handles the block
+/// splitting. Otherwise, execution proceeds as described below.
+///
+/// Everything before \p SplitPt stays in \p Old and everything starting with \p
+/// SplitPt moves to a new block. The two blocks are joined by an unconditional
+/// branch. The new block with name \p BBName is returned.
BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt,
- DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,
+ DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,
MemorySSAUpdater *MSSAU = nullptr,
- const Twine &BBName = "", bool Before = false);
-
-/// Split the specified block at the specified instruction \p SplitPt.
-/// All instructions before \p SplitPt are moved to a new block and all
-/// instructions after \p SplitPt stay in the old block. The new block and the
-/// old block are joined by inserting an unconditional branch to the end of the
-/// new block. The new block with name \p BBName is returned.
-BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction *SplitPt,
- DomTreeUpdater *DTU, LoopInfo *LI,
- MemorySSAUpdater *MSSAU, const Twine &BBName = "");
-
+ const Twine &BBName = "", bool Before = false);
+
+/// Split the specified block at the specified instruction \p SplitPt.
+/// All instructions before \p SplitPt are moved to a new block and all
+/// instructions after \p SplitPt stay in the old block. The new block and the
+/// old block are joined by inserting an unconditional branch to the end of the
+/// new block. The new block with name \p BBName is returned.
+BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction *SplitPt,
+ DomTreeUpdater *DTU, LoopInfo *LI,
+ MemorySSAUpdater *MSSAU, const Twine &BBName = "");
+
+/// This method introduces at least one new basic block into the function and
+/// moves some of the predecessors of BB to be predecessors of the new block.
+/// The new predecessors are indicated by the Preds array. The new block is
+/// given a suffix of 'Suffix'. Returns new basic block to which predecessors
+/// from Preds are now pointing.
+///
+/// If BB is a landingpad block then additional basicblock might be introduced.
+/// It will have Suffix+".split_lp". See SplitLandingPadPredecessors for more
+/// details on this case.
+///
+/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but
+/// no other analyses. In particular, it does not preserve LoopSimplify
+/// (because it's complicated to handle the case where one of the edges being
+/// split is an exit of a loop with other exits).
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,
+ const char *Suffix, DominatorTree *DT,
+ LoopInfo *LI = nullptr,
+ MemorySSAUpdater *MSSAU = nullptr,
+ bool PreserveLCSSA = false);
+
/// This method introduces at least one new basic block into the function and
/// moves some of the predecessors of BB to be predecessors of the new block.
/// The new predecessors are indicated by the Preds array. The new block is
@@ -310,31 +332,9 @@ BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction *SplitPt,
/// no other analyses. In particular, it does not preserve LoopSimplify
/// (because it's complicated to handle the case where one of the edges being
/// split is an exit of a loop with other exits).
-///
-/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,
- const char *Suffix, DominatorTree *DT,
- LoopInfo *LI = nullptr,
- MemorySSAUpdater *MSSAU = nullptr,
- bool PreserveLCSSA = false);
-
-/// This method introduces at least one new basic block into the function and
-/// moves some of the predecessors of BB to be predecessors of the new block.
-/// The new predecessors are indicated by the Preds array. The new block is
-/// given a suffix of 'Suffix'. Returns new basic block to which predecessors
-/// from Preds are now pointing.
-///
-/// If BB is a landingpad block then additional basicblock might be introduced.
-/// It will have Suffix+".split_lp". See SplitLandingPadPredecessors for more
-/// details on this case.
-///
-/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but
-/// no other analyses. In particular, it does not preserve LoopSimplify
-/// (because it's complicated to handle the case where one of the edges being
-/// split is an exit of a loop with other exits).
-BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,
const char *Suffix,
- DomTreeUpdater *DTU = nullptr,
+ DomTreeUpdater *DTU = nullptr,
LoopInfo *LI = nullptr,
MemorySSAUpdater *MSSAU = nullptr,
bool PreserveLCSSA = false);
@@ -350,31 +350,31 @@ BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,
/// no other analyses. In particular, it does not preserve LoopSimplify
/// (because it's complicated to handle the case where one of the edges being
/// split is an exit of a loop with other exits).
-///
-/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
-void SplitLandingPadPredecessors(BasicBlock *OrigBB,
- ArrayRef<BasicBlock *> Preds,
- const char *Suffix, const char *Suffix2,
- SmallVectorImpl<BasicBlock *> &NewBBs,
- DominatorTree *DT, LoopInfo *LI = nullptr,
- MemorySSAUpdater *MSSAU = nullptr,
- bool PreserveLCSSA = false);
-
-/// This method transforms the landing pad, OrigBB, by introducing two new basic
-/// blocks into the function. One of those new basic blocks gets the
-/// predecessors listed in Preds. The other basic block gets the remaining
-/// predecessors of OrigBB. The landingpad instruction OrigBB is clone into both
-/// of the new basic blocks. The new blocks are given the suffixes 'Suffix1' and
-/// 'Suffix2', and are returned in the NewBBs vector.
-///
-/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but
-/// no other analyses. In particular, it does not preserve LoopSimplify
-/// (because it's complicated to handle the case where one of the edges being
-/// split is an exit of a loop with other exits).
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+void SplitLandingPadPredecessors(BasicBlock *OrigBB,
+ ArrayRef<BasicBlock *> Preds,
+ const char *Suffix, const char *Suffix2,
+ SmallVectorImpl<BasicBlock *> &NewBBs,
+ DominatorTree *DT, LoopInfo *LI = nullptr,
+ MemorySSAUpdater *MSSAU = nullptr,
+ bool PreserveLCSSA = false);
+
+/// This method transforms the landing pad, OrigBB, by introducing two new basic
+/// blocks into the function. One of those new basic blocks gets the
+/// predecessors listed in Preds. The other basic block gets the remaining
+/// predecessors of OrigBB. The landingpad instruction OrigBB is clone into both
+/// of the new basic blocks. The new blocks are given the suffixes 'Suffix1' and
+/// 'Suffix2', and are returned in the NewBBs vector.
+///
+/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but
+/// no other analyses. In particular, it does not preserve LoopSimplify
+/// (because it's complicated to handle the case where one of the edges being
+/// split is an exit of a loop with other exits).
void SplitLandingPadPredecessors(
BasicBlock *OrigBB, ArrayRef<BasicBlock *> Preds, const char *Suffix,
const char *Suffix2, SmallVectorImpl<BasicBlock *> &NewBBs,
- DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,
+ DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,
MemorySSAUpdater *MSSAU = nullptr, bool PreserveLCSSA = false);
/// This method duplicates the specified return instruction into a predecessor
@@ -406,39 +406,39 @@ ReturnInst *FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB,
/// Returns the NewBasicBlock's terminator.
///
/// Updates DT and LI if given.
-///
-/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore,
+ bool Unreachable, MDNode *BranchWeights,
+ DominatorTree *DT,
+ LoopInfo *LI = nullptr,
+ BasicBlock *ThenBlock = nullptr);
+
+/// Split the containing block at the specified instruction - everything before
+/// SplitBefore stays in the old basic block, and the rest of the instructions
+/// in the BB are moved to a new block. The two blocks are connected by a
+/// conditional branch (with value of Cmp being the condition).
+/// Before:
+/// Head
+/// SplitBefore
+/// Tail
+/// After:
+/// Head
+/// if (Cond)
+/// ThenBlock
+/// SplitBefore
+/// Tail
+///
+/// If \p ThenBlock is not specified, a new block will be created for it.
+/// If \p Unreachable is true, the newly created block will end with
+/// UnreachableInst, otherwise it branches to Tail.
+/// Returns the NewBasicBlock's terminator.
+///
+/// Updates DT and LI if given.
Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore,
- bool Unreachable, MDNode *BranchWeights,
- DominatorTree *DT,
- LoopInfo *LI = nullptr,
- BasicBlock *ThenBlock = nullptr);
-
-/// Split the containing block at the specified instruction - everything before
-/// SplitBefore stays in the old basic block, and the rest of the instructions
-/// in the BB are moved to a new block. The two blocks are connected by a
-/// conditional branch (with value of Cmp being the condition).
-/// Before:
-/// Head
-/// SplitBefore
-/// Tail
-/// After:
-/// Head
-/// if (Cond)
-/// ThenBlock
-/// SplitBefore
-/// Tail
-///
-/// If \p ThenBlock is not specified, a new block will be created for it.
-/// If \p Unreachable is true, the newly created block will end with
-/// UnreachableInst, otherwise it branches to Tail.
-/// Returns the NewBasicBlock's terminator.
-///
-/// Updates DT and LI if given.
-Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore,
bool Unreachable,
MDNode *BranchWeights = nullptr,
- DomTreeUpdater *DTU = nullptr,
+ DomTreeUpdater *DTU = nullptr,
LoopInfo *LI = nullptr,
BasicBlock *ThenBlock = nullptr);
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h
index 173218b15c..edb268a5b1 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h
@@ -103,10 +103,10 @@ namespace llvm {
IRBuilderBase &B, const DataLayout &DL,
const TargetLibraryInfo *TLI);
- /// Emit a call to the mempcpy function.
- Value *emitMemPCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B,
- const DataLayout &DL, const TargetLibraryInfo *TLI);
-
+ /// Emit a call to the mempcpy function.
+ Value *emitMemPCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B,
+ const DataLayout &DL, const TargetLibraryInfo *TLI);
+
/// Emit a call to the memchr function. This assumes that Ptr is a pointer,
/// Val is an i32 value, and Len is an 'intptr_t' value.
Value *emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilderBase &B,
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h
index 520a4de374..52b14df3ed 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h
@@ -94,7 +94,7 @@ public:
/// If a new function was created by outlining, this method can be called
/// to update the call graph for the new function. Note that the old one
/// still needs to be re-analyzed or manually updated.
- void registerOutlinedFunction(Function &OriginalFn, Function &NewFn);
+ void registerOutlinedFunction(Function &OriginalFn, Function &NewFn);
/// Replace \p OldFn in the call graph (and SCC) with \p NewFn. The uses
/// outside the call graph and the function \p OldFn are not modified.
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h
index d15d6828ce..55e8d5d0b2 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h
@@ -275,49 +275,49 @@ void updateProfileCallee(
Function *Callee, int64_t entryDelta,
const ValueMap<const Value *, WeakTrackingVH> *VMap = nullptr);
-/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified
-/// basic blocks and extract their scope. These are candidates for duplication
-/// when cloning.
-void identifyNoAliasScopesToClone(
- ArrayRef<BasicBlock *> BBs, SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
-
-/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified
-/// instruction range and extract their scope. These are candidates for
-/// duplication when cloning.
-void identifyNoAliasScopesToClone(
- BasicBlock::iterator Start, BasicBlock::iterator End,
- SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
-
-/// Duplicate the specified list of noalias decl scopes.
-/// The 'Ext' string is added as an extension to the name.
-/// Afterwards, the ClonedScopes contains the mapping of the original scope
-/// MDNode onto the cloned scope.
-/// Be aware that the cloned scopes are still part of the original scope domain.
-void cloneNoAliasScopes(
- ArrayRef<MDNode *> NoAliasDeclScopes,
- DenseMap<MDNode *, MDNode *> &ClonedScopes,
- StringRef Ext, LLVMContext &Context);
-
-/// Adapt the metadata for the specified instruction according to the
-/// provided mapping. This is normally used after cloning an instruction, when
-/// some noalias scopes needed to be cloned.
-void adaptNoAliasScopes(
- llvm::Instruction *I, const DenseMap<MDNode *, MDNode *> &ClonedScopes,
- LLVMContext &Context);
-
-/// Clone the specified noalias decl scopes. Then adapt all instructions in the
-/// NewBlocks basicblocks to the cloned versions.
-/// 'Ext' will be added to the duplicate scope names.
-void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes,
- ArrayRef<BasicBlock *> NewBlocks,
- LLVMContext &Context, StringRef Ext);
-
-/// Clone the specified noalias decl scopes. Then adapt all instructions in the
-/// [IStart, IEnd] (IEnd included !) range to the cloned versions. 'Ext' will be
-/// added to the duplicate scope names.
-void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes,
- Instruction *IStart, Instruction *IEnd,
- LLVMContext &Context, StringRef Ext);
+/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified
+/// basic blocks and extract their scope. These are candidates for duplication
+/// when cloning.
+void identifyNoAliasScopesToClone(
+ ArrayRef<BasicBlock *> BBs, SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
+
+/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified
+/// instruction range and extract their scope. These are candidates for
+/// duplication when cloning.
+void identifyNoAliasScopesToClone(
+ BasicBlock::iterator Start, BasicBlock::iterator End,
+ SmallVectorImpl<MDNode *> &NoAliasDeclScopes);
+
+/// Duplicate the specified list of noalias decl scopes.
+/// The 'Ext' string is added as an extension to the name.
+/// Afterwards, the ClonedScopes contains the mapping of the original scope
+/// MDNode onto the cloned scope.
+/// Be aware that the cloned scopes are still part of the original scope domain.
+void cloneNoAliasScopes(
+ ArrayRef<MDNode *> NoAliasDeclScopes,
+ DenseMap<MDNode *, MDNode *> &ClonedScopes,
+ StringRef Ext, LLVMContext &Context);
+
+/// Adapt the metadata for the specified instruction according to the
+/// provided mapping. This is normally used after cloning an instruction, when
+/// some noalias scopes needed to be cloned.
+void adaptNoAliasScopes(
+ llvm::Instruction *I, const DenseMap<MDNode *, MDNode *> &ClonedScopes,
+ LLVMContext &Context);
+
+/// Clone the specified noalias decl scopes. Then adapt all instructions in the
+/// NewBlocks basicblocks to the cloned versions.
+/// 'Ext' will be added to the duplicate scope names.
+void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes,
+ ArrayRef<BasicBlock *> NewBlocks,
+ LLVMContext &Context, StringRef Ext);
+
+/// Clone the specified noalias decl scopes. Then adapt all instructions in the
+/// [IStart, IEnd] (IEnd included !) range to the cloned versions. 'Ext' will be
+/// added to the duplicate scope names.
+void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes,
+ Instruction *IStart, Instruction *IEnd,
+ LLVMContext &Context, StringRef Ext);
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_CLONING_H
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h
index c09449953d..7fc4011991 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h
@@ -20,11 +20,11 @@
#ifndef LLVM_TRANSFORM_UTILS_DEBUGIFY_H
#define LLVM_TRANSFORM_UTILS_DEBUGIFY_H
-#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Bitcode/BitcodeWriterPass.h"
-#include "llvm/IR/IRPrintingPasses.h"
-#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/Bitcode/BitcodeWriterPass.h"
+#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
@@ -82,8 +82,8 @@ struct DebugifyStatistics {
/// Map pass names to a per-pass DebugifyStatistics instance.
using DebugifyStatsMap = llvm::MapVector<llvm::StringRef, DebugifyStatistics>;
-void exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map);
-
+void exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map);
+
llvm::ModulePass *
createCheckDebugifyModulePass(bool Strip = false,
llvm::StringRef NameOfWrappedPass = "",
@@ -99,62 +99,62 @@ struct NewPMCheckDebugifyPass
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
};
-struct DebugifyEachInstrumentation {
- DebugifyStatsMap StatsMap;
-
- void registerCallbacks(PassInstrumentationCallbacks &PIC);
-};
-
-/// DebugifyCustomPassManager wraps each pass with the debugify passes if
-/// needed.
-/// NOTE: We support legacy custom pass manager only.
-/// TODO: Add New PM support for custom pass manager.
-class DebugifyCustomPassManager : public legacy::PassManager {
- DebugifyStatsMap DIStatsMap;
- bool EnableDebugifyEach = false;
-
-public:
- using super = legacy::PassManager;
-
- void add(Pass *P) override {
- // Wrap each pass with (-check)-debugify passes if requested, making
- // exceptions for passes which shouldn't see -debugify instrumentation.
- bool WrapWithDebugify = EnableDebugifyEach && !P->getAsImmutablePass() &&
- !isIRPrintingPass(P) && !isBitcodeWriterPass(P);
- if (!WrapWithDebugify) {
- super::add(P);
- return;
- }
-
- // Apply -debugify/-check-debugify before/after each pass and collect
- // debug info loss statistics.
- PassKind Kind = P->getPassKind();
- StringRef Name = P->getPassName();
-
- // TODO: Implement Debugify for LoopPass.
- switch (Kind) {
- case PT_Function:
- super::add(createDebugifyFunctionPass());
- super::add(P);
- super::add(createCheckDebugifyFunctionPass(true, Name, &DIStatsMap));
- break;
- case PT_Module:
- super::add(createDebugifyModulePass());
- super::add(P);
- super::add(createCheckDebugifyModulePass(true, Name, &DIStatsMap));
- break;
- default:
- super::add(P);
- break;
- }
- }
-
- void enableDebugifyEach() { EnableDebugifyEach = true; }
-
- const DebugifyStatsMap &getDebugifyStatsMap() const { return DIStatsMap; }
-};
-} // namespace llvm
-
+struct DebugifyEachInstrumentation {
+ DebugifyStatsMap StatsMap;
+
+ void registerCallbacks(PassInstrumentationCallbacks &PIC);
+};
+
+/// DebugifyCustomPassManager wraps each pass with the debugify passes if
+/// needed.
+/// NOTE: We support legacy custom pass manager only.
+/// TODO: Add New PM support for custom pass manager.
+class DebugifyCustomPassManager : public legacy::PassManager {
+ DebugifyStatsMap DIStatsMap;
+ bool EnableDebugifyEach = false;
+
+public:
+ using super = legacy::PassManager;
+
+ void add(Pass *P) override {
+ // Wrap each pass with (-check)-debugify passes if requested, making
+ // exceptions for passes which shouldn't see -debugify instrumentation.
+ bool WrapWithDebugify = EnableDebugifyEach && !P->getAsImmutablePass() &&
+ !isIRPrintingPass(P) && !isBitcodeWriterPass(P);
+ if (!WrapWithDebugify) {
+ super::add(P);
+ return;
+ }
+
+ // Apply -debugify/-check-debugify before/after each pass and collect
+ // debug info loss statistics.
+ PassKind Kind = P->getPassKind();
+ StringRef Name = P->getPassName();
+
+ // TODO: Implement Debugify for LoopPass.
+ switch (Kind) {
+ case PT_Function:
+ super::add(createDebugifyFunctionPass());
+ super::add(P);
+ super::add(createCheckDebugifyFunctionPass(true, Name, &DIStatsMap));
+ break;
+ case PT_Module:
+ super::add(createDebugifyModulePass());
+ super::add(P);
+ super::add(createCheckDebugifyModulePass(true, Name, &DIStatsMap));
+ break;
+ default:
+ super::add(P);
+ break;
+ }
+ }
+
+ void enableDebugifyEach() { EnableDebugifyEach = true; }
+
+ const DebugifyStatsMap &getDebugifyStatsMap() const { return DIStatsMap; }
+};
+} // namespace llvm
+
#endif // LLVM_TRANSFORM_UTILS_DEBUGIFY_H
#ifdef __GNUC__
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h
index cdd35469b1..6417ea5882 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h
@@ -1,31 +1,31 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- FixIrreducible.h - Convert irreducible control-flow into 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H
-#define LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-struct FixIrreduciblePass : PassInfoMixin<FixIrreduciblePass> {
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- FixIrreducible.h - Convert irreducible control-flow into 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H
+#define LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+struct FixIrreduciblePass : PassInfoMixin<FixIrreduciblePass> {
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h
index e755bf4087..c9ede371d9 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h
@@ -1,31 +1,31 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- InstructionNamer.h - Give anonymous instructions names -------------===//
-//
-// 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 LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H
-#define LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-struct InstructionNamerPass : PassInfoMixin<InstructionNamerPass> {
- PreservedAnalyses run(Function &, FunctionAnalysisManager &);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- InstructionNamer.h - Give anonymous instructions names -------------===//
+//
+// 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 LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H
+#define LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+struct InstructionNamerPass : PassInfoMixin<InstructionNamerPass> {
+ PreservedAnalyses run(Function &, FunctionAnalysisManager &);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h
index 40cf2cb596..9c76913256 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h
@@ -36,8 +36,8 @@
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
#include <cstdint>
#include <limits>
@@ -101,9 +101,9 @@ bool wouldInstructionBeTriviallyDead(Instruction *I,
/// recursively. Return true if any instructions were deleted.
bool RecursivelyDeleteTriviallyDeadInstructions(
Value *V, const TargetLibraryInfo *TLI = nullptr,
- MemorySSAUpdater *MSSAU = nullptr,
- std::function<void(Value *)> AboutToDeleteCallback =
- std::function<void(Value *)>());
+ MemorySSAUpdater *MSSAU = nullptr,
+ std::function<void(Value *)> AboutToDeleteCallback =
+ std::function<void(Value *)>());
/// Delete all of the instructions in `DeadInsts`, and all other instructions
/// that deleting these in turn causes to be trivially dead.
@@ -115,9 +115,9 @@ bool RecursivelyDeleteTriviallyDeadInstructions(
/// empty afterward.
void RecursivelyDeleteTriviallyDeadInstructions(
SmallVectorImpl<WeakTrackingVH> &DeadInsts,
- const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
- std::function<void(Value *)> AboutToDeleteCallback =
- std::function<void(Value *)>());
+ const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
+ std::function<void(Value *)> AboutToDeleteCallback =
+ std::function<void(Value *)>());
/// Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow
/// instructions that are not trivially dead. These will be ignored.
@@ -125,9 +125,9 @@ void RecursivelyDeleteTriviallyDeadInstructions(
/// were found and deleted.
bool RecursivelyDeleteTriviallyDeadInstructionsPermissive(
SmallVectorImpl<WeakTrackingVH> &DeadInsts,
- const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
- std::function<void(Value *)> AboutToDeleteCallback =
- std::function<void(Value *)>());
+ const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr,
+ std::function<void(Value *)> AboutToDeleteCallback =
+ std::function<void(Value *)>());
/// If the specified value is an effectively dead PHI node, due to being a
/// def-use chain of single-use nodes that either forms a cycle or is terminated
@@ -179,11 +179,11 @@ bool EliminateDuplicatePHINodes(BasicBlock *BB);
/// It returns true if a modification was made, possibly deleting the basic
/// block that was pointed to. LoopHeaders is an optional input parameter
/// providing the set of loop headers that SimplifyCFG should not eliminate.
-extern cl::opt<bool> RequireAndPreserveDomTree;
+extern cl::opt<bool> RequireAndPreserveDomTree;
bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
- DomTreeUpdater *DTU = nullptr,
+ DomTreeUpdater *DTU = nullptr,
const SimplifyCFGOptions &Options = {},
- ArrayRef<WeakVH> LoopHeaders = {});
+ ArrayRef<WeakVH> LoopHeaders = {});
/// This function is used to flatten a CFG. For example, it uses parallel-and
/// and parallel-or mode to collapse if-conditions and merge if-regions with
@@ -193,9 +193,9 @@ bool FlattenCFG(BasicBlock *BB, AAResults *AA = nullptr);
/// If this basic block is ONLY a setcc and a branch, and if a predecessor
/// branches to us and one of our successors, fold the setcc into the
/// predecessor and use logical operations to pick the right destination.
-bool FoldBranchToCommonDest(BranchInst *BI, llvm::DomTreeUpdater *DTU = nullptr,
- MemorySSAUpdater *MSSAU = nullptr,
- const TargetTransformInfo *TTI = nullptr,
+bool FoldBranchToCommonDest(BranchInst *BI, llvm::DomTreeUpdater *DTU = nullptr,
+ MemorySSAUpdater *MSSAU = nullptr,
+ const TargetTransformInfo *TTI = nullptr,
unsigned BonusInstThreshold = 1);
/// This function takes a virtual register computed by an Instruction and
@@ -339,13 +339,13 @@ DIExpression *salvageDebugInfoImpl(Instruction &I, DIExpression *DIExpr,
bool replaceAllDbgUsesWith(Instruction &From, Value &To, Instruction &DomPoint,
DominatorTree &DT);
-/// Remove all instructions from a basic block other than its terminator
-/// and any present EH pad instructions. Returns a pair where the first element
-/// is the number of instructions (excluding debug info instrinsics) that have
-/// been removed, and the second element is the number of debug info intrinsics
-/// that have been removed.
-std::pair<unsigned, unsigned>
-removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB);
+/// Remove all instructions from a basic block other than its terminator
+/// and any present EH pad instructions. Returns a pair where the first element
+/// is the number of instructions (excluding debug info instrinsics) that have
+/// been removed, and the second element is the number of debug info intrinsics
+/// that have been removed.
+std::pair<unsigned, unsigned>
+removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB);
/// Insert an unreachable instruction before the specified
/// instruction, making it and the rest of the code in the block dead.
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h
index 913345fe1e..df15ce4fca 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h
@@ -1,51 +1,51 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- llvm/Transforms/Utils/LoopPeel.h ----- Peeling utilities -*- 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 defines some loop peeling utilities. It does not define any
-// actual pass or policy.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
-#define LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
-
-#include "llvm/Analysis/TargetTransformInfo.h"
-
-namespace llvm {
-
-bool canPeel(Loop *L);
-
-bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE,
- DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA);
-
-TargetTransformInfo::PeelingPreferences
-gatherPeelingPreferences(Loop *L, ScalarEvolution &SE,
- const TargetTransformInfo &TTI,
- Optional<bool> UserAllowPeeling,
- Optional<bool> UserAllowProfileBasedPeeling,
- bool UnrollingSpecficValues = false);
-
-void computePeelCount(Loop *L, unsigned LoopSize,
- TargetTransformInfo::PeelingPreferences &PP,
- unsigned &TripCount, ScalarEvolution &SE,
- unsigned Threshold = UINT_MAX);
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- llvm/Transforms/Utils/LoopPeel.h ----- Peeling utilities -*- 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 defines some loop peeling utilities. It does not define any
+// actual pass or policy.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
+#define LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
+
+#include "llvm/Analysis/TargetTransformInfo.h"
+
+namespace llvm {
+
+bool canPeel(Loop *L);
+
+bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE,
+ DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA);
+
+TargetTransformInfo::PeelingPreferences
+gatherPeelingPreferences(Loop *L, ScalarEvolution &SE,
+ const TargetTransformInfo &TTI,
+ Optional<bool> UserAllowPeeling,
+ Optional<bool> UserAllowProfileBasedPeeling,
+ bool UnrollingSpecficValues = false);
+
+void computePeelCount(Loop *L, unsigned LoopSize,
+ TargetTransformInfo::PeelingPreferences &PP,
+ unsigned &TripCount, ScalarEvolution &SE,
+ unsigned Threshold = UINT_MAX);
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h
index b13b8c79b0..acfbf03d02 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h
@@ -40,8 +40,8 @@ class TargetTransformInfo;
bool LoopRotation(Loop *L, LoopInfo *LI, const TargetTransformInfo *TTI,
AssumptionCache *AC, DominatorTree *DT, ScalarEvolution *SE,
MemorySSAUpdater *MSSAU, const SimplifyQuery &SQ,
- bool RotationOnly, unsigned Threshold, bool IsUtilMode,
- bool PrepareForLTO = false);
+ bool RotationOnly, unsigned Threshold, bool IsUtilMode,
+ bool PrepareForLTO = false);
} // namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h
index f3d2d970b9..dc655420b5 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h
@@ -33,8 +33,8 @@ class AAResults;
class AliasSet;
class AliasSetTracker;
class BasicBlock;
-class BlockFrequencyInfo;
-class ICFLoopSafetyInfo;
+class BlockFrequencyInfo;
+class ICFLoopSafetyInfo;
class IRBuilderBase;
class Loop;
class LoopInfo;
@@ -82,14 +82,14 @@ bool formDedicatedExitBlocks(Loop *L, DominatorTree *DT, LoopInfo *LI,
/// changes to CFG, preserved.
///
/// Returns true if any modifications are made.
-///
-/// This function may introduce unused PHI nodes. If \p PHIsToRemove is not
-/// nullptr, those are added to it (before removing, the caller has to check if
-/// they still do not have any uses). Otherwise the PHIs are directly removed.
-bool formLCSSAForInstructions(
- SmallVectorImpl<Instruction *> &Worklist, const DominatorTree &DT,
- const LoopInfo &LI, ScalarEvolution *SE, IRBuilderBase &Builder,
- SmallVectorImpl<PHINode *> *PHIsToRemove = nullptr);
+///
+/// This function may introduce unused PHI nodes. If \p PHIsToRemove is not
+/// nullptr, those are added to it (before removing, the caller has to check if
+/// they still do not have any uses). Otherwise the PHIs are directly removed.
+bool formLCSSAForInstructions(
+ SmallVectorImpl<Instruction *> &Worklist, const DominatorTree &DT,
+ const LoopInfo &LI, ScalarEvolution *SE, IRBuilderBase &Builder,
+ SmallVectorImpl<PHINode *> *PHIsToRemove = nullptr);
/// Put loop into LCSSA form.
///
@@ -118,28 +118,28 @@ bool formLCSSA(Loop &L, const DominatorTree &DT, const LoopInfo *LI,
bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI,
ScalarEvolution *SE);
-/// Flags controlling how much is checked when sinking or hoisting
-/// instructions. The number of memory access in the loop (and whether there
-/// are too many) is determined in the constructors when using MemorySSA.
-class SinkAndHoistLICMFlags {
-public:
- // Explicitly set limits.
- SinkAndHoistLICMFlags(unsigned LicmMssaOptCap,
- unsigned LicmMssaNoAccForPromotionCap, bool IsSink,
- Loop *L = nullptr, MemorySSA *MSSA = nullptr);
- // Use default limits.
- SinkAndHoistLICMFlags(bool IsSink, Loop *L = nullptr,
- MemorySSA *MSSA = nullptr);
-
- void setIsSink(bool B) { IsSink = B; }
- bool getIsSink() { return IsSink; }
- bool tooManyMemoryAccesses() { return NoOfMemAccTooLarge; }
- bool tooManyClobberingCalls() { return LicmMssaOptCounter >= LicmMssaOptCap; }
- void incrementClobberingCalls() { ++LicmMssaOptCounter; }
-
-protected:
- bool NoOfMemAccTooLarge = false;
- unsigned LicmMssaOptCounter = 0;
+/// Flags controlling how much is checked when sinking or hoisting
+/// instructions. The number of memory access in the loop (and whether there
+/// are too many) is determined in the constructors when using MemorySSA.
+class SinkAndHoistLICMFlags {
+public:
+ // Explicitly set limits.
+ SinkAndHoistLICMFlags(unsigned LicmMssaOptCap,
+ unsigned LicmMssaNoAccForPromotionCap, bool IsSink,
+ Loop *L = nullptr, MemorySSA *MSSA = nullptr);
+ // Use default limits.
+ SinkAndHoistLICMFlags(bool IsSink, Loop *L = nullptr,
+ MemorySSA *MSSA = nullptr);
+
+ void setIsSink(bool B) { IsSink = B; }
+ bool getIsSink() { return IsSink; }
+ bool tooManyMemoryAccesses() { return NoOfMemAccTooLarge; }
+ bool tooManyClobberingCalls() { return LicmMssaOptCounter >= LicmMssaOptCap; }
+ void incrementClobberingCalls() { ++LicmMssaOptCounter; }
+
+protected:
+ bool NoOfMemAccTooLarge = false;
+ unsigned LicmMssaOptCounter = 0;
unsigned LicmMssaOptCap;
unsigned LicmMssaNoAccForPromotionCap;
bool IsSink;
@@ -150,13 +150,13 @@ protected:
/// reverse depth first order w.r.t the DominatorTree. This allows us to visit
/// uses before definitions, allowing us to sink a loop body in one pass without
/// iteration. Takes DomTreeNode, AAResults, LoopInfo, DominatorTree,
-/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all
+/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all
/// instructions of the loop and loop safety information as
/// arguments. Diagnostics is emitted via \p ORE. It returns changed status.
bool sinkRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *,
- BlockFrequencyInfo *, TargetLibraryInfo *,
- TargetTransformInfo *, Loop *, AliasSetTracker *,
- MemorySSAUpdater *, ICFLoopSafetyInfo *,
+ BlockFrequencyInfo *, TargetLibraryInfo *,
+ TargetTransformInfo *, Loop *, AliasSetTracker *,
+ MemorySSAUpdater *, ICFLoopSafetyInfo *,
SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *);
/// Walk the specified region of the CFG (defined by all blocks
@@ -164,14 +164,14 @@ bool sinkRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *,
/// first order w.r.t the DominatorTree. This allows us to visit definitions
/// before uses, allowing us to hoist a loop body in one pass without iteration.
/// Takes DomTreeNode, AAResults, LoopInfo, DominatorTree,
-/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all
-/// instructions of the loop and loop safety information as arguments.
-/// Diagnostics is emitted via \p ORE. It returns changed status.
+/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all
+/// instructions of the loop and loop safety information as arguments.
+/// Diagnostics is emitted via \p ORE. It returns changed status.
bool hoistRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *,
- BlockFrequencyInfo *, TargetLibraryInfo *, Loop *,
- AliasSetTracker *, MemorySSAUpdater *, ScalarEvolution *,
- ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &,
- OptimizationRemarkEmitter *);
+ BlockFrequencyInfo *, TargetLibraryInfo *, Loop *,
+ AliasSetTracker *, MemorySSAUpdater *, ScalarEvolution *,
+ ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &,
+ OptimizationRemarkEmitter *);
/// This function deletes dead loops. The caller of this function needs to
/// guarantee that the loop is infact dead.
@@ -187,12 +187,12 @@ bool hoistRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *,
void deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
LoopInfo *LI, MemorySSA *MSSA = nullptr);
-/// Remove the backedge of the specified loop. Handles loop nests and general
-/// loop structures subject to the precondition that the loop has no parent
-/// loop and has a single latch block. Preserves all listed analyses.
-void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
- LoopInfo &LI, MemorySSA *MSSA);
-
+/// Remove the backedge of the specified loop. Handles loop nests and general
+/// loop structures subject to the precondition that the loop has no parent
+/// loop and has a single latch block. Preserves all listed analyses.
+void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
+ LoopInfo &LI, MemorySSA *MSSA);
+
/// Try to promote memory values to scalars by sinking stores out of
/// the loop and moving loads to before the loop. We do this by looping over
/// the stores in the loop, looking for stores to Must pointers which are
@@ -227,13 +227,13 @@ Optional<const MDOperand *> findStringMetadataForLoop(const Loop *TheLoop,
/// Find named metadata for a loop with an integer value.
llvm::Optional<int> getOptionalIntLoopAttribute(Loop *TheLoop, StringRef Name);
-/// Find a combination of metadata ("llvm.loop.vectorize.width" and
-/// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a
-/// ElementCount. If the metadata "llvm.loop.vectorize.width" cannot be found
-/// then None is returned.
-Optional<ElementCount>
-getOptionalElementCountLoopAttribute(Loop *TheLoop);
-
+/// Find a combination of metadata ("llvm.loop.vectorize.width" and
+/// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a
+/// ElementCount. If the metadata "llvm.loop.vectorize.width" cannot be found
+/// then None is returned.
+Optional<ElementCount>
+getOptionalElementCountLoopAttribute(Loop *TheLoop);
+
/// Create a new loop identifier for a loop created from a loop transformation.
///
/// @param OrigLoopID The loop ID of the loop before the transformation.
@@ -269,9 +269,9 @@ bool hasDisableAllTransformsHint(const Loop *L);
/// Look for the loop attribute that disables the LICM transformation heuristics.
bool hasDisableLICMTransformsHint(const Loop *L);
-/// Look for the loop attribute that requires progress within the loop.
-bool hasMustProgress(const Loop *L);
-
+/// Look for the loop attribute that requires progress within the loop.
+bool hasMustProgress(const Loop *L);
+
/// The mode sets how eager a transformation should be applied.
enum TransformationMode {
/// The pass can use heuristics to determine whether a transformation should
@@ -314,9 +314,9 @@ TransformationMode hasLICMVersioningTransformation(Loop *L);
void addStringMetadataToLoop(Loop *TheLoop, const char *MDString,
unsigned V = 0);
-/// Returns true if Name is applied to TheLoop and enabled.
-bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name);
-
+/// Returns true if Name is applied to TheLoop and enabled.
+bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name);
+
/// Returns a loop's estimated trip count based on branch weight metadata.
/// In addition if \p EstimatedLoopInvocationWeight is not null it is
/// initialized with weight of loop's latch leading to the exit.
@@ -362,29 +362,29 @@ bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
OptimizationRemarkEmitter *ORE = nullptr);
/// Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
-Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
- Value *Right);
+Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
+ Value *Right);
/// Generates an ordered vector reduction using extracts to reduce the value.
-Value *getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src,
- unsigned Op, RecurKind MinMaxKind = RecurKind::None,
- ArrayRef<Value *> RedOps = None);
+Value *getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src,
+ unsigned Op, RecurKind MinMaxKind = RecurKind::None,
+ ArrayRef<Value *> RedOps = None);
/// Generates a vector reduction using shufflevectors to reduce the value.
/// Fast-math-flags are propagated using the IRBuilder's setting.
Value *getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op,
- RecurKind MinMaxKind = RecurKind::None,
+ RecurKind MinMaxKind = RecurKind::None,
ArrayRef<Value *> RedOps = None);
/// Create a target reduction of the given vector. The reduction operation
/// is described by the \p Opcode parameter. min/max reductions require
-/// additional information supplied in \p RdxKind.
+/// additional information supplied in \p RdxKind.
/// The target is queried to determine if intrinsics or shuffle sequences are
/// required to implement the reduction.
/// Fast-math-flags are propagated using the IRBuilder's setting.
Value *createSimpleTargetReduction(IRBuilderBase &B,
- const TargetTransformInfo *TTI, Value *Src,
- RecurKind RdxKind,
+ const TargetTransformInfo *TTI, Value *Src,
+ RecurKind RdxKind,
ArrayRef<Value *> RedOps = None);
/// Create a generic target reduction using a recurrence descriptor \p Desc
@@ -392,7 +392,7 @@ Value *createSimpleTargetReduction(IRBuilderBase &B,
/// required to implement the reduction.
/// Fast-math-flags are propagated using the RecurrenceDescriptor.
Value *createTargetReduction(IRBuilderBase &B, const TargetTransformInfo *TTI,
- RecurrenceDescriptor &Desc, Value *Src);
+ RecurrenceDescriptor &Desc, Value *Src);
/// Get the intersection (logical and) of all of the potential IR flags
/// of each scalar operation (VL) that will be converted into a vector (I).
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h
index fb33ce142b..dd7394a3f0 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h
@@ -23,7 +23,7 @@
#define LLVM_TRANSFORMS_UTILS_LOOPVERSIONING_H
#include "llvm/Analysis/ScalarEvolution.h"
-#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
@@ -50,9 +50,9 @@ public:
/// It uses runtime check provided by the user. If \p UseLAIChecks is true,
/// we will retain the default checks made by LAI. Otherwise, construct an
/// object having no checks and we expect the user to add them.
- LoopVersioning(const LoopAccessInfo &LAI,
- ArrayRef<RuntimePointerCheck> Checks, Loop *L, LoopInfo *LI,
- DominatorTree *DT, ScalarEvolution *SE);
+ LoopVersioning(const LoopAccessInfo &LAI,
+ ArrayRef<RuntimePointerCheck> Checks, Loop *L, LoopInfo *LI,
+ DominatorTree *DT, ScalarEvolution *SE);
/// Performs the CFG manipulation part of versioning the loop including
/// the DominatorTree and LoopInfo updates.
@@ -130,7 +130,7 @@ private:
SmallVector<RuntimePointerCheck, 4> AliasChecks;
/// The set of SCEV checks that we are versioning for.
- const SCEVUnionPredicate &Preds;
+ const SCEVUnionPredicate &Preds;
/// Maps a pointer to the pointer checking group that the pointer
/// belongs to.
@@ -149,14 +149,14 @@ private:
DominatorTree *DT;
ScalarEvolution *SE;
};
-
-/// Expose LoopVersioning as a pass. Currently this is only used for
-/// unit-testing. It adds all memchecks necessary to remove all may-aliasing
-/// array accesses from the loop.
-class LoopVersioningPass : public PassInfoMixin<LoopVersioningPass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
-};
+
+/// Expose LoopVersioning as a pass. Currently this is only used for
+/// unit-testing. It adds all memchecks necessary to remove all may-aliasing
+/// array accesses from the loop.
+class LoopVersioningPass : public PassInfoMixin<LoopVersioningPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
+};
}
#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h
index 5a801fc704..1d177dd618 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h
@@ -1,37 +1,37 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- LowerSwitch.h - Eliminate Switch instructions ----------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// The LowerSwitch transformation rewrites switch instructions with a sequence
-// of branches, which allows targets to get away with not implementing the
-// switch instruction until it is convenient.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H
-#define LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-struct LowerSwitchPass : public PassInfoMixin<LowerSwitchPass> {
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- LowerSwitch.h - Eliminate Switch instructions ----------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// The LowerSwitch transformation rewrites switch instructions with a sequence
+// of branches, which allows targets to get away with not implementing the
+// switch instruction until it is convenient.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H
+#define LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+struct LowerSwitchPass : public PassInfoMixin<LowerSwitchPass> {
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h
index 8606974e57..948e51e22b 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h
@@ -1,105 +1,105 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- MatrixUtils.h - Utilities to lower matrix intrinsics -----*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-// Utilities for generating tiled loops for matrix operations.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H
-#define LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H
-
-#include "llvm/ADT/StringRef.h"
-
-namespace llvm {
-class DomTreeUpdater;
-class BasicBlock;
-class Value;
-class Loop;
-class LoopInfo;
-class IRBuilderBase;
-
-/// A helper struct to create IR loop nests for tiling in IR of the following
-/// form:
-/// for CurrentColumn = 0..NumColumns
-/// for CurrentRow = 0..NumRows
-/// for CurrentInner = 0..NumInner
-struct TileInfo {
- /// Number of rows of the matrix.
- unsigned NumRows;
-
- /// Number of columns of the matrix.
- unsigned NumColumns;
-
- /// Number of columns of the first matrix of a multiply /
- /// number of rows of the second matrix of a multiply.
- unsigned NumInner;
-
- /// Number of rows/columns in a tile.
- unsigned TileSize = -1;
-
- /// Start row of the current tile to compute.
- Value *CurrentRow;
-
- /// Start column of the current tile to compute.
- Value *CurrentCol;
-
- /// Current tile offset during the tile computation.
- Value *CurrentK;
-
- /// Header of the outermost loop iterating from 0..NumColumns.
- BasicBlock *ColumnLoopHeader = nullptr;
-
- /// Header of the second loop iterating from 0..NumRows.
- BasicBlock *RowLoopHeader = nullptr;
- /// Latch of the second loop iterating from 0..NumRows.
- BasicBlock *RowLoopLatch = nullptr;
- /// Header of the innermost loop iterating from 0..NumInner.
- BasicBlock *InnerLoopHeader = nullptr;
- /// Latch of the innermost loop iterating from 0..NumInner.
- BasicBlock *InnerLoopLatch = nullptr;
-
- TileInfo(unsigned NumRows, unsigned NumColumns, unsigned NumInner,
- unsigned TileSize)
- : NumRows(NumRows), NumColumns(NumColumns), NumInner(NumInner),
- TileSize(TileSize) {}
-
- /// Creates an IR loop nests for tiling of the form below. Returns the block
- /// for the inner loop body and sets {Column,Row,Inner}LoopHeader/Latch
- /// fields.
- ///
- /// for CurrentColumn = 0..NumColumns
- /// for CurrentRow = 0..NumRows
- /// for CurrentInner = 0..NumInner
- BasicBlock *CreateTiledLoops(BasicBlock *Start, BasicBlock *End,
- IRBuilderBase &B, DomTreeUpdater &DTU,
- LoopInfo &LI);
-
-private:
- /// Creates a new loop with header, body and latch blocks that iterates from
- /// [0, Bound). Updates \p Preheader to branch to the new header and uses \p
- /// Exit as exit block. Adds the new loop blocks to \L and applies dominator
- /// tree updates to \p DTU.
- static BasicBlock *CreateLoop(BasicBlock *Preheader, BasicBlock *Exit,
- Value *Bound, Value *Step, StringRef Name,
- IRBuilderBase &B, DomTreeUpdater &DTU, Loop *L,
- LoopInfo &LI);
-};
-} // namespace llvm
-
-#endif
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- MatrixUtils.h - Utilities to lower matrix intrinsics -----*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Utilities for generating tiled loops for matrix operations.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H
+#define LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H
+
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+class DomTreeUpdater;
+class BasicBlock;
+class Value;
+class Loop;
+class LoopInfo;
+class IRBuilderBase;
+
+/// A helper struct to create IR loop nests for tiling in IR of the following
+/// form:
+/// for CurrentColumn = 0..NumColumns
+/// for CurrentRow = 0..NumRows
+/// for CurrentInner = 0..NumInner
+struct TileInfo {
+ /// Number of rows of the matrix.
+ unsigned NumRows;
+
+ /// Number of columns of the matrix.
+ unsigned NumColumns;
+
+ /// Number of columns of the first matrix of a multiply /
+ /// number of rows of the second matrix of a multiply.
+ unsigned NumInner;
+
+ /// Number of rows/columns in a tile.
+ unsigned TileSize = -1;
+
+ /// Start row of the current tile to compute.
+ Value *CurrentRow;
+
+ /// Start column of the current tile to compute.
+ Value *CurrentCol;
+
+ /// Current tile offset during the tile computation.
+ Value *CurrentK;
+
+ /// Header of the outermost loop iterating from 0..NumColumns.
+ BasicBlock *ColumnLoopHeader = nullptr;
+
+ /// Header of the second loop iterating from 0..NumRows.
+ BasicBlock *RowLoopHeader = nullptr;
+ /// Latch of the second loop iterating from 0..NumRows.
+ BasicBlock *RowLoopLatch = nullptr;
+ /// Header of the innermost loop iterating from 0..NumInner.
+ BasicBlock *InnerLoopHeader = nullptr;
+ /// Latch of the innermost loop iterating from 0..NumInner.
+ BasicBlock *InnerLoopLatch = nullptr;
+
+ TileInfo(unsigned NumRows, unsigned NumColumns, unsigned NumInner,
+ unsigned TileSize)
+ : NumRows(NumRows), NumColumns(NumColumns), NumInner(NumInner),
+ TileSize(TileSize) {}
+
+ /// Creates an IR loop nests for tiling of the form below. Returns the block
+ /// for the inner loop body and sets {Column,Row,Inner}LoopHeader/Latch
+ /// fields.
+ ///
+ /// for CurrentColumn = 0..NumColumns
+ /// for CurrentRow = 0..NumRows
+ /// for CurrentInner = 0..NumInner
+ BasicBlock *CreateTiledLoops(BasicBlock *Start, BasicBlock *End,
+ IRBuilderBase &B, DomTreeUpdater &DTU,
+ LoopInfo &LI);
+
+private:
+ /// Creates a new loop with header, body and latch blocks that iterates from
+ /// [0, Bound). Updates \p Preheader to branch to the new header and uses \p
+ /// Exit as exit block. Adds the new loop blocks to \L and applies dominator
+ /// tree updates to \p DTU.
+ static BasicBlock *CreateLoop(BasicBlock *Preheader, BasicBlock *Exit,
+ Value *Bound, Value *Step, StringRef Name,
+ IRBuilderBase &B, DomTreeUpdater &DTU, Loop *L,
+ LoopInfo &LI);
+};
+} // namespace llvm
+
+#endif
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h
index 1e90f7590f..f7aab0a1c5 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h
@@ -1,37 +1,37 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- MetaRenamer.h - Rename everything with metasyntatic names ----------===//
-//
-// 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 pass renames everything with metasyntatic names. The intent is to use
-// this pass after bugpoint reduction to conceal the nature of the original
-// program.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_UTILS_METARENAMER_H
-#define LLVM_TRANSFORMS_UTILS_METARENAMER_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-struct MetaRenamerPass : PassInfoMixin<MetaRenamerPass> {
- PreservedAnalyses run(Module &, ModuleAnalysisManager &);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_METARENAMER_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- MetaRenamer.h - Rename everything with metasyntatic names ----------===//
+//
+// 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 pass renames everything with metasyntatic names. The intent is to use
+// this pass after bugpoint reduction to conceal the nature of the original
+// program.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_METARENAMER_H
+#define LLVM_TRANSFORMS_UTILS_METARENAMER_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+struct MetaRenamerPass : PassInfoMixin<MetaRenamerPass> {
+ PreservedAnalyses run(Module &, ModuleAnalysisManager &);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_METARENAMER_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h
index 628696ecb0..ced45bb3bd 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h
@@ -77,13 +77,13 @@ class raw_ostream;
enum PredicateType { PT_Branch, PT_Assume, PT_Switch };
-/// Constraint for a predicate of the form "cmp Pred Op, OtherOp", where Op
-/// is the value the constraint applies to (the ssa.copy result).
-struct PredicateConstraint {
- CmpInst::Predicate Predicate;
- Value *OtherOp;
-};
-
+/// Constraint for a predicate of the form "cmp Pred Op, OtherOp", where Op
+/// is the value the constraint applies to (the ssa.copy result).
+struct PredicateConstraint {
+ CmpInst::Predicate Predicate;
+ Value *OtherOp;
+};
+
// Base class for all predicate information we provide.
// All of our predicate information has at least a comparison.
class PredicateBase : public ilist_node<PredicateBase> {
@@ -97,9 +97,9 @@ public:
// predicates, this is different to OriginalOp which refers to the initial
// operand.
Value *RenamedOp;
- // The condition associated with this predicate.
- Value *Condition;
-
+ // The condition associated with this predicate.
+ Value *Condition;
+
PredicateBase(const PredicateBase &) = delete;
PredicateBase &operator=(const PredicateBase &) = delete;
PredicateBase() = delete;
@@ -109,22 +109,22 @@ public:
PB->Type == PT_Switch;
}
- /// Fetch condition in the form of PredicateConstraint, if possible.
- Optional<PredicateConstraint> getConstraint() const;
-
+ /// Fetch condition in the form of PredicateConstraint, if possible.
+ Optional<PredicateConstraint> getConstraint() const;
+
protected:
- PredicateBase(PredicateType PT, Value *Op, Value *Condition)
- : Type(PT), OriginalOp(Op), Condition(Condition) {}
+ PredicateBase(PredicateType PT, Value *Op, Value *Condition)
+ : Type(PT), OriginalOp(Op), Condition(Condition) {}
};
// Provides predicate information for assumes. Since assumes are always true,
// we simply provide the assume instruction, so you can tell your relative
// position to it.
-class PredicateAssume : public PredicateBase {
+class PredicateAssume : public PredicateBase {
public:
IntrinsicInst *AssumeInst;
PredicateAssume(Value *Op, IntrinsicInst *AssumeInst, Value *Condition)
- : PredicateBase(PT_Assume, Op, Condition), AssumeInst(AssumeInst) {}
+ : PredicateBase(PT_Assume, Op, Condition), AssumeInst(AssumeInst) {}
PredicateAssume() = delete;
static bool classof(const PredicateBase *PB) {
return PB->Type == PT_Assume;
@@ -134,7 +134,7 @@ public:
// Mixin class for edge predicates. The FROM block is the block where the
// predicate originates, and the TO block is the block where the predicate is
// valid.
-class PredicateWithEdge : public PredicateBase {
+class PredicateWithEdge : public PredicateBase {
public:
BasicBlock *From;
BasicBlock *To;
@@ -146,7 +146,7 @@ public:
protected:
PredicateWithEdge(PredicateType PType, Value *Op, BasicBlock *From,
BasicBlock *To, Value *Cond)
- : PredicateBase(PType, Op, Cond), From(From), To(To) {}
+ : PredicateBase(PType, Op, Cond), From(From), To(To) {}
};
// Provides predicate information for branches.
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
index d1f41d91a0..02e8cf94ba 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
@@ -33,488 +33,488 @@
#include "llvm/Support/CommandLine.h"
namespace llvm {
-extern cl::opt<unsigned> SCEVCheapExpansionBudget;
-
-/// Return true if the given expression is safe to expand in the sense that
-/// all materialized values are safe to speculate anywhere their operands are
-/// defined.
-bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE);
-
-/// Return true if the given expression is safe to expand in the sense that
-/// all materialized values are defined and safe to speculate at the specified
-/// location and their operands are defined at this location.
-bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint,
- ScalarEvolution &SE);
-
-/// struct for holding enough information to help calculate the cost of the
-/// given SCEV when expanded into IR.
-struct SCEVOperand {
- explicit SCEVOperand(unsigned Opc, int Idx, const SCEV *S) :
- ParentOpcode(Opc), OperandIdx(Idx), S(S) { }
- /// LLVM instruction opcode that uses the operand.
- unsigned ParentOpcode;
- /// The use index of an expanded instruction.
- int OperandIdx;
- /// The SCEV operand to be costed.
- const SCEV* S;
-};
-
-/// This class uses information about analyze scalars to rewrite expressions
-/// in canonical form.
-///
-/// Clients should create an instance of this class when rewriting is needed,
-/// and destroy it when finished to allow the release of the associated
-/// memory.
-class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
- ScalarEvolution &SE;
- const DataLayout &DL;
-
- // New instructions receive a name to identify them with the current pass.
- const char *IVName;
-
- /// Indicates whether LCSSA phis should be created for inserted values.
- bool PreserveLCSSA;
-
- // InsertedExpressions caches Values for reuse, so must track RAUW.
- DenseMap<std::pair<const SCEV *, Instruction *>, TrackingVH<Value>>
- InsertedExpressions;
-
- // InsertedValues only flags inserted instructions so needs no RAUW.
- DenseSet<AssertingVH<Value>> InsertedValues;
- DenseSet<AssertingVH<Value>> InsertedPostIncValues;
-
- /// Keep track of the existing IR values re-used during expansion.
- /// FIXME: Ideally re-used instructions would not be added to
- /// InsertedValues/InsertedPostIncValues.
- SmallPtrSet<Value *, 16> ReusedValues;
-
- /// A memoization of the "relevant" loop for a given SCEV.
- DenseMap<const SCEV *, const Loop *> RelevantLoops;
-
- /// Addrecs referring to any of the given loops are expanded in post-inc
- /// mode. For example, expanding {1,+,1}<L> in post-inc mode returns the add
- /// instruction that adds one to the phi for {0,+,1}<L>, as opposed to a new
- /// phi starting at 1. This is only supported in non-canonical mode.
- PostIncLoopSet PostIncLoops;
-
- /// When this is non-null, addrecs expanded in the loop it indicates should
- /// be inserted with increments at IVIncInsertPos.
- const Loop *IVIncInsertLoop;
-
- /// When expanding addrecs in the IVIncInsertLoop loop, insert the IV
- /// increment at this position.
- Instruction *IVIncInsertPos;
-
- /// Phis that complete an IV chain. Reuse
- DenseSet<AssertingVH<PHINode>> ChainedPhis;
-
- /// When true, SCEVExpander tries to expand expressions in "canonical" form.
- /// When false, expressions are expanded in a more literal form.
- ///
- /// In "canonical" form addrecs are expanded as arithmetic based on a
- /// canonical induction variable. Note that CanonicalMode doesn't guarantee
- /// that all expressions are expanded in "canonical" form. For some
- /// expressions literal mode can be preferred.
- bool CanonicalMode;
-
- /// When invoked from LSR, the expander is in "strength reduction" mode. The
- /// only difference is that phi's are only reused if they are already in
- /// "expanded" form.
- bool LSRMode;
-
- typedef IRBuilder<TargetFolder, IRBuilderCallbackInserter> BuilderType;
- BuilderType Builder;
-
- // RAII object that stores the current insertion point and restores it when
- // the object is destroyed. This includes the debug location. Duplicated
- // from InsertPointGuard to add SetInsertPoint() which is used to updated
- // InsertPointGuards stack when insert points are moved during SCEV
- // expansion.
- class SCEVInsertPointGuard {
- IRBuilderBase &Builder;
- AssertingVH<BasicBlock> Block;
- BasicBlock::iterator Point;
- DebugLoc DbgLoc;
- SCEVExpander *SE;
-
- SCEVInsertPointGuard(const SCEVInsertPointGuard &) = delete;
- SCEVInsertPointGuard &operator=(const SCEVInsertPointGuard &) = delete;
-
- public:
- SCEVInsertPointGuard(IRBuilderBase &B, SCEVExpander *SE)
- : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
- DbgLoc(B.getCurrentDebugLocation()), SE(SE) {
- SE->InsertPointGuards.push_back(this);
- }
-
- ~SCEVInsertPointGuard() {
- // These guards should always created/destroyed in FIFO order since they
- // are used to guard lexically scoped blocks of code in
- // ScalarEvolutionExpander.
- assert(SE->InsertPointGuards.back() == this);
- SE->InsertPointGuards.pop_back();
- Builder.restoreIP(IRBuilderBase::InsertPoint(Block, Point));
- Builder.SetCurrentDebugLocation(DbgLoc);
- }
-
- BasicBlock::iterator GetInsertPoint() const { return Point; }
- void SetInsertPoint(BasicBlock::iterator I) { Point = I; }
- };
-
- /// Stack of pointers to saved insert points, used to keep insert points
- /// consistent when instructions are moved.
- SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards;
-
+extern cl::opt<unsigned> SCEVCheapExpansionBudget;
+
+/// Return true if the given expression is safe to expand in the sense that
+/// all materialized values are safe to speculate anywhere their operands are
+/// defined.
+bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE);
+
+/// Return true if the given expression is safe to expand in the sense that
+/// all materialized values are defined and safe to speculate at the specified
+/// location and their operands are defined at this location.
+bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint,
+ ScalarEvolution &SE);
+
+/// struct for holding enough information to help calculate the cost of the
+/// given SCEV when expanded into IR.
+struct SCEVOperand {
+ explicit SCEVOperand(unsigned Opc, int Idx, const SCEV *S) :
+ ParentOpcode(Opc), OperandIdx(Idx), S(S) { }
+ /// LLVM instruction opcode that uses the operand.
+ unsigned ParentOpcode;
+ /// The use index of an expanded instruction.
+ int OperandIdx;
+ /// The SCEV operand to be costed.
+ const SCEV* S;
+};
+
+/// This class uses information about analyze scalars to rewrite expressions
+/// in canonical form.
+///
+/// Clients should create an instance of this class when rewriting is needed,
+/// and destroy it when finished to allow the release of the associated
+/// memory.
+class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
+ ScalarEvolution &SE;
+ const DataLayout &DL;
+
+ // New instructions receive a name to identify them with the current pass.
+ const char *IVName;
+
+ /// Indicates whether LCSSA phis should be created for inserted values.
+ bool PreserveLCSSA;
+
+ // InsertedExpressions caches Values for reuse, so must track RAUW.
+ DenseMap<std::pair<const SCEV *, Instruction *>, TrackingVH<Value>>
+ InsertedExpressions;
+
+ // InsertedValues only flags inserted instructions so needs no RAUW.
+ DenseSet<AssertingVH<Value>> InsertedValues;
+ DenseSet<AssertingVH<Value>> InsertedPostIncValues;
+
+ /// Keep track of the existing IR values re-used during expansion.
+ /// FIXME: Ideally re-used instructions would not be added to
+ /// InsertedValues/InsertedPostIncValues.
+ SmallPtrSet<Value *, 16> ReusedValues;
+
+ /// A memoization of the "relevant" loop for a given SCEV.
+ DenseMap<const SCEV *, const Loop *> RelevantLoops;
+
+ /// Addrecs referring to any of the given loops are expanded in post-inc
+ /// mode. For example, expanding {1,+,1}<L> in post-inc mode returns the add
+ /// instruction that adds one to the phi for {0,+,1}<L>, as opposed to a new
+ /// phi starting at 1. This is only supported in non-canonical mode.
+ PostIncLoopSet PostIncLoops;
+
+ /// When this is non-null, addrecs expanded in the loop it indicates should
+ /// be inserted with increments at IVIncInsertPos.
+ const Loop *IVIncInsertLoop;
+
+ /// When expanding addrecs in the IVIncInsertLoop loop, insert the IV
+ /// increment at this position.
+ Instruction *IVIncInsertPos;
+
+ /// Phis that complete an IV chain. Reuse
+ DenseSet<AssertingVH<PHINode>> ChainedPhis;
+
+ /// When true, SCEVExpander tries to expand expressions in "canonical" form.
+ /// When false, expressions are expanded in a more literal form.
+ ///
+ /// In "canonical" form addrecs are expanded as arithmetic based on a
+ /// canonical induction variable. Note that CanonicalMode doesn't guarantee
+ /// that all expressions are expanded in "canonical" form. For some
+ /// expressions literal mode can be preferred.
+ bool CanonicalMode;
+
+ /// When invoked from LSR, the expander is in "strength reduction" mode. The
+ /// only difference is that phi's are only reused if they are already in
+ /// "expanded" form.
+ bool LSRMode;
+
+ typedef IRBuilder<TargetFolder, IRBuilderCallbackInserter> BuilderType;
+ BuilderType Builder;
+
+ // RAII object that stores the current insertion point and restores it when
+ // the object is destroyed. This includes the debug location. Duplicated
+ // from InsertPointGuard to add SetInsertPoint() which is used to updated
+ // InsertPointGuards stack when insert points are moved during SCEV
+ // expansion.
+ class SCEVInsertPointGuard {
+ IRBuilderBase &Builder;
+ AssertingVH<BasicBlock> Block;
+ BasicBlock::iterator Point;
+ DebugLoc DbgLoc;
+ SCEVExpander *SE;
+
+ SCEVInsertPointGuard(const SCEVInsertPointGuard &) = delete;
+ SCEVInsertPointGuard &operator=(const SCEVInsertPointGuard &) = delete;
+
+ public:
+ SCEVInsertPointGuard(IRBuilderBase &B, SCEVExpander *SE)
+ : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
+ DbgLoc(B.getCurrentDebugLocation()), SE(SE) {
+ SE->InsertPointGuards.push_back(this);
+ }
+
+ ~SCEVInsertPointGuard() {
+ // These guards should always created/destroyed in FIFO order since they
+ // are used to guard lexically scoped blocks of code in
+ // ScalarEvolutionExpander.
+ assert(SE->InsertPointGuards.back() == this);
+ SE->InsertPointGuards.pop_back();
+ Builder.restoreIP(IRBuilderBase::InsertPoint(Block, Point));
+ Builder.SetCurrentDebugLocation(DbgLoc);
+ }
+
+ BasicBlock::iterator GetInsertPoint() const { return Point; }
+ void SetInsertPoint(BasicBlock::iterator I) { Point = I; }
+ };
+
+ /// Stack of pointers to saved insert points, used to keep insert points
+ /// consistent when instructions are moved.
+ SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards;
+
#ifndef NDEBUG
- const char *DebugType;
+ const char *DebugType;
#endif
- friend struct SCEVVisitor<SCEVExpander, Value *>;
-
-public:
- /// Construct a SCEVExpander in "canonical" mode.
- explicit SCEVExpander(ScalarEvolution &se, const DataLayout &DL,
- const char *name, bool PreserveLCSSA = true)
- : SE(se), DL(DL), IVName(name), PreserveLCSSA(PreserveLCSSA),
- IVIncInsertLoop(nullptr), IVIncInsertPos(nullptr), CanonicalMode(true),
- LSRMode(false),
- Builder(se.getContext(), TargetFolder(DL),
- IRBuilderCallbackInserter(
- [this](Instruction *I) { rememberInstruction(I); })) {
+ friend struct SCEVVisitor<SCEVExpander, Value *>;
+
+public:
+ /// Construct a SCEVExpander in "canonical" mode.
+ explicit SCEVExpander(ScalarEvolution &se, const DataLayout &DL,
+ const char *name, bool PreserveLCSSA = true)
+ : SE(se), DL(DL), IVName(name), PreserveLCSSA(PreserveLCSSA),
+ IVIncInsertLoop(nullptr), IVIncInsertPos(nullptr), CanonicalMode(true),
+ LSRMode(false),
+ Builder(se.getContext(), TargetFolder(DL),
+ IRBuilderCallbackInserter(
+ [this](Instruction *I) { rememberInstruction(I); })) {
#ifndef NDEBUG
- DebugType = "";
+ DebugType = "";
#endif
- }
+ }
- ~SCEVExpander() {
- // Make sure the insert point guard stack is consistent.
- assert(InsertPointGuards.empty());
- }
+ ~SCEVExpander() {
+ // Make sure the insert point guard stack is consistent.
+ assert(InsertPointGuards.empty());
+ }
#ifndef NDEBUG
- void setDebugType(const char *s) { DebugType = s; }
+ void setDebugType(const char *s) { DebugType = s; }
#endif
- /// Erase the contents of the InsertedExpressions map so that users trying
- /// to expand the same expression into multiple BasicBlocks or different
- /// places within the same BasicBlock can do so.
- void clear() {
- InsertedExpressions.clear();
- InsertedValues.clear();
- InsertedPostIncValues.clear();
- ReusedValues.clear();
- ChainedPhis.clear();
- }
-
- /// Return a vector containing all instructions inserted during expansion.
- SmallVector<Instruction *, 32> getAllInsertedInstructions() const {
- SmallVector<Instruction *, 32> Result;
- for (auto &VH : InsertedValues) {
- Value *V = VH;
- if (ReusedValues.contains(V))
- continue;
- if (auto *Inst = dyn_cast<Instruction>(V))
- Result.push_back(Inst);
+ /// Erase the contents of the InsertedExpressions map so that users trying
+ /// to expand the same expression into multiple BasicBlocks or different
+ /// places within the same BasicBlock can do so.
+ void clear() {
+ InsertedExpressions.clear();
+ InsertedValues.clear();
+ InsertedPostIncValues.clear();
+ ReusedValues.clear();
+ ChainedPhis.clear();
+ }
+
+ /// Return a vector containing all instructions inserted during expansion.
+ SmallVector<Instruction *, 32> getAllInsertedInstructions() const {
+ SmallVector<Instruction *, 32> Result;
+ for (auto &VH : InsertedValues) {
+ Value *V = VH;
+ if (ReusedValues.contains(V))
+ continue;
+ if (auto *Inst = dyn_cast<Instruction>(V))
+ Result.push_back(Inst);
}
- for (auto &VH : InsertedPostIncValues) {
- Value *V = VH;
- if (ReusedValues.contains(V))
- continue;
- if (auto *Inst = dyn_cast<Instruction>(V))
- Result.push_back(Inst);
- }
-
- return Result;
- }
-
- /// Return true for expressions that can't be evaluated at runtime
- /// within given \b Budget.
- ///
- /// At is a parameter which specifies point in code where user is going to
- /// expand this expression. Sometimes this knowledge can lead to
- /// a less pessimistic cost estimation.
- bool isHighCostExpansion(const SCEV *Expr, Loop *L, unsigned Budget,
- const TargetTransformInfo *TTI,
- const Instruction *At) {
- assert(TTI && "This function requires TTI to be provided.");
- assert(At && "This function requires At instruction to be provided.");
- if (!TTI) // In assert-less builds, avoid crashing
- return true; // by always claiming to be high-cost.
- SmallVector<SCEVOperand, 8> Worklist;
- SmallPtrSet<const SCEV *, 8> Processed;
- int BudgetRemaining = Budget * TargetTransformInfo::TCC_Basic;
- Worklist.emplace_back(-1, -1, Expr);
- while (!Worklist.empty()) {
- const SCEVOperand WorkItem = Worklist.pop_back_val();
- if (isHighCostExpansionHelper(WorkItem, L, *At, BudgetRemaining,
- *TTI, Processed, Worklist))
- return true;
+ for (auto &VH : InsertedPostIncValues) {
+ Value *V = VH;
+ if (ReusedValues.contains(V))
+ continue;
+ if (auto *Inst = dyn_cast<Instruction>(V))
+ Result.push_back(Inst);
}
- assert(BudgetRemaining >= 0 && "Should have returned from inner loop.");
- return false;
- }
-
- /// Return the induction variable increment's IV operand.
- Instruction *getIVIncOperand(Instruction *IncV, Instruction *InsertPos,
- bool allowScale);
-
- /// Utility for hoisting an IV increment.
- bool hoistIVInc(Instruction *IncV, Instruction *InsertPos);
-
- /// replace congruent phis with their most canonical representative. Return
- /// the number of phis eliminated.
- unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT,
- SmallVectorImpl<WeakTrackingVH> &DeadInsts,
- const TargetTransformInfo *TTI = nullptr);
-
- /// Insert code to directly compute the specified SCEV expression into the
- /// program. The code is inserted into the specified block.
- Value *expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I) {
- return expandCodeForImpl(SH, Ty, I, true);
- }
-
- /// Insert code to directly compute the specified SCEV expression into the
- /// program. The code is inserted into the SCEVExpander's current
- /// insertion point. If a type is specified, the result will be expanded to
- /// have that type, with a cast if necessary.
- Value *expandCodeFor(const SCEV *SH, Type *Ty = nullptr) {
- return expandCodeForImpl(SH, Ty, true);
- }
-
- /// Generates a code sequence that evaluates this predicate. The inserted
- /// instructions will be at position \p Loc. The result will be of type i1
- /// and will have a value of 0 when the predicate is false and 1 otherwise.
- Value *expandCodeForPredicate(const SCEVPredicate *Pred, Instruction *Loc);
-
- /// A specialized variant of expandCodeForPredicate, handling the case when
- /// we are expanding code for a SCEVEqualPredicate.
- Value *expandEqualPredicate(const SCEVEqualPredicate *Pred, Instruction *Loc);
-
- /// Generates code that evaluates if the \p AR expression will overflow.
- Value *generateOverflowCheck(const SCEVAddRecExpr *AR, Instruction *Loc,
- bool Signed);
-
- /// A specialized variant of expandCodeForPredicate, handling the case when
- /// we are expanding code for a SCEVWrapPredicate.
- Value *expandWrapPredicate(const SCEVWrapPredicate *P, Instruction *Loc);
-
- /// A specialized variant of expandCodeForPredicate, handling the case when
- /// we are expanding code for a SCEVUnionPredicate.
- Value *expandUnionPredicate(const SCEVUnionPredicate *Pred, Instruction *Loc);
-
- /// Set the current IV increment loop and position.
- void setIVIncInsertPos(const Loop *L, Instruction *Pos) {
- assert(!CanonicalMode &&
- "IV increment positions are not supported in CanonicalMode");
- IVIncInsertLoop = L;
- IVIncInsertPos = Pos;
- }
-
- /// Enable post-inc expansion for addrecs referring to the given
- /// loops. Post-inc expansion is only supported in non-canonical mode.
- void setPostInc(const PostIncLoopSet &L) {
- assert(!CanonicalMode &&
- "Post-inc expansion is not supported in CanonicalMode");
- PostIncLoops = L;
- }
-
- /// Disable all post-inc expansion.
- void clearPostInc() {
- PostIncLoops.clear();
-
- // When we change the post-inc loop set, cached expansions may no
- // longer be valid.
- InsertedPostIncValues.clear();
- }
-
- /// Disable the behavior of expanding expressions in canonical form rather
- /// than in a more literal form. Non-canonical mode is useful for late
- /// optimization passes.
- void disableCanonicalMode() { CanonicalMode = false; }
-
- void enableLSRMode() { LSRMode = true; }
-
- /// Set the current insertion point. This is useful if multiple calls to
- /// expandCodeFor() are going to be made with the same insert point and the
- /// insert point may be moved during one of the expansions (e.g. if the
- /// insert point is not a block terminator).
- void setInsertPoint(Instruction *IP) {
- assert(IP);
- Builder.SetInsertPoint(IP);
- }
-
- /// Clear the current insertion point. This is useful if the instruction
- /// that had been serving as the insertion point may have been deleted.
- void clearInsertPoint() { Builder.ClearInsertionPoint(); }
-
- /// Set location information used by debugging information.
- void SetCurrentDebugLocation(DebugLoc L) {
- Builder.SetCurrentDebugLocation(std::move(L));
- }
-
- /// Get location information used by debugging information.
- DebugLoc getCurrentDebugLocation() const {
- return Builder.getCurrentDebugLocation();
- }
-
- /// Return true if the specified instruction was inserted by the code
- /// rewriter. If so, the client should not modify the instruction. Note that
- /// this also includes instructions re-used during expansion.
- bool isInsertedInstruction(Instruction *I) const {
- return InsertedValues.count(I) || InsertedPostIncValues.count(I);
- }
-
- void setChainedPhi(PHINode *PN) { ChainedPhis.insert(PN); }
-
- /// Try to find the ValueOffsetPair for S. The function is mainly used to
- /// check whether S can be expanded cheaply. If this returns a non-None
- /// value, we know we can codegen the `ValueOffsetPair` into a suitable
- /// expansion identical with S so that S can be expanded cheaply.
- ///
- /// L is a hint which tells in which loop to look for the suitable value.
- /// On success return value which is equivalent to the expanded S at point
- /// At. Return nullptr if value was not found.
- ///
- /// Note that this function does not perform an exhaustive search. I.e if it
- /// didn't find any value it does not mean that there is no such value.
- ///
- Optional<ScalarEvolution::ValueOffsetPair>
- getRelatedExistingExpansion(const SCEV *S, const Instruction *At, Loop *L);
-
- /// Returns a suitable insert point after \p I, that dominates \p
- /// MustDominate. Skips instructions inserted by the expander.
- BasicBlock::iterator findInsertPointAfter(Instruction *I,
- Instruction *MustDominate);
-
-private:
- LLVMContext &getContext() const { return SE.getContext(); }
-
- /// Insert code to directly compute the specified SCEV expression into the
- /// program. The code is inserted into the SCEVExpander's current
- /// insertion point. If a type is specified, the result will be expanded to
- /// have that type, with a cast if necessary. If \p Root is true, this
- /// indicates that \p SH is the top-level expression to expand passed from
- /// an external client call.
- Value *expandCodeForImpl(const SCEV *SH, Type *Ty, bool Root);
-
- /// Insert code to directly compute the specified SCEV expression into the
- /// program. The code is inserted into the specified block. If \p
- /// Root is true, this indicates that \p SH is the top-level expression to
- /// expand passed from an external client call.
- Value *expandCodeForImpl(const SCEV *SH, Type *Ty, Instruction *I, bool Root);
-
- /// Recursive helper function for isHighCostExpansion.
- bool isHighCostExpansionHelper(
- const SCEVOperand &WorkItem, Loop *L, const Instruction &At,
- int &BudgetRemaining, const TargetTransformInfo &TTI,
- SmallPtrSetImpl<const SCEV *> &Processed,
- SmallVectorImpl<SCEVOperand> &Worklist);
-
- /// Insert the specified binary operator, doing a small amount of work to
- /// avoid inserting an obviously redundant operation, and hoisting to an
- /// outer loop when the opportunity is there and it is safe.
- Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS,
- SCEV::NoWrapFlags Flags, bool IsSafeToHoist);
-
- /// Arrange for there to be a cast of V to Ty at IP, reusing an existing
- /// cast if a suitable one exists, moving an existing cast if a suitable one
- /// exists but isn't in the right place, or creating a new one.
- Value *ReuseOrCreateCast(Value *V, Type *Ty, Instruction::CastOps Op,
- BasicBlock::iterator IP);
-
- /// Insert a cast of V to the specified type, which must be possible with a
- /// noop cast, doing what we can to share the casts.
- Value *InsertNoopCastOfTo(Value *V, Type *Ty);
-
- /// Expand a SCEVAddExpr with a pointer type into a GEP instead of using
- /// ptrtoint+arithmetic+inttoptr.
- Value *expandAddToGEP(const SCEV *const *op_begin, const SCEV *const *op_end,
- PointerType *PTy, Type *Ty, Value *V);
- Value *expandAddToGEP(const SCEV *Op, PointerType *PTy, Type *Ty, Value *V);
-
- /// Find a previous Value in ExprValueMap for expand.
- ScalarEvolution::ValueOffsetPair
- FindValueInExprValueMap(const SCEV *S, const Instruction *InsertPt);
-
- Value *expand(const SCEV *S);
-
- /// Determine the most "relevant" loop for the given SCEV.
- const Loop *getRelevantLoop(const SCEV *);
-
- Value *visitConstant(const SCEVConstant *S) { return S->getValue(); }
-
- Value *visitPtrToIntExpr(const SCEVPtrToIntExpr *S);
-
- Value *visitTruncateExpr(const SCEVTruncateExpr *S);
-
- Value *visitZeroExtendExpr(const SCEVZeroExtendExpr *S);
-
- Value *visitSignExtendExpr(const SCEVSignExtendExpr *S);
-
- Value *visitAddExpr(const SCEVAddExpr *S);
-
- Value *visitMulExpr(const SCEVMulExpr *S);
-
- Value *visitUDivExpr(const SCEVUDivExpr *S);
-
- Value *visitAddRecExpr(const SCEVAddRecExpr *S);
-
- Value *visitSMaxExpr(const SCEVSMaxExpr *S);
-
- Value *visitUMaxExpr(const SCEVUMaxExpr *S);
-
- Value *visitSMinExpr(const SCEVSMinExpr *S);
-
- Value *visitUMinExpr(const SCEVUMinExpr *S);
-
- Value *visitUnknown(const SCEVUnknown *S) { return S->getValue(); }
-
- void rememberInstruction(Value *I);
-
- bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L);
-
- bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L);
-
- Value *expandAddRecExprLiterally(const SCEVAddRecExpr *);
- PHINode *getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
- const Loop *L, Type *ExpandTy, Type *IntTy,
- Type *&TruncTy, bool &InvertStep);
- Value *expandIVInc(PHINode *PN, Value *StepV, const Loop *L, Type *ExpandTy,
- Type *IntTy, bool useSubtract);
-
- void hoistBeforePos(DominatorTree *DT, Instruction *InstToHoist,
- Instruction *Pos, PHINode *LoopPhi);
-
- void fixupInsertPoints(Instruction *I);
-
- /// If required, create LCSSA PHIs for \p Users' operand \p OpIdx. If new
- /// LCSSA PHIs have been created, return the LCSSA PHI available at \p User.
- /// If no PHIs have been created, return the unchanged operand \p OpIdx.
- Value *fixupLCSSAFormFor(Instruction *User, unsigned OpIdx);
-};
-
-/// Helper to remove instructions inserted during SCEV expansion, unless they
-/// are marked as used.
-class SCEVExpanderCleaner {
- SCEVExpander &Expander;
-
- DominatorTree &DT;
-
- /// Indicates whether the result of the expansion is used. If false, the
- /// instructions added during expansion are removed.
- bool ResultUsed;
-
-public:
- SCEVExpanderCleaner(SCEVExpander &Expander, DominatorTree &DT)
- : Expander(Expander), DT(DT), ResultUsed(false) {}
-
- ~SCEVExpanderCleaner();
-
- /// Indicate that the result of the expansion is used.
- void markResultUsed() { ResultUsed = true; }
-};
-} // namespace llvm
-
+
+ return Result;
+ }
+
+ /// Return true for expressions that can't be evaluated at runtime
+ /// within given \b Budget.
+ ///
+ /// At is a parameter which specifies point in code where user is going to
+ /// expand this expression. Sometimes this knowledge can lead to
+ /// a less pessimistic cost estimation.
+ bool isHighCostExpansion(const SCEV *Expr, Loop *L, unsigned Budget,
+ const TargetTransformInfo *TTI,
+ const Instruction *At) {
+ assert(TTI && "This function requires TTI to be provided.");
+ assert(At && "This function requires At instruction to be provided.");
+ if (!TTI) // In assert-less builds, avoid crashing
+ return true; // by always claiming to be high-cost.
+ SmallVector<SCEVOperand, 8> Worklist;
+ SmallPtrSet<const SCEV *, 8> Processed;
+ int BudgetRemaining = Budget * TargetTransformInfo::TCC_Basic;
+ Worklist.emplace_back(-1, -1, Expr);
+ while (!Worklist.empty()) {
+ const SCEVOperand WorkItem = Worklist.pop_back_val();
+ if (isHighCostExpansionHelper(WorkItem, L, *At, BudgetRemaining,
+ *TTI, Processed, Worklist))
+ return true;
+ }
+ assert(BudgetRemaining >= 0 && "Should have returned from inner loop.");
+ return false;
+ }
+
+ /// Return the induction variable increment's IV operand.
+ Instruction *getIVIncOperand(Instruction *IncV, Instruction *InsertPos,
+ bool allowScale);
+
+ /// Utility for hoisting an IV increment.
+ bool hoistIVInc(Instruction *IncV, Instruction *InsertPos);
+
+ /// replace congruent phis with their most canonical representative. Return
+ /// the number of phis eliminated.
+ unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT,
+ SmallVectorImpl<WeakTrackingVH> &DeadInsts,
+ const TargetTransformInfo *TTI = nullptr);
+
+ /// Insert code to directly compute the specified SCEV expression into the
+ /// program. The code is inserted into the specified block.
+ Value *expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I) {
+ return expandCodeForImpl(SH, Ty, I, true);
+ }
+
+ /// Insert code to directly compute the specified SCEV expression into the
+ /// program. The code is inserted into the SCEVExpander's current
+ /// insertion point. If a type is specified, the result will be expanded to
+ /// have that type, with a cast if necessary.
+ Value *expandCodeFor(const SCEV *SH, Type *Ty = nullptr) {
+ return expandCodeForImpl(SH, Ty, true);
+ }
+
+ /// Generates a code sequence that evaluates this predicate. The inserted
+ /// instructions will be at position \p Loc. The result will be of type i1
+ /// and will have a value of 0 when the predicate is false and 1 otherwise.
+ Value *expandCodeForPredicate(const SCEVPredicate *Pred, Instruction *Loc);
+
+ /// A specialized variant of expandCodeForPredicate, handling the case when
+ /// we are expanding code for a SCEVEqualPredicate.
+ Value *expandEqualPredicate(const SCEVEqualPredicate *Pred, Instruction *Loc);
+
+ /// Generates code that evaluates if the \p AR expression will overflow.
+ Value *generateOverflowCheck(const SCEVAddRecExpr *AR, Instruction *Loc,
+ bool Signed);
+
+ /// A specialized variant of expandCodeForPredicate, handling the case when
+ /// we are expanding code for a SCEVWrapPredicate.
+ Value *expandWrapPredicate(const SCEVWrapPredicate *P, Instruction *Loc);
+
+ /// A specialized variant of expandCodeForPredicate, handling the case when
+ /// we are expanding code for a SCEVUnionPredicate.
+ Value *expandUnionPredicate(const SCEVUnionPredicate *Pred, Instruction *Loc);
+
+ /// Set the current IV increment loop and position.
+ void setIVIncInsertPos(const Loop *L, Instruction *Pos) {
+ assert(!CanonicalMode &&
+ "IV increment positions are not supported in CanonicalMode");
+ IVIncInsertLoop = L;
+ IVIncInsertPos = Pos;
+ }
+
+ /// Enable post-inc expansion for addrecs referring to the given
+ /// loops. Post-inc expansion is only supported in non-canonical mode.
+ void setPostInc(const PostIncLoopSet &L) {
+ assert(!CanonicalMode &&
+ "Post-inc expansion is not supported in CanonicalMode");
+ PostIncLoops = L;
+ }
+
+ /// Disable all post-inc expansion.
+ void clearPostInc() {
+ PostIncLoops.clear();
+
+ // When we change the post-inc loop set, cached expansions may no
+ // longer be valid.
+ InsertedPostIncValues.clear();
+ }
+
+ /// Disable the behavior of expanding expressions in canonical form rather
+ /// than in a more literal form. Non-canonical mode is useful for late
+ /// optimization passes.
+ void disableCanonicalMode() { CanonicalMode = false; }
+
+ void enableLSRMode() { LSRMode = true; }
+
+ /// Set the current insertion point. This is useful if multiple calls to
+ /// expandCodeFor() are going to be made with the same insert point and the
+ /// insert point may be moved during one of the expansions (e.g. if the
+ /// insert point is not a block terminator).
+ void setInsertPoint(Instruction *IP) {
+ assert(IP);
+ Builder.SetInsertPoint(IP);
+ }
+
+ /// Clear the current insertion point. This is useful if the instruction
+ /// that had been serving as the insertion point may have been deleted.
+ void clearInsertPoint() { Builder.ClearInsertionPoint(); }
+
+ /// Set location information used by debugging information.
+ void SetCurrentDebugLocation(DebugLoc L) {
+ Builder.SetCurrentDebugLocation(std::move(L));
+ }
+
+ /// Get location information used by debugging information.
+ DebugLoc getCurrentDebugLocation() const {
+ return Builder.getCurrentDebugLocation();
+ }
+
+ /// Return true if the specified instruction was inserted by the code
+ /// rewriter. If so, the client should not modify the instruction. Note that
+ /// this also includes instructions re-used during expansion.
+ bool isInsertedInstruction(Instruction *I) const {
+ return InsertedValues.count(I) || InsertedPostIncValues.count(I);
+ }
+
+ void setChainedPhi(PHINode *PN) { ChainedPhis.insert(PN); }
+
+ /// Try to find the ValueOffsetPair for S. The function is mainly used to
+ /// check whether S can be expanded cheaply. If this returns a non-None
+ /// value, we know we can codegen the `ValueOffsetPair` into a suitable
+ /// expansion identical with S so that S can be expanded cheaply.
+ ///
+ /// L is a hint which tells in which loop to look for the suitable value.
+ /// On success return value which is equivalent to the expanded S at point
+ /// At. Return nullptr if value was not found.
+ ///
+ /// Note that this function does not perform an exhaustive search. I.e if it
+ /// didn't find any value it does not mean that there is no such value.
+ ///
+ Optional<ScalarEvolution::ValueOffsetPair>
+ getRelatedExistingExpansion(const SCEV *S, const Instruction *At, Loop *L);
+
+ /// Returns a suitable insert point after \p I, that dominates \p
+ /// MustDominate. Skips instructions inserted by the expander.
+ BasicBlock::iterator findInsertPointAfter(Instruction *I,
+ Instruction *MustDominate);
+
+private:
+ LLVMContext &getContext() const { return SE.getContext(); }
+
+ /// Insert code to directly compute the specified SCEV expression into the
+ /// program. The code is inserted into the SCEVExpander's current
+ /// insertion point. If a type is specified, the result will be expanded to
+ /// have that type, with a cast if necessary. If \p Root is true, this
+ /// indicates that \p SH is the top-level expression to expand passed from
+ /// an external client call.
+ Value *expandCodeForImpl(const SCEV *SH, Type *Ty, bool Root);
+
+ /// Insert code to directly compute the specified SCEV expression into the
+ /// program. The code is inserted into the specified block. If \p
+ /// Root is true, this indicates that \p SH is the top-level expression to
+ /// expand passed from an external client call.
+ Value *expandCodeForImpl(const SCEV *SH, Type *Ty, Instruction *I, bool Root);
+
+ /// Recursive helper function for isHighCostExpansion.
+ bool isHighCostExpansionHelper(
+ const SCEVOperand &WorkItem, Loop *L, const Instruction &At,
+ int &BudgetRemaining, const TargetTransformInfo &TTI,
+ SmallPtrSetImpl<const SCEV *> &Processed,
+ SmallVectorImpl<SCEVOperand> &Worklist);
+
+ /// Insert the specified binary operator, doing a small amount of work to
+ /// avoid inserting an obviously redundant operation, and hoisting to an
+ /// outer loop when the opportunity is there and it is safe.
+ Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS,
+ SCEV::NoWrapFlags Flags, bool IsSafeToHoist);
+
+ /// Arrange for there to be a cast of V to Ty at IP, reusing an existing
+ /// cast if a suitable one exists, moving an existing cast if a suitable one
+ /// exists but isn't in the right place, or creating a new one.
+ Value *ReuseOrCreateCast(Value *V, Type *Ty, Instruction::CastOps Op,
+ BasicBlock::iterator IP);
+
+ /// Insert a cast of V to the specified type, which must be possible with a
+ /// noop cast, doing what we can to share the casts.
+ Value *InsertNoopCastOfTo(Value *V, Type *Ty);
+
+ /// Expand a SCEVAddExpr with a pointer type into a GEP instead of using
+ /// ptrtoint+arithmetic+inttoptr.
+ Value *expandAddToGEP(const SCEV *const *op_begin, const SCEV *const *op_end,
+ PointerType *PTy, Type *Ty, Value *V);
+ Value *expandAddToGEP(const SCEV *Op, PointerType *PTy, Type *Ty, Value *V);
+
+ /// Find a previous Value in ExprValueMap for expand.
+ ScalarEvolution::ValueOffsetPair
+ FindValueInExprValueMap(const SCEV *S, const Instruction *InsertPt);
+
+ Value *expand(const SCEV *S);
+
+ /// Determine the most "relevant" loop for the given SCEV.
+ const Loop *getRelevantLoop(const SCEV *);
+
+ Value *visitConstant(const SCEVConstant *S) { return S->getValue(); }
+
+ Value *visitPtrToIntExpr(const SCEVPtrToIntExpr *S);
+
+ Value *visitTruncateExpr(const SCEVTruncateExpr *S);
+
+ Value *visitZeroExtendExpr(const SCEVZeroExtendExpr *S);
+
+ Value *visitSignExtendExpr(const SCEVSignExtendExpr *S);
+
+ Value *visitAddExpr(const SCEVAddExpr *S);
+
+ Value *visitMulExpr(const SCEVMulExpr *S);
+
+ Value *visitUDivExpr(const SCEVUDivExpr *S);
+
+ Value *visitAddRecExpr(const SCEVAddRecExpr *S);
+
+ Value *visitSMaxExpr(const SCEVSMaxExpr *S);
+
+ Value *visitUMaxExpr(const SCEVUMaxExpr *S);
+
+ Value *visitSMinExpr(const SCEVSMinExpr *S);
+
+ Value *visitUMinExpr(const SCEVUMinExpr *S);
+
+ Value *visitUnknown(const SCEVUnknown *S) { return S->getValue(); }
+
+ void rememberInstruction(Value *I);
+
+ bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L);
+
+ bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L);
+
+ Value *expandAddRecExprLiterally(const SCEVAddRecExpr *);
+ PHINode *getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
+ const Loop *L, Type *ExpandTy, Type *IntTy,
+ Type *&TruncTy, bool &InvertStep);
+ Value *expandIVInc(PHINode *PN, Value *StepV, const Loop *L, Type *ExpandTy,
+ Type *IntTy, bool useSubtract);
+
+ void hoistBeforePos(DominatorTree *DT, Instruction *InstToHoist,
+ Instruction *Pos, PHINode *LoopPhi);
+
+ void fixupInsertPoints(Instruction *I);
+
+ /// If required, create LCSSA PHIs for \p Users' operand \p OpIdx. If new
+ /// LCSSA PHIs have been created, return the LCSSA PHI available at \p User.
+ /// If no PHIs have been created, return the unchanged operand \p OpIdx.
+ Value *fixupLCSSAFormFor(Instruction *User, unsigned OpIdx);
+};
+
+/// Helper to remove instructions inserted during SCEV expansion, unless they
+/// are marked as used.
+class SCEVExpanderCleaner {
+ SCEVExpander &Expander;
+
+ DominatorTree &DT;
+
+ /// Indicates whether the result of the expansion is used. If false, the
+ /// instructions added during expansion are removed.
+ bool ResultUsed;
+
+public:
+ SCEVExpanderCleaner(SCEVExpander &Expander, DominatorTree &DT)
+ : Expander(Expander), DT(DT), ResultUsed(false) {}
+
+ ~SCEVExpanderCleaner();
+
+ /// Indicate that the result of the expansion is used.
+ void markResultUsed() { ResultUsed = true; }
+};
+} // namespace llvm
+
#endif
#ifdef __GNUC__
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h
index df04cc9255..37ace5188d 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h
@@ -1,88 +1,88 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- SimplifyCFGOptions.h - Control structure for SimplifyCFG -*- 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
-//
-//===----------------------------------------------------------------------===//
-//
-// A set of parameters used to control the transforms in the SimplifyCFG pass.
-// Options may change depending on the position in the optimization pipeline.
-// For example, canonical form that includes switches and branches may later be
-// replaced by lookup tables and selects.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
-#define LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
-
-namespace llvm {
-
-class AssumptionCache;
-
-struct SimplifyCFGOptions {
- int BonusInstThreshold = 1;
- bool ForwardSwitchCondToPhi = false;
- bool ConvertSwitchToLookupTable = false;
- bool NeedCanonicalLoop = true;
- bool HoistCommonInsts = false;
- bool SinkCommonInsts = false;
- bool SimplifyCondBranch = true;
- bool FoldTwoEntryPHINode = true;
-
- AssumptionCache *AC = nullptr;
-
- // Support 'builder' pattern to set members by name at construction time.
- SimplifyCFGOptions &bonusInstThreshold(int I) {
- BonusInstThreshold = I;
- return *this;
- }
- SimplifyCFGOptions &forwardSwitchCondToPhi(bool B) {
- ForwardSwitchCondToPhi = B;
- return *this;
- }
- SimplifyCFGOptions &convertSwitchToLookupTable(bool B) {
- ConvertSwitchToLookupTable = B;
- return *this;
- }
- SimplifyCFGOptions &needCanonicalLoops(bool B) {
- NeedCanonicalLoop = B;
- return *this;
- }
- SimplifyCFGOptions &hoistCommonInsts(bool B) {
- HoistCommonInsts = B;
- return *this;
- }
- SimplifyCFGOptions &sinkCommonInsts(bool B) {
- SinkCommonInsts = B;
- return *this;
- }
- SimplifyCFGOptions &setAssumptionCache(AssumptionCache *Cache) {
- AC = Cache;
- return *this;
- }
- SimplifyCFGOptions &setSimplifyCondBranch(bool B) {
- SimplifyCondBranch = B;
- return *this;
- }
-
- SimplifyCFGOptions &setFoldTwoEntryPHINode(bool B) {
- FoldTwoEntryPHINode = B;
- return *this;
- }
-};
-
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- SimplifyCFGOptions.h - Control structure for SimplifyCFG -*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// A set of parameters used to control the transforms in the SimplifyCFG pass.
+// Options may change depending on the position in the optimization pipeline.
+// For example, canonical form that includes switches and branches may later be
+// replaced by lookup tables and selects.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
+#define LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
+
+namespace llvm {
+
+class AssumptionCache;
+
+struct SimplifyCFGOptions {
+ int BonusInstThreshold = 1;
+ bool ForwardSwitchCondToPhi = false;
+ bool ConvertSwitchToLookupTable = false;
+ bool NeedCanonicalLoop = true;
+ bool HoistCommonInsts = false;
+ bool SinkCommonInsts = false;
+ bool SimplifyCondBranch = true;
+ bool FoldTwoEntryPHINode = true;
+
+ AssumptionCache *AC = nullptr;
+
+ // Support 'builder' pattern to set members by name at construction time.
+ SimplifyCFGOptions &bonusInstThreshold(int I) {
+ BonusInstThreshold = I;
+ return *this;
+ }
+ SimplifyCFGOptions &forwardSwitchCondToPhi(bool B) {
+ ForwardSwitchCondToPhi = B;
+ return *this;
+ }
+ SimplifyCFGOptions &convertSwitchToLookupTable(bool B) {
+ ConvertSwitchToLookupTable = B;
+ return *this;
+ }
+ SimplifyCFGOptions &needCanonicalLoops(bool B) {
+ NeedCanonicalLoop = B;
+ return *this;
+ }
+ SimplifyCFGOptions &hoistCommonInsts(bool B) {
+ HoistCommonInsts = B;
+ return *this;
+ }
+ SimplifyCFGOptions &sinkCommonInsts(bool B) {
+ SinkCommonInsts = B;
+ return *this;
+ }
+ SimplifyCFGOptions &setAssumptionCache(AssumptionCache *Cache) {
+ AC = Cache;
+ return *this;
+ }
+ SimplifyCFGOptions &setSimplifyCondBranch(bool B) {
+ SimplifyCondBranch = B;
+ return *this;
+ }
+
+ SimplifyCFGOptions &setFoldTwoEntryPHINode(bool B) {
+ FoldTwoEntryPHINode = B;
+ return *this;
+ }
+};
+
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h
index 4430fcba51..375bf2963a 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h
@@ -22,8 +22,8 @@
#ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
#define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
-#include "llvm/Analysis/ScalarEvolutionExpressions.h"
-#include "llvm/IR/ConstantRange.h"
+#include "llvm/Analysis/ScalarEvolutionExpressions.h"
+#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/ValueHandle.h"
namespace llvm {
@@ -66,27 +66,27 @@ bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT,
LoopInfo *LI, const TargetTransformInfo *TTI,
SmallVectorImpl<WeakTrackingVH> &Dead);
-/// Collect information about induction variables that are used by sign/zero
-/// extend operations. This information is recorded by CollectExtend and provides
-/// the input to WidenIV.
-struct WideIVInfo {
- PHINode *NarrowIV = nullptr;
-
- // Widest integer type created [sz]ext
- Type *WidestNativeType = nullptr;
-
- // Was a sext user seen before a zext?
- bool IsSigned = false;
-};
-
-/// Widen Induction Variables - Extend the width of an IV to cover its
-/// widest uses.
-PHINode *createWideIV(const WideIVInfo &WI,
- LoopInfo *LI, ScalarEvolution *SE, SCEVExpander &Rewriter,
- DominatorTree *DT, SmallVectorImpl<WeakTrackingVH> &DeadInsts,
- unsigned &NumElimExt, unsigned &NumWidened,
- bool HasGuards, bool UsePostIncrementRanges);
-
+/// Collect information about induction variables that are used by sign/zero
+/// extend operations. This information is recorded by CollectExtend and provides
+/// the input to WidenIV.
+struct WideIVInfo {
+ PHINode *NarrowIV = nullptr;
+
+ // Widest integer type created [sz]ext
+ Type *WidestNativeType = nullptr;
+
+ // Was a sext user seen before a zext?
+ bool IsSigned = false;
+};
+
+/// Widen Induction Variables - Extend the width of an IV to cover its
+/// widest uses.
+PHINode *createWideIV(const WideIVInfo &WI,
+ LoopInfo *LI, ScalarEvolution *SE, SCEVExpander &Rewriter,
+ DominatorTree *DT, SmallVectorImpl<WeakTrackingVH> &DeadInsts,
+ unsigned &NumElimExt, unsigned &NumWidened,
+ bool HasGuards, bool UsePostIncrementRanges);
+
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h
index 3d012f6277..29e2eb9b3d 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h
@@ -66,7 +66,7 @@ private:
Value *optimizeStrpCpyChk(CallInst *CI, IRBuilderBase &B, LibFunc Func);
Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilderBase &B, LibFunc Func);
Value *optimizeStrLenChk(CallInst *CI, IRBuilderBase &B);
- Value *optimizeMemPCpyChk(CallInst *CI, IRBuilderBase &B);
+ Value *optimizeMemPCpyChk(CallInst *CI, IRBuilderBase &B);
Value *optimizeMemCCpyChk(CallInst *CI, IRBuilderBase &B);
Value *optimizeSNPrintfChk(CallInst *CI, IRBuilderBase &B);
Value *optimizeSPrintfChk(CallInst *CI,IRBuilderBase &B);
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h
index e977ff1eb4..ab438af771 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h
@@ -1,36 +1,36 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- StripGCRelocates.h - -----------------------------------------------===//
-//
-// 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 LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H
-#define LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class Function;
-
-class StripGCRelocates : public PassInfoMixin<StripGCRelocates> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- StripGCRelocates.h - -----------------------------------------------===//
+//
+// 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 LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H
+#define LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class Function;
+
+class StripGCRelocates : public PassInfoMixin<StripGCRelocates> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h
index 91d1d57e53..bd010e3803 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h
@@ -1,37 +1,37 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- StripNonLineTableDebugInfo.h - -------------------------------------===//
-//
-// 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 LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H
-#define LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class Module;
-
-class StripNonLineTableDebugInfoPass
- : public PassInfoMixin<StripNonLineTableDebugInfoPass> {
-public:
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-};
-
-} // end namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- StripNonLineTableDebugInfo.h - -------------------------------------===//
+//
+// 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 LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H
+#define LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class Module;
+
+class StripNonLineTableDebugInfoPass
+ : public PassInfoMixin<StripNonLineTableDebugInfoPass> {
+public:
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
index d836f64cc0..dcb046c476 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
@@ -14,24 +14,24 @@
//===----------------------------------------------------------------------===//
//
// This pass is used to ensure that functions have at most one return and one
-// unreachable instruction in them.
+// unreachable instruction in them.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
#define LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
-#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
namespace llvm {
class BasicBlock;
-class UnifyFunctionExitNodesLegacyPass : public FunctionPass {
+class UnifyFunctionExitNodesLegacyPass : public FunctionPass {
public:
static char ID; // Pass identification, replacement for typeid
- UnifyFunctionExitNodesLegacyPass();
+ UnifyFunctionExitNodesLegacyPass();
// We can preserve non-critical-edgeness when we unify function exit nodes
void getAnalysisUsage(AnalysisUsage &AU) const override;
@@ -41,12 +41,12 @@ public:
Pass *createUnifyFunctionExitNodesPass();
-class UnifyFunctionExitNodesPass
- : public PassInfoMixin<UnifyFunctionExitNodesPass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-
+class UnifyFunctionExitNodesPass
+ : public PassInfoMixin<UnifyFunctionExitNodesPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h
index 642da24966..ef6ef6f92b 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h
@@ -1,33 +1,33 @@
-#pragma once
-
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-//===- UnifyLoopExits.h - Redirect exiting edges to one block -*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H
-#define LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H
-
-#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-
-class UnifyLoopExitsPass : public PassInfoMixin<UnifyLoopExitsPass> {
-public:
- PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-};
-} // namespace llvm
-
-#endif // LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- UnifyLoopExits.h - Redirect exiting edges to one block -*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H
+#define LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class UnifyLoopExitsPass : public PassInfoMixin<UnifyLoopExitsPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h b/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index 1b07676bd2..08103ad050 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -36,7 +36,7 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/Analysis/LoopAccessAnalysis.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
-#include "llvm/Support/TypeSize.h"
+#include "llvm/Support/TypeSize.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
namespace llvm {
@@ -51,14 +51,14 @@ namespace llvm {
/// for example 'force', means a decision has been made. So, we need to be
/// careful NOT to add them if the user hasn't specifically asked so.
class LoopVectorizeHints {
- enum HintKind {
- HK_WIDTH,
- HK_UNROLL,
- HK_FORCE,
- HK_ISVECTORIZED,
- HK_PREDICATE,
- HK_SCALABLE
- };
+ enum HintKind {
+ HK_WIDTH,
+ HK_UNROLL,
+ HK_FORCE,
+ HK_ISVECTORIZED,
+ HK_PREDICATE,
+ HK_SCALABLE
+ };
/// Hint - associates name and validation with the hint value.
struct Hint {
@@ -87,9 +87,9 @@ class LoopVectorizeHints {
/// Vector Predicate
Hint Predicate;
- /// Says whether we should use fixed width or scalable vectorization.
- Hint Scalable;
-
+ /// Says whether we should use fixed width or scalable vectorization.
+ Hint Scalable;
+
/// Return the loop metadata prefix.
static StringRef Prefix() { return "llvm.loop."; }
@@ -115,9 +115,9 @@ public:
/// Dumps all the hint information.
void emitRemarkWithHints() const;
- ElementCount getWidth() const {
- return ElementCount::get(Width.Value, isScalable());
- }
+ ElementCount getWidth() const {
+ return ElementCount::get(Width.Value, isScalable());
+ }
unsigned getInterleave() const { return Interleave.Value; }
unsigned getIsVectorized() const { return IsVectorized.Value; }
unsigned getPredicate() const { return Predicate.Value; }
@@ -128,8 +128,8 @@ public:
return (ForceKind)Force.Value;
}
- bool isScalable() const { return Scalable.Value; }
-
+ bool isScalable() const { return Scalable.Value; }
+
/// If hints are provided that force vectorization, use the AlwaysPrint
/// pass name to force the frontend to print the diagnostic.
const char *vectorizeAnalysisPassName() const;
@@ -140,9 +140,9 @@ public:
// enabled by default because can be unsafe or inefficient. For example,
// reordering floating-point operations will change the way round-off
// error accumulates in the loop.
- ElementCount EC = getWidth();
- return getForce() == LoopVectorizeHints::FK_Enabled ||
- EC.getKnownMinValue() > 1;
+ ElementCount EC = getWidth();
+ return getForce() == LoopVectorizeHints::FK_Enabled ||
+ EC.getKnownMinValue() > 1;
}
bool isPotentiallyUnsafe() const {
@@ -225,10 +225,10 @@ public:
Function *F, std::function<const LoopAccessInfo &(Loop &)> *GetLAA,
LoopInfo *LI, OptimizationRemarkEmitter *ORE,
LoopVectorizationRequirements *R, LoopVectorizeHints *H, DemandedBits *DB,
- AssumptionCache *AC, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI)
+ AssumptionCache *AC, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI)
: TheLoop(L), LI(LI), PSE(PSE), TTI(TTI), TLI(TLI), DT(DT),
- GetLAA(GetLAA), ORE(ORE), Requirements(R), Hints(H), DB(DB), AC(AC),
- BFI(BFI), PSI(PSI) {}
+ GetLAA(GetLAA), ORE(ORE), Requirements(R), Hints(H), DB(DB), AC(AC),
+ BFI(BFI), PSI(PSI) {}
/// ReductionList contains the reduction descriptors for all
/// of the reductions that were found in the loop.
@@ -253,7 +253,7 @@ public:
/// Return true if we can vectorize this loop while folding its tail by
/// masking, and mark all respective loads/stores for masking.
- /// This object's state is only modified iff this function returns true.
+ /// This object's state is only modified iff this function returns true.
bool prepareToFoldTailByMasking();
/// Returns the primary induction variable.
@@ -312,19 +312,19 @@ public:
/// Returns true if the value V is uniform within the loop.
bool isUniform(Value *V);
- /// A uniform memory op is a load or store which accesses the same memory
- /// location on all lanes.
- bool isUniformMemOp(Instruction &I) {
- Value *Ptr = getLoadStorePointerOperand(&I);
- if (!Ptr)
- return false;
- // Note: There's nothing inherent which prevents predicated loads and
- // stores from being uniform. The current lowering simply doesn't handle
- // it; in particular, the cost model distinguishes scatter/gather from
- // scalar w/predication, and we currently rely on the scalar path.
- return isUniform(Ptr) && !blockNeedsPredication(I.getParent());
- }
-
+ /// A uniform memory op is a load or store which accesses the same memory
+ /// location on all lanes.
+ bool isUniformMemOp(Instruction &I) {
+ Value *Ptr = getLoadStorePointerOperand(&I);
+ if (!Ptr)
+ return false;
+ // Note: There's nothing inherent which prevents predicated loads and
+ // stores from being uniform. The current lowering simply doesn't handle
+ // it; in particular, the cost model distinguishes scatter/gather from
+ // scalar w/predication, and we currently rely on the scalar path.
+ return isUniform(Ptr) && !blockNeedsPredication(I.getParent());
+ }
+
/// Returns the information that we collected about runtime memory check.
const RuntimePointerChecking *getRuntimePointerChecking() const {
return LAI->getRuntimePointerChecking();
@@ -332,21 +332,21 @@ public:
const LoopAccessInfo *getLAI() const { return LAI; }
- bool isSafeForAnyVectorWidth() const {
- return LAI->getDepChecker().isSafeForAnyVectorWidth();
- }
-
+ bool isSafeForAnyVectorWidth() const {
+ return LAI->getDepChecker().isSafeForAnyVectorWidth();
+ }
+
unsigned getMaxSafeDepDistBytes() { return LAI->getMaxSafeDepDistBytes(); }
- uint64_t getMaxSafeVectorWidthInBits() const {
- return LAI->getDepChecker().getMaxSafeVectorWidthInBits();
+ uint64_t getMaxSafeVectorWidthInBits() const {
+ return LAI->getDepChecker().getMaxSafeVectorWidthInBits();
}
bool hasStride(Value *V) { return LAI->hasStride(V); }
/// Returns true if vector representation of the instruction \p I
/// requires mask.
- bool isMaskRequired(const Instruction *I) { return MaskedOp.contains(I); }
+ bool isMaskRequired(const Instruction *I) { return MaskedOp.contains(I); }
unsigned getNumStores() const { return LAI->getNumStores(); }
unsigned getNumLoads() const { return LAI->getNumLoads(); }
@@ -403,17 +403,17 @@ private:
bool canVectorizeOuterLoop();
/// Return true if all of the instructions in the block can be speculatively
- /// executed, and record the loads/stores that require masking.
+ /// executed, and record the loads/stores that require masking.
/// \p SafePtrs is a list of addresses that are known to be legal and we know
/// that we can read from them without segfault.
- /// \p MaskedOp is a list of instructions that have to be transformed into
- /// calls to the appropriate masked intrinsic when the loop is vectorized.
- /// \p ConditionalAssumes is a list of assume instructions in predicated
- /// blocks that must be dropped if the CFG gets flattened.
- bool blockCanBePredicated(
- BasicBlock *BB, SmallPtrSetImpl<Value *> &SafePtrs,
- SmallPtrSetImpl<const Instruction *> &MaskedOp,
- SmallPtrSetImpl<Instruction *> &ConditionalAssumes) const;
+ /// \p MaskedOp is a list of instructions that have to be transformed into
+ /// calls to the appropriate masked intrinsic when the loop is vectorized.
+ /// \p ConditionalAssumes is a list of assume instructions in predicated
+ /// blocks that must be dropped if the CFG gets flattened.
+ bool blockCanBePredicated(
+ BasicBlock *BB, SmallPtrSetImpl<Value *> &SafePtrs,
+ SmallPtrSetImpl<const Instruction *> &MaskedOp,
+ SmallPtrSetImpl<Instruction *> &ConditionalAssumes) const;
/// Updates the vectorization state by adding \p Phi to the inductions list.
/// This can set \p Phi as the main induction of the loop if \p Phi is a
@@ -521,10 +521,10 @@ private:
/// Assume instructions in predicated blocks must be dropped if the CFG gets
/// flattened.
SmallPtrSet<Instruction *, 8> ConditionalAssumes;
-
- /// BFI and PSI are used to check for profile guided size optimizations.
- BlockFrequencyInfo *BFI;
- ProfileSummaryInfo *PSI;
+
+ /// BFI and PSI are used to check for profile guided size optimizations.
+ BlockFrequencyInfo *BFI;
+ ProfileSummaryInfo *PSI;
};
} // namespace llvm
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/SLPVectorizer.h b/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/SLPVectorizer.h
index 7fe02f6714..b63850ce9f 100644
--- a/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/SLPVectorizer.h
+++ b/contrib/libs/llvm12/include/llvm/Transforms/Vectorize/SLPVectorizer.h
@@ -33,7 +33,7 @@
namespace llvm {
-class AAResults;
+class AAResults;
class AssumptionCache;
class BasicBlock;
class CmpInst;
@@ -41,7 +41,7 @@ class DataLayout;
class DemandedBits;
class DominatorTree;
class Function;
-class GetElementPtrInst;
+class GetElementPtrInst;
class InsertElementInst;
class InsertValueInst;
class Instruction;
@@ -71,7 +71,7 @@ struct SLPVectorizerPass : public PassInfoMixin<SLPVectorizerPass> {
ScalarEvolution *SE = nullptr;
TargetTransformInfo *TTI = nullptr;
TargetLibraryInfo *TLI = nullptr;
- AAResults *AA = nullptr;
+ AAResults *AA = nullptr;
LoopInfo *LI = nullptr;
DominatorTree *DT = nullptr;
AssumptionCache *AC = nullptr;
@@ -83,7 +83,7 @@ public:
// Glue for old PM.
bool runImpl(Function &F, ScalarEvolution *SE_, TargetTransformInfo *TTI_,
- TargetLibraryInfo *TLI_, AAResults *AA_, LoopInfo *LI_,
+ TargetLibraryInfo *TLI_, AAResults *AA_, LoopInfo *LI_,
DominatorTree *DT_, AssumptionCache *AC_, DemandedBits *DB_,
OptimizationRemarkEmitter *ORE_);