Merge pull request #1 from drcut/MICRO_dev
fix bug for AllocaInst that are wrapped in a PR
This commit is contained in:
commit
50d615da64
|
@ -319,6 +319,7 @@ void handle_local_variable_intra_warp(std::vector<ParallelRegion> PRs,
|
|||
// we should handle allocation generated by PHI
|
||||
{
|
||||
std::vector<llvm::Instruction *> instruction_to_fix;
|
||||
std::vector<llvm::AllocaInst *> instruction_to_move;
|
||||
auto F = PRs[0].start_block->getParent();
|
||||
for (auto bb = F->begin(); bb != F->end(); bb++) {
|
||||
for (auto ii = bb->begin(); ii != bb->end(); ii++) {
|
||||
|
@ -343,6 +344,7 @@ void handle_local_variable_intra_warp(std::vector<ParallelRegion> PRs,
|
|||
}
|
||||
}
|
||||
if (allStoreNonDivergence) {
|
||||
instruction_to_move.push_back(alloc);
|
||||
continue;
|
||||
}
|
||||
// Do not duplicate var used outside PRs
|
||||
|
@ -366,6 +368,8 @@ void handle_local_variable_intra_warp(std::vector<ParallelRegion> PRs,
|
|||
}
|
||||
if (!used_in_non_PR) {
|
||||
instruction_to_fix.push_back(alloc);
|
||||
} else {
|
||||
instruction_to_move.push_back(alloc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -373,6 +377,18 @@ void handle_local_variable_intra_warp(std::vector<ParallelRegion> PRs,
|
|||
for (auto inst : instruction_to_fix) {
|
||||
AddContextSaveRestore(inst, intra_warp_loop);
|
||||
}
|
||||
for (auto alloc : instruction_to_move) {
|
||||
// need to move all allocInst to the entry basic block
|
||||
IRBuilder<> builder(&*(alloc->getParent()
|
||||
->getParent()
|
||||
->getEntryBlock()
|
||||
.getFirstInsertionPt()));
|
||||
auto newAllocInst =
|
||||
builder.CreateAlloca(alloc->getType()->getElementType(),
|
||||
alloc->getArraySize(), alloc->getName());
|
||||
alloc->replaceAllUsesWith(newAllocInst);
|
||||
alloc->removeFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto parallel_regions : PRs) {
|
||||
|
|
Loading…
Reference in New Issue