Reputation: 2347
Does the back() of a Function guarantee to return the terminator basic block of CFG in LLVM?
Upvotes: 9
Views: 4109
Reputation: 2004
No. There could be multiple terminator basic blocks of a function, for instance a function containing multiple return statements. each basic block that contains a return statement from the function will then be called a terminator block or terminator basic block. To detect all basic blocks that are terminator basic blocks (i.e. contain a return statement) do the following:
runOnFunction {
for BB in F:
for I in BB:
if (ReturnInst *RI = dyn_cast<ReturnInst> I)
BB is terminator Basic Block
endif
endfor
endfor
}
Upvotes: 1
Reputation: 30281
I don't think, since there's no such a thing as a "terminator BB": there very well may be multiple BBs terminated by a return.
Upvotes: 6