The last base block of a function in LLVM

Does the back () function of a function guarantee the return of the base block of the CFG terminator to LLVM?

+6
source share
2 answers

I donโ€™t think, since there is no such thing as a โ€œBB terminatorโ€: there can very well be several BBs completed with a return.

+3
source

Not. There may be several basic blocks of a function terminator, for example, a function containing several return statements. each base block containing a function return statement will be called a terminator block or a terminator base block. To find all the base blocks that are the base blocks of the terminator (i.e., contain the return statement), follow these steps:

runOnFunction { for BB in F: for I in BB: if (ReturnInst *RI = dyn_cast<ReturnInst> I) BB is terminator Basic Block endif endfor endfor } 
0
source

Source: https://habr.com/ru/post/910711/


All Articles