Skip to content

Commit 27de435

Browse files
committed
[llvm] export private API so that VectorizeTests builds against Windows DLL
1 parent f75abf2 commit 27de435

File tree

6 files changed

+64
-48
lines changed

6 files changed

+64
-48
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "llvm/IR/DebugLoc.h"
3939
#include "llvm/IR/FMF.h"
4040
#include "llvm/IR/Operator.h"
41+
#include "llvm/Support/Compiler.h"
4142
#include "llvm/Support/InstructionCost.h"
4243
#include <algorithm>
4344
#include <cassert>
@@ -77,7 +78,7 @@ using VPlanPtr = std::unique_ptr<VPlan>;
7778

7879
/// VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
7980
/// A VPBlockBase can be either a VPBasicBlock or a VPRegionBlock.
80-
class VPBlockBase {
81+
class LLVM_ABI_FOR_TEST VPBlockBase {
8182
friend class VPBlockUtils;
8283

8384
const unsigned char SubclassID; ///< Subclass identifier (for isa/dyn_cast).
@@ -384,9 +385,10 @@ class VPBlockBase {
384385
/// and is responsible for deleting its defined values. Single-value
385386
/// recipes must inherit from VPSingleDef instead of inheriting from both
386387
/// VPRecipeBase and VPValue separately.
387-
class VPRecipeBase : public ilist_node_with_parent<VPRecipeBase, VPBasicBlock>,
388-
public VPDef,
389-
public VPUser {
388+
class LLVM_ABI_FOR_TEST VPRecipeBase
389+
: public ilist_node_with_parent<VPRecipeBase, VPBasicBlock>,
390+
public VPDef,
391+
public VPUser {
390392
friend VPBasicBlock;
391393
friend class VPBlockUtils;
392394

@@ -634,7 +636,7 @@ class VPIRFlags {
634636
char AllowContract : 1;
635637
char ApproxFunc : 1;
636638

637-
FastMathFlagsTy(const FastMathFlags &FMF);
639+
LLVM_ABI_FOR_TEST FastMathFlagsTy(const FastMathFlags &FMF);
638640
};
639641

640642
OperationType OpType;
@@ -786,7 +788,7 @@ class VPIRFlags {
786788
/// Returns true if the recipe has fast-math flags.
787789
bool hasFastMathFlags() const { return OpType == OperationType::FPMathOp; }
788790

789-
FastMathFlags getFastMathFlags() const;
791+
LLVM_ABI_FOR_TEST FastMathFlags getFastMathFlags() const;
790792

791793
/// Returns true if the recipe has non-negative flag.
792794
bool hasNonNegFlag() const { return OpType == OperationType::NonNegOp; }
@@ -870,7 +872,7 @@ struct VPRecipeWithIRFlags : public VPSingleDefRecipe, public VPIRFlags {
870872

871873
/// Helper to access the operand that contains the unroll part for this recipe
872874
/// after unrolling.
873-
template <unsigned PartOpIdx> class VPUnrollPartAccessor {
875+
template <unsigned PartOpIdx> class LLVM_ABI_FOR_TEST VPUnrollPartAccessor {
874876
protected:
875877
/// Return the VPValue operand containing the unroll part or null if there is
876878
/// no such operand.
@@ -912,9 +914,9 @@ class VPIRMetadata {
912914
/// While as any Recipe it may generate a sequence of IR instructions when
913915
/// executed, these instructions would always form a single-def expression as
914916
/// the VPInstruction is also a single def-use vertex.
915-
class VPInstruction : public VPRecipeWithIRFlags,
916-
public VPIRMetadata,
917-
public VPUnrollPartAccessor<1> {
917+
class LLVM_ABI_FOR_TEST VPInstruction : public VPRecipeWithIRFlags,
918+
public VPIRMetadata,
919+
public VPUnrollPartAccessor<1> {
918920
friend class VPlanSlp;
919921

920922
public:
@@ -1198,7 +1200,7 @@ class VPPhiAccessors {
11981200
#endif
11991201
};
12001202

1201-
struct VPPhi : public VPInstruction, public VPPhiAccessors {
1203+
struct LLVM_ABI_FOR_TEST VPPhi : public VPInstruction, public VPPhiAccessors {
12021204
VPPhi(ArrayRef<VPValue *> Operands, DebugLoc DL, const Twine &Name = "")
12031205
: VPInstruction(Instruction::PHI, Operands, DL, Name) {}
12041206

@@ -1319,7 +1321,8 @@ struct VPIRPhi : public VPIRInstruction, public VPPhiAccessors {
13191321
/// opcode and operands of the recipe. This recipe covers most of the
13201322
/// traditional vectorization cases where each recipe transforms into a
13211323
/// vectorized version of itself.
1322-
class VPWidenRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
1324+
class LLVM_ABI_FOR_TEST VPWidenRecipe : public VPRecipeWithIRFlags,
1325+
public VPIRMetadata {
13231326
unsigned Opcode;
13241327

13251328
public:
@@ -1504,7 +1507,8 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
15041507
};
15051508

15061509
/// A recipe for widening Call instructions using library calls.
1507-
class VPWidenCallRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
1510+
class LLVM_ABI_FOR_TEST VPWidenCallRecipe : public VPRecipeWithIRFlags,
1511+
public VPIRMetadata {
15081512
/// Variant stores a pointer to the chosen function. There is a 1:1 mapping
15091513
/// between a given VF and the chosen vectorized variant, so there will be a
15101514
/// different VPlan for each VF with a valid variant.
@@ -1598,7 +1602,8 @@ class VPHistogramRecipe : public VPRecipeBase {
15981602
};
15991603

16001604
/// A recipe for widening select instructions.
1601-
struct VPWidenSelectRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
1605+
struct LLVM_ABI_FOR_TEST VPWidenSelectRecipe : public VPRecipeWithIRFlags,
1606+
public VPIRMetadata {
16021607
VPWidenSelectRecipe(SelectInst &I, ArrayRef<VPValue *> Operands)
16031608
: VPRecipeWithIRFlags(VPDef::VPWidenSelectSC, Operands, I),
16041609
VPIRMetadata(I) {}
@@ -1642,7 +1647,7 @@ struct VPWidenSelectRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
16421647
};
16431648

16441649
/// A recipe for handling GEP instructions.
1645-
class VPWidenGEPRecipe : public VPRecipeWithIRFlags {
1650+
class LLVM_ABI_FOR_TEST VPWidenGEPRecipe : public VPRecipeWithIRFlags {
16461651
bool isPointerLoopInvariant() const {
16471652
return getOperand(0)->isDefinedOutsideLoopRegions();
16481653
}
@@ -1835,7 +1840,8 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags,
18351840
/// * VPWidenPointerInductionRecipe: Generate vector and scalar values for a
18361841
/// pointer induction. Produces either a vector PHI per-part or scalar values
18371842
/// per-lane based on the canonical induction.
1838-
class VPHeaderPHIRecipe : public VPSingleDefRecipe, public VPPhiAccessors {
1843+
class LLVM_ABI_FOR_TEST VPHeaderPHIRecipe : public VPSingleDefRecipe,
1844+
public VPPhiAccessors {
18391845
protected:
18401846
VPHeaderPHIRecipe(unsigned char VPDefID, Instruction *UnderlyingInstr,
18411847
VPValue *Start, DebugLoc DL = DebugLoc::getUnknown())
@@ -2112,7 +2118,8 @@ class VPWidenPointerInductionRecipe : public VPWidenInductionRecipe,
21122118
/// recipe is placed in an entry block to a (non-replicate) region, it must have
21132119
/// exactly 2 incoming values, the first from the predecessor of the region and
21142120
/// the second from the exiting block of the region.
2115-
class VPWidenPHIRecipe : public VPSingleDefRecipe, public VPPhiAccessors {
2121+
class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe,
2122+
public VPPhiAccessors {
21162123
/// Name to use for the generated IR instruction for the widened phi.
21172124
std::string Name;
21182125

@@ -2257,7 +2264,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
22572264

22582265
/// A recipe for vectorizing a phi-node as a sequence of mask-based select
22592266
/// instructions.
2260-
class VPBlendRecipe : public VPSingleDefRecipe {
2267+
class LLVM_ABI_FOR_TEST VPBlendRecipe : public VPSingleDefRecipe {
22612268
public:
22622269
/// The blend operation is a User of the incoming values and of their
22632270
/// respective masks, ordered [I0, M0, I1, M1, I2, M2, ...]. Note that M0 can
@@ -2324,7 +2331,7 @@ class VPBlendRecipe : public VPSingleDefRecipe {
23242331
/// or stores into one wide load/store and shuffles. The first operand of a
23252332
/// VPInterleave recipe is the address, followed by the stored values, followed
23262333
/// by an optional mask.
2327-
class VPInterleaveRecipe : public VPRecipeBase {
2334+
class LLVM_ABI_FOR_TEST VPInterleaveRecipe : public VPRecipeBase {
23282335
const InterleaveGroup<Instruction> *IG;
23292336

23302337
/// Indicates if the interleave group is in a conditional block and requires a
@@ -2424,7 +2431,7 @@ class VPInterleaveRecipe : public VPRecipeBase {
24242431
/// A recipe to represent inloop reduction operations, performing a reduction on
24252432
/// a vector operand into a scalar value, and adding the result to a chain.
24262433
/// The Operands are {ChainOp, VecOp, [Condition]}.
2427-
class VPReductionRecipe : public VPRecipeWithIRFlags {
2434+
class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
24282435
/// The recurrence kind for the reduction in question.
24292436
RecurKind RdxKind;
24302437
bool IsOrdered;
@@ -2570,7 +2577,7 @@ class VPPartialReductionRecipe : public VPReductionRecipe {
25702577
/// intrinsics, performing a reduction on a vector operand with the explicit
25712578
/// vector length (EVL) into a scalar value, and adding the result to a chain.
25722579
/// The Operands are {ChainOp, VecOp, EVL, [Condition]}.
2573-
class VPReductionEVLRecipe : public VPReductionRecipe {
2580+
class LLVM_ABI_FOR_TEST VPReductionEVLRecipe : public VPReductionRecipe {
25742581
public:
25752582
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp,
25762583
DebugLoc DL = {})
@@ -2613,7 +2620,8 @@ class VPReductionEVLRecipe : public VPReductionRecipe {
26132620
/// copies of the original scalar type, one per lane, instead of producing a
26142621
/// single copy of widened type for all lanes. If the instruction is known to be
26152622
/// a single scalar, only one copy, per lane zero, will be generated.
2616-
class VPReplicateRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
2623+
class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags,
2624+
public VPIRMetadata {
26172625
/// Indicator if only a single replica per lane is needed.
26182626
bool IsSingleScalar;
26192627

@@ -2691,7 +2699,7 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
26912699
};
26922700

26932701
/// A recipe for generating conditional branches on the bits of a mask.
2694-
class VPBranchOnMaskRecipe : public VPRecipeBase {
2702+
class LLVM_ABI_FOR_TEST VPBranchOnMaskRecipe : public VPRecipeBase {
26952703
public:
26962704
VPBranchOnMaskRecipe(VPValue *BlockInMask, DebugLoc DL)
26972705
: VPRecipeBase(VPDef::VPBranchOnMaskSC, {BlockInMask}, DL) {}
@@ -2848,7 +2856,7 @@ class VPExpressionRecipe : public VPSingleDefRecipe {
28482856
/// order to merge values that are set under such a branch and feed their uses.
28492857
/// The phi nodes can be scalar or vector depending on the users of the value.
28502858
/// This recipe works in concert with VPBranchOnMaskRecipe.
2851-
class VPPredInstPHIRecipe : public VPSingleDefRecipe {
2859+
class LLVM_ABI_FOR_TEST VPPredInstPHIRecipe : public VPSingleDefRecipe {
28522860
public:
28532861
/// Construct a VPPredInstPHIRecipe given \p PredInst whose value needs a phi
28542862
/// nodes after merging back from a Branch-on-Mask.
@@ -2889,7 +2897,8 @@ class VPPredInstPHIRecipe : public VPSingleDefRecipe {
28892897

28902898
/// A common base class for widening memory operations. An optional mask can be
28912899
/// provided as the last operand.
2892-
class VPWidenMemoryRecipe : public VPRecipeBase, public VPIRMetadata {
2900+
class LLVM_ABI_FOR_TEST VPWidenMemoryRecipe : public VPRecipeBase,
2901+
public VPIRMetadata {
28932902
protected:
28942903
Instruction &Ingredient;
28952904

@@ -2970,7 +2979,8 @@ class VPWidenMemoryRecipe : public VPRecipeBase, public VPIRMetadata {
29702979

29712980
/// A recipe for widening load operations, using the address to load from and an
29722981
/// optional mask.
2973-
struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
2982+
struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final : public VPWidenMemoryRecipe,
2983+
public VPValue {
29742984
VPWidenLoadRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask,
29752985
bool Consecutive, bool Reverse,
29762986
const VPIRMetadata &Metadata, DebugLoc DL)
@@ -3049,7 +3059,7 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
30493059

30503060
/// A recipe for widening store operations, using the stored value, the address
30513061
/// to store to and an optional mask.
3052-
struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
3062+
struct LLVM_ABI_FOR_TEST VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
30533063
VPWidenStoreRecipe(StoreInst &Store, VPValue *Addr, VPValue *StoredVal,
30543064
VPValue *Mask, bool Consecutive, bool Reverse,
30553065
const VPIRMetadata &Metadata, DebugLoc DL)
@@ -3409,8 +3419,8 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe {
34093419

34103420
/// A recipe for handling phi nodes of integer and floating-point inductions,
34113421
/// producing their scalar values.
3412-
class VPScalarIVStepsRecipe : public VPRecipeWithIRFlags,
3413-
public VPUnrollPartAccessor<3> {
3422+
class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags,
3423+
public VPUnrollPartAccessor<3> {
34143424
Instruction::BinaryOps InductionOpcode;
34153425

34163426
public:
@@ -3519,7 +3529,7 @@ struct CastInfo<VPPhiAccessors, const VPRecipeBase *>
35193529
/// VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph. It
35203530
/// holds a sequence of zero or more VPRecipe's each representing a sequence of
35213531
/// output IR instructions. All PHI-like recipes must come before any non-PHI recipes.
3522-
class VPBasicBlock : public VPBlockBase {
3532+
class LLVM_ABI_FOR_TEST VPBasicBlock : public VPBlockBase {
35233533
friend class VPlan;
35243534

35253535
/// Use VPlan::createVPBasicBlock to create VPBasicBlocks.
@@ -3707,7 +3717,7 @@ class VPIRBasicBlock : public VPBasicBlock {
37073717
/// this replication indicator helps to keep a single model for multiple
37083718
/// candidate VF's. The actual replication takes place only once the desired VF
37093719
/// and UF have been determined.
3710-
class VPRegionBlock : public VPBlockBase {
3720+
class LLVM_ABI_FOR_TEST VPRegionBlock : public VPBlockBase {
37113721
friend class VPlan;
37123722

37133723
/// Hold the Single Entry of the SESE region modelled by the VPRegionBlock.
@@ -3896,7 +3906,7 @@ class VPlan {
38963906
TripCount = TC;
38973907
}
38983908

3899-
~VPlan();
3909+
LLVM_ABI_FOR_TEST ~VPlan();
39003910

39013911
void setEntry(VPBasicBlock *VPBB) {
39023912
Entry = VPBB;
@@ -3926,8 +3936,8 @@ class VPlan {
39263936
}
39273937

39283938
/// Returns the VPRegionBlock of the vector loop.
3929-
VPRegionBlock *getVectorLoopRegion();
3930-
const VPRegionBlock *getVectorLoopRegion() const;
3939+
LLVM_ABI_FOR_TEST VPRegionBlock *getVectorLoopRegion();
3940+
LLVM_ABI_FOR_TEST const VPRegionBlock *getVectorLoopRegion() const;
39313941

39323942
/// Returns the 'middle' block of the plan, that is the block that selects
39333943
/// whether to execute the scalar tail loop or the exit block from the loop
@@ -4166,7 +4176,7 @@ class VPlan {
41664176
/// instructions in \p IRBB, except its terminator which is managed by the
41674177
/// successors of the block in VPlan. The returned block is owned by the VPlan
41684178
/// and deleted once the VPlan is destroyed.
4169-
VPIRBasicBlock *createVPIRBasicBlock(BasicBlock *IRBB);
4179+
LLVM_ABI_FOR_TEST VPIRBasicBlock *createVPIRBasicBlock(BasicBlock *IRBB);
41704180

41714181
/// Returns true if the VPlan is based on a loop with an early exit. That is
41724182
/// the case if the VPlan has either more than one exit block or a single exit

llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/GraphTraits.h"
2121
#include "llvm/IR/Dominators.h"
2222
#include "llvm/Support/GenericDomTree.h"
23+
#include "llvm/Support/GenericDomTreeConstruction.h"
2324

2425
namespace llvm {
2526

llvm/lib/Transforms/Vectorize/VPlanSLP.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class VPInterleavedAccessInfo {
4747
InterleavedAccessInfo &IAI);
4848

4949
public:
50-
VPInterleavedAccessInfo(VPlan &Plan, InterleavedAccessInfo &IAI);
50+
LLVM_ABI_FOR_TEST VPInterleavedAccessInfo(VPlan &Plan,
51+
InterleavedAccessInfo &IAI);
5152
VPInterleavedAccessInfo(const VPInterleavedAccessInfo &) = delete;
5253
VPInterleavedAccessInfo &operator=(const VPInterleavedAccessInfo &) = delete;
5354

@@ -132,7 +133,7 @@ class VPlanSlp {
132133

133134
/// Tries to build an SLP tree rooted at \p Operands and returns a
134135
/// VPInstruction combining \p Operands, if they can be combined.
135-
VPInstruction *buildGraph(ArrayRef<VPValue *> Operands);
136+
LLVM_ABI_FOR_TEST VPInstruction *buildGraph(ArrayRef<VPValue *> Operands);
136137

137138
/// Return the width of the widest combined bundle in bits.
138139
unsigned getWidestBundleBits() const { return WidestBundleBits; }

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "VPlanVerifier.h"
1818
#include "llvm/ADT/STLFunctionalExtras.h"
1919
#include "llvm/Support/CommandLine.h"
20+
#include "llvm/Support/Compiler.h"
2021

2122
namespace llvm {
2223

@@ -53,7 +54,8 @@ struct VPlanTransforms {
5354
verifyVPlanIsValid(Plan);
5455
}
5556

56-
static std::unique_ptr<VPlan> buildPlainCFG(Loop *TheLoop, LoopInfo &LI);
57+
LLVM_ABI_FOR_TEST static std::unique_ptr<VPlan> buildPlainCFG(Loop *TheLoop,
58+
LoopInfo &LI);
5759

5860
/// Prepare the plan for vectorization. It will introduce a dedicated
5961
/// VPBasicBlock for the vector pre-header as well as a VPBasicBlock as exit
@@ -63,16 +65,14 @@ struct VPlanTransforms {
6365
/// blocks. \p InductionTy is the type of the canonical induction and used for
6466
/// related values, like the trip count expression. It also creates a VPValue
6567
/// expression for the original trip count.
66-
static void prepareForVectorization(VPlan &Plan, Type *InductionTy,
67-
PredicatedScalarEvolution &PSE,
68-
bool RequiresScalarEpilogueCheck,
69-
bool TailFolded, Loop *TheLoop,
70-
DebugLoc IVDL, bool HasUncountableExit,
71-
VFRange &Range);
68+
LLVM_ABI_FOR_TEST static void prepareForVectorization(
69+
VPlan &Plan, Type *InductionTy, PredicatedScalarEvolution &PSE,
70+
bool RequiresScalarEpilogueCheck, bool TailFolded, Loop *TheLoop,
71+
DebugLoc IVDL, bool HasUncountableExit, VFRange &Range);
7272

7373
/// Replace loops in \p Plan's flat CFG with VPRegionBlocks, turning \p Plan's
7474
/// flat CFG into a hierarchical CFG.
75-
static void createLoopRegions(VPlan &Plan);
75+
LLVM_ABI_FOR_TEST static void createLoopRegions(VPlan &Plan);
7676

7777
/// Wrap runtime check block \p CheckBlock in a VPIRBB and \p Cond in a
7878
/// VPValue and connect the block to \p Plan, using the VPValue as branch
@@ -83,7 +83,7 @@ struct VPlanTransforms {
8383
/// Replaces the VPInstructions in \p Plan with corresponding
8484
/// widen recipes. Returns false if any VPInstructions could not be converted
8585
/// to a wide recipe if needed.
86-
static bool tryToConvertVPInstructionsToVPRecipes(
86+
LLVM_ABI_FOR_TEST static bool tryToConvertVPInstructionsToVPRecipes(
8787
VPlanPtr &Plan,
8888
function_ref<const InductionDescriptor *(PHINode *)>
8989
GetIntOrFpInductionDescriptor,

llvm/lib/Transforms/Vectorize/VPlanValue.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/ADT/StringMap.h"
2727
#include "llvm/ADT/TinyPtrVector.h"
2828
#include "llvm/ADT/iterator_range.h"
29+
#include "llvm/Support/Compiler.h"
2930

3031
namespace llvm {
3132

@@ -44,7 +45,7 @@ class VPPhiAccessors;
4445
// flow into, within and out of the VPlan. VPValues can stand for live-ins
4546
// coming from the input IR and instructions which VPlan will generate if
4647
// executed.
47-
class VPValue {
48+
class LLVM_ABI_FOR_TEST VPValue {
4849
friend class VPDef;
4950
friend struct VPDoubleValueDef;
5051
friend class VPInterleaveRecipe;

0 commit comments

Comments
 (0)