Skip to content

Commit 5c7902d

Browse files
resolve comment
1 parent 29a4c14 commit 5c7902d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ static cl::list<std::string>
168168
cl::desc("Prevent function(s) from being devirtualized"),
169169
cl::Hidden, cl::CommaSeparated);
170170

171-
/// If this value is other than 0, the devirt module pass will stop
172-
/// transformation once the total number of devirtualizations reach the cutoff
173-
/// value.
171+
/// If explicitly specified, the devirt module pass will stop transformation
172+
/// once the total number of devirtualizations reach the cutoff value. Setting
173+
/// this option to 0 explicitly will do 0 devirtualization.
174174
static cl::opt<unsigned> WholeProgramDevirtCutoff(
175175
"wholeprogramdevirt-cutoff",
176-
cl::desc("Max number of devirtualization for devirt module pass"),
176+
cl::desc("Max number of devirtualizations for devirt module pass"),
177177
cl::init(0));
178178

179179
/// Mechanism to add runtime checking of devirtualization decisions, optionally
@@ -324,6 +324,9 @@ VirtualCallTarget::VirtualCallTarget(GlobalValue *Fn, const TypeMemberInfo *TM)
324324

325325
namespace {
326326

327+
// Tracks the number of devirted calls in the IR transformation.
328+
static unsigned NumDevirtCalls = 0;
329+
327330
// A slot in a set of virtual tables. The TypeID identifies the set of virtual
328331
// tables, and the ByteOffset is the offset in bytes from the address point to
329332
// the virtual function pointer.
@@ -1177,14 +1180,16 @@ void DevirtModule::applySingleImplDevirt(VTableSlotInfo &SlotInfo,
11771180
if (!OptimizedCalls.insert(&VCallSite.CB).second)
11781181
continue;
11791182

1183+
// Stop when the number of devirted calls reaches the cutoff.
11801184
if (WholeProgramDevirtCutoff.getNumOccurrences() > 0 &&
1181-
NumSingleImpl >= WholeProgramDevirtCutoff)
1185+
NumDevirtCalls >= WholeProgramDevirtCutoff)
11821186
return;
11831187

11841188
if (RemarksEnabled)
11851189
VCallSite.emitRemark("single-impl",
11861190
TheFn->stripPointerCasts()->getName(), OREGetter);
11871191
NumSingleImpl++;
1192+
NumDevirtCalls++;
11881193
auto &CB = VCallSite.CB;
11891194
assert(!CB.getCalledFunction() && "devirtualizing direct call?");
11901195
IRBuilder<> Builder(&CB);

0 commit comments

Comments
 (0)