================ @@ -488,6 +490,35 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction { /// Callee type id. ConstantInt *TypeId = nullptr; + + CallSiteInfo() {} + + /// Extracts the numeric type id from the CallBase's type operand bundle, + /// and sets TypeId. This is used as type id for the indirect call in the + /// call graph section. + CallSiteInfo(const CallBase &CB) { + // Call graph section needs numeric type id only for indirect calls. + if (!CB.isIndirectCall()) + return; + + auto Opt = CB.getOperandBundle(LLVMContext::OB_type); + if (!Opt.has_value()) + return; + + // Get generalized type id string + auto OB = Opt.value(); ---------------- ilovepi wrote:
What kind of UB are you referring to? The typical/recommended usage is to check validity either using `has_value()` or `operator()` e.g. `if(!opt) return;`, and then use `*Opt` as needed w/o using `.value()`. Also, FWIW, we had some large code changes removing the use of `optional.has_value()/optional.value()` a while back to use these patterns. https://github.com/llvm/llvm-project/pull/87575 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits