[llvm] [ProfileData] Add a variant of getValueProfDataFromInst (PR #95993)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 21:10:08 PDT 2024


================
@@ -294,6 +294,13 @@ getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
                          uint32_t MaxNumValueData, uint32_t &ActualNumValueData,
                          uint64_t &TotalC, bool GetNoICPValue = false);
 
+/// Extract the value profile data from \p Inst and returns them if \p Inst is
+/// annotated with value profile data. Returns an empty vector otherwise.
+std::vector<InstrProfValueData>
----------------
kazutakahirata wrote:

> Does it make sense to use `SmallVector` instead of `std::vector` in this patch?

Sure.  I just built clang with instrumentation FDO.  Four inline elements would cover 100% of the cases.  Three inline elements would cover 84% of the cases.  Given:

```
sizeof(SmallVector<InstrProfValueData> == 64
sizeof(SmallVector<InstrProfValueData, 3>) == 64
sizeof(SmallVector<InstrProfValueData, 4>) == 80
```

I think we can go with either 3 or 4.

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


More information about the llvm-commits mailing list