[llvm] [clang-tools-extra] [clang] [compiler-rt] [IRPGO][ValueProfile] Instrument virtual table address that could be used to do virtual table address comparision for indirect-call-promotion. (PR #66825)

Mingming Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 15 14:46:10 PST 2023


================
@@ -1441,6 +1531,9 @@ void OverlapStats::dump(raw_fd_ostream &OS) const {
     case IPVK_MemOPSize:
       strncpy(ProfileKindName, "MemOP", 19);
       break;
+    case IPVK_VTableTarget:
+      strncpy(ProfileKindName, "VTable", 6);
----------------
minglotus-6 wrote:

thanks for the catch! I updated this to `strncpy(ProfileKindName, "VTable", 19);`.
 Updated the initializer to `ProfileKindName[20] = {0}` to make it clearer.
- C string literals are [null terminated](https://softwareengineering.stackexchange.com/questions/344603/are-c-strings-always-null-terminated-or-does-it-depend-on-the-platform), and `strncpy` will [pad destination will zeros if the end of source is seen](https://cplusplus.com/reference/cstring/strncpy/) before 19 chars are copied here.

I just realized '19' is chosen as 'sizeof(ProfileKindName) - 1' with this comment.


https://github.com/llvm/llvm-project/pull/66825


More information about the cfe-commits mailing list