This is an archive of the discontinued LLVM Phabricator instance.

[SampleFDO] Provide a virtual desructor for SampleProfileLoaderBaseImpl
ClosedPublic

Authored by kazu on Feb 16 2021, 12:47 PM.

Details

Summary

This patch fixes a warning:

llvm-project/llvm/include/llvm/ProfileData/SampleProfileLoaderBaseImpl.h:69:7:
error: 'llvm::SampleProfileLoaderBaseImpl' has virtual functions but
non-virtual destructor [-Werror,-Wnon-virtual-dtor]

That said, I am not sure who is responsible for freeing:

FunctionSamples *Samples = nullptr;

Diff Detail

Event Timeline

kazu created this revision.Feb 16 2021, 12:47 PM
kazu requested review of this revision.Feb 16 2021, 12:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2021, 12:47 PM
xur accepted this revision.Feb 16 2021, 1:06 PM

Thanks for fixing this. I think this is fine. I don't think there will a direct allocation of the base type. We always use the derived type to allocate the object.
Samples field will be freed by the Reader which is an uniqe_pointer.

This revision is now accepted and ready to land.Feb 16 2021, 1:06 PM
This revision was landed with ongoing or failed builds.Feb 16 2021, 1:18 PM
This revision was automatically updated to reflect the committed changes.

Hey, sorry - my commit to fix this (making the dtor protected and default, but non-virtual) collided with this one, so I undid this one in favor of mine. (since the objects don't seem to be owned polymorphically, but concretely such as in llvm/lib/Transforms/IPO/SampleProfile.cpp: SampleProfileLoader SampleLoader;

No worry. This fix also works for me. Thank you and Kazu for the quick
response! Much appreciated.

-Rong