Skip to content

Commit a0aa5b3

Browse files
author
Jessica Paquette
committedSep 6, 2018
Output per-function size-info remarks
This patch adds per-function size information remarks. Previously, passing -Rpass-analysis=size-info would only give you per-module changes. By adding the ability to do this per-function, it's easier to see which functions contributed the most to size changes. https://reviews.llvm.org/D51467 llvm-svn: 341588
1 parent b23648c commit a0aa5b3

File tree

5 files changed

+250
-26
lines changed

5 files changed

+250
-26
lines changed
 

‎llvm/include/llvm/IR/LegacyPassManagers.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,23 @@ class PMDataManager {
406406
/// Set the initial size of the module if the user has specified that they
407407
/// want remarks for size.
408408
/// Returns 0 if the remark was not requested.
409-
unsigned initSizeRemarkInfo(Module &M);
409+
unsigned initSizeRemarkInfo(
410+
Module &M,
411+
StringMap<std::pair<unsigned, unsigned>> &FunctionToInstrCount);
410412

411413
/// Emit a remark signifying that the number of IR instructions in the module
412414
/// changed.
413415
/// \p F is optionally passed by passes which run on Functions, and thus
414416
/// always know whether or not a non-empty function is available.
415-
void emitInstrCountChangedRemark(Pass *P, Module &M, int64_t Delta,
416-
unsigned CountBefore, Function *F = nullptr);
417+
///
418+
/// \p FunctionToInstrCount maps the name of a \p Function to a pair. The
419+
/// first member of the pair is the IR count of the \p Function before running
420+
/// \p P, and the second member is the IR count of the \p Function after
421+
/// running \p P.
422+
void emitInstrCountChangedRemark(
423+
Pass *P, Module &M, int64_t Delta, unsigned CountBefore,
424+
StringMap<std::pair<unsigned, unsigned>> &FunctionToInstrCount,
425+
Function *F = nullptr);
417426

418427
protected:
419428
// Top level manager.

‎llvm/lib/Analysis/CallGraphSCCPass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
132132

133133
{
134134
unsigned InstrCount, SCCCount = 0;
135+
StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount;
135136
bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
136137
TimeRegion PassTimer(getPassTimer(CGSP));
137138
if (EmitICRemark)
138-
InstrCount = initSizeRemarkInfo(M);
139+
InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount);
139140
Changed = CGSP->runOnSCC(CurSCC);
140141

141142
if (EmitICRemark) {
@@ -146,7 +147,8 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
146147
// Yep. Emit a remark and update InstrCount.
147148
int64_t Delta =
148149
static_cast<int64_t>(SCCCount) - static_cast<int64_t>(InstrCount);
149-
emitInstrCountChangedRemark(P, M, Delta, InstrCount);
150+
emitInstrCountChangedRemark(P, M, Delta, InstrCount,
151+
FunctionToInstrCount);
150152
InstrCount = SCCCount;
151153
}
152154
}

‎llvm/lib/Analysis/LoopPass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ bool LPPassManager::runOnFunction(Function &F) {
195195

196196
// Walk Loops
197197
unsigned InstrCount, FunctionSize = 0;
198+
StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount;
198199
bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
199200
// Collect the initial size of the module and the function we're looking at.
200201
if (EmitICRemark) {
201-
InstrCount = initSizeRemarkInfo(M);
202+
InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount);
202203
FunctionSize = F.getInstructionCount();
203204
}
204205
while (!LQ.empty()) {
@@ -226,7 +227,8 @@ bool LPPassManager::runOnFunction(Function &F) {
226227
if (NewSize != FunctionSize) {
227228
int64_t Delta = static_cast<int64_t>(NewSize) -
228229
static_cast<int64_t>(FunctionSize);
229-
emitInstrCountChangedRemark(P, M, Delta, InstrCount, &F);
230+
emitInstrCountChangedRemark(P, M, Delta, InstrCount,
231+
FunctionToInstrCount, &F);
230232
InstrCount = static_cast<int64_t>(InstrCount) + Delta;
231233
FunctionSize = NewSize;
232234
}

‎llvm/lib/IR/LegacyPassManager.cpp

Lines changed: 111 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,32 @@ bool PMDataManager::isPassDebuggingExecutionsOrMore() const {
136136
return PassDebugging >= Executions;
137137
}
138138

139-
unsigned PMDataManager::initSizeRemarkInfo(Module &M) {
139+
unsigned PMDataManager::initSizeRemarkInfo(
140+
Module &M, StringMap<std::pair<unsigned, unsigned>> &FunctionToInstrCount) {
140141
// Only calculate getInstructionCount if the size-info remark is requested.
141-
return M.getInstructionCount();
142+
unsigned InstrCount = 0;
143+
144+
// Collect instruction counts for every function. We'll use this to emit
145+
// per-function size remarks later.
146+
for (Function &F : M) {
147+
unsigned FCount = F.getInstructionCount();
148+
149+
// Insert a record into FunctionToInstrCount keeping track of the current
150+
// size of the function as the first member of a pair. Set the second
151+
// member to 0; if the function is deleted by the pass, then when we get
152+
// here, we'll be able to let the user know that F no longer contributes to
153+
// the module.
154+
FunctionToInstrCount[F.getName().str()] =
155+
std::pair<unsigned, unsigned>(FCount, 0);
156+
InstrCount += FCount;
157+
}
158+
return InstrCount;
142159
}
143160

144-
void PMDataManager::emitInstrCountChangedRemark(Pass *P, Module &M,
145-
int64_t Delta,
146-
unsigned CountBefore,
147-
Function *F) {
161+
void PMDataManager::emitInstrCountChangedRemark(
162+
Pass *P, Module &M, int64_t Delta, unsigned CountBefore,
163+
StringMap<std::pair<unsigned, unsigned>> &FunctionToInstrCount,
164+
Function *F) {
148165
// If it's a pass manager, don't emit a remark. (This hinges on the assumption
149166
// that the only passes that return non-null with getAsPMDataManager are pass
150167
// managers.) The reason we have to do this is to avoid emitting remarks for
@@ -155,6 +172,33 @@ void PMDataManager::emitInstrCountChangedRemark(Pass *P, Module &M,
155172
// Set to true if this isn't a module pass or CGSCC pass.
156173
bool CouldOnlyImpactOneFunction = (F != nullptr);
157174

175+
// Helper lambda that updates the changes to the size of some function.
176+
auto UpdateFunctionChanges =
177+
[&FunctionToInstrCount](Function &MaybeChangedFn) {
178+
// Update the total module count.
179+
unsigned FnSize = MaybeChangedFn.getInstructionCount();
180+
auto It = FunctionToInstrCount.find(MaybeChangedFn.getName());
181+
182+
// If we created a new function, then we need to add it to the map and
183+
// say that it changed from 0 instructions to FnSize.
184+
if (It == FunctionToInstrCount.end()) {
185+
FunctionToInstrCount[MaybeChangedFn.getName()] =
186+
std::pair<unsigned, unsigned>(0, FnSize);
187+
return;
188+
}
189+
// Insert the new function size into the second member of the pair. This
190+
// tells us whether or not this function changed in size.
191+
It->second.second = FnSize;
192+
};
193+
194+
// We need to initially update all of the function sizes.
195+
// If no function was passed in, then we're either a module pass or an
196+
// CGSCC pass.
197+
if (!CouldOnlyImpactOneFunction)
198+
std::for_each(M.begin(), M.end(), UpdateFunctionChanges);
199+
else
200+
UpdateFunctionChanges(*F);
201+
158202
// Do we have a function we can use to emit a remark?
159203
if (!CouldOnlyImpactOneFunction) {
160204
// We need a function containing at least one basic block in order to output
@@ -185,6 +229,55 @@ void PMDataManager::emitInstrCountChangedRemark(Pass *P, Module &M,
185229
<< "; Delta: "
186230
<< DiagnosticInfoOptimizationBase::Argument("DeltaInstrCount", Delta);
187231
F->getContext().diagnose(R); // Not using ORE for layering reasons.
232+
233+
// Emit per-function size change remarks separately.
234+
std::string PassName = P->getPassName().str();
235+
236+
// Helper lambda that emits a remark when the size of a function has changed.
237+
auto EmitFunctionSizeChangedRemark = [&FunctionToInstrCount, &F, &BB,
238+
&PassName](const std::string &Fname) {
239+
unsigned FnCountBefore, FnCountAfter;
240+
std::pair<unsigned, unsigned> &Change = FunctionToInstrCount[Fname];
241+
std::tie(FnCountBefore, FnCountAfter) = Change;
242+
int64_t FnDelta = static_cast<int64_t>(FnCountAfter) -
243+
static_cast<int64_t>(FnCountBefore);
244+
245+
if (FnDelta == 0)
246+
return;
247+
248+
// FIXME: We shouldn't use BB for the location here. Unfortunately, because
249+
// the function that we're looking at could have been deleted, we can't use
250+
// it for the source location. We *want* remarks when a function is deleted
251+
// though, so we're kind of stuck here as is. (This remark, along with the
252+
// whole-module size change remarks really ought not to have source
253+
// locations at all.)
254+
OptimizationRemarkAnalysis FR("size-info", "FunctionIRSizeChange",
255+
DiagnosticLocation(), &BB);
256+
FR << DiagnosticInfoOptimizationBase::Argument("Pass", PassName)
257+
<< ": Function: "
258+
<< DiagnosticInfoOptimizationBase::Argument("Function", Fname)
259+
<< ": IR instruction count changed from "
260+
<< DiagnosticInfoOptimizationBase::Argument("IRInstrsBefore",
261+
FnCountBefore)
262+
<< " to "
263+
<< DiagnosticInfoOptimizationBase::Argument("IRInstrsAfter",
264+
FnCountAfter)
265+
<< "; Delta: "
266+
<< DiagnosticInfoOptimizationBase::Argument("DeltaInstrCount", FnDelta);
267+
F->getContext().diagnose(FR);
268+
269+
// Update the function size.
270+
Change.first = FnCountAfter;
271+
};
272+
273+
// Are we looking at more than one function? If so, emit remarks for all of
274+
// the functions in the module. Otherwise, only emit one remark.
275+
if (!CouldOnlyImpactOneFunction)
276+
std::for_each(FunctionToInstrCount.keys().begin(),
277+
FunctionToInstrCount.keys().end(),
278+
EmitFunctionSizeChangedRemark);
279+
else
280+
EmitFunctionSizeChangedRemark(F->getName().str());
188281
}
189282

190283
void PassManagerPrettyStackEntry::print(raw_ostream &OS) const {
@@ -1284,9 +1377,10 @@ bool BBPassManager::runOnFunction(Function &F) {
12841377
Module &M = *F.getParent();
12851378

12861379
unsigned InstrCount, BBSize = 0;
1380+
StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount;
12871381
bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
12881382
if (EmitICRemark)
1289-
InstrCount = initSizeRemarkInfo(M);
1383+
InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount);
12901384

12911385
for (BasicBlock &BB : F) {
12921386
// Collect the initial size of the basic block.
@@ -1313,7 +1407,8 @@ bool BBPassManager::runOnFunction(Function &F) {
13131407
if (NewSize != BBSize) {
13141408
int64_t Delta =
13151409
static_cast<int64_t>(NewSize) - static_cast<int64_t>(BBSize);
1316-
emitInstrCountChangedRemark(BP, M, Delta, InstrCount, &F);
1410+
emitInstrCountChangedRemark(BP, M, Delta, InstrCount,
1411+
FunctionToInstrCount, &F);
13171412
InstrCount = static_cast<int64_t>(InstrCount) + Delta;
13181413
BBSize = NewSize;
13191414
}
@@ -1522,10 +1617,11 @@ bool FPPassManager::runOnFunction(Function &F) {
15221617
populateInheritedAnalysis(TPM->activeStack);
15231618

15241619
unsigned InstrCount, FunctionSize = 0;
1620+
StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount;
15251621
bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
15261622
// Collect the initial size of the module.
15271623
if (EmitICRemark) {
1528-
InstrCount = initSizeRemarkInfo(M);
1624+
InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount);
15291625
FunctionSize = F.getInstructionCount();
15301626
}
15311627

@@ -1550,7 +1646,8 @@ bool FPPassManager::runOnFunction(Function &F) {
15501646
if (NewSize != FunctionSize) {
15511647
int64_t Delta = static_cast<int64_t>(NewSize) -
15521648
static_cast<int64_t>(FunctionSize);
1553-
emitInstrCountChangedRemark(FP, M, Delta, InstrCount, &F);
1649+
emitInstrCountChangedRemark(FP, M, Delta, InstrCount,
1650+
FunctionToInstrCount, &F);
15541651
InstrCount = static_cast<int64_t>(InstrCount) + Delta;
15551652
FunctionSize = NewSize;
15561653
}
@@ -1619,10 +1716,11 @@ MPPassManager::runOnModule(Module &M) {
16191716
Changed |= getContainedPass(Index)->doInitialization(M);
16201717

16211718
unsigned InstrCount, ModuleCount = 0;
1719+
StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount;
16221720
bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
16231721
// Collect the initial size of the module.
16241722
if (EmitICRemark) {
1625-
InstrCount = initSizeRemarkInfo(M);
1723+
InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount);
16261724
ModuleCount = InstrCount;
16271725
}
16281726

@@ -1646,7 +1744,8 @@ MPPassManager::runOnModule(Module &M) {
16461744
if (ModuleCount != InstrCount) {
16471745
int64_t Delta = static_cast<int64_t>(ModuleCount) -
16481746
static_cast<int64_t>(InstrCount);
1649-
emitInstrCountChangedRemark(MP, M, Delta, InstrCount);
1747+
emitInstrCountChangedRemark(MP, M, Delta, InstrCount,
1748+
FunctionToInstrCount);
16501749
InstrCount = ModuleCount;
16511750
}
16521751
}

‎llvm/test/Other/size-remarks.ll

Lines changed: 119 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
; Ensure that IR count remarks in the legacy pass manager work.
22
; What this test should check for:
3-
; * Positive, nonzero sizes before/after
3+
; * Positive, nonzero sizes before/after for whole-module remarks
4+
; (It's okay to have nonzero sizes in per-function remarks, since a function
5+
; can be created/destroyed by a pass.)
46
; * Nonzero deltas
57
; * Sizes are being tracked properly across multiple remarks. E.g, if we have
68
; original_count_1, final_count_1, and
@@ -20,56 +22,111 @@
2022
; CGSCC-SAME: IR instruction count changed from
2123
; CGSCC-SAME: [[ORIG:[1-9][0-9]*]] to [[FINAL:[1-9][0-9]*]];
2224
; CGSCC-SAME: Delta: [[DELTA:-?[1-9][0-9]*]]
25+
; CGSCC-NEXT: remark: <unknown>:0:0: Function Integration/Inlining:
26+
; CGSCC-SAME: Function: bar: IR instruction count changed from
27+
; CGSCC-SAME: [[ORIGFN:[1-9][0-9]*]] to [[FINALFN:[0-9][0-9]*]];
28+
; CGSCC-SAME: Delta: [[DELTAFN:-?[1-9][0-9]*]]
2329
; CGSCC-NEXT: ---
2430
; CGSCC-DAG: !Analysis
2531
; CGSCC-NEXT: Pass: size-info
2632
; CGSCC-NEXT: Name: IRSizeChange
2733
; CGSCC-NEXT: Function:
28-
; CGSCC-NEXT: Args:
34+
; CGSCC-NEXT: Args:
2935
; CGSCC-NEXT: - Pass: Function Integration/Inlining
3036
; CGSCC-NEXT: - String: ': IR instruction count changed from '
3137
; CGSCC-NEXT: - IRInstrsBefore: '[[ORIG]]'
3238
; CGSCC-NEXT: - String: ' to '
3339
; CGSCC-NEXT: - IRInstrsAfter: '[[FINAL]]'
3440
; CGSCC-NEXT: - String: '; Delta: '
3541
; CGSCC-NEXT: - DeltaInstrCount: '[[DELTA]]'
42+
; CGSCC-DAG: --- !Analysis
43+
; CGSCC-NEXT: Pass: size-info
44+
; CGSCC-NEXT: Name: FunctionIRSizeChange
45+
; CGSCC-NEXT: Function:
46+
; CGSCC-NEXT: Args:
47+
; CGSCC-NEXT: - Pass: Function Integration/Inlining
48+
; CGSCC-NEXT: - String: ': Function: '
49+
; CGSCC-NEXT: - Function: bar
50+
; CGSCC-NEXT: - String: ': IR instruction count changed from '
51+
; CGSCC-NEXT: - IRInstrsBefore: '[[ORIGFN]]'
52+
; CGSCC-NEXT: - String: ' to '
53+
; CGSCC-NEXT: - IRInstrsAfter: '[[FINALFN]]'
54+
; CGSCC-NEXT: - String: '; Delta: '
55+
; CGSCC-NEXT: - DeltaInstrCount: '[[DELTAFN]]'
56+
; CGSCC-NEXT: ...
3657

3758
; RUN: opt < %s -instcombine -pass-remarks-analysis='size-info' \
3859
; RUN:-pass-remarks-output=%t.yaml -S -o /dev/null 2> %t; \
3960
; RUN: cat %t %t.yaml | FileCheck %s -check-prefix=FUNC
4061
; FUNC: remark: <unknown>:0:0: Combine redundant instructions:
4162
; FUNC-SAME: IR instruction count changed from
42-
; FUNC-SAME: [[SIZE1:[1-9][0-9]*]] to [[SIZE2:[1-9][0-9]*]];
63+
; FUNC-SAME: [[SIZE1:[1-9][0-9]*]] to [[SIZE2:[0-9][0-9]*]];
4364
; FUNC-SAME: Delta: [[DELTA1:-?[1-9][0-9]*]]
65+
; FUNC-NEXT: remark: <unknown>:0:0: Combine redundant instructions: Function:
66+
; FUNC-SAME: foo: IR instruction count changed from
67+
; FUNC-SAME: [[FOOSIZE1:[1-9][0-9]*]] to [[FOOSIZE2:[0-9][0-9]*]];
68+
; FUNC-SAME: Delta: [[DELTAFOO:-?[1-9][0-9]*]]
4469
; FUNC-NEXT: remark: <unknown>:0:0: Combine redundant instructions:
4570
; FUNC-SAME: IR instruction count changed from
4671
; FUNC-SAME: [[SIZE2]] to [[SIZE3:[1-9][0-9]*]];
4772
; FUNC-SAME: Delta: [[DELTA2:-?[1-9][0-9]*]]
73+
; FUNC-NEXT: remark: <unknown>:0:0: Combine redundant instructions: Function:
74+
; FUNC-SAME: bar: IR instruction count changed from
75+
; FUNC-SAME: [[BARSIZE1:[1-9][0-9]*]] to [[BARSIZE2:[0-9][0-9]*]];
76+
; FUNC-SAME: Delta: [[DELTABAR:-?[1-9][0-9]*]]
4877
; FUNC-NEXT: ---
4978
; FUNC-DAG: !Analysis
5079
; FUNC-NEXT: Pass: size-info
5180
; FUNC-NEXT: Name: IRSizeChange
5281
; FUNC-NEXT: Function:
53-
; FUNC-NEXT: Args:
82+
; FUNC-NEXT: Args:
5483
; FUNC-NEXT: - Pass: Combine redundant instructions
5584
; FUNC-NEXT: - String: ': IR instruction count changed from '
5685
; FUNC-NEXT: - IRInstrsBefore: '[[SIZE1]]'
5786
; FUNC-NEXT: - String: ' to '
5887
; FUNC-NEXT: - IRInstrsAfter: '[[SIZE2]]'
5988
; FUNC-NEXT: - String: '; Delta: '
6089
; FUNC-NEXT: - DeltaInstrCount: '[[DELTA1]]'
90+
; FUNC-DAG: --- !Analysis
91+
; FUNC-NEXT: Pass: size-info
92+
; FUNC-NEXT: Name: FunctionIRSizeChange
93+
; FUNC-NEXT: Function:
94+
; FUNC-NEXT: Args:
95+
; FUNC-NEXT: - Pass: Combine redundant instructions
96+
; FUNC-NEXT: - String: ': Function: '
97+
; FUNC-NEXT: - Function: foo
98+
; FUNC-NEXT: - String: ': IR instruction count changed from '
99+
; FUNC-NEXT: - IRInstrsBefore: '[[FOOSIZE1]]'
100+
; FUNC-NEXT: - String: ' to '
101+
; FUNC-NEXT: - IRInstrsAfter: '[[FOOSIZE2]]'
102+
; FUNC-NEXT: - String: '; Delta: '
103+
; FUNC-NEXT: - DeltaInstrCount: '[[DELTAFOO]]'
61104
; FUNC: --- !Analysis
62105
; FUNC-NEXT: Pass: size-info
63106
; FUNC-NEXT: Name: IRSizeChange
64107
; FUNC-NEXT: Function:
65-
; FUNC-NEXT: Args:
108+
; FUNC-NEXT: Args:
66109
; FUNC-NEXT: - Pass: Combine redundant instructions
67110
; FUNC-NEXT: - String: ': IR instruction count changed from '
68111
; FUNC-NEXT: - IRInstrsBefore: '[[SIZE2]]'
69112
; FUNC-NEXT: - String: ' to '
70113
; FUNC-NEXT: - IRInstrsAfter: '[[SIZE3]]'
71114
; FUNC-NEXT: - String: '; Delta: '
72115
; FUNC-NEXT: - DeltaInstrCount: '[[DELTA2]]'
116+
; FUNC-DAG: --- !Analysis
117+
; FUNC-NEXT: Pass: size-info
118+
; FUNC-NEXT: Name: FunctionIRSizeChange
119+
; FUNC-NEXT: Function:
120+
; FUNC-NEXT: Args:
121+
; FUNC-NEXT: - Pass: Combine redundant instructions
122+
; FUNC-NEXT: - String: ': Function: '
123+
; FUNC-NEXT: - Function: bar
124+
; FUNC-NEXT: - String: ': IR instruction count changed from '
125+
; FUNC-NEXT: - IRInstrsBefore: '[[BARSIZE1]]'
126+
; FUNC-NEXT: - String: ' to '
127+
; FUNC-NEXT: - IRInstrsAfter: '[[BARSIZE2]]'
128+
; FUNC-NEXT: - String: '; Delta: '
129+
; FUNC-NEXT: - DeltaInstrCount: '[[DELTABAR]]'
73130

74131
; RUN: opt < %s -globaldce -pass-remarks-analysis='size-info' \
75132
; RUN: -pass-remarks-output=%t.yaml -S -o /dev/null 2> %t; \
@@ -79,19 +136,37 @@
79136
; MODULE-SAME: IR instruction count changed from
80137
; MODULE-SAME: [[ORIG:[1-9][0-9]*]] to [[FINAL:[1-9][0-9]*]];
81138
; MODULE-SAME: Delta: [[DELTA:-?[1-9][0-9]*]]
139+
; MODULE-NEXT: remark:
140+
; MODULE-SAME: Dead Global Elimination: Function: pluto:
141+
; MODULE-SAME: IR instruction count changed from [[ORIGFN:[1-9][0-9]*]] to
142+
; MODULE-SAME: [[FINALFN:[0-9][0-9]*]]; Delta: [[DELTAFN:-?[1-9][0-9]*]]
82143
; MODULE-NEXT: ---
83144
; MODULE-DAG: !Analysis
84145
; MODULE-NEXT: Pass: size-info
85146
; MODULE-NEXT: Name: IRSizeChange
86147
; MODULE-NEXT: Function:
87-
; MODULE-NEXT: Args:
148+
; MODULE-NEXT: Args:
88149
; MODULE-NEXT: - Pass: Dead Global Elimination
89150
; MODULE-NEXT: - String: ': IR instruction count changed from '
90151
; MODULE-NEXT: - IRInstrsBefore: '[[ORIG]]'
91152
; MODULE-NEXT: - String: ' to '
92153
; MODULE-NEXT: - IRInstrsAfter: '[[FINAL]]'
93154
; MODULE-NEXT: - String: '; Delta: '
94155
; MODULE-NEXT: - DeltaInstrCount: '[[DELTA]]'
156+
; MODULE-DAG: --- !Analysis
157+
; MODULE-NEXT: Pass: size-info
158+
; MODULE-NEXT: Name: FunctionIRSizeChange
159+
; MODULE-NEXT: Function:
160+
; MODULE-NEXT: Args:
161+
; MODULE-NEXT: - Pass: Dead Global Elimination
162+
; MODULE-NEXT: - String: ': Function: '
163+
; MODULE-NEXT: - Function: pluto
164+
; MODULE-NEXT: - String: ': IR instruction count changed from '
165+
; MODULE-NEXT: - IRInstrsBefore: '[[ORIGFN]]'
166+
; MODULE-NEXT: - String: ' to '
167+
; MODULE-NEXT: - IRInstrsAfter: '[[FINALFN]]'
168+
; MODULE-NEXT: - String: '; Delta: '
169+
; MODULE-NEXT: - DeltaInstrCount: '[[DELTAFN]]'
95170

96171
; RUN: opt < %s -dce -pass-remarks-analysis='size-info' \
97172
; RUN: -pass-remarks-output=%t.yaml -S -o /dev/null 2> %t; \
@@ -100,6 +175,9 @@
100175
; BB-SAME: IR instruction count changed from
101176
; BB-SAME: [[ORIG:[1-9][0-9]*]] to [[FINAL:[1-9][0-9]*]];
102177
; BB-SAME: Delta: [[DELTA:-?[1-9][0-9]*]]
178+
; BB-NEXT: remark: <unknown>:0:0: Dead Code Elimination: Function: bar:
179+
; BB-SAME: IR instruction count changed from [[ORIGFN:[1-9][0-9]*]] to
180+
; BB-SAME: [[FINALFN:[0-9][0-9]*]]; Delta: [[DELTAFN:-?[1-9][0-9]*]]
103181
; BB-NEXT: ---
104182
; BB-DAG: !Analysis
105183
; BB-NEXT: Pass: size-info
@@ -113,6 +191,20 @@
113191
; BB-NEXT: - IRInstrsAfter: '[[FINAL]]'
114192
; BB-NEXT: - String: '; Delta: '
115193
; BB-NEXT: - DeltaInstrCount: '[[DELTA]]'
194+
; BB-DAG: --- !Analysis
195+
; BB-NEXT: Pass: size-info
196+
; BB-NEXT: Name: FunctionIRSizeChange
197+
; BB-NEXT: Function:
198+
; BB-NEXT: Args:
199+
; BB-NEXT: - Pass: Dead Code Elimination
200+
; BB-NEXT: - String: ': Function: '
201+
; BB-NEXT: - Function: bar
202+
; BB-NEXT: - String: ': IR instruction count changed from '
203+
; BB-NEXT: - IRInstrsBefore: '[[ORIGFN]]'
204+
; BB-NEXT: - String: ' to '
205+
; BB-NEXT: - IRInstrsAfter: '[[FINALFN]]'
206+
; BB-NEXT: - String: '; Delta: '
207+
; BB-NEXT: - DeltaInstrCount: '[[DELTAFN]]'
116208

117209
; RUN: opt < %s -loop-unroll -pass-remarks-analysis='size-info' \
118210
; RUN: -pass-remarks-output=%t.yaml -S -o /dev/null 2> %t; \
@@ -121,19 +213,39 @@
121213
; LOOP-SAME: IR instruction count changed from
122214
; LOOP-SAME: [[ORIG:[1-9][0-9]*]] to [[FINAL:[1-9][0-9]*]];
123215
; LOOP-SAME: Delta: [[DELTA:-?[1-9][0-9]*]]
216+
; LOOP-NEXT: remark: <unknown>:0:0: Unroll loops: Function: bar:
217+
; LOOP-SAME: IR instruction count changed from [[ORIGFN:[1-9][0-9]*]]
218+
; LOOP-SAME: to [[FINALFN:[0-9][0-9]*]];
219+
; Since bar is the only function containing a loop, its delta must be identical
220+
; to the whole module remark's delta.
221+
; LOOP-SAME: Delta: [[DELTA]]
124222
; LOOP-NEXT: ---
125223
; LOOP-DAG: !Analysis
126224
; LOOP-NEXT: Pass: size-info
127225
; LOOP-NEXT: Name: IRSizeChange
128226
; LOOP-NEXT: Function:
129-
; LOOP-NEXT: Args:
227+
; LOOP-NEXT: Args:
130228
; LOOP-DAG: - Pass: Unroll loops
131229
; LOOP-NEXT: - String: ': IR instruction count changed from '
132230
; LOOP-NEXT: - IRInstrsBefore: '[[ORIG]]'
133231
; LOOP-NEXT: - String: ' to '
134232
; LOOP-NEXT: - IRInstrsAfter: '[[FINAL]]'
135233
; LOOP-NEXT: - String: '; Delta: '
136234
; LOOP-NEXT: - DeltaInstrCount: '[[DELTA]]'
235+
; LOOP-DAG: --- !Analysis
236+
; LOOP-NEXT: Pass: size-info
237+
; LOOP-NEXT: Name: FunctionIRSizeChange
238+
; LOOP-NEXT: Function:
239+
; LOOP-NEXT: Args:
240+
; LOOP-NEXT: - Pass: Unroll loops
241+
; LOOP-NEXT: - String: ': Function: '
242+
; LOOP-NEXT: - Function: bar
243+
; LOOP-NEXT: - String: ': IR instruction count changed from '
244+
; LOOP-NEXT: - IRInstrsBefore: '[[ORIGFN]]'
245+
; LOOP-NEXT: - String: ' to '
246+
; LOOP-NEXT: - IRInstrsAfter: '[[FINALFN]]'
247+
; LOOP-NEXT: - String: '; Delta: '
248+
; LOOP-NEXT: - DeltaInstrCount: '[[DELTA]]'
137249
declare i1 ()* @boop()
138250

139251
define internal i1 @pluto() {

0 commit comments

Comments
 (0)
Please sign in to comment.