I want to check if a call instruction is part of a control flow, say if(cond) call1 else call2, i want to check for each callsite CallBase object, if this callsite lies in a block that is in a conditional control flow, how do I check that?

I want to check if a call site CallBase, lies in a block which is in a block that is conditionally reached, say

define i32 @foo(i1 %condition) {
    br i1 %condition, label %true_block, label %false_block

    %call_true = call i32 @bar()
    br label %exit_block

    %call_false = call i32 @baz()
    br label %exit_block

    %result = phi i32 [ %call_true, %true_block ], [ %call_false, %false_block ]
    ret i32 %result

Here bar() and baz() are conditionally reached, so yes for those two call sites, but say if the entry had a call called foo() it would not be conditional.

Is there an API that can tell me this, if not what are the algorithmic steps I need to write to check it, I suspect I would need Dominator Information as well, I appreciate any help. Thanks!

I think pretty much similar has been discussed here How to determine whether an IR is in main function but not in control flow block?

Thanks this helped, But I am still unsure when the parent block of CallBase is part of a loop block, will the hypothesis still hold, true, that if the parent block of CallBase does not postdominte Entry then it lies inside conditionally reached Basic Block?