diff --git a/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp b/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp
index 8ec14c80805c052b4a356df7b29b6f1cae2ab775..a0fa9fcde477018cf00af5c932512ce804105c9d 100644
--- a/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp
+++ b/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp
@@ -1541,11 +1541,7 @@ void CGT_X86::codeGen(DFInternalNode *N) {
     DEBUG(errs() << "hasx86GenFuncForCPU : " << CFx86 << "\n");
     DEBUG(errs() << "GPU Fun: " << (GF ? GF->getName() : "null") << "\n");
     DEBUG(errs() << "hasx86GenFuncForGPU : " << GFx86 << "\n");
-<<<<<<< HEAD
-=======
-    DEBUG(errs() << "SPIR Fun: " << (SF ? SF->getName() : "null" ) << "\n");
-    DEBUG(errs() << "hasx86GenFuncForSPIR : " << SFx86 << "\n");
-    
+
     DEBUG(errs() << "Node Name (for policy) : "
                  << N->getFuncPointer()->getName() << "\n");
 
@@ -1565,17 +1561,19 @@ void CGT_X86::codeGen(DFInternalNode *N) {
     FunctionType *FT = CF->getFunctionType();
     if (GF)
       assert(FT == GF->getFunctionType() &&
-             "Type mismatch between generated functions for GPU and CPU targets.\n");
+             "Type mismatch between generated functions for GPU and CPU "
+             "targets.\n");
 
     // Code generation of wrapper function
     Function *F_wrapper;
     ValueToValueMapTy VMap;
-    F_wrapper = Function::Create(FT, CF->getLinkage(), CF->getName()+"_wrapper", &M);
+    F_wrapper =
+        Function::Create(FT, CF->getLinkage(), CF->getName() + "_wrapper", &M);
 
     // Copy argument names over
     Function::arg_iterator dest_iterator = F_wrapper->arg_begin();
-    for (Function::arg_iterator i = CF->arg_begin(), e = CF->arg_end();
-         i != e; ++i) {
+    for (Function::arg_iterator i = CF->arg_begin(), e = CF->arg_end(); i != e;
+         ++i) {
       dest_iterator->setName(i->getName());
       VMap[&*i] = &*dest_iterator;
       ++dest_iterator;
@@ -1583,7 +1581,8 @@ void CGT_X86::codeGen(DFInternalNode *N) {
     // Gather all arguments of wrapper in a vector, to prepare the call to
     // the individual gen functions
     std::vector<Value *> GenFuncCallArgs;
-    for (Function::arg_iterator i = F_wrapper->arg_begin(), e = F_wrapper->arg_end();
+    for (Function::arg_iterator i = F_wrapper->arg_begin(),
+                                e = F_wrapper->arg_end();
          i != e; ++i) {
       GenFuncCallArgs.push_back(&*i);
     }
@@ -1593,33 +1592,33 @@ void CGT_X86::codeGen(DFInternalNode *N) {
     BBcurrent = BasicBlock::Create(M.getContext(), "entry", F_wrapper);
 
     StringRef FName = N->getFuncPointer()->getName();
-    size_t nameSize = FName.size()+1;
+    size_t nameSize = FName.size() + 1;
     std::vector<Constant *> NameV;
-    for (char c: FName) {
+    for (char c : FName) {
       NameV.push_back(ConstantInt::get(Type::getInt8Ty(M.getContext()), c));
     }
     NameV.push_back(ConstantInt::get(Type::getInt8Ty(M.getContext()), '\0'));
     ArrayType *NameType =
-      ArrayType::get(IntegerType::get(M.getContext(), 8), nameSize);
+        ArrayType::get(IntegerType::get(M.getContext(), 8), nameSize);
     AllocaInst *AI = new AllocaInst(NameType, 0, nullptr, "", BBcurrent);
     Constant *NameConst = ConstantArray::get(NameType, NameV);
     StoreInst *StI = new StoreInst(NameConst, AI, BBcurrent);
-    CastInst *BI = BitCastInst::CreatePointerCast(AI,
-                     Type::getInt8PtrTy(M.getContext()), "", BBcurrent);
+    CastInst *BI = BitCastInst::CreatePointerCast(
+        AI, Type::getInt8PtrTy(M.getContext()), "", BBcurrent);
     std::vector<Value *> Args;
     Args.push_back(BI);
-    Args.push_back(ConstantInt::get(Type::getInt64Ty(M.getContext()), -1, true));
-    FunctionCallee RTF =
-      M.getOrInsertFunction("llvm_visc_policy_getVersion",
-      runtimeModule->getFunction("llvm_visc_policy_getVersion")->getFunctionType());
+    Args.push_back(
+        ConstantInt::get(Type::getInt64Ty(M.getContext()), -1, true));
+    FunctionCallee RTF = M.getOrInsertFunction(
+        "llvm_visc_policy_getVersion",
+        runtimeModule->getFunction("llvm_visc_policy_getVersion")
+            ->getFunctionType());
     CallInst *RTFInst = CallInst::Create(RTF, Args, "", BBcurrent);
 
     ConstantInt *CmpConst =
-      ConstantInt::get(Type::getInt32Ty(M.getContext()), 0, true);
-    CmpInst *CmpI = CmpInst::Create(Instruction::ICmp,
-                                    CmpInst::ICMP_EQ,
-                                    RTFInst, CmpConst,
-                                    "", BBcurrent);
+        ConstantInt::get(Type::getInt32Ty(M.getContext()), 0, true);
+    CmpInst *CmpI = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ,
+                                    RTFInst, CmpConst, "", BBcurrent);
 
     BBtrue = BasicBlock::Create(M.getContext(), "version_cpu", F_wrapper);
     BBfalse = BasicBlock::Create(M.getContext(), "not_cpu", F_wrapper);
@@ -1632,51 +1631,53 @@ void CGT_X86::codeGen(DFInternalNode *N) {
     BBcurrent = BBfalse;
     if (GF) {
       // We have a GPU version. Generate policy check and call
-      CmpConst =
-         ConstantInt::get(Type::getInt32Ty(M.getContext()), 1, true);
-      CmpI = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ,
-                             RTFInst, CmpConst, "", BBcurrent);
-      BBtrue =  BasicBlock::Create(M.getContext(), "version_gpu", F_wrapper);
+      CmpConst = ConstantInt::get(Type::getInt32Ty(M.getContext()), 1, true);
+      CmpI = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, RTFInst,
+                             CmpConst, "", BBcurrent);
+      BBtrue = BasicBlock::Create(M.getContext(), "version_gpu", F_wrapper);
       BBfalse = BasicBlock::Create(M.getContext(), "not_gpu", F_wrapper);
       BrI = BranchInst::Create(BBtrue, BBfalse, CmpI, BBcurrent);
-      
+
       GenFuncCI = CallInst::Create(GF, GenFuncCallArgs, "", BBtrue);
       RI = ReturnInst::Create(M.getContext(), GenFuncCI, BBtrue);
 
       if (DeviceAbstraction) {
-        // Prepare arguments and function for call to wait for device runtime call
+        // Prepare arguments and function for call to wait for device runtime
+        // call
         std::vector<Value *> Args; // TODO: add the device type as argument?
-        FunctionCallee RTF =
-          M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus",
-          runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType());
+        FunctionCallee RTF = M.getOrInsertFunction(
+            "llvm_visc_deviceAbstraction_waitOnDeviceStatus",
+            runtimeModule
+                ->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")
+                ->getFunctionType());
         CallInst *RTFInst = CallInst::Create(RTF, Args, "", GenFuncCI);
       }
     }
 
     // Switch basic block pointers
     BBcurrent = BBfalse;
-   // if (SF) {
-      // We have a GPU version. Generate policy check and call
-   //   CmpConst =
-     //    ConstantInt::get(Type::getInt32Ty(M.getContext()), 2, true);
-      //CmpI = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ,
-        //                     RTFInst, CmpConst, "", BBcurrent);
-      //BBtrue =  BasicBlock::Create(M.getContext(), "version_spir", F_wrapper);
-     // BBfalse = BasicBlock::Create(M.getContext(), "not_spir", F_wrapper);
-     // BrI = BranchInst::Create(BBtrue, BBfalse, CmpI, BBcurrent);
-      
-     // GenFuncCI = CallInst::Create(SF, GenFuncCallArgs, "", BBtrue);
-     // RI = ReturnInst::Create(M.getContext(), GenFuncCI, BBtrue);
-
-     // if (DeviceAbstraction) {
-        // Prepare arguments and function for call to wait for device runtime call
-      //  std::vector<Value *> Args; // TODO: add the device type as argument?
-       // FunctionCallee RTF =
-        //  M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus",
-         // runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType());
-       // CallInst *RTFInst = CallInst::Create(RTF, Args, "", GenFuncCI);
-     // }
-   // }
+    // if (SF) {
+    // We have a GPU version. Generate policy check and call
+    //   CmpConst =
+    //    ConstantInt::get(Type::getInt32Ty(M.getContext()), 2, true);
+    // CmpI = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ,
+    //                     RTFInst, CmpConst, "", BBcurrent);
+    // BBtrue =  BasicBlock::Create(M.getContext(), "version_spir", F_wrapper);
+    // BBfalse = BasicBlock::Create(M.getContext(), "not_spir", F_wrapper);
+    // BrI = BranchInst::Create(BBtrue, BBfalse, CmpI, BBcurrent);
+
+    // GenFuncCI = CallInst::Create(SF, GenFuncCallArgs, "", BBtrue);
+    // RI = ReturnInst::Create(M.getContext(), GenFuncCI, BBtrue);
+
+    // if (DeviceAbstraction) {
+    // Prepare arguments and function for call to wait for device runtime call
+    //  std::vector<Value *> Args; // TODO: add the device type as argument?
+    // FunctionCallee RTF =
+    //  M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus",
+    // runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType());
+    // CallInst *RTFInst = CallInst::Create(RTF, Args, "", GenFuncCI);
+    // }
+    // }
 
     RI = ReturnInst::Create(M.getContext(),
                             UndefValue::get(FT->getReturnType()), BBfalse);
@@ -1689,13 +1690,12 @@ void CGT_X86::codeGen(DFInternalNode *N) {
 
     // assert(false && "got to the point where we have to combine\n");
   }
-
 }
 
 // Code generation for leaf nodes
-void CGT_X86::codeGen(DFLeafNode* N) {
+void CGT_X86::codeGen(DFLeafNode *N) {
   // Skip code generation if it is a dummy node
-  if(N->isDummyNode()) {
+  if (N->isDummyNode()) {
     DEBUG(errs() << "Skipping dummy node\n");
     return;
   }
@@ -1712,24 +1712,24 @@ void CGT_X86::codeGen(DFLeafNode* N) {
 
   // Check if clone already exists. If it does, it means we have visited this
   // function before and nothing else needs to be done for this leaf node.
-//  if(N->getGenFunc() != NULL)
-//    return;
+  //  if(N->getGenFunc() != NULL)
+  //    return;
 
   if (!preferredTargetIncludes(N, visc::CPU_TARGET)) {
-    DEBUG(errs() << "No CPU hint for node " << N->getFuncPointer()->getName() <<
-                    " : skipping it\n");
+    DEBUG(errs() << "No CPU hint for node " << N->getFuncPointer()->getName()
+                 << " : skipping it\n");
 
     DEBUG(errs() << "Check for cudnn or promise hint for node "
-                 << N->getFuncPointer()->getName() <<  "\n");
+                 << N->getFuncPointer()->getName() << "\n");
 
     switch (N->getTag()) {
-       case visc::GPU_TARGET:
-         // A leaf node should not have an x86 function for GPU
-         // by design of DFG2LLVM_NVPTX backend
-         assert(!(N->hasX86GenFuncForTarget(visc::GPU_TARGET)) && "");
-         break;
-       default:
-         break;
+    case visc::GPU_TARGET:
+      // A leaf node should not have an x86 function for GPU
+      // by design of DFG2LLVM_NVPTX backend
+      assert(!(N->hasX86GenFuncForTarget(visc::GPU_TARGET)) && "");
+      break;
+    default:
+      break;
     }
 
     return;
@@ -1739,7 +1739,7 @@ void CGT_X86::codeGen(DFLeafNode* N) {
          "Error: Visiting a node for which code already generated\n");
 
   std::vector<IntrinsicInst *> IItoRemove;
-  std::vector<std::pair<IntrinsicInst *, Value *> > IItoReplace;
+  std::vector<std::pair<IntrinsicInst *, Value *>> IItoReplace;
   BuildDFG::HandleToDFNode Leaf_HandleToDFNodeMap;
 
   // Get the function associated woth the dataflow node
@@ -1755,41 +1755,39 @@ void CGT_X86::codeGen(DFLeafNode* N) {
 
   // Add the new argument to the argument list. Add arguments only if the cild
   // graph of parent node is not streaming
-  if(!N->getParent()->isChildGraphStreaming())
+  if (!N->getParent()->isChildGraphStreaming())
     F_X86 = addIdxDimArgs(F_X86);
 
   // Add generated function info to DFNode
-//  N->setGenFunc(F_X86, visc::CPU_TARGET);
+  //  N->setGenFunc(F_X86, visc::CPU_TARGET);
   N->addGenFunc(F_X86, visc::CPU_TARGET, true);
 
   // Go through the arguments, and any pointer arguments with in attribute need
   // to have x86_argument_ptr call to get the x86 ptr of the argument
   // Insert these calls in a new BB which would dominate all other BBs
   // Create new BB
-  BasicBlock* EntryBB = &*F_X86->begin();
-  BasicBlock* BB = BasicBlock::Create(M.getContext(), "getVISCPtrArgs", F_X86, EntryBB);
-  BranchInst* Terminator = BranchInst::Create(EntryBB, BB);
+  BasicBlock *EntryBB = &*F_X86->begin();
+  BasicBlock *BB =
+      BasicBlock::Create(M.getContext(), "getVISCPtrArgs", F_X86, EntryBB);
+  BranchInst *Terminator = BranchInst::Create(EntryBB, BB);
   // Insert calls
-  for(Function::arg_iterator ai = F_X86->arg_begin(), ae = F_X86->arg_end();
-        ai != ae; ++ai) {
-    if (F_X86->getAttributes().hasAttribute(ai->getArgNo()+1, Attribute::In)) {
-      assert(ai->getType()->isPointerTy()
-          && "Only pointer arguments can have visc in/out attributes ");
+  for (Function::arg_iterator ai = F_X86->arg_begin(), ae = F_X86->arg_end();
+       ai != ae; ++ai) {
+    if (F_X86->getAttributes().hasAttribute(ai->getArgNo() + 1,
+                                            Attribute::In)) {
+      assert(ai->getType()->isPointerTy() &&
+             "Only pointer arguments can have visc in/out attributes ");
       Function::arg_iterator aiNext = ai;
       ++aiNext;
-      Argument* size = &*aiNext;
-      assert(size->getType() == Type::getInt64Ty(M.getContext())
-          && "Next argument after a pointer should be an i64 type");
-      CastInst* BI = BitCastInst::CreatePointerCast(&*ai,
-                                                    Type::getInt8PtrTy(M.getContext()),
-                                                    ai->getName()+".i8ptr",
-                                                    Terminator);
-      Value* ArgPtrCallArgs[] = {BI, size};
+      Argument *size = &*aiNext;
+      assert(size->getType() == Type::getInt64Ty(M.getContext()) &&
+             "Next argument after a pointer should be an i64 type");
+      CastInst *BI = BitCastInst::CreatePointerCast(
+          &*ai, Type::getInt8PtrTy(M.getContext()), ai->getName() + ".i8ptr",
+          Terminator);
+      Value *ArgPtrCallArgs[] = {BI, size};
       CallInst::Create(llvm_visc_x86_argument_ptr,
-                                              ArrayRef<Value*>(ArgPtrCallArgs, 2),
-                                              "",
-                                              Terminator);
-
+                       ArrayRef<Value *>(ArgPtrCallArgs, 2), "", Terminator);
     }
   }
   DEBUG(errs() << *BB << "\n");
@@ -1799,17 +1797,19 @@ void CGT_X86::codeGen(DFLeafNode* N) {
     Instruction *I = &(*i);
     DEBUG(errs() << *I << "\n");
     // Leaf nodes should not contain VISC graph intrinsics or launch
-    assert(!BuildDFG::isViscLaunchIntrinsic(I) && "Launch intrinsic within a dataflow graph!");
-    assert(!BuildDFG::isViscGraphIntrinsic(I) && "VISC graph intrinsic within a leaf dataflow node!");
+    assert(!BuildDFG::isViscLaunchIntrinsic(I) &&
+           "Launch intrinsic within a dataflow graph!");
+    assert(!BuildDFG::isViscGraphIntrinsic(I) &&
+           "VISC graph intrinsic within a leaf dataflow node!");
 
     if (BuildDFG::isViscQueryIntrinsic(I)) {
-      IntrinsicInst* II = cast<IntrinsicInst>(I);
-      IntrinsicInst* ArgII;
-      DFNode* ArgDFNode;
+      IntrinsicInst *II = cast<IntrinsicInst>(I);
+      IntrinsicInst *ArgII;
+      DFNode *ArgDFNode;
 
       /***********************************************************************
-      *                        Handle VISC Query intrinsics                  *
-      ***********************************************************************/
+       *                        Handle VISC Query intrinsics                  *
+       ***********************************************************************/
       switch (II->getIntrinsicID()) {
       /**************************** llvm.visc.getNode() *******************/
       case Intrinsic::visc_getNode: {
@@ -1838,8 +1838,9 @@ void CGT_X86::codeGen(DFLeafNode* N) {
         // get the appropriate field
         ArgII = cast<IntrinsicInst>((II->getOperand(0))->stripPointerCasts());
         int numOfDim = Leaf_HandleToDFNodeMap[ArgII]->getNumOfDim();
-        IntegerType* IntTy = Type::getInt32Ty(M.getContext());
-        ConstantInt* numOfDimConstant = ConstantInt::getSigned(IntTy, (int64_t) numOfDim);
+        IntegerType *IntTy = Type::getInt32Ty(M.getContext());
+        ConstantInt *numOfDimConstant =
+            ConstantInt::getSigned(IntTy, (int64_t)numOfDim);
 
         II->replaceAllUsesWith(numOfDimConstant);
         IItoRemove.push_back(II);
@@ -1855,46 +1856,46 @@ void CGT_X86::codeGen(DFLeafNode* N) {
         // The dfnode argument should be an ancestor of this leaf node or
         // the leaf node itself
         int parentLevel = N->getAncestorHops(ArgDFNode);
-        assert(( parentLevel >= 0 || ArgDFNode == (DFNode*)N )
-               && "Invalid DFNode argument to getNodeInstanceID_[xyz]!");
+        assert((parentLevel >= 0 || ArgDFNode == (DFNode *)N) &&
+               "Invalid DFNode argument to getNodeInstanceID_[xyz]!");
 
         // Get specified dimension
         // (dim = 0) => x
         // (dim = 1) => y
         // (dim = 2) => z
-        int dim = (int) (II->getIntrinsicID() -
-                         Intrinsic::visc_getNodeInstanceID_x);
-        assert((dim >= 0) && (dim < 3)
-               && "Invalid dimension for getNodeInstanceID_[xyz]. Check Intrinsic ID!");
+        int dim =
+            (int)(II->getIntrinsicID() - Intrinsic::visc_getNodeInstanceID_x);
+        assert((dim >= 0) && (dim < 3) &&
+               "Invalid dimension for getNodeInstanceID_[xyz]. Check Intrinsic "
+               "ID!");
 
         // For immediate ancestor, use the extra argument introduced in
         // F_X86
         int numParamsF = F->getFunctionType()->getNumParams();
         int numParamsF_X86 = F_X86->getFunctionType()->getNumParams();
-        assert((numParamsF_X86 - numParamsF == 6)
-               && "Difference of arguments between function and its clone is not 6!");
+        assert(
+            (numParamsF_X86 - numParamsF == 6) &&
+            "Difference of arguments between function and its clone is not 6!");
 
-        if(parentLevel == 0) {
+        if (parentLevel == 0) {
           // Case when the query is for this node itself
-          unsigned offset = 3 + (3-dim);
+          unsigned offset = 3 + (3 - dim);
           // Traverse argument list of F_X86 in reverse order to find the
           // correct index or dim argument.
-          Argument* indexVal = getArgumentFromEnd(F_X86, offset);
+          Argument *indexVal = getArgumentFromEnd(F_X86, offset);
           assert(indexVal && "Index argument not found. Invalid offset!");
 
           DEBUG(errs() << *II << " replaced with " << *indexVal << "\n");
 
           II->replaceAllUsesWith(indexVal);
           IItoRemove.push_back(II);
-        }
-        else {
+        } else {
           // Case when query is for an ancestor
-          Value* args[] = {
-            ConstantInt::get(Type::getInt32Ty(II->getContext()), parentLevel),
-            ConstantInt::get(Type::getInt32Ty(II->getContext()), dim)
-          };
-          CallInst* CI = CallInst::Create(llvm_visc_x86_getDimInstance,
-                                          ArrayRef<Value*>(args, 2),
+          Value *args[] = {
+              ConstantInt::get(Type::getInt32Ty(II->getContext()), parentLevel),
+              ConstantInt::get(Type::getInt32Ty(II->getContext()), dim)};
+          CallInst *CI = CallInst::Create(llvm_visc_x86_getDimInstance,
+                                          ArrayRef<Value *>(args, 2),
                                           "nodeInstanceID", II);
           DEBUG(errs() << *II << " replaced with " << *CI << "\n");
           II->replaceAllUsesWith(CI);
@@ -1913,46 +1914,46 @@ void CGT_X86::codeGen(DFLeafNode* N) {
         // The dfnode argument should be an ancestor of this leaf node or
         // the leaf node itself
         int parentLevel = N->getAncestorHops(ArgDFNode);
-        assert(( parentLevel >= 0 || ArgDFNode == (DFNode*)N )
-               && "Invalid DFNode argument to getNodeInstanceID_[xyz]!");
+        assert((parentLevel >= 0 || ArgDFNode == (DFNode *)N) &&
+               "Invalid DFNode argument to getNodeInstanceID_[xyz]!");
 
         // Get specified dimension
         // (dim = 0) => x
         // (dim = 1) => y
         // (dim = 2) => z
-        int dim = (int) (II->getIntrinsicID() -
-                         Intrinsic::visc_getNumNodeInstances_x);
-        assert((dim >= 0) && (dim < 3)
-               && "Invalid dimension for getNumNodeInstances_[xyz]. Check Intrinsic ID!");
+        int dim =
+            (int)(II->getIntrinsicID() - Intrinsic::visc_getNumNodeInstances_x);
+        assert((dim >= 0) && (dim < 3) &&
+               "Invalid dimension for getNumNodeInstances_[xyz]. Check "
+               "Intrinsic ID!");
 
         // For immediate ancestor, use the extra argument introduced in
         // F_X86
         int numParamsF = F->getFunctionType()->getNumParams();
         int numParamsF_X86 = F_X86->getFunctionType()->getNumParams();
-        assert((numParamsF_X86 - numParamsF == 6)
-               && "Difference of arguments between function and its clone is not 6!");
+        assert(
+            (numParamsF_X86 - numParamsF == 6) &&
+            "Difference of arguments between function and its clone is not 6!");
 
-        if(parentLevel == 0) {
+        if (parentLevel == 0) {
           // Case when the query is for this node itself
           unsigned offset = 3 - dim;
           // Traverse argument list of F_X86 in reverse order to find the
           // correct index or dim argument.
-          Argument* limitVal = getArgumentFromEnd(F_X86, offset);
+          Argument *limitVal = getArgumentFromEnd(F_X86, offset);
           assert(limitVal && "Limit argument not found. Invalid offset!");
 
-          DEBUG(errs() << *II << " replaced with " <<  *limitVal << "\n");
+          DEBUG(errs() << *II << " replaced with " << *limitVal << "\n");
 
           II->replaceAllUsesWith(limitVal);
           IItoRemove.push_back(II);
-        }
-        else {
+        } else {
           // Case when query is from the ancestor
-          Value* args[] = {
-            ConstantInt::get(Type::getInt32Ty(II->getContext()), parentLevel),
-            ConstantInt::get(Type::getInt32Ty(II->getContext()), dim)
-          };
-          CallInst* CI = CallInst::Create(llvm_visc_x86_getDimLimit,
-                                          ArrayRef<Value*>(args, 2),
+          Value *args[] = {
+              ConstantInt::get(Type::getInt32Ty(II->getContext()), parentLevel),
+              ConstantInt::get(Type::getInt32Ty(II->getContext()), dim)};
+          CallInst *CI = CallInst::Create(llvm_visc_x86_getDimLimit,
+                                          ArrayRef<Value *>(args, 2),
                                           "numNodeInstances", II);
           DEBUG(errs() << *II << " replaced with " << *CI << "\n");
           II->replaceAllUsesWith(CI);
@@ -1962,19 +1963,18 @@ void CGT_X86::codeGen(DFLeafNode* N) {
         break;
       }
       default:
-        DEBUG(errs() << "Found unknown intrinsic with ID = " <<
-              II->getIntrinsicID() << "\n");
+        DEBUG(errs() << "Found unknown intrinsic with ID = "
+                     << II->getIntrinsicID() << "\n");
         assert(false && "Unknown VISC Intrinsic!");
         break;
       }
 
     } else {
-      //TODO: how to handle address space qualifiers in load/store
+      // TODO: how to handle address space qualifiers in load/store
     }
-
   }
 
-  //TODO:
+  // TODO:
   // When to replace the uses?
   // In which order is it safe to replace the instructions in
   // IItoReplace?
@@ -1982,8 +1982,7 @@ void CGT_X86::codeGen(DFLeafNode* N) {
   // It is a good idea to have them in one vector and chech the type
   // using dyn_cast in order to determine if we replace with inst or value
 
-
-  //TODO: maybe leave these instructions to be removed by a later DCE pass
+  // TODO: maybe leave these instructions to be removed by a later DCE pass
   for (std::vector<IntrinsicInst *>::iterator i = IItoRemove.begin();
        i != IItoRemove.end(); ++i) {
     (*i)->replaceAllUsesWith(UndefValue::get((*i)->getType()));
@@ -1996,7 +1995,7 @@ void CGT_X86::codeGen(DFLeafNode* N) {
 } // End of namespace
 
 char DFG2LLVM_X86::ID = 0;
-static RegisterPass<DFG2LLVM_X86> X("dfg2llvm-x86",
-                                    "Dataflow Graph to LLVM for X86 backend",
-                                    false /* does not modify the CFG */,
-                                    true /* transformation, not just analysis */);
+static RegisterPass<DFG2LLVM_X86>
+    X("dfg2llvm-x86", "Dataflow Graph to LLVM for X86 backend",
+      false /* does not modify the CFG */,
+      true /* transformation, not just analysis */);