for example, the builtinFunction() can only in main function but cannot in if/switch
//case1:
if(flag)
builtinFunction();//error
//case2:
switch(num)
case1:
builtinFunction();//error
break;
default:
for example, the builtinFunction() can only in main function but cannot in if/switch
//case1:
if(flag)
builtinFunction();//error
//case2:
switch(num)
case1:
builtinFunction();//error
break;
default:
The terms in main function
and not in control flow block
are quite fuzzy. If you mean something like there are no paths from a function entrypoint to all function returns that skip builtinFunction
invocation, then dominance and post-dominance may be things you’re looking for.
I’m assuming that what you want to know is if a basic block is not contained within conditional block, such as an if
, switch
, or while
block; in other words, what you want to ask is whether or not there are any conditions that control the execution of a block (aka, control dependence).
Two basic blocks A and B have the same control dependences if and only if A dominates B and B postdominates A. By definition, the entry block of a function dominates all other blocks in the function. Consequently, all you need to check is whether or not the block you are interested in postdominates the entry block. This will guarantee that the block, and every instruction within it, is executed exactly once every time the function is executed.
Unfortunately, the non-entry block you’re looking at could be in a loop and still post-dominate the entry…
Yes, I want to ask is whether or not there are any conditions that control the execution of a block.
Thank you very much!
I think follows picture cannot meet this definition.
A and B have the same control dependence C, but A don’t dominates B and B don’t postdominates A.