[PATCH] [FastIsel][X86] Fix invalid register replacement for bool args
    Keno Fischer 
    kfischer at college.harvard.edu
       
    Thu Nov 13 01:04:04 PST 2014
    
    
  
Hi ributzka,
Consider the following IR:
  %3 = load i8* undef
  %4 = trunc i8 %3 to i1
  %5 = call %jl_value_t.0* @foo(..., i1 %4, ...)
  ret %jl_value_t.0* %5
Bools (that are the result of direct truncs) are lowered as whatever
the argument to the trunc was and a "and 1", causing the part of the
MBB responsible for this argument to look something like this:
  %vreg8<def,tied1> = AND8ri %vreg7<kill,tied0>, 1, %EFLAGS<imp-def>; GR8:%vreg8,%vreg7
Later, when the load is lowered, it will insert
  %vreg15<def> = MOV8rm %vreg14, 1, %noreg, 0, %noreg; mem:LD1[undef] GR8:%vreg15 GR64:%vreg14
but remember to (at the end of isel) replace vreg7 by vreg5. Now for
the bug. In fast isel lowering, we mistakenly mark vreg8 as the result
of the load instead of the trunc. This adds a fixup to have
vreg8 replaced by whatever the result of the load is as well, so
we end up with
  %vreg15<def,tied1> = AND8ri %vreg15<kill,tied0>, 1, %EFLAGS<imp-def>; GR8:%vreg15
which is an SSA violation and causes problems later down the road.
This fixes PR21557.
http://reviews.llvm.org/D6245
Files:
  lib/Target/X86/X86FastISel.cpp
  test/CodeGen/X86/fast-isel-call-bool.ll
  test/CodeGen/X86/fast-isel-x86-64.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6245.16138.patch
Type: text/x-patch
Size: 2312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141113/206c9d40/attachment.bin>
    
    
More information about the llvm-commits
mailing list