[llvm-commits] [llvm] r89125 - in /llvm/trunk: lib/CodeGen/PHIElimination.cpp test/CodeGen/X86/2008-04-15-LiveVariableBug.ll test/CodeGen/X86/stack-color-with-reg.ll

Evan Cheng evan.cheng at apple.com
Tue Nov 17 11:28:12 PST 2009


Hi Jakob,

I don't think this is the right way to do it. Checking RegisterRegAlloc::getDefault() seems pretty horrible.

If I understand correctly, PHI elim should not require LiveVariables. It does this:
LiveVariables *LV = getAnalysisIfAvailable<LiveVariables>();

So if LV is not available, i.e. not required by the register allocator, it should not perform splitting. That should work, right?

Evan

On Nov 17, 2009, at 11:15 AM, Jakob Stoklund Olesen wrote:

> Author: stoklund
> Date: Tue Nov 17 13:15:50 2009
> New Revision: 89125
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=89125&view=rev
> Log:
> Enable -split-phi-edges by default, except when -regalloc=local.
> 
> The local register allocator doesn't like it when LiveVariables is run.
> We should also disable edge splitting under -O0, but that has to wait a bit.
> 
> Modified:
>    llvm/trunk/lib/CodeGen/PHIElimination.cpp
>    llvm/trunk/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll
>    llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll
> 
> Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=89125&r1=89124&r2=89125&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original)
> +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Nov 17 13:15:50 2009
> @@ -21,6 +21,7 @@
> #include "llvm/CodeGen/MachineInstr.h"
> #include "llvm/CodeGen/MachineInstrBuilder.h"
> #include "llvm/CodeGen/MachineRegisterInfo.h"
> +#include "llvm/CodeGen/RegAllocRegistry.h"
> #include "llvm/Function.h"
> #include "llvm/Target/TargetMachine.h"
> #include "llvm/ADT/SmallPtrSet.h"
> @@ -39,7 +40,7 @@
> static cl::opt<bool>
> SplitEdges("split-phi-edges",
>            cl::desc("Split critical edges during phi elimination"),
> -           cl::init(false), cl::Hidden);
> +           cl::init(true), cl::Hidden);
> 
> char PHIElimination::ID = 0;
> static RegisterPass<PHIElimination>
> @@ -47,10 +48,21 @@
> 
> const PassInfo *const llvm::PHIEliminationID = &X;
> 
> +namespace llvm { FunctionPass *createLocalRegisterAllocator(); }
> +
> +// Should we run edge splitting?
> +static bool shouldSplitEdges() {
> +  // Edge splitting breaks the local register allocator. It cannot tolerate
> +  // LiveVariables being run.
> +  if (RegisterRegAlloc::getDefault() == createLocalRegisterAllocator)
> +    return false;
> +  return SplitEdges;
> +}
> +
> void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
>   AU.addPreserved<LiveVariables>();
>   AU.addPreserved<MachineDominatorTree>();
> -  if (SplitEdges) {
> +  if (shouldSplitEdges()) {
>     AU.addRequired<LiveVariables>();
>   } else {
>     AU.setPreservesCFG();
> @@ -67,7 +79,7 @@
>   bool Changed = false;
> 
>   // Split critical edges to help the coalescer
> -  if (SplitEdges)
> +  if (shouldSplitEdges())
>     for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
>       Changed |= SplitPHIEdges(Fn, *I);
> 
> 
> Modified: llvm/trunk/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll?rev=89125&r1=89124&r2=89125&view=diff
> 
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll Tue Nov 17 13:15:50 2009
> @@ -1,5 +1,6 @@
> ; RUN: llc < %s -mtriple=x86_64-apple-darwin
> ; RUN: llc < %s -mtriple=x86_64-apple-darwin -relocation-model=pic -disable-fp-elim -O0 -regalloc=local
> +; PR5534
> 
> 	%struct.CGPoint = type { double, double }
> 	%struct.NSArray = type { %struct.NSObject }
> 
> Modified: llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll?rev=89125&r1=89124&r2=89125&view=diff
> 
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Tue Nov 17 13:15:50 2009
> @@ -1,6 +1,6 @@
> ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t
> ; RUN:   grep stackcoloring %t | grep "stack slot refs replaced with reg refs"  | grep 6
> -; RUN:   grep asm-printer %t   | grep 177
> +; RUN:   grep asm-printer %t   | grep 175
> 
> 	type { [62 x %struct.Bitvec*] }		; type %0
> 	type { i8* }		; type %1
> 
> 
> _______________________________________________
> 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