[clang] [Clang] Emit type metadata on vtables when IRPGO instrumentation option is on. (PR #70841)

Mingming Liu via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 22:18:44 PDT 2023


================
@@ -0,0 +1,145 @@
+// Test that type metadata are emitted with -fprofile-generate
+//
+// RUN: %clang -fprofile-generate -fno-lto -target x86_64-unknown-linux -emit-llvm -S %s -o - | FileCheck %s --check-prefix=ITANIUM
+// RUN: %clang -fprofile-generate -fno-lto -target x86_64-pc-windows-msvc -emit-llvm -S %s -o - | FileCheck %s --check-prefix=MS
----------------
minglotus-6 wrote:

thanks! I updated the existing test (and removed the forked one) by only generating `!type` annotations iff clang cc1 option `-fprofile-instrument` is set to `llvm` (the FDO build).  CS-FDO and clang instrumentation sets this cc1 option differently, and it's intentional for this PR not to emit `!type` in these two settings mainly because there is no usage.

A longer story from some interesting findings when I tried to figured out how clang options work for the use case in this pr. Currently, clang driver accepts two options for FDO
   1.  `-fprofile-generate` (a [`Flag`](https://github.com/llvm/llvm-project/blob/c14e086b23929b0ac7092c45349a4f9749eda39c/clang/include/clang/Driver/Options.td#L1653) option that doesn't accept value according to https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option
  2. `-fprofile-generate=` (a [`Joined`](https://github.com/llvm/llvm-project/blob/c14e086b23929b0ac7092c45349a4f9749eda39c/clang/include/clang/Driver/Options.td#L1656) option that accepts the value 
  
I initially add [`CC1Option`](https://github.com/llvm/llvm-project/blob/c14e086b23929b0ac7092c45349a4f9749eda39c/clang/include/clang/Driver/Options.td#L64) to both (and added corresponding codegen options); and during this process found `-fprofile-instrument=llvm` is true if clang user either specified `-fprofile-generate` or `-fprofile-generate=path/to` (but not CS-FDO or clang instrumentation FDO),  so decided to just rely on this.
   

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


More information about the cfe-commits mailing list