2012-12-07 2 views

답변

0

넌 LLVM을 사용하려고 할 :: PHINode :: getBasicBlockIndex (const BasicBlock * BB).

1

이전 질문이지만 최근에 같은 대답을해야했습니다. CFGStmtMap을 사용하여 문의 BBL을 쿼리 할 수 ​​있습니다.

const FunctionDecl* FD = ...; 
const CFG* cfg = ...; 
std::unique_ptr<ParentMap> PM = llvm::make_unique<ParentMap>(FD->getBody()); 
std::unique_ptr<CFGStmtMap> CM = llvm::make_unique<CFGStmtMap>(cfg, PM.get()); 
// do your traversal and for a given Stmt `stmt` you can get 
// its containing block: 
CFGBlock* stmt_block = CM->getBlock(stmt); 
const unsigned int block_id = stmt_block->getBlockID();