Page MenuHomePhabricator

[X86] Fix tls variable lowering issue with large code model
AbandonedPublic

Authored by LuoYuanke on Feb 17 2019, 5:53 AM.

Details

Summary

The problem here is the lowering for tls variable. Below is the DAG for the code.
SelectionDAG has 11 nodes:

t0: ch = EntryToken
      t8: i64,ch = load<(load 8 from `i8 addrspace(257)* null`, addrspace 257)> t0, Constant:i64<0>, undef:i64
        t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64<i32* @x> 0 [TF=10]
      t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64
    t12: i64 = add t8, t11
  t4: i32,ch = load<(dereferenceable load 4 from @x)> t0, t12, undef:i64
t6: ch = CopyToReg t0, Register:i32 %0, t4

And when mcmodel is large, below instruction can NOT be folded.

  t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64<i32* @x> 0 [TF=10]
t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64

So "t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64" is lowered to " Morphed node: t11: i64,ch = MOV64rm<Mem:(load 8 from got)> t10, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i32 $noreg, t0"

When llvm start to lower "t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64<i32* @x> 0 [TF=10]", it fails.

My patch is to fold the load and X86ISD::WrapperRIP.

Diff Detail

Event Timeline

LuoYuanke created this revision.Feb 17 2019, 5:53 AM
craig.topper retitled this revision from Fix tls variable lowering issue. to [X86] Fix tls variable lowering issue with large code model.Feb 17 2019, 4:04 PM
craig.topper added a reviewer: rnk.
craig.topper added a subscriber: llvm-commits.

It looks like this review was not subscribed to llvm-commits when it was created. This prevents the general mailing list from being notified of its existence. Can you abandon this and submit a new review with llvm-commits subscribed from the start?

It's also helpful to start reviews with a tag like "[X86]" that indicates the area of the compiler you're changing. It helps potentially interested people search through the many emails on llvm-commits and find the things they might be interested in.

LuoYuanke abandoned this revision.Feb 17 2019, 5:07 PM

Thanks. I abandon the review and create a new review at https://reviews.llvm.org/D58336.