12f09f445SMaksim Panchenko //===- bolt/Rewrite/BoltDiff.cpp ------------------------------------------===//
2a34c753fSRafael Auler //
3a34c753fSRafael Auler // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4a34c753fSRafael Auler // See https://llvm.org/LICENSE.txt for license information.
5a34c753fSRafael Auler // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6a34c753fSRafael Auler //
7a34c753fSRafael Auler //===----------------------------------------------------------------------===//
8a34c753fSRafael Auler //
9a34c753fSRafael Auler // RewriteInstance methods related to comparing one instance to another, used
10a34c753fSRafael Auler // by the boltdiff tool to print a report.
11a34c753fSRafael Auler //
12a34c753fSRafael Auler //===----------------------------------------------------------------------===//
13a34c753fSRafael Auler
14a34c753fSRafael Auler #include "bolt/Passes/IdenticalCodeFolding.h"
15a34c753fSRafael Auler #include "bolt/Profile/ProfileReaderBase.h"
16a34c753fSRafael Auler #include "bolt/Rewrite/RewriteInstance.h"
17a34c753fSRafael Auler #include "llvm/Support/CommandLine.h"
18a34c753fSRafael Auler
19a34c753fSRafael Auler #undef DEBUG_TYPE
20a34c753fSRafael Auler #define DEBUG_TYPE "boltdiff"
21a34c753fSRafael Auler
22a34c753fSRafael Auler using namespace llvm;
23a34c753fSRafael Auler using namespace object;
24a34c753fSRafael Auler using namespace bolt;
25a34c753fSRafael Auler
26a34c753fSRafael Auler namespace opts {
27a34c753fSRafael Auler extern cl::OptionCategory BoltDiffCategory;
28a34c753fSRafael Auler extern cl::opt<bool> NeverPrint;
29a34c753fSRafael Auler extern cl::opt<bool> ICF;
30a34c753fSRafael Auler
31b92436efSFangrui Song static cl::opt<bool> IgnoreLTOSuffix(
32b92436efSFangrui Song "ignore-lto-suffix",
33a34c753fSRafael Auler cl::desc("ignore lto_priv or const suffixes when matching functions"),
34b92436efSFangrui Song cl::init(true), cl::cat(BoltDiffCategory));
35a34c753fSRafael Auler
36b92436efSFangrui Song static cl::opt<bool> PrintUnmapped(
37b92436efSFangrui Song "print-unmapped",
38a34c753fSRafael Auler cl::desc("print functions of binary 2 that were not matched to any "
39a34c753fSRafael Auler "function in binary 1"),
40a34c753fSRafael Auler cl::cat(BoltDiffCategory));
41a34c753fSRafael Auler
42b92436efSFangrui Song static cl::opt<bool> PrintProfiledUnmapped(
43b92436efSFangrui Song "print-profiled-unmapped",
44a34c753fSRafael Auler cl::desc("print functions that have profile in binary 1 but do not "
45a34c753fSRafael Auler "in binary 2"),
46a34c753fSRafael Auler cl::cat(BoltDiffCategory));
47a34c753fSRafael Auler
48b92436efSFangrui Song static cl::opt<bool> PrintDiffCFG(
49b92436efSFangrui Song "print-diff-cfg",
50a34c753fSRafael Auler cl::desc("print the CFG of important functions that changed in "
51a34c753fSRafael Auler "binary 2"),
52a34c753fSRafael Auler cl::cat(BoltDiffCategory));
53a34c753fSRafael Auler
54a34c753fSRafael Auler static cl::opt<bool>
55a34c753fSRafael Auler PrintDiffBBs("print-diff-bbs",
56a34c753fSRafael Auler cl::desc("print the basic blocks showed in top differences"),
57a34c753fSRafael Auler cl::cat(BoltDiffCategory));
58a34c753fSRafael Auler
59b92436efSFangrui Song static cl::opt<bool> MatchByHash(
60b92436efSFangrui Song "match-by-hash",
61a34c753fSRafael Auler cl::desc("match functions in binary 2 to binary 1 if they have the same "
62a34c753fSRafael Auler "hash of a function in binary 1"),
63a34c753fSRafael Auler cl::cat(BoltDiffCategory));
64a34c753fSRafael Auler
65b92436efSFangrui Song static cl::opt<bool> IgnoreUnchanged(
66b92436efSFangrui Song "ignore-unchanged",
67a34c753fSRafael Auler cl::desc("do not diff functions whose contents have not been changed from "
68a34c753fSRafael Auler "one binary to another"),
69a34c753fSRafael Auler cl::cat(BoltDiffCategory));
70a34c753fSRafael Auler
71b92436efSFangrui Song static cl::opt<unsigned> DisplayCount(
72b92436efSFangrui Song "display-count",
73a34c753fSRafael Auler cl::desc("number of functions to display when printing the top largest "
74a34c753fSRafael Auler "differences in function activity"),
75b92436efSFangrui Song cl::init(10), cl::cat(BoltDiffCategory));
76a34c753fSRafael Auler
77b92436efSFangrui Song static cl::opt<bool> NormalizeByBin1(
78b92436efSFangrui Song "normalize-by-bin1",
79a34c753fSRafael Auler cl::desc("show execution count of functions in binary 2 as a ratio of the "
80a34c753fSRafael Auler "total samples in binary 1 - make sure both profiles have equal "
81a34c753fSRafael Auler "collection time and sampling rate for this to make sense"),
82a34c753fSRafael Auler cl::cat(BoltDiffCategory));
83a34c753fSRafael Auler
84a34c753fSRafael Auler } // end namespace opts
85a34c753fSRafael Auler
86a34c753fSRafael Auler namespace llvm {
87a34c753fSRafael Auler namespace bolt {
88a34c753fSRafael Auler
89a34c753fSRafael Auler namespace {
90a34c753fSRafael Auler
91a34c753fSRafael Auler /// Helper used to print colored numbers
printColoredPercentage(double Perc)92a34c753fSRafael Auler void printColoredPercentage(double Perc) {
93a34c753fSRafael Auler if (outs().has_colors() && Perc > 0.0)
94a34c753fSRafael Auler outs().changeColor(raw_ostream::RED);
95a34c753fSRafael Auler else if (outs().has_colors() && Perc < 0.0)
96a34c753fSRafael Auler outs().changeColor(raw_ostream::GREEN);
97a34c753fSRafael Auler else if (outs().has_colors())
98a34c753fSRafael Auler outs().changeColor(raw_ostream::YELLOW);
99a34c753fSRafael Auler outs() << format("%.2f", Perc) << "%";
100a34c753fSRafael Auler if (outs().has_colors())
101a34c753fSRafael Auler outs().resetColor();
102a34c753fSRafael Auler }
103a34c753fSRafael Auler
setLightColor()104a34c753fSRafael Auler void setLightColor() {
105a34c753fSRafael Auler if (opts::PrintDiffBBs && outs().has_colors())
106a34c753fSRafael Auler outs().changeColor(raw_ostream::CYAN);
107a34c753fSRafael Auler }
108a34c753fSRafael Auler
setTitleColor()109a34c753fSRafael Auler void setTitleColor() {
110a34c753fSRafael Auler if (outs().has_colors())
111a34c753fSRafael Auler outs().changeColor(raw_ostream::WHITE, /*Bold=*/true);
112a34c753fSRafael Auler }
113a34c753fSRafael Auler
setRegularColor()114a34c753fSRafael Auler void setRegularColor() {
115a34c753fSRafael Auler if (outs().has_colors())
116a34c753fSRafael Auler outs().resetColor();
117a34c753fSRafael Auler }
118a34c753fSRafael Auler
119a34c753fSRafael Auler } // end anonymous namespace
120a34c753fSRafael Auler
121a34c753fSRafael Auler /// Perform the comparison between two binaries with profiling information
122a34c753fSRafael Auler class RewriteInstanceDiff {
123a34c753fSRafael Auler typedef std::tuple<const BinaryBasicBlock *, const BinaryBasicBlock *, double>
124a34c753fSRafael Auler EdgeTy;
125a34c753fSRafael Auler
126a34c753fSRafael Auler RewriteInstance &RI1;
127a34c753fSRafael Auler RewriteInstance &RI2;
128a34c753fSRafael Auler
129a34c753fSRafael Auler // The map of functions keyed by functions in binary 2, providing its
130a34c753fSRafael Auler // corresponding function in binary 1
131a34c753fSRafael Auler std::map<const BinaryFunction *, const BinaryFunction *> FuncMap;
132a34c753fSRafael Auler
133a34c753fSRafael Auler // The map of basic blocks correspondence, analogue to FuncMap for BBs,
134a34c753fSRafael Auler // sorted by score difference
135a34c753fSRafael Auler std::map<const BinaryBasicBlock *, const BinaryBasicBlock *> BBMap;
136a34c753fSRafael Auler
137a34c753fSRafael Auler // The map of edge correspondence
138a34c753fSRafael Auler std::map<double, std::pair<EdgeTy, EdgeTy>> EdgeMap;
139a34c753fSRafael Auler
140a34c753fSRafael Auler // Maps all known basic blocks back to their parent function
141a34c753fSRafael Auler std::map<const BinaryBasicBlock *, const BinaryFunction *> BBToFuncMap;
142a34c753fSRafael Auler
143a34c753fSRafael Auler // Accounting which functions were matched
144a34c753fSRafael Auler std::set<const BinaryFunction *> Bin1MappedFuncs;
145a34c753fSRafael Auler std::set<const BinaryFunction *> Bin2MappedFuncs;
146a34c753fSRafael Auler
147a34c753fSRafael Auler // Structures for our 3 matching strategies: by name, by hash and by lto name,
148a34c753fSRafael Auler // from the strongest to the weakest bind between two functions
149a34c753fSRafael Auler StringMap<const BinaryFunction *> NameLookup;
150a34c753fSRafael Auler DenseMap<size_t, const BinaryFunction *> HashLookup;
151a34c753fSRafael Auler StringMap<const BinaryFunction *> LTONameLookup1;
152a34c753fSRafael Auler StringMap<const BinaryFunction *> LTONameLookup2;
153a34c753fSRafael Auler
154a34c753fSRafael Auler // Score maps used to order and find hottest functions
155a34c753fSRafael Auler std::multimap<double, const BinaryFunction *> LargestBin1;
156a34c753fSRafael Auler std::multimap<double, const BinaryFunction *> LargestBin2;
157a34c753fSRafael Auler
158a34c753fSRafael Auler // Map multiple functions in the same LTO bucket to a single parent function
159a34c753fSRafael Auler // representing all functions sharing the same prefix
160a34c753fSRafael Auler std::map<const BinaryFunction *, const BinaryFunction *> LTOMap1;
161a34c753fSRafael Auler std::map<const BinaryFunction *, const BinaryFunction *> LTOMap2;
162a34c753fSRafael Auler std::map<const BinaryFunction *, double> LTOAggregatedScore1;
163a34c753fSRafael Auler std::map<const BinaryFunction *, double> LTOAggregatedScore2;
164a34c753fSRafael Auler
165a34c753fSRafael Auler // Map scores in bin2 and 1 keyed by a binary 2 function - post-matching
166a34c753fSRafael Auler DenseMap<const BinaryFunction *, std::pair<double, double>> ScoreMap;
167a34c753fSRafael Auler
getNormalizedScore(const BinaryFunction & Function,const RewriteInstance & Ctx)168a34c753fSRafael Auler double getNormalizedScore(const BinaryFunction &Function,
169a34c753fSRafael Auler const RewriteInstance &Ctx) {
170a34c753fSRafael Auler if (!opts::NormalizeByBin1)
17140c2e0faSMaksim Panchenko return static_cast<double>(Function.getFunctionScore()) /
17240c2e0faSMaksim Panchenko Ctx.getTotalScore();
17340c2e0faSMaksim Panchenko return static_cast<double>(Function.getFunctionScore()) /
17440c2e0faSMaksim Panchenko RI1.getTotalScore();
175a34c753fSRafael Auler }
176a34c753fSRafael Auler
getNormalizedScore(const BinaryBasicBlock & BB,const RewriteInstance & Ctx)177a34c753fSRafael Auler double getNormalizedScore(const BinaryBasicBlock &BB,
178a34c753fSRafael Auler const RewriteInstance &Ctx) {
179a34c753fSRafael Auler if (!opts::NormalizeByBin1)
18040c2e0faSMaksim Panchenko return static_cast<double>(BB.getKnownExecutionCount()) /
18140c2e0faSMaksim Panchenko Ctx.getTotalScore();
18240c2e0faSMaksim Panchenko return static_cast<double>(BB.getKnownExecutionCount()) /
18340c2e0faSMaksim Panchenko RI1.getTotalScore();
184a34c753fSRafael Auler }
185a34c753fSRafael Auler
getNormalizedScore(BinaryBasicBlock::branch_info_iterator BIIter,const RewriteInstance & Ctx)186a34c753fSRafael Auler double getNormalizedScore(BinaryBasicBlock::branch_info_iterator BIIter,
187a34c753fSRafael Auler const RewriteInstance &Ctx) {
188a34c753fSRafael Auler double Score =
18940c2e0faSMaksim Panchenko BIIter->Count == BinaryBasicBlock::COUNT_NO_PROFILE ? 0 : BIIter->Count;
190a34c753fSRafael Auler if (!opts::NormalizeByBin1)
191a34c753fSRafael Auler return Score / Ctx.getTotalScore();
192a34c753fSRafael Auler return Score / RI1.getTotalScore();
193a34c753fSRafael Auler }
194a34c753fSRafael Auler
195a34c753fSRafael Auler /// Initialize data structures used for function lookup in binary 1, used
196a34c753fSRafael Auler /// later when matching functions in binary 2 to corresponding functions
197a34c753fSRafael Auler /// in binary 1
buildLookupMaps()198a34c753fSRafael Auler void buildLookupMaps() {
199a34c753fSRafael Auler for (const auto &BFI : RI1.BC->getBinaryFunctions()) {
200a34c753fSRafael Auler StringRef LTOName;
201a34c753fSRafael Auler const BinaryFunction &Function = BFI.second;
202a34c753fSRafael Auler const double Score = getNormalizedScore(Function, RI1);
203a34c753fSRafael Auler LargestBin1.insert(std::make_pair<>(Score, &Function));
204253b8f0aSAmir Ayupov for (const StringRef &Name : Function.getNames()) {
205a34c753fSRafael Auler if (Optional<StringRef> OptionalLTOName = getLTOCommonName(Name))
206a34c753fSRafael Auler LTOName = *OptionalLTOName;
207a34c753fSRafael Auler NameLookup[Name] = &Function;
208a34c753fSRafael Auler }
209a34c753fSRafael Auler if (opts::MatchByHash && Function.hasCFG())
210a34c753fSRafael Auler HashLookup[Function.computeHash(/*UseDFS=*/true)] = &Function;
211a34c753fSRafael Auler if (opts::IgnoreLTOSuffix && !LTOName.empty()) {
212a34c753fSRafael Auler if (!LTONameLookup1.count(LTOName))
213a34c753fSRafael Auler LTONameLookup1[LTOName] = &Function;
214a34c753fSRafael Auler LTOMap1[&Function] = LTONameLookup1[LTOName];
215a34c753fSRafael Auler }
216a34c753fSRafael Auler }
217a34c753fSRafael Auler
218a34c753fSRafael Auler // Compute LTONameLookup2 and LargestBin2
219a34c753fSRafael Auler for (const auto &BFI : RI2.BC->getBinaryFunctions()) {
220a34c753fSRafael Auler StringRef LTOName;
221a34c753fSRafael Auler const BinaryFunction &Function = BFI.second;
222a34c753fSRafael Auler const double Score = getNormalizedScore(Function, RI2);
223a34c753fSRafael Auler LargestBin2.insert(std::make_pair<>(Score, &Function));
224253b8f0aSAmir Ayupov for (const StringRef &Name : Function.getNames()) {
225a34c753fSRafael Auler if (Optional<StringRef> OptionalLTOName = getLTOCommonName(Name))
226a34c753fSRafael Auler LTOName = *OptionalLTOName;
227a34c753fSRafael Auler }
228a34c753fSRafael Auler if (opts::IgnoreLTOSuffix && !LTOName.empty()) {
229a34c753fSRafael Auler if (!LTONameLookup2.count(LTOName))
230a34c753fSRafael Auler LTONameLookup2[LTOName] = &Function;
231a34c753fSRafael Auler LTOMap2[&Function] = LTONameLookup2[LTOName];
232a34c753fSRafael Auler }
233a34c753fSRafael Auler }
234a34c753fSRafael Auler }
235a34c753fSRafael Auler
236a34c753fSRafael Auler /// Match functions in binary 2 with functions in binary 1
matchFunctions()237a34c753fSRafael Auler void matchFunctions() {
238a34c753fSRafael Auler outs() << "BOLT-DIFF: Mapping functions in Binary2 to Binary1\n";
239a34c753fSRafael Auler uint64_t BothHaveProfile = 0ull;
240a34c753fSRafael Auler std::set<const BinaryFunction *> Bin1ProfiledMapped;
241a34c753fSRafael Auler
242a34c753fSRafael Auler for (const auto &BFI2 : RI2.BC->getBinaryFunctions()) {
243a34c753fSRafael Auler const BinaryFunction &Function2 = BFI2.second;
244a34c753fSRafael Auler StringRef LTOName;
245a34c753fSRafael Auler bool Match = false;
246253b8f0aSAmir Ayupov for (const StringRef &Name : Function2.getNames()) {
247a34c753fSRafael Auler auto Iter = NameLookup.find(Name);
248a34c753fSRafael Auler if (Optional<StringRef> OptionalLTOName = getLTOCommonName(Name))
249a34c753fSRafael Auler LTOName = *OptionalLTOName;
250a34c753fSRafael Auler if (Iter == NameLookup.end())
251a34c753fSRafael Auler continue;
252a34c753fSRafael Auler FuncMap.insert(std::make_pair<>(&Function2, Iter->second));
253a34c753fSRafael Auler Bin1MappedFuncs.insert(Iter->second);
254a34c753fSRafael Auler Bin2MappedFuncs.insert(&Function2);
255a34c753fSRafael Auler if (Function2.hasValidProfile() && Iter->second->hasValidProfile()) {
256a34c753fSRafael Auler ++BothHaveProfile;
257a34c753fSRafael Auler Bin1ProfiledMapped.insert(Iter->second);
258a34c753fSRafael Auler }
259a34c753fSRafael Auler Match = true;
260a34c753fSRafael Auler break;
261a34c753fSRafael Auler }
262a34c753fSRafael Auler if (Match || !Function2.hasCFG())
263a34c753fSRafael Auler continue;
264a34c753fSRafael Auler auto Iter = HashLookup.find(Function2.computeHash(/*UseDFS*/ true));
265a34c753fSRafael Auler if (Iter != HashLookup.end()) {
266a34c753fSRafael Auler FuncMap.insert(std::make_pair<>(&Function2, Iter->second));
267a34c753fSRafael Auler Bin1MappedFuncs.insert(Iter->second);
268a34c753fSRafael Auler Bin2MappedFuncs.insert(&Function2);
269a34c753fSRafael Auler if (Function2.hasValidProfile() && Iter->second->hasValidProfile()) {
270a34c753fSRafael Auler ++BothHaveProfile;
271a34c753fSRafael Auler Bin1ProfiledMapped.insert(Iter->second);
272a34c753fSRafael Auler }
273a34c753fSRafael Auler continue;
274a34c753fSRafael Auler }
275a34c753fSRafael Auler if (LTOName.empty())
276a34c753fSRafael Auler continue;
277a34c753fSRafael Auler auto LTOIter = LTONameLookup1.find(LTOName);
278a34c753fSRafael Auler if (LTOIter != LTONameLookup1.end()) {
279a34c753fSRafael Auler FuncMap.insert(std::make_pair<>(&Function2, LTOIter->second));
280a34c753fSRafael Auler Bin1MappedFuncs.insert(LTOIter->second);
281a34c753fSRafael Auler Bin2MappedFuncs.insert(&Function2);
282a34c753fSRafael Auler if (Function2.hasValidProfile() && LTOIter->second->hasValidProfile()) {
283a34c753fSRafael Auler ++BothHaveProfile;
284a34c753fSRafael Auler Bin1ProfiledMapped.insert(LTOIter->second);
285a34c753fSRafael Auler }
286a34c753fSRafael Auler }
287a34c753fSRafael Auler }
288a34c753fSRafael Auler PrintProgramStats PPS(opts::NeverPrint);
289a34c753fSRafael Auler outs() << "* BOLT-DIFF: Starting print program stats pass for binary 1\n";
290a34c753fSRafael Auler PPS.runOnFunctions(*RI1.BC);
291a34c753fSRafael Auler outs() << "* BOLT-DIFF: Starting print program stats pass for binary 2\n";
292a34c753fSRafael Auler PPS.runOnFunctions(*RI2.BC);
293a34c753fSRafael Auler outs() << "=====\n";
294a34c753fSRafael Auler outs() << "Inputs share " << BothHaveProfile
295a34c753fSRafael Auler << " functions with valid profile.\n";
296a34c753fSRafael Auler if (opts::PrintProfiledUnmapped) {
297a34c753fSRafael Auler outs() << "\nFunctions in profile 1 that are missing in the profile 2:\n";
298a34c753fSRafael Auler std::vector<const BinaryFunction *> Unmapped;
299a34c753fSRafael Auler for (const auto &BFI : RI1.BC->getBinaryFunctions()) {
300a34c753fSRafael Auler const BinaryFunction &Function = BFI.second;
301a34c753fSRafael Auler if (!Function.hasValidProfile() || Bin1ProfiledMapped.count(&Function))
302a34c753fSRafael Auler continue;
303a34c753fSRafael Auler Unmapped.emplace_back(&Function);
304a34c753fSRafael Auler }
305d2c87699SAmir Ayupov llvm::sort(Unmapped,
306a34c753fSRafael Auler [&](const BinaryFunction *A, const BinaryFunction *B) {
307a34c753fSRafael Auler return A->getFunctionScore() > B->getFunctionScore();
308a34c753fSRafael Auler });
309a34c753fSRafael Auler for (const BinaryFunction *Function : Unmapped) {
310a34c753fSRafael Auler outs() << Function->getPrintName() << " : ";
311a34c753fSRafael Auler outs() << Function->getFunctionScore() << "\n";
312a34c753fSRafael Auler }
313a34c753fSRafael Auler outs() << "=====\n";
314a34c753fSRafael Auler }
315a34c753fSRafael Auler }
316a34c753fSRafael Auler
317a34c753fSRafael Auler /// Check if opcodes in BB1 match those in BB2
compareBBs(const BinaryBasicBlock & BB1,const BinaryBasicBlock & BB2) const318a34c753fSRafael Auler bool compareBBs(const BinaryBasicBlock &BB1,
319a34c753fSRafael Auler const BinaryBasicBlock &BB2) const {
320a34c753fSRafael Auler auto Iter1 = BB1.begin();
321a34c753fSRafael Auler auto Iter2 = BB2.begin();
322a34c753fSRafael Auler if ((Iter1 == BB1.end() && Iter2 != BB2.end()) ||
323a34c753fSRafael Auler (Iter1 != BB1.end() && Iter2 == BB2.end()))
324a34c753fSRafael Auler return false;
325a34c753fSRafael Auler
326a34c753fSRafael Auler while (Iter1 != BB1.end()) {
32740c2e0faSMaksim Panchenko if (Iter2 == BB2.end() || Iter1->getOpcode() != Iter2->getOpcode())
328a34c753fSRafael Auler return false;
329a34c753fSRafael Auler
330a34c753fSRafael Auler ++Iter1;
331a34c753fSRafael Auler ++Iter2;
332a34c753fSRafael Auler }
333a34c753fSRafael Auler
334a34c753fSRafael Auler if (Iter2 != BB2.end())
335a34c753fSRafael Auler return false;
336a34c753fSRafael Auler return true;
337a34c753fSRafael Auler }
338a34c753fSRafael Auler
339a34c753fSRafael Auler /// For a function in binary 2 that matched one in binary 1, now match each
340a34c753fSRafael Auler /// individual basic block in it to its corresponding blocks in binary 1.
341a34c753fSRafael Auler /// Also match each edge in binary 2 to the corresponding ones in binary 1.
matchBasicBlocks()342a34c753fSRafael Auler void matchBasicBlocks() {
343a34c753fSRafael Auler for (const auto &MapEntry : FuncMap) {
344a34c753fSRafael Auler const BinaryFunction *const &Func1 = MapEntry.second;
345a34c753fSRafael Auler const BinaryFunction *const &Func2 = MapEntry.first;
346a34c753fSRafael Auler
347*8477bc67SFabian Parzefall auto Iter1 = Func1->getLayout().block_begin();
348*8477bc67SFabian Parzefall auto Iter2 = Func2->getLayout().block_begin();
349a34c753fSRafael Auler
350a34c753fSRafael Auler bool Match = true;
351a34c753fSRafael Auler std::map<const BinaryBasicBlock *, const BinaryBasicBlock *> Map;
352a34c753fSRafael Auler std::map<double, std::pair<EdgeTy, EdgeTy>> EMap;
353*8477bc67SFabian Parzefall while (Iter1 != Func1->getLayout().block_end()) {
354*8477bc67SFabian Parzefall if (Iter2 == Func2->getLayout().block_end()) {
355a34c753fSRafael Auler Match = false;
356a34c753fSRafael Auler break;
357a34c753fSRafael Auler }
358a34c753fSRafael Auler if (!compareBBs(**Iter1, **Iter2)) {
359a34c753fSRafael Auler Match = false;
360a34c753fSRafael Auler break;
361a34c753fSRafael Auler }
362a34c753fSRafael Auler Map.insert(std::make_pair<>(*Iter2, *Iter1));
363a34c753fSRafael Auler
364a34c753fSRafael Auler auto SuccIter1 = (*Iter1)->succ_begin();
365a34c753fSRafael Auler auto SuccIter2 = (*Iter2)->succ_begin();
366a34c753fSRafael Auler auto BIIter1 = (*Iter1)->branch_info_begin();
367a34c753fSRafael Auler auto BIIter2 = (*Iter2)->branch_info_begin();
368a34c753fSRafael Auler while (SuccIter1 != (*Iter1)->succ_end()) {
369a34c753fSRafael Auler if (SuccIter2 == (*Iter2)->succ_end()) {
370a34c753fSRafael Auler Match = false;
371a34c753fSRafael Auler break;
372a34c753fSRafael Auler }
373a34c753fSRafael Auler const double ScoreEdge1 = getNormalizedScore(BIIter1, RI1);
374a34c753fSRafael Auler const double ScoreEdge2 = getNormalizedScore(BIIter2, RI2);
375a34c753fSRafael Auler EMap.insert(std::make_pair<>(
376a34c753fSRafael Auler std::abs(ScoreEdge2 - ScoreEdge1),
377a34c753fSRafael Auler std::make_pair<>(
378a34c753fSRafael Auler std::make_tuple<>(*Iter2, *SuccIter2, ScoreEdge2),
379a34c753fSRafael Auler std::make_tuple<>(*Iter1, *SuccIter1, ScoreEdge1))));
380a34c753fSRafael Auler
381a34c753fSRafael Auler ++SuccIter1;
382a34c753fSRafael Auler ++SuccIter2;
383a34c753fSRafael Auler ++BIIter1;
384a34c753fSRafael Auler ++BIIter2;
385a34c753fSRafael Auler }
386a34c753fSRafael Auler if (SuccIter2 != (*Iter2)->succ_end())
387a34c753fSRafael Auler Match = false;
388a34c753fSRafael Auler if (!Match)
389a34c753fSRafael Auler break;
390a34c753fSRafael Auler
391a34c753fSRafael Auler BBToFuncMap[*Iter1] = Func1;
392a34c753fSRafael Auler BBToFuncMap[*Iter2] = Func2;
393a34c753fSRafael Auler ++Iter1;
394a34c753fSRafael Auler ++Iter2;
395a34c753fSRafael Auler }
396*8477bc67SFabian Parzefall if (!Match || Iter2 != Func2->getLayout().block_end())
397a34c753fSRafael Auler continue;
398a34c753fSRafael Auler
399a34c753fSRafael Auler BBMap.insert(Map.begin(), Map.end());
400a34c753fSRafael Auler EdgeMap.insert(EMap.begin(), EMap.end());
401a34c753fSRafael Auler }
402a34c753fSRafael Auler }
403a34c753fSRafael Auler
404a34c753fSRafael Auler /// Print the largest differences in basic block performance from binary 1
405a34c753fSRafael Auler /// to binary 2
reportHottestBBDiffs()406a34c753fSRafael Auler void reportHottestBBDiffs() {
407a34c753fSRafael Auler std::map<double, const BinaryBasicBlock *> LargestDiffs;
408a34c753fSRafael Auler for (const auto &MapEntry : BBMap) {
409a34c753fSRafael Auler const BinaryBasicBlock *BB2 = MapEntry.first;
410a34c753fSRafael Auler const BinaryBasicBlock *BB1 = MapEntry.second;
411a34c753fSRafael Auler LargestDiffs.insert(
412a34c753fSRafael Auler std::make_pair<>(std::abs(getNormalizedScore(*BB2, RI2) -
413a34c753fSRafael Auler getNormalizedScore(*BB1, RI1)),
414a34c753fSRafael Auler BB2));
415a34c753fSRafael Auler }
416a34c753fSRafael Auler
417a34c753fSRafael Auler unsigned Printed = 0;
418a34c753fSRafael Auler setTitleColor();
419a34c753fSRafael Auler outs()
420a34c753fSRafael Auler << "\nTop " << opts::DisplayCount
421a34c753fSRafael Auler << " largest differences in basic block performance bin 2 -> bin 1:\n";
422a34c753fSRafael Auler outs() << "=========================================================\n";
423a34c753fSRafael Auler setRegularColor();
424a34c753fSRafael Auler outs() << " * Functions with different contents do not appear here\n\n";
425a34c753fSRafael Auler for (auto I = LargestDiffs.rbegin(), E = LargestDiffs.rend(); I != E; ++I) {
426a34c753fSRafael Auler const BinaryBasicBlock *BB2 = I->second;
427a34c753fSRafael Auler const double Score2 = getNormalizedScore(*BB2, RI2);
428a34c753fSRafael Auler const double Score1 = getNormalizedScore(*BBMap[BB2], RI1);
429a34c753fSRafael Auler outs() << "BB " << BB2->getName() << " from "
430a34c753fSRafael Auler << BBToFuncMap[BB2]->getDemangledName()
431a34c753fSRafael Auler << "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
432a34c753fSRafael Auler << "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
433a34c753fSRafael Auler outs() << "%\t(Difference: ";
434a34c753fSRafael Auler printColoredPercentage((Score2 - Score1) * 100.0);
435a34c753fSRafael Auler outs() << ")\n";
436a34c753fSRafael Auler if (opts::PrintDiffBBs) {
437a34c753fSRafael Auler setLightColor();
438a34c753fSRafael Auler BB2->dump();
439a34c753fSRafael Auler setRegularColor();
440a34c753fSRafael Auler }
441a34c753fSRafael Auler if (Printed++ == opts::DisplayCount)
442a34c753fSRafael Auler break;
443a34c753fSRafael Auler }
444a34c753fSRafael Auler }
445a34c753fSRafael Auler
446a34c753fSRafael Auler /// Print the largest differences in edge counts from one binary to another
reportHottestEdgeDiffs()447a34c753fSRafael Auler void reportHottestEdgeDiffs() {
448a34c753fSRafael Auler unsigned Printed = 0;
449a34c753fSRafael Auler setTitleColor();
45040c2e0faSMaksim Panchenko outs() << "\nTop " << opts::DisplayCount
451a34c753fSRafael Auler << " largest differences in edge hotness bin 2 -> bin 1:\n";
452a34c753fSRafael Auler outs() << "=========================================================\n";
453a34c753fSRafael Auler setRegularColor();
454a34c753fSRafael Auler outs() << " * Functions with different contents do not appear here\n";
455a34c753fSRafael Auler for (auto I = EdgeMap.rbegin(), E = EdgeMap.rend(); I != E; ++I) {
456a34c753fSRafael Auler std::tuple<const BinaryBasicBlock *, const BinaryBasicBlock *, double>
457a34c753fSRafael Auler &Edge2 = I->second.first;
458a34c753fSRafael Auler std::tuple<const BinaryBasicBlock *, const BinaryBasicBlock *, double>
459a34c753fSRafael Auler &Edge1 = I->second.second;
460a34c753fSRafael Auler const double Score2 = std::get<2>(Edge2);
461a34c753fSRafael Auler const double Score1 = std::get<2>(Edge1);
462a34c753fSRafael Auler outs() << "Edge (" << std::get<0>(Edge2)->getName() << " -> "
463a34c753fSRafael Auler << std::get<1>(Edge2)->getName() << ") in "
464a34c753fSRafael Auler << BBToFuncMap[std::get<0>(Edge2)]->getDemangledName()
465a34c753fSRafael Auler << "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
466a34c753fSRafael Auler << "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
467a34c753fSRafael Auler outs() << "%\t(Difference: ";
468a34c753fSRafael Auler printColoredPercentage((Score2 - Score1) * 100.0);
469a34c753fSRafael Auler outs() << ")\n";
470a34c753fSRafael Auler if (opts::PrintDiffBBs) {
471a34c753fSRafael Auler setLightColor();
472a34c753fSRafael Auler std::get<0>(Edge2)->dump();
473a34c753fSRafael Auler std::get<1>(Edge2)->dump();
474a34c753fSRafael Auler setRegularColor();
475a34c753fSRafael Auler }
476a34c753fSRafael Auler if (Printed++ == opts::DisplayCount)
477a34c753fSRafael Auler break;
478a34c753fSRafael Auler }
479a34c753fSRafael Auler }
480a34c753fSRafael Auler
481a34c753fSRafael Auler /// For LTO functions sharing the same prefix (for example, func1.lto_priv.1
482a34c753fSRafael Auler /// and func1.lto_priv.2 share the func1.lto_priv prefix), compute aggregated
483a34c753fSRafael Auler /// scores for them. This is used to avoid reporting all LTO functions as
484a34c753fSRafael Auler /// having a large difference in performance because hotness shifted from
485a34c753fSRafael Auler /// LTO variant 1 to variant 2, even though they represent the same function.
computeAggregatedLTOScore()486a34c753fSRafael Auler void computeAggregatedLTOScore() {
487a34c753fSRafael Auler for (const auto &BFI : RI1.BC->getBinaryFunctions()) {
488a34c753fSRafael Auler const BinaryFunction &Function = BFI.second;
489a34c753fSRafael Auler double Score = getNormalizedScore(Function, RI1);
490a34c753fSRafael Auler auto Iter = LTOMap1.find(&Function);
491a34c753fSRafael Auler if (Iter == LTOMap1.end())
492a34c753fSRafael Auler continue;
493a34c753fSRafael Auler LTOAggregatedScore1[Iter->second] += Score;
494a34c753fSRafael Auler }
495a34c753fSRafael Auler
496a34c753fSRafael Auler double UnmappedScore = 0;
497a34c753fSRafael Auler for (const auto &BFI : RI2.BC->getBinaryFunctions()) {
498a34c753fSRafael Auler const BinaryFunction &Function = BFI.second;
499a34c753fSRafael Auler bool Matched = FuncMap.find(&Function) != FuncMap.end();
500a34c753fSRafael Auler double Score = getNormalizedScore(Function, RI2);
501a34c753fSRafael Auler auto Iter = LTOMap2.find(&Function);
502a34c753fSRafael Auler if (Iter == LTOMap2.end()) {
503a34c753fSRafael Auler if (!Matched)
504a34c753fSRafael Auler UnmappedScore += Score;
505a34c753fSRafael Auler continue;
506a34c753fSRafael Auler }
507a34c753fSRafael Auler LTOAggregatedScore2[Iter->second] += Score;
508a34c753fSRafael Auler if (FuncMap.find(Iter->second) == FuncMap.end())
509a34c753fSRafael Auler UnmappedScore += Score;
510a34c753fSRafael Auler }
511a34c753fSRafael Auler int64_t Unmapped =
512a34c753fSRafael Auler RI2.BC->getBinaryFunctions().size() - Bin2MappedFuncs.size();
513a34c753fSRafael Auler outs() << "BOLT-DIFF: " << Unmapped
514a34c753fSRafael Auler << " functions in Binary2 have no correspondence to any other "
515a34c753fSRafael Auler "function in Binary1.\n";
516a34c753fSRafael Auler
517a34c753fSRafael Auler // Print the hotness score of functions in binary 2 that were not matched
518a34c753fSRafael Auler // to any function in binary 1
519a34c753fSRafael Auler outs() << "BOLT-DIFF: These unmapped functions in Binary2 represent "
520a34c753fSRafael Auler << format("%.2f", UnmappedScore * 100.0) << "% of execution.\n";
521a34c753fSRafael Auler }
522a34c753fSRafael Auler
523a34c753fSRafael Auler /// Print the largest hotness differences from binary 2 to binary 1
reportHottestFuncDiffs()524a34c753fSRafael Auler void reportHottestFuncDiffs() {
525a34c753fSRafael Auler std::multimap<double, decltype(FuncMap)::value_type> LargestDiffs;
526a34c753fSRafael Auler for (const auto &MapEntry : FuncMap) {
527a34c753fSRafael Auler const BinaryFunction *const &Func1 = MapEntry.second;
528a34c753fSRafael Auler const BinaryFunction *const &Func2 = MapEntry.first;
529a34c753fSRafael Auler double Score1 = getNormalizedScore(*Func1, RI1);
530a34c753fSRafael Auler auto Iter1 = LTOMap1.find(Func1);
531ee0e9ccbSMaksim Panchenko if (Iter1 != LTOMap1.end())
532a34c753fSRafael Auler Score1 = LTOAggregatedScore1[Iter1->second];
533a34c753fSRafael Auler double Score2 = getNormalizedScore(*Func2, RI2);
534a34c753fSRafael Auler auto Iter2 = LTOMap2.find(Func2);
535ee0e9ccbSMaksim Panchenko if (Iter2 != LTOMap2.end())
536a34c753fSRafael Auler Score2 = LTOAggregatedScore2[Iter2->second];
537a34c753fSRafael Auler if (Score1 == 0.0 || Score2 == 0.0)
538a34c753fSRafael Auler continue;
539a34c753fSRafael Auler LargestDiffs.insert(
540a34c753fSRafael Auler std::make_pair<>(std::abs(Score1 - Score2), MapEntry));
541a34c753fSRafael Auler ScoreMap[Func2] = std::make_pair<>(Score1, Score2);
542a34c753fSRafael Auler }
543a34c753fSRafael Auler
544a34c753fSRafael Auler unsigned Printed = 0;
545a34c753fSRafael Auler setTitleColor();
546a34c753fSRafael Auler outs() << "\nTop " << opts::DisplayCount
547a34c753fSRafael Auler << " largest differences in performance bin 2 -> bin 1:\n";
548a34c753fSRafael Auler outs() << "=========================================================\n";
549a34c753fSRafael Auler setRegularColor();
550a34c753fSRafael Auler for (auto I = LargestDiffs.rbegin(), E = LargestDiffs.rend(); I != E; ++I) {
551a34c753fSRafael Auler const std::pair<const BinaryFunction *const, const BinaryFunction *>
552a34c753fSRafael Auler &MapEntry = I->second;
553a34c753fSRafael Auler if (opts::IgnoreUnchanged &&
554a34c753fSRafael Auler MapEntry.second->computeHash(/*UseDFS=*/true) ==
555a34c753fSRafael Auler MapEntry.first->computeHash(/*UseDFS=*/true))
556a34c753fSRafael Auler continue;
557a34c753fSRafael Auler const std::pair<double, double> &Scores = ScoreMap[MapEntry.first];
558a34c753fSRafael Auler outs() << "Function " << MapEntry.first->getDemangledName();
559a34c753fSRafael Auler if (MapEntry.first->getDemangledName() !=
560a34c753fSRafael Auler MapEntry.second->getDemangledName())
561a34c753fSRafael Auler outs() << "\nmatched " << MapEntry.second->getDemangledName();
562a34c753fSRafael Auler outs() << "\n\tScore bin1 = " << format("%.2f", Scores.first * 100.0)
563a34c753fSRafael Auler << "%\n\tScore bin2 = " << format("%.2f", Scores.second * 100.0)
564a34c753fSRafael Auler << "%\t(Difference: ";
565a34c753fSRafael Auler printColoredPercentage((Scores.second - Scores.first) * 100.0);
566a34c753fSRafael Auler outs() << ")";
567a34c753fSRafael Auler if (MapEntry.second->computeHash(/*UseDFS=*/true) !=
568a34c753fSRafael Auler MapEntry.first->computeHash(/*UseDFS=*/true)) {
569a34c753fSRafael Auler outs() << "\t[Functions have different contents]";
570a34c753fSRafael Auler if (opts::PrintDiffCFG) {
571a34c753fSRafael Auler outs() << "\n *** CFG for function in binary 1:\n";
572a34c753fSRafael Auler setLightColor();
573a34c753fSRafael Auler MapEntry.second->dump();
574a34c753fSRafael Auler setRegularColor();
575a34c753fSRafael Auler outs() << "\n *** CFG for function in binary 2:\n";
576a34c753fSRafael Auler setLightColor();
577a34c753fSRafael Auler MapEntry.first->dump();
578a34c753fSRafael Auler setRegularColor();
579a34c753fSRafael Auler }
580a34c753fSRafael Auler }
581a34c753fSRafael Auler outs() << "\n";
582a34c753fSRafael Auler if (Printed++ == opts::DisplayCount)
583a34c753fSRafael Auler break;
584a34c753fSRafael Auler }
585a34c753fSRafael Auler }
586a34c753fSRafael Auler
587a34c753fSRafael Auler /// Print hottest functions from each binary
reportHottestFuncs()588a34c753fSRafael Auler void reportHottestFuncs() {
589a34c753fSRafael Auler unsigned Printed = 0;
590a34c753fSRafael Auler setTitleColor();
591a34c753fSRafael Auler outs() << "\nTop " << opts::DisplayCount
592a34c753fSRafael Auler << " hottest functions in binary 2:\n";
593a34c753fSRafael Auler outs() << "=====================================\n";
594a34c753fSRafael Auler setRegularColor();
595a34c753fSRafael Auler for (auto I = LargestBin2.rbegin(), E = LargestBin2.rend(); I != E; ++I) {
596a34c753fSRafael Auler const std::pair<const double, const BinaryFunction *> &MapEntry = *I;
597a34c753fSRafael Auler outs() << "Function " << MapEntry.second->getDemangledName() << "\n";
598a34c753fSRafael Auler auto Iter = ScoreMap.find(MapEntry.second);
599ee0e9ccbSMaksim Panchenko if (Iter != ScoreMap.end())
600a34c753fSRafael Auler outs() << "\tScore bin1 = "
601a34c753fSRafael Auler << format("%.2f", Iter->second.first * 100.0) << "%\n";
602a34c753fSRafael Auler outs() << "\tScore bin2 = " << format("%.2f", MapEntry.first * 100.0)
603a34c753fSRafael Auler << "%\n";
604a34c753fSRafael Auler if (Printed++ == opts::DisplayCount)
605a34c753fSRafael Auler break;
606a34c753fSRafael Auler }
607a34c753fSRafael Auler
608a34c753fSRafael Auler Printed = 0;
609a34c753fSRafael Auler setTitleColor();
610a34c753fSRafael Auler outs() << "\nTop " << opts::DisplayCount
611a34c753fSRafael Auler << " hottest functions in binary 1:\n";
612a34c753fSRafael Auler outs() << "=====================================\n";
613a34c753fSRafael Auler setRegularColor();
614a34c753fSRafael Auler for (auto I = LargestBin1.rbegin(), E = LargestBin1.rend(); I != E; ++I) {
615a34c753fSRafael Auler const std::pair<const double, const BinaryFunction *> &MapEntry = *I;
616a34c753fSRafael Auler outs() << "Function " << MapEntry.second->getDemangledName()
617a34c753fSRafael Auler << "\n\tScore bin1 = " << format("%.2f", MapEntry.first * 100.0)
618a34c753fSRafael Auler << "%\n";
619a34c753fSRafael Auler if (Printed++ == opts::DisplayCount)
620a34c753fSRafael Auler break;
621a34c753fSRafael Auler }
622a34c753fSRafael Auler }
623a34c753fSRafael Auler
624a34c753fSRafael Auler /// Print functions in binary 2 that did not match anything in binary 1.
625a34c753fSRafael Auler /// Unfortunately, in an LTO build, even a small change can lead to several
626a34c753fSRafael Auler /// LTO variants being unmapped, corresponding to local functions that never
627a34c753fSRafael Auler /// appear in one of the binaries because they were previously inlined.
reportUnmapped()628a34c753fSRafael Auler void reportUnmapped() {
629a34c753fSRafael Auler outs() << "List of functions from binary 2 that were not matched with any "
630a34c753fSRafael Auler << "function in binary 1:\n";
631a34c753fSRafael Auler for (const auto &BFI2 : RI2.BC->getBinaryFunctions()) {
632a34c753fSRafael Auler const BinaryFunction &Function2 = BFI2.second;
633a34c753fSRafael Auler if (Bin2MappedFuncs.count(&Function2))
634a34c753fSRafael Auler continue;
635a34c753fSRafael Auler outs() << Function2.getPrintName() << "\n";
636a34c753fSRafael Auler }
637a34c753fSRafael Auler }
638a34c753fSRafael Auler
639a34c753fSRafael Auler public:
640a34c753fSRafael Auler /// Main entry point: coordinate all tasks necessary to compare two binaries
compareAndReport()641a34c753fSRafael Auler void compareAndReport() {
642a34c753fSRafael Auler buildLookupMaps();
643a34c753fSRafael Auler matchFunctions();
644a34c753fSRafael Auler if (opts::IgnoreLTOSuffix)
645a34c753fSRafael Auler computeAggregatedLTOScore();
646a34c753fSRafael Auler matchBasicBlocks();
647a34c753fSRafael Auler reportHottestFuncDiffs();
648a34c753fSRafael Auler reportHottestBBDiffs();
649a34c753fSRafael Auler reportHottestEdgeDiffs();
650a34c753fSRafael Auler reportHottestFuncs();
651a34c753fSRafael Auler if (!opts::PrintUnmapped)
652a34c753fSRafael Auler return;
653a34c753fSRafael Auler reportUnmapped();
654a34c753fSRafael Auler }
655a34c753fSRafael Auler
RewriteInstanceDiff(RewriteInstance & RI1,RewriteInstance & RI2)656a34c753fSRafael Auler RewriteInstanceDiff(RewriteInstance &RI1, RewriteInstance &RI2)
657a34c753fSRafael Auler : RI1(RI1), RI2(RI2) {
658a34c753fSRafael Auler compareAndReport();
659a34c753fSRafael Auler }
660a34c753fSRafael Auler
661a34c753fSRafael Auler };
662a34c753fSRafael Auler
663a34c753fSRafael Auler } // end nampespace bolt
664a34c753fSRafael Auler } // end namespace llvm
665a34c753fSRafael Auler
compare(RewriteInstance & RI2)666a34c753fSRafael Auler void RewriteInstance::compare(RewriteInstance &RI2) {
667a34c753fSRafael Auler outs() << "BOLT-DIFF: ======== Binary1 vs. Binary2 ========\n";
668a34c753fSRafael Auler outs() << "Trace for binary 1 has " << this->getTotalScore()
669a34c753fSRafael Auler << " instructions executed.\n";
670a34c753fSRafael Auler outs() << "Trace for binary 2 has " << RI2.getTotalScore()
671a34c753fSRafael Auler << " instructions executed.\n";
672a34c753fSRafael Auler if (opts::NormalizeByBin1) {
67340c2e0faSMaksim Panchenko double Diff2to1 =
67440c2e0faSMaksim Panchenko static_cast<double>(RI2.getTotalScore() - this->getTotalScore()) /
675a34c753fSRafael Auler this->getTotalScore();
676a34c753fSRafael Auler outs() << "Binary2 change in score with respect to Binary1: ";
677a34c753fSRafael Auler printColoredPercentage(Diff2to1 * 100.0);
678a34c753fSRafael Auler outs() << "\n";
679a34c753fSRafael Auler }
680a34c753fSRafael Auler
681a34c753fSRafael Auler if (!this->getTotalScore() || !RI2.getTotalScore()) {
682a34c753fSRafael Auler outs() << "BOLT-DIFF: Both binaries must have recorded activity in known "
683a34c753fSRafael Auler "functions.\n";
684a34c753fSRafael Auler return;
685a34c753fSRafael Auler }
686a34c753fSRafael Auler
687a34c753fSRafael Auler // Pre-pass ICF
688a34c753fSRafael Auler if (opts::ICF) {
689a34c753fSRafael Auler IdenticalCodeFolding ICF(opts::NeverPrint);
690a34c753fSRafael Auler outs() << "BOLT-DIFF: Starting ICF pass for binary 1";
691a34c753fSRafael Auler ICF.runOnFunctions(*BC);
692a34c753fSRafael Auler outs() << "BOLT-DIFF: Starting ICF pass for binary 2";
693a34c753fSRafael Auler ICF.runOnFunctions(*RI2.BC);
694a34c753fSRafael Auler }
695a34c753fSRafael Auler
696a34c753fSRafael Auler RewriteInstanceDiff RID(*this, RI2);
697a34c753fSRafael Auler }
698