@@ -1837,14 +1837,11 @@ struct IRAttributeManifest {
18371837};
18381838
18391839// / Helper to tie a abstract state implementation to an abstract attribute.
1840- template <typename StateTy, typename Base, class ... Ts >
1841- struct StateWrapper : public Base , public StateTy {
1840+ template <typename StateTy, typename Base>
1841+ struct StateWrapper : public StateTy , public Base {
18421842 // / Provide static access to the type of the state.
18431843 using StateType = StateTy;
18441844
1845- StateWrapper (const IRPosition &IRP, Ts... Args)
1846- : Base(IRP), StateTy(Args...) {}
1847-
18481845 // / See AbstractAttribute::getState(...).
18491846 StateType &getState () override { return *this ; }
18501847
@@ -1854,15 +1851,15 @@ struct StateWrapper : public Base, public StateTy {
18541851
18551852// / Helper class that provides common functionality to manifest IR attributes.
18561853template <Attribute::AttrKind AK, typename Base>
1857- struct IRAttribute : public Base {
1858- IRAttribute (const IRPosition &IRP) : Base(IRP) {}
1854+ struct IRAttribute : public IRPosition , public Base {
1855+ IRAttribute (const IRPosition &IRP) : IRPosition(IRP) {}
1856+ ~IRAttribute () {}
18591857
18601858 // / See AbstractAttribute::initialize(...).
18611859 virtual void initialize (Attributor &A) override {
18621860 const IRPosition &IRP = this ->getIRPosition ();
18631861 if (isa<UndefValue>(IRP.getAssociatedValue ()) ||
1864- this ->hasAttr (getAttrKind (), /* IgnoreSubsumingPositions */ false ,
1865- &A)) {
1862+ hasAttr (getAttrKind (), /* IgnoreSubsumingPositions */ false , &A)) {
18661863 this ->getState ().indicateOptimisticFixpoint ();
18671864 return ;
18681865 }
@@ -1882,12 +1879,11 @@ struct IRAttribute : public Base {
18821879
18831880 // / See AbstractAttribute::manifest(...).
18841881 ChangeStatus manifest (Attributor &A) override {
1885- if (isa<UndefValue>(this -> getIRPosition ().getAssociatedValue ()))
1882+ if (isa<UndefValue>(getIRPosition ().getAssociatedValue ()))
18861883 return ChangeStatus::UNCHANGED;
18871884 SmallVector<Attribute, 4 > DeducedAttrs;
1888- getDeducedAttributes (this ->getAnchorValue ().getContext (), DeducedAttrs);
1889- return IRAttributeManifest::manifestAttrs (A, this ->getIRPosition (),
1890- DeducedAttrs);
1885+ getDeducedAttributes (getAnchorValue ().getContext (), DeducedAttrs);
1886+ return IRAttributeManifest::manifestAttrs (A, getIRPosition (), DeducedAttrs);
18911887 }
18921888
18931889 // / Return the kind that identifies the abstract attribute implementation.
@@ -1898,6 +1894,9 @@ struct IRAttribute : public Base {
18981894 SmallVectorImpl<Attribute> &Attrs) const {
18991895 Attrs.emplace_back (Attribute::get (Ctx, getAttrKind ()));
19001896 }
1897+
1898+ // / Return an IR position, see struct IRPosition.
1899+ const IRPosition &getIRPosition () const override { return *this ; }
19011900};
19021901
19031902// / Base struct for all "concrete attribute" deductions.
@@ -1943,11 +1942,9 @@ struct IRAttribute : public Base {
19431942// / both directions will be added in the future.
19441943// / NOTE: The mechanics of adding a new "concrete" abstract attribute are
19451944// / described in the file comment.
1946- struct AbstractAttribute : public IRPosition {
1945+ struct AbstractAttribute {
19471946 using StateType = AbstractState;
19481947
1949- AbstractAttribute (const IRPosition &IRP) : IRPosition(IRP) {}
1950-
19511948 // / Virtual destructor.
19521949 virtual ~AbstractAttribute () {}
19531950
@@ -1966,8 +1963,7 @@ struct AbstractAttribute : public IRPosition {
19661963 virtual const StateType &getState () const = 0;
19671964
19681965 // / Return an IR position, see struct IRPosition.
1969- const IRPosition &getIRPosition () const { return *this ; };
1970- IRPosition &getIRPosition () { return *this ; };
1966+ virtual const IRPosition &getIRPosition () const = 0;
19711967
19721968 // / Helper functions, for debug purposes only.
19731969 // /{
@@ -2183,9 +2179,9 @@ struct AAWillReturn
21832179
21842180// / An abstract attribute for undefined behavior.
21852181struct AAUndefinedBehavior
2186- : public StateWrapper<BooleanState, AbstractAttribute> {
2187- using Base = StateWrapper<BooleanState, AbstractAttribute>;
2188- AAUndefinedBehavior (const IRPosition &IRP, Attributor &A) : Base (IRP) {}
2182+ : public StateWrapper<BooleanState, AbstractAttribute>,
2183+ public IRPosition {
2184+ AAUndefinedBehavior (const IRPosition &IRP, Attributor &A) : IRPosition (IRP) {}
21892185
21902186 // / Return true if "undefined behavior" is assumed.
21912187 bool isAssumedToCauseUB () const { return getAssumed (); }
@@ -2199,6 +2195,9 @@ struct AAUndefinedBehavior
21992195 // / Return true if "undefined behavior" is known for a specific instruction.
22002196 virtual bool isKnownToCauseUB (Instruction *I) const = 0;
22012197
2198+ // / Return an IR position, see struct IRPosition.
2199+ const IRPosition &getIRPosition () const override { return *this ; }
2200+
22022201 // / Create an abstract attribute view for the position \p IRP.
22032202 static AAUndefinedBehavior &createForPosition (const IRPosition &IRP,
22042203 Attributor &A);
@@ -2208,9 +2207,9 @@ struct AAUndefinedBehavior
22082207};
22092208
22102209// / An abstract interface to determine reachability of point A to B.
2211- struct AAReachability : public StateWrapper <BooleanState, AbstractAttribute> {
2212- using Base = StateWrapper<BooleanState, AbstractAttribute>;
2213- AAReachability (const IRPosition &IRP, Attributor &A) : Base (IRP) {}
2210+ struct AAReachability : public StateWrapper <BooleanState, AbstractAttribute>,
2211+ public IRPosition {
2212+ AAReachability (const IRPosition &IRP, Attributor &A) : IRPosition (IRP) {}
22142213
22152214 // / Returns true if 'From' instruction is assumed to reach, 'To' instruction.
22162215 // / Users should provide two positions they are interested in, and the class
@@ -2227,6 +2226,9 @@ struct AAReachability : public StateWrapper<BooleanState, AbstractAttribute> {
22272226 return isPotentiallyReachable (From, To);
22282227 }
22292228
2229+ // / Return an IR position, see struct IRPosition.
2230+ const IRPosition &getIRPosition () const override { return *this ; }
2231+
22302232 // / Create an abstract attribute view for the position \p IRP.
22312233 static AAReachability &createForPosition (const IRPosition &IRP,
22322234 Attributor &A);
@@ -2293,9 +2295,9 @@ struct AANoReturn
22932295};
22942296
22952297// / An abstract interface for liveness abstract attribute.
2296- struct AAIsDead : public StateWrapper <BooleanState, AbstractAttribute> {
2297- using Base = StateWrapper<BooleanState, AbstractAttribute>;
2298- AAIsDead (const IRPosition &IRP, Attributor &A) : Base (IRP) {}
2298+ struct AAIsDead : public StateWrapper <BooleanState, AbstractAttribute>,
2299+ public IRPosition {
2300+ AAIsDead (const IRPosition &IRP, Attributor &A) : IRPosition (IRP) {}
22992301
23002302protected:
23012303 // / The query functions are protected such that other attributes need to go
@@ -2334,6 +2336,9 @@ struct AAIsDead : public StateWrapper<BooleanState, AbstractAttribute> {
23342336 }
23352337
23362338public:
2339+ // / Return an IR position, see struct IRPosition.
2340+ const IRPosition &getIRPosition () const override { return *this ; }
2341+
23372342 // / Create an abstract attribute view for the position \p IRP.
23382343 static AAIsDead &createForPosition (const IRPosition &IRP, Attributor &A);
23392344
@@ -2609,9 +2614,12 @@ struct AANoCapture
26092614};
26102615
26112616// / An abstract interface for value simplify abstract attribute.
2612- struct AAValueSimplify : public StateWrapper <BooleanState, AbstractAttribute> {
2613- using Base = StateWrapper<BooleanState, AbstractAttribute>;
2614- AAValueSimplify (const IRPosition &IRP, Attributor &A) : Base(IRP) {}
2617+ struct AAValueSimplify : public StateWrapper <BooleanState, AbstractAttribute>,
2618+ public IRPosition {
2619+ AAValueSimplify (const IRPosition &IRP, Attributor &A) : IRPosition(IRP) {}
2620+
2621+ // / Return an IR position, see struct IRPosition.
2622+ const IRPosition &getIRPosition () const { return *this ; }
26152623
26162624 // / Return an assumed simplified value if a single candidate is found. If
26172625 // / there cannot be one, return original value. If it is not clear yet, return
@@ -2626,16 +2634,19 @@ struct AAValueSimplify : public StateWrapper<BooleanState, AbstractAttribute> {
26262634 static const char ID;
26272635};
26282636
2629- struct AAHeapToStack : public StateWrapper <BooleanState, AbstractAttribute> {
2630- using Base = StateWrapper<BooleanState, AbstractAttribute>;
2631- AAHeapToStack (const IRPosition &IRP, Attributor &A) : Base (IRP) {}
2637+ struct AAHeapToStack : public StateWrapper <BooleanState, AbstractAttribute>,
2638+ public IRPosition {
2639+ AAHeapToStack (const IRPosition &IRP, Attributor &A) : IRPosition (IRP) {}
26322640
26332641 // / Returns true if HeapToStack conversion is assumed to be possible.
26342642 bool isAssumedHeapToStack () const { return getAssumed (); }
26352643
26362644 // / Returns true if HeapToStack conversion is known to be possible.
26372645 bool isKnownHeapToStack () const { return getKnown (); }
26382646
2647+ // / Return an IR position, see struct IRPosition.
2648+ const IRPosition &getIRPosition () const { return *this ; }
2649+
26392650 // / Create an abstract attribute view for the position \p IRP.
26402651 static AAHeapToStack &createForPosition (const IRPosition &IRP, Attributor &A);
26412652
@@ -2653,10 +2664,9 @@ struct AAHeapToStack : public StateWrapper<BooleanState, AbstractAttribute> {
26532664// / (=nocapture), it is (for now) not written (=readonly & noalias), we know
26542665// / what values are necessary to make the private copy look like the original
26552666// / one, and the values we need can be loaded (=dereferenceable).
2656- struct AAPrivatizablePtr
2657- : public StateWrapper<BooleanState, AbstractAttribute> {
2658- using Base = StateWrapper<BooleanState, AbstractAttribute>;
2659- AAPrivatizablePtr (const IRPosition &IRP, Attributor &A) : Base(IRP) {}
2667+ struct AAPrivatizablePtr : public StateWrapper <BooleanState, AbstractAttribute>,
2668+ public IRPosition {
2669+ AAPrivatizablePtr (const IRPosition &IRP, Attributor &A) : IRPosition(IRP) {}
26602670
26612671 // / Returns true if pointer privatization is assumed to be possible.
26622672 bool isAssumedPrivatizablePtr () const { return getAssumed (); }
@@ -2668,6 +2678,13 @@ struct AAPrivatizablePtr
26682678 // / value. None means it is not clear yet, nullptr means there is none.
26692679 virtual Optional<Type *> getPrivatizableType () const = 0;
26702680
2681+ // / Return an IR position, see struct IRPosition.
2682+ // /
2683+ // /{
2684+ IRPosition &getIRPosition () { return *this ; }
2685+ const IRPosition &getIRPosition () const { return *this ; }
2686+ // /}
2687+
26712688 // / Create an abstract attribute view for the position \p IRP.
26722689 static AAPrivatizablePtr &createForPosition (const IRPosition &IRP,
26732690 Attributor &A);
@@ -2886,11 +2903,15 @@ struct AAMemoryLocation
28862903};
28872904
28882905// / An abstract interface for range value analysis.
2889- struct AAValueConstantRange
2890- : public StateWrapper<IntegerRangeState, AbstractAttribute, uint32_t > {
2891- using Base = StateWrapper<IntegerRangeState, AbstractAttribute, uint32_t >;
2906+ struct AAValueConstantRange : public IntegerRangeState ,
2907+ public AbstractAttribute,
2908+ public IRPosition {
28922909 AAValueConstantRange (const IRPosition &IRP, Attributor &A)
2893- : Base(IRP, IRP.getAssociatedType()->getIntegerBitWidth ()) {}
2910+ : IntegerRangeState(IRP.getAssociatedType()->getIntegerBitWidth ()),
2911+ IRPosition(IRP) {}
2912+
2913+ // / Return an IR position, see struct IRPosition.
2914+ const IRPosition &getIRPosition () const override { return *this ; }
28942915
28952916 // / See AbstractAttribute::getState(...).
28962917 IntegerRangeState &getState () override { return *this ; }
0 commit comments