This is an archive of the discontinued LLVM Phabricator instance.

NaCl's x86 DataLayout should specify an alignment for f80
AbandonedPublic

Authored by jfb on Oct 15 2014, 3:27 PM.

Details

Summary

This is a follow-up to D2436.

NaCl on x86 doesn't support x87, but it sometimes happens that an f80 value gets temporarily created nonetheless, causing DataLayout::getAlignmentInfo to assert out when selecting fp_extend. This problem shows up when compiling:

pnacl-llc -mtriple=i686-none-nacl-gnu -filetype=obj -O3 -mcpu=pentium4m compiler-rt/lib/floatdidf.c

It's not clear why fp_entend gets generated and then removed, it looks like ISel starts with:

; Function Attrs: nounwind readnone
define double @__floatdidf(i64 %a) #0 {
entry:
  %shr3 = lshr i64 %a, 32
  %conv = trunc i64 %shr3 to i32
  %conv1 = sitofp i32 %conv to double
  %mul = fmul double %conv1, 0x41F0000000000000
  %and = and i64 %a, 4294967295
  %or = or i64 %and, 4841369599423283200
  %sub = fadd double %mul, 0xC330000000000000
  %0 = bitcast i64 %or to double
  %add = fadd double %0, %sub
  ret double %add
}

And generates:

BB#0: derived from LLVM BB %entry
%vreg0<def> = MOV32rm <fi#-1>, 1, %noreg, 0, %noreg; mem:LD4[FixedStack-1](align=16) GR32:%vreg0
%vreg1<def> = CVTSI2SDrm <fi#-1>, 1, %noreg, 4, %noreg; mem:LD4[FixedStack-1+4] FR64:%vreg1
%vreg2<def,tied1> = MULSDrm %vreg1<tied0>, %noreg, 1, %noreg, <cp#0>, %noreg; mem:LD8[ConstantPool] FR64:%vreg2,%vreg1
MOV32mr <fi#0>, 1, %noreg, 0, %noreg, %vreg0<kill>; mem:ST4[FixedStack0](align=8) GR32:%vreg0
MOV32mi <fi#0>, 1, %noreg, 4, %noreg, 1127219200; mem:ST4[FixedStack0+4]
%vreg3<def,tied1> = ADDSDrm %vreg2<tied0>, %noreg, 1, %noreg, <cp#1>, %noreg; mem:LD8[ConstantPool] FR64:%vreg3,%vreg2
%vreg4<def,tied1> = ADDSDrm %vreg3<tied0>, <fi#0>, 1, %noreg, 0, %noreg; mem:LD8[FixedStack0] FR64:%vreg4,%vreg3
MOVSDmr <fi#1>, 1, %noreg, 0, %noreg, %vreg4<kill>; mem:ST8[FixedStack1] FR64:%vreg4
%vreg5<def> = LD_Fp64m80 <fi#1>, 1, %noreg, 0, %noreg, %FPSW<imp-def,dead>; mem:LD8[FixedStack1](align=4) RFP80:%vreg5
RETL %vreg5<kill>; RFP80:%vreg5

The final code gets rid of LD_Fp64m80, so this may be exposing another bug, or may simply be some form of canonicalization. Clarifications welcome here.

Diff Detail

Event Timeline

jfb updated this revision to Diff 14965.Oct 15 2014, 3:27 PM
jfb retitled this revision from to NaCl's x86 DataLayout should specify an alignment for f80.
jfb updated this object.
jfb edited the test plan for this revision. (Show Details)
jfb added reviewers: dschuff, rafael.
jfb added a subscriber: Unknown Object (MLST).

I think this is exposing a different bug. You may need to make sure that all of the fp80 bits are marked as not legal for NaCl.

espindola edited reviewers, added: espindola; removed: rafael.Mar 15 2018, 11:01 AM
jfb abandoned this revision.May 7 2018, 9:53 PM