@@ -821,19 +821,31 @@ struct IndexCall : public PointerUnion<CallsiteInfo *, AllocInfo *> {
821
821
822
822
IndexCall *operator ->() { return this ; }
823
823
824
- PointerUnion<CallsiteInfo *, AllocInfo *> getBase () const { return *this ; }
825
-
826
824
void print (raw_ostream &OS) const {
827
- if (auto *AI = llvm::dyn_cast_if_present<AllocInfo *>(getBase ())) {
825
+ PointerUnion<CallsiteInfo *, AllocInfo *> Base = *this ;
826
+ if (auto *AI = llvm::dyn_cast_if_present<AllocInfo *>(Base)) {
828
827
OS << *AI;
829
828
} else {
830
- auto *CI = llvm::dyn_cast_if_present<CallsiteInfo *>(getBase () );
829
+ auto *CI = llvm::dyn_cast_if_present<CallsiteInfo *>(Base );
831
830
assert (CI);
832
831
OS << *CI;
833
832
}
834
833
}
835
834
};
835
+ } // namespace
836
+
837
+ namespace llvm {
838
+ template <> struct simplify_type <IndexCall> {
839
+ using SimpleType = PointerUnion<CallsiteInfo *, AllocInfo *>;
840
+ static SimpleType getSimplifiedValue (IndexCall &Val) { return Val; }
841
+ };
842
+ template <> struct simplify_type <const IndexCall> {
843
+ using SimpleType = const PointerUnion<CallsiteInfo *, AllocInfo *>;
844
+ static SimpleType getSimplifiedValue (const IndexCall &Val) { return Val; }
845
+ };
846
+ } // namespace llvm
836
847
848
+ namespace {
837
849
// / CRTP derived class for graphs built from summary index (ThinLTO).
838
850
class IndexCallsiteContextGraph
839
851
: public CallsiteContextGraph<IndexCallsiteContextGraph, FunctionSummary,
@@ -1877,9 +1889,9 @@ uint64_t ModuleCallsiteContextGraph::getLastStackId(Instruction *Call) {
1877
1889
}
1878
1890
1879
1891
uint64_t IndexCallsiteContextGraph::getLastStackId (IndexCall &Call) {
1880
- assert (isa<CallsiteInfo *>(Call. getBase () ));
1892
+ assert (isa<CallsiteInfo *>(Call));
1881
1893
CallStack<CallsiteInfo, SmallVector<unsigned >::const_iterator>
1882
- CallsiteContext (dyn_cast_if_present<CallsiteInfo *>(Call. getBase () ));
1894
+ CallsiteContext (dyn_cast_if_present<CallsiteInfo *>(Call));
1883
1895
// Need to convert index into stack id.
1884
1896
return Index.getStackIdAtIndex (CallsiteContext.back ());
1885
1897
}
@@ -1911,10 +1923,10 @@ std::string IndexCallsiteContextGraph::getLabel(const FunctionSummary *Func,
1911
1923
unsigned CloneNo) const {
1912
1924
auto VI = FSToVIMap.find (Func);
1913
1925
assert (VI != FSToVIMap.end ());
1914
- if (isa<AllocInfo *>(Call. getBase () ))
1926
+ if (isa<AllocInfo *>(Call))
1915
1927
return (VI->second .name () + " -> alloc" ).str ();
1916
1928
else {
1917
- auto *Callsite = dyn_cast_if_present<CallsiteInfo *>(Call. getBase () );
1929
+ auto *Callsite = dyn_cast_if_present<CallsiteInfo *>(Call);
1918
1930
return (VI->second .name () + " -> " +
1919
1931
getMemProfFuncName (Callsite->Callee .name (),
1920
1932
Callsite->Clones [CloneNo]))
@@ -1933,9 +1945,9 @@ ModuleCallsiteContextGraph::getStackIdsWithContextNodesForCall(
1933
1945
1934
1946
std::vector<uint64_t >
1935
1947
IndexCallsiteContextGraph::getStackIdsWithContextNodesForCall (IndexCall &Call) {
1936
- assert (isa<CallsiteInfo *>(Call. getBase () ));
1948
+ assert (isa<CallsiteInfo *>(Call));
1937
1949
CallStack<CallsiteInfo, SmallVector<unsigned >::const_iterator>
1938
- CallsiteContext (dyn_cast_if_present<CallsiteInfo *>(Call. getBase () ));
1950
+ CallsiteContext (dyn_cast_if_present<CallsiteInfo *>(Call));
1939
1951
return getStackIdsWithContextNodes<CallsiteInfo,
1940
1952
SmallVector<unsigned >::const_iterator>(
1941
1953
CallsiteContext);
@@ -2696,8 +2708,7 @@ bool IndexCallsiteContextGraph::findProfiledCalleeThroughTailCalls(
2696
2708
2697
2709
const FunctionSummary *
2698
2710
IndexCallsiteContextGraph::getCalleeFunc (IndexCall &Call) {
2699
- ValueInfo Callee =
2700
- dyn_cast_if_present<CallsiteInfo *>(Call.getBase ())->Callee ;
2711
+ ValueInfo Callee = dyn_cast_if_present<CallsiteInfo *>(Call)->Callee ;
2701
2712
if (Callee.getSummaryList ().empty ())
2702
2713
return nullptr ;
2703
2714
return dyn_cast<FunctionSummary>(Callee.getSummaryList ()[0 ]->getBaseObject ());
@@ -2707,8 +2718,7 @@ bool IndexCallsiteContextGraph::calleeMatchesFunc(
2707
2718
IndexCall &Call, const FunctionSummary *Func,
2708
2719
const FunctionSummary *CallerFunc,
2709
2720
std::vector<std::pair<IndexCall, FunctionSummary *>> &FoundCalleeChain) {
2710
- ValueInfo Callee =
2711
- dyn_cast_if_present<CallsiteInfo *>(Call.getBase ())->Callee ;
2721
+ ValueInfo Callee = dyn_cast_if_present<CallsiteInfo *>(Call)->Callee ;
2712
2722
// If there is no summary list then this is a call to an externally defined
2713
2723
// symbol.
2714
2724
AliasSummary *Alias =
@@ -2751,10 +2761,8 @@ bool IndexCallsiteContextGraph::calleeMatchesFunc(
2751
2761
}
2752
2762
2753
2763
bool IndexCallsiteContextGraph::sameCallee (IndexCall &Call1, IndexCall &Call2) {
2754
- ValueInfo Callee1 =
2755
- dyn_cast_if_present<CallsiteInfo *>(Call1.getBase ())->Callee ;
2756
- ValueInfo Callee2 =
2757
- dyn_cast_if_present<CallsiteInfo *>(Call2.getBase ())->Callee ;
2764
+ ValueInfo Callee1 = dyn_cast_if_present<CallsiteInfo *>(Call1)->Callee ;
2765
+ ValueInfo Callee2 = dyn_cast_if_present<CallsiteInfo *>(Call2)->Callee ;
2758
2766
return Callee1 == Callee2;
2759
2767
}
2760
2768
@@ -3610,7 +3618,7 @@ IndexCallsiteContextGraph::cloneFunctionForCallsite(
3610
3618
// Confirm this matches the CloneNo provided by the caller, which is based on
3611
3619
// the number of function clones we have.
3612
3620
assert (CloneNo ==
3613
- (isa<AllocInfo *>(Call.call (). getBase () )
3621
+ (isa<AllocInfo *>(Call.call ())
3614
3622
? Call.call ().dyn_cast <AllocInfo *>()->Versions .size ()
3615
3623
: Call.call ().dyn_cast <CallsiteInfo *>()->Clones .size ()));
3616
3624
// Walk all the instructions in this function. Create a new version for
0 commit comments