'How to find two llvm basic blocks correspond to a part of if-then body and a part of if-else body in the if statement
When I want to check the branches of opposites on LLVM IR's cfg, what should I do to find that these two basic blocks correspond to a part of paired if-then body and if-else body in the if statement?
for example:
int foo(int a, int b, int c){
if(a > b){
c = 1;
if(a / 2 > b * 3){
c = 3;
}
}else{
c = 2;
}
c ++;
return c;
}
How can I find the block if.then and the block if.else be the part of paired if-else's body and if-then's body in the source code?
I have an idea. I don't know whether it's feasible.
My opinion is to find the control dependency of if.then and if.else by post dominators and check the dependency edges have same inner node (here is entry) and entry has only these two outer edges on cfg.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

