Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

PPC: LLVM ERROR: Cannot select: ... = PPCISD::ADD_TLS #16554

Open Quuxplusone opened 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR16555
Status NEW
Importance P normal
Reported by Kai Nacke (kai@redstar.de)
Reported on 2013-07-07 11:09:03 -0700
Last modified on 2017-11-14 20:36:00 -0800
Version trunk
Hardware Other Linux
CC codeman.consulting@gmail.com, llvm-bugs@lists.llvm.org, wschmidt@linux.vnet.ibm.com
Fixed by commit(s)
Attachments tlsbug.ll (629 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 10821
IR file demonstrating the problem.

Compiling the attached tlsbug.ll file on Linux/PPC results in the error message:

LLVM ERROR: Cannot select: 0x105a0ee8: i32 = PPCISD::ADD_TLS 0x105a0e58,
0x105a0ca8 [ORD=1] [ID=7]
  0x105a0e58: i32 = PPCISD::LD_GOT_TPREL_L 0x105a0af8, 0x105a0dc8 [ORD=1] [ID=6]
    0x105a0af8: i32 = TargetGlobalTLSAddress<%rt.lifetime.BlkInfo.0.84** @_D2rt8lifetime18__blkcache_storagePS2rt8lifetime7BlkInfo> 0 [ORD=1] [ID=2]
    0x105a0dc8: i32 = PPCISD::ADDIS_GOT_TPREL_HA 0x105a0d38, 0x105a0af8 [ORD=1] [ID=5]
      0x105a0d38: i64 = Register %X2 [ID=4]
      0x105a0af8: i32 = TargetGlobalTLSAddress<%rt.lifetime.BlkInfo.0.84** @_D2rt8lifetime18__blkcache_storagePS2rt8lifetime7BlkInfo> 0 [ORD=1] [ID=2]
  0x105a0ca8: i32 = TargetGlobalTLSAddress<%rt.lifetime.BlkInfo.0.84** @_D2rt8lifetime18__blkcache_storagePS2rt8lifetime7BlkInfo> 0 [TF=128] [ORD=1] [ID=3]
In function: _D2rt5tlsgc4initFZPS2rt5tlsgc4Data

This is a reduced test case produced by the LDC D compiler.
Quuxplusone commented 11 years ago

Attached tlsbug.ll (629 bytes, application/octet-stream): IR file demonstrating the problem.

Quuxplusone commented 11 years ago

TLS is not supported on 32-bit PowerPC. Still, I'm surprised we got into this code at all, and I'll look into why that happened. But in general you shouldn't expect TLS to work for PPC32 at this time.

Quuxplusone commented 11 years ago
With current trunk, this fails for me in the way I would expect.  I.e., it
indicates that TLS is not supported for PPC32 except for the very simple local-
exec case.

$ $LLVM_INSTALL/bin/llc pr16555.ll
only local-exec is currently supported for ppc32
UNREACHABLE executed at /home/wschmidt/llvm/llvm-
test3/lib/Target/PowerPC/PPCISelLowering.cpp:1358!
0  llc       0x000000001101c680 llvm::sys::PrintStackTrace(_IO_FILE*) +
4286818280
1  llc       0x000000001101c8dc
2  llc       0x000000001101c220
3            0x00000fff8d1c0418 __kernel_sigtramp_rt64 + 0
4  libc.so.6 0x00000fff8cc99f38 abort + 4293567192
5  llc       0x000000001100649c llvm::llvm_unreachable_internal(char const*,
char const*, unsigned int) + 4286735244
6  llc       0x0000000010635c64
llvm::PPCTargetLowering::LowerGlobalTLSAddress(llvm::SDValue,
llvm::SelectionDAG&) const + 4276906588
7  llc       0x000000001064fc84
llvm::PPCTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&)
const + 4277011412
8  llc       0x00000000108ae4f0
9  llc       0x00000000108af0e8 llvm::SelectionDAG::Legalize() + 4279419824
10 llc       0x0000000010867bb8 llvm::SelectionDAGISel::CodeGenAndEmitDAG() +
4279132432
11 llc       0x000000001086a734
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 4279143516
12 llc       0x000000001086b098
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 4279145752
13 llc       0x000000001086e29c
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) +
4279158532
14 llc       0x0000000010629760
15 llc       0x0000000010a2aa68
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 4280914808
16 llc       0x0000000010f999d8
llvm::FPPassManager::runOnFunction(llvm::Function&) + 4286315128
17 llc       0x0000000010f99a4c llvm::FPPassManager::runOnModule(llvm::Module&)
+ 4286315220
18 llc       0x0000000010f99308 llvm::MPPassManager::runOnModule(llvm::Module&)
+ 4286313456
19 llc       0x0000000010f995a4 llvm::PassManagerImpl::run(llvm::Module&) +
4286314100
20 llc       0x0000000010f996a4 llvm::PassManager::run(llvm::Module&) +
4286314332
21 llc       0x00000000101ca2c4
22 llc       0x00000000101baf00 main + 4272397856
23 libc.so.6 0x00000fff8cc7f07c
24 libc.so.6 0x00000fff8cc7f29c __libc_start_main + 4293465508
Stack dump:
0.  Program arguments: /home/wschmidt/llvm/install/llvm-test3/bin/llc pr16555.ll
1.  Running pass 'Function Pass Manager' on module 'pr16555.ll'.
2.  Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function
'@_D2rt5tlsgc4initFZPS2rt5tlsgc4Data'
Aborted

It's not at all clear to me how you could be getting past this check on a 32-
bit target:

  bool is64bit = PPCSubTarget.isPPC64();

  TLSModel::Model Model = getTargetMachine().getTLSModel(GV);

  if (Model == TLSModel::LocalExec) {
    SDValue TGAHi = DAG.getTargetGlobalAddress(GV, dl, PtrVT, 0,
                                               PPCII::MO_TPREL_HA);
    SDValue TGALo = DAG.getTargetGlobalAddress(GV, dl, PtrVT, 0,
                                               PPCII::MO_TPREL_LO);
    SDValue TLSReg = DAG.getRegister(is64bit ? PPC::X13 : PPC::R2,
                                     is64bit ? MVT::i64 : MVT::i32);
    SDValue Hi = DAG.getNode(PPCISD::Hi, dl, PtrVT, TGAHi, TLSReg);
    return DAG.getNode(PPCISD::Lo, dl, PtrVT, TGALo, Hi);
  }

  if (!is64bit)
    llvm_unreachable("only local-exec is currently supported for ppc32");
Quuxplusone commented 11 years ago

Ok, I'll look what to do here.

Quuxplusone commented 10 years ago
Kai, have you resolved this issue?  Can this bug be closed?

Thanks,
Bill
Quuxplusone commented 6 years ago

Small or large code model used to trigger this. Comments in PPCISelLowering.cpp indicate that only medium supports it.