[llvm-commits] [llvm] r86322 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Nov 6 18:28:58 PST 2009


On Nov 6, 2009, at 6:11 PM, Evan Cheng wrote:

> Sorry, Jakob. I don't think this patch is right. The check is  
> whether the early coalescer should be handling the cases where the  
> normal coalescer cannot.

I am not sure I understand. The conflict test is a correctness issue.

The old code looked like this:

> -  if (!HaveConflict)
> -    return false; // Let coalescer handle it

That is: If there is no conflict, it is /not/ safe to coalesce. This  
is clearly wrong - if there is a conflict, the early coalescer must  
stay clear.

This fix fixes the miscompilations in MallocBench.

I was seeing code like this:

2508	%reg1248<def> = MOV32rr %reg1069<kill>
		register: %reg1248 Removing [2072,2086] from: %reg1248,0.000000e+00  
= [2054,2086:0)  0 at 2054-(2086)
  RESULT: %reg1248,0.000000e+00 = [2054,2072:0)  0 at 2054-(2220* phi)  
replace range with [2072,2086:1) RESULT: %reg1248,0.000000e+00 =  
[2054,2072:0)[2072,2086:1)  0 at 2054-(2220* phi) 1@?-(2086) +[2510,2536:2)

2516	%reg1249<def> = MOV32rr %reg1065<kill>
		register: %reg1249 Removing [2072,2094] from: %reg1249,0.000000e+00  
= [2062,2094:0)  0 at 2062-(2094)
  RESULT: %reg1249,0.000000e+00 = [2062,2072:0)  0 at 2062-(2220* phi)  
replace range with [2072,2094:1) RESULT: %reg1249,0.000000e+00 =  
[2062,2072:0)[2072,2094:1)  0 at 2062-(2220* phi) 1@?-(2094) +[2518,2536:2)


PHI Join: %reg1065<def> = MOV32rr %reg1248<kill>
Moving: 2510 %reg1248<def> = MOV32rr %reg1069<kill>
   added range [2510,2536] to reg1065

The early coalescer wanted to define %reg1065 at index 2508, even  
though it is being used at the next instruction. This is the  
miscompilation.

> Perhaps hacking on the early coalescer is not the right approach?  
> We're probably better off starting over by adding on-demand critical  
> edge splitting in phi elimination.

I agree. I am simply using the early coalescer to detect the cases  
where critical edge splitting is necessary.

/jakob




More information about the llvm-commits mailing list