Skip to content
Snippets Groups Projects
Commit 5c2f443c authored by kotsifa2's avatar kotsifa2
Browse files

Bug fixes in dfg2llvm-nxptx pass.

parent b0779fd6
No related branches found
No related tags found
No related merge requests found
......@@ -186,8 +186,10 @@ namespace {
DEBUG(errs() << F_nvptx->getName() << "\t: Handling getNodeInstanceID\n");
ArgII = cast<IntrinsicInst>((II->getOperand(0))->stripPointerCasts());
ArgDFNode = Leaf_HandleToDFNodeMap[ArgII];
assert(ArgDFNode && "Arg node is NULL");
// A leaf node always has a parent
DFNode* ParentDFNode = DFG.getHandleToDFNodeMap()[ArgII];
DFNode* ParentDFNode = ArgDFNode->getParent();
assert(ParentDFNode && "Parent node of a leaf is NULL");
// Get the number associated with the required dimension
// FIXME: The order is important!
......@@ -195,6 +197,7 @@ namespace {
uint64_t dim = II->getIntrinsicID() -
Intrinsic::visc_getNodeInstanceID_x;
assert((dim >= 0) && (dim < 3) && "Invalid dimension argument");
DEBUG(errs() << "\t dimension = " << dim << "\n");
// Argument of the function to be called
ConstantInt * DimConstant =
......@@ -259,7 +262,8 @@ namespace {
ArgII = cast<IntrinsicInst>((II->getOperand(0))->stripPointerCasts());
ArgDFNode = Leaf_HandleToDFNodeMap[ArgII];
// A leaf node always has a parent
DFNode* ParentDFNode = DFG.getHandleToDFNodeMap()[ArgII];
DFNode* ParentDFNode = ArgDFNode->getParent();
assert(ParentDFNode && "Parent node of a leaf is NULL");
// Get the number associated with the required dimension
// FIXME: The order is important!
......@@ -267,6 +271,7 @@ namespace {
uint64_t dim = II->getIntrinsicID() -
Intrinsic::visc_getNumNodeInstances_x;
assert((dim >= 0) && (dim < 3) && "Invalid dimension argument");
DEBUG(errs() << "\t dimension = " << dim << "\n");
// Argument of the function to be called
ConstantInt * DimConstant =
......@@ -327,11 +332,13 @@ namespace {
}
//We need to do this explicitly: DCE pass will not remove them because we
// We need to do this explicitly: DCE pass will not remove them because we
// have assumed theworst memory behaviour for these function calls
for (std::vector<IntrinsicInst *>::iterator i = IItoRemove.begin();
i != IItoRemove.end(); ++i)
(*i)->eraseFromParent();
// Traverse the vector backwards, otherwise definitions are deleted while
// their subsequent uses are still around
for (std::vector<IntrinsicInst *>::reverse_iterator ri = IItoRemove.rbegin(),
re = IItoRemove.rend(); ri != re; ++ri)
(*ri)->eraseFromParent();
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment