From 9478c3f8e57369984256a76f26ae68084766f5ea Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 23 Apr 2009 23:13:24 +0000 Subject: Factor out a bit of code that appears in several places into a utility function. llvm-svn: 69937 --- .../lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index fd5fcbb1aad..3e6da24a4a1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -1020,6 +1020,17 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) { &NewValues[0], NewValues.size())); } +/// CopyToExportRegsIfNeeded - If the given value has virtual registers +/// created for it, emit nodes to copy the value into the virtual +/// registers. +void SelectionDAGLowering::CopyToExportRegsIfNeeded(Value *V) { + if (!V->use_empty()) { + DenseMap::iterator VMI = FuncInfo.ValueMap.find(V); + if (VMI != FuncInfo.ValueMap.end()) + CopyValueToVirtualRegister(V, VMI->second); + } +} + /// ExportFromCurrentBlock - If this condition isn't known to be exported from /// the current basic block, add it to ValueMap now so that we'll get a /// CopyTo/FromReg. @@ -1572,11 +1583,7 @@ void SelectionDAGLowering::visitInvoke(InvokeInst &I) { // If the value of the invoke is used outside of its defining block, make it // available as a virtual register. - if (!I.use_empty()) { - DenseMap::iterator VMI = FuncInfo.ValueMap.find(&I); - if (VMI != FuncInfo.ValueMap.end()) - CopyValueToVirtualRegister(&I, VMI->second); - } + CopyToExportRegsIfNeeded(&I); // Update successor info CurMBB->addSuccessor(Return); @@ -5924,10 +5931,7 @@ LowerArguments(BasicBlock *LLVMBB) { SDL->getCurDebugLoc())); // If this argument is live outside of the entry block, insert a copy from // whereever we got it to the vreg that other BB's will reference it as. - DenseMap::iterator VMI=FuncInfo->ValueMap.find(AI); - if (VMI != FuncInfo->ValueMap.end()) { - SDL->CopyValueToVirtualRegister(AI, VMI->second); - } + SDL->CopyToExportRegsIfNeeded(AI); } a += NumValues; } -- cgit v1.2.3