Basic blocks of codes are the number of instructions exist in a source code, which are executed sequentially.
Basic blocks are sequence of codes.
Some of the statements which ends sequence of codes and give born to basic blocks are,
- If Else
- Switch Case
- Do While, etc.
For example:
Take source code as shown below.
a = 0;
b = b+c;
c = 0;
If (a>d)
{
c = b;
b++;
}
else
{
c = d;
d++;
}
a= b+d;
Basic blocks in above source code are
(1) | (2) | (3) | (4) |
a = 0;b = b+c;c = 0; | c = b;b++; | c = d;d++; | a= b+d; |
Basic blocks are useful in finding repeated variables, used in same basic clock.