Skip to content

Commit 0922a15

Browse files
committed
Adds debug statements to ARM areInlineCompatible
This makes it easier to see why your function isn't getting inlined for.
1 parent ea8e670 commit 0922a15

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,53 @@ bool ARMTTIImpl::areInlineCompatible(const Function *Caller,
102102
// the callers'.
103103
bool MatchSubset = ((CallerBits & CalleeBits) & InlineFeaturesAllowed) ==
104104
(CalleeBits & InlineFeaturesAllowed);
105+
106+
LLVM_DEBUG({
107+
dbgs() << "=== Inline compatibility debug ===\n";
108+
dbgs() << "Caller: " << Caller->getName() << "\n";
109+
dbgs() << "Callee: " << Callee->getName() << "\n";
110+
111+
// Bit diffs
112+
FeatureBitset MissingInCaller = CalleeBits & ~CallerBits; // callee-only
113+
FeatureBitset ExtraInCaller = CallerBits & ~CalleeBits; // caller-only
114+
115+
// Counts
116+
dbgs() << "Only-in-caller bit count: " << ExtraInCaller.count() << "\n";
117+
dbgs() << "Only-in-callee bit count: " << MissingInCaller.count() << "\n";
118+
119+
dbgs() << "Only-in-caller feature indices [";
120+
{
121+
bool First = true;
122+
for (size_t I = 0, E = ExtraInCaller.size(); I < E; ++I) {
123+
if (ExtraInCaller.test(I)) {
124+
if (!First)
125+
dbgs() << ", ";
126+
dbgs() << I;
127+
First = false;
128+
}
129+
}
130+
}
131+
dbgs() << "]\n";
132+
133+
dbgs() << "Only-in-callee feature indices [";
134+
{
135+
bool First = true;
136+
for (size_t I = 0, E = MissingInCaller.size(); I < E; ++I) {
137+
if (MissingInCaller.test(I)) {
138+
if (!First)
139+
dbgs() << ", ";
140+
dbgs() << I;
141+
First = false;
142+
}
143+
}
144+
}
145+
dbgs() << "]\n";
146+
147+
// Indicies map to features as found in
148+
// llvm-project/(your_build)/lib/Target/ARM/ARMGenSubtargetInfo.inc
149+
dbgs() << "MatchExact=" << (MatchExact ? "true" : "false")
150+
<< " MatchSubset=" << (MatchSubset ? "true" : "false") << "\n";
151+
});
105152
return MatchExact && MatchSubset;
106153
}
107154

0 commit comments

Comments
 (0)