================
@@ -488,6 +490,38 @@ 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()) {
+        errs() << "warning: cannot find indirect call type operand bundle for  
"
+                  "call graph section\n";
+        return;
----------------
ilovepi wrote:

If you really need a diagnostic in these cases, you'll need to use one of the 
diagnostic handlers. Even if it was wrapped in `LLVM_DEBUG`, the existing 
warning has no context, so it isn't actionable to the user (e.g. no ability to 
know which function or call site is the problem).  
https://github.com/llvm/llvm-project/blob/b1b1bfa7bea0ce489b5ea9134e17a43c695df5ec/llvm/include/llvm/IR/DiagnosticInfo.h#L1036
 is an example diagnostic I've implemented in the past, but I'm not 100% sure 
those are appropriate at this point in the backend. I think its probably fine, 
but you can probably check some of the other files under `CodeGen` to find a 
related example. I'll take a look tomorrow to see if I can point you in the 
right direction.

All in all, though I'd suggest dropping for now. But if you really need it, 
then you'll need to create a diagnostic type and use the `diagnose` (or is it 
`Report`?) API from the context (or the closest diagnostic handler ... I'd have 
to doublecheck). I'd also guard the diagnostic by checking if the call graph 
section is enabled. I believe you have a codegen flag for it, so you should be 
able to guard whatever you're spitting out only in cases where the message 
makes sense.

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

Reply via email to