[llvm-commits] [llvm] r66147 - /llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp

Nick Lewycky nicholas at mxc.ca
Thu Mar 5 00:01:27 PST 2009


Hi Owen, I think this causes a new warning:

PreAllocSplitting.cpp: In member function 
‘llvm::MachineInstr*<unnamed>::PreAllocSplitting::FoldRestore(unsigned 
int, const llvm::TargetRegisterClass*, llvm::MachineInstr*, 
llvm::MachineBasicBlock*, int, llvm::SmallPtrSet<llvm::MachineInstr*, 
4u>&)’:
PreAllocSplitting.cpp:1018: warning: comparison between signed and 
unsigned integer expressions

Nick

Owen Anderson wrote:
> Author: resistor
> Date: Thu Mar  5 01:19:18 2009
> New Revision: 66147
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=66147&view=rev
> Log:
> Be more careful about choosing restore points when doing restore folding.  This fixes some subtle miscompilations.
> 
> Modified:
>     llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp
> 
> Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=66147&r1=66146&r2=66147&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original)
> +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Thu Mar  5 01:19:18 2009
> @@ -38,10 +38,12 @@
>  
>  static cl::opt<int> PreSplitLimit("pre-split-limit", cl::init(-1), cl::Hidden);
>  static cl::opt<int> DeadSplitLimit("dead-split-limit", cl::init(-1), cl::Hidden);
> +static cl::opt<int> RestoreFoldLimit("restore-fold-limit", cl::init(-1), cl::Hidden);
>  
>  STATISTIC(NumSplits, "Number of intervals split");
>  STATISTIC(NumRemats, "Number of intervals split by rematerialization");
>  STATISTIC(NumFolds, "Number of intervals split with spill folding");
> +STATISTIC(NumRestoreFolds, "Number of intervals split with restore folding");
>  STATISTIC(NumRenumbers, "Number of intervals renumbered into new registers");
>  STATISTIC(NumDeadSpills, "Number of dead spills removed");
>  
> @@ -1013,15 +1015,32 @@
>                                               MachineBasicBlock* MBB,
>                                               int SS,
>                                       SmallPtrSet<MachineInstr*, 4>& RefsInMBB) {
> +  if ((int)RestoreFoldLimit != -1 && RestoreFoldLimit == NumRestoreFolds)
> +    return 0;
> +                                       
>    // Go top down if RefsInMBB is empty.
>    if (RefsInMBB.empty())
>      return 0;
>    
>    // Can't fold a restore between a call stack setup and teardown.
>    MachineBasicBlock::iterator FoldPt = Barrier;
> -  while (FoldPt != MBB->getFirstTerminator() && !RefsInMBB.count(FoldPt)) {
> -    ++FoldPt;
> +  
> +  // Advance from barrier to call frame teardown.
> +  while (FoldPt != MBB->getFirstTerminator() &&
> +         FoldPt->getOpcode() != TRI->getCallFrameDestroyOpcode()) {
> +    if (RefsInMBB.count(FoldPt))
> +      return 0;
>      
> +    ++FoldPt;
> +  }
> +  
> +  if (FoldPt == MBB->getFirstTerminator())
> +    return 0;
> +  else
> +    ++FoldPt;
> +  
> +  // Now find the restore point.
> +  while (FoldPt != MBB->getFirstTerminator() && !RefsInMBB.count(FoldPt)) {
>      if (FoldPt->getOpcode() == TRI->getCallFrameSetupOpcode()) {
>        while (FoldPt != MBB->getFirstTerminator() &&
>               FoldPt->getOpcode() != TRI->getCallFrameDestroyOpcode()) {
> @@ -1031,8 +1050,11 @@
>          ++FoldPt;
>        }
>        
> -      ++FoldPt;
> -    }
> +      if (FoldPt == MBB->getFirstTerminator())
> +        return 0;
> +    } 
> +    
> +    ++FoldPt;
>    }
>    
>    if (FoldPt == MBB->getFirstTerminator())
> @@ -1054,7 +1076,7 @@
>    if (FMI) {
>      LIs->ReplaceMachineInstrInMaps(FoldPt, FMI);
>      FMI = MBB->insert(MBB->erase(FoldPt), FMI);
> -    ++NumFolds;
> +    ++NumRestoreFolds;
>    }
>    
>    return FMI;
> @@ -1171,6 +1193,7 @@
>    if (MachineInstr* LMI = FoldRestore(CurrLI->reg, RC, Barrier,
>                                        BarrierMBB, SS, RefsInMBB)) {
>      RestorePt = LMI;
> +    RestoreIndex = LIs->getInstructionIndex(RestorePt);
>      FoldedRestore = true;
>    } else {
>      TII->loadRegFromStackSlot(*BarrierMBB, RestorePt, CurrLI->reg, SS, RC);
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 




More information about the llvm-commits mailing list