Skip to content

Commit

Permalink
[jnc_ct] use llvm::Instruction* instead of llvm::BasicBlock::iterator…
Browse files Browse the repository at this point in the history
… for reaction instruction

also use llvm::Instruction::getNextNode instead of BasicBlock::iterator::operator++
  • Loading branch information
vovkos committed Jun 26, 2024
1 parent 8832ee0 commit e4f2d9a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/jnc_ct/jnc_ct_ControlFlowMgr/jnc_ct_ControlFlowMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct ReactorBody {
BasicBlock* m_bodyBlock;
BasicBlock* m_followBlock;
BasicBlock* m_reactionBlock;
llvm::BasicBlock::iterator m_llvmReactionIt;
llvm::Instruction* m_llvmReactionInst;
Value m_reactionIdxValue;
Value m_userDataValue;
size_t m_reactionBindingCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ControlFlowMgr::enterReactor(
m_reactorBody->m_followBlock = createBlock("reactor_follow");
m_reactorBody->m_reactionBlock = NULL;
m_reactorBody->m_reactionBindingCount = 0;
m_reactorBody->m_llvmReactionInst = NULL;

setCurrentBlock(m_reactorBody->m_bodyBlock);
m_reactorBody->m_bodyBlock->m_flags |= BasicBlockFlag_Jumped | BasicBlockFlag_Reachable;
Expand Down Expand Up @@ -177,7 +178,7 @@ ControlFlowMgr::finalizeReactiveExpressionImpl() {

BasicBlock* reactionBlock;

if (!m_reactorBody->m_llvmReactionIt)
if (!m_reactorBody->m_llvmReactionInst)
reactionBlock = m_reactorBody->m_reactionBlock;
else {
llvm::BasicBlock* llvmBlock = m_reactorBody->m_reactionBlock->getLlvmBlock();
Expand All @@ -190,7 +191,7 @@ ControlFlowMgr::finalizeReactiveExpressionImpl() {
reactionBlock = new BasicBlock(m_module, "reaction_block");
reactionBlock->m_function = m_reactorBody->m_reactionBlock->m_function;
reactionBlock->m_llvmBlock = llvmBlock->splitBasicBlock(
++m_reactorBody->m_llvmReactionIt,
m_reactorBody->m_llvmReactionInst->getNextNode(),
reactionBlock->m_name >> toLlvm
);

Expand All @@ -201,7 +202,7 @@ ControlFlowMgr::finalizeReactiveExpressionImpl() {
size_t reactionIdx = m_reactorBody->m_reactionBlockArray.getCount();
m_reactorBody->m_reactionBlockArray.append(reactionBlock);
m_reactorBody->m_reactionBlock = NULL;
m_reactorBody->m_llvmReactionIt = NULL;
m_reactorBody->m_llvmReactionInst = NULL;
return reactionIdx;
}

Expand Down
2 changes: 1 addition & 1 deletion src/jnc_ct/jnc_ct_FunctionMgr/jnc_ct_AsyncRegionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ AsyncRegionMgr::preserveCrossRegionValue(
getLlvmInstructionString(llvmAlloca).sz()
);

llvm::Instruction* llvmNextInst = &*++llvm::BasicBlock::iterator(llvmOpInst);
llvm::Instruction* llvmNextInst = llvmOpInst->getNextNode();
ASSERT(llvmNextInst); // each block must have a terminator, which is never an operand
llvmIrBuilder->SetInsertPoint(llvmNextInst);
llvmIrBuilder->CreateStore(llvmOpInst, llvmAlloca);
Expand Down
2 changes: 1 addition & 1 deletion src/jnc_ct/jnc_ct_Module/jnc_ct_LlvmIrBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ LlvmIrBuilder::restoreInsertPoint(const LlvmIrInsertPoint& insertPoint) {
if (insertPoint.m_llvmInstruction == &insertPoint.m_llvmBlock->back())
m_llvmIrBuilder->SetInsertPoint(insertPoint.m_llvmBlock);
else
m_llvmIrBuilder->SetInsertPoint(&*++llvm::BasicBlock::iterator(insertPoint.m_llvmInstruction));
m_llvmIrBuilder->SetInsertPoint(insertPoint.m_llvmInstruction->getNextNode());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/jnc_ct/jnc_ct_Module/jnc_ct_Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ ControlFlowMgr::enterReactiveExpression() {
m_reactorBody->m_reactionBindingCount = 0;

if (m_module->hasCodeGen() && !m_currentBlock->getLlvmBlock()->empty())
m_reactorBody->m_llvmReactionIt = llvm::BasicBlock::iterator(m_currentBlock->getLlvmBlock()->back());
m_reactorBody->m_llvmReactionInst = &m_currentBlock->getLlvmBlock()->back();
}

//..............................................................................
Expand Down

0 comments on commit e4f2d9a

Please sign in to comment.