Open Quuxplusone opened 11 years ago
Attached tlsbug.ll
(629 bytes, application/octet-stream): IR file demonstrating the problem.
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.
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");
Ok, I'll look what to do here.
Kai, have you resolved this issue? Can this bug be closed?
Thanks,
Bill
Small or large code model used to trigger this. Comments in PPCISelLowering.cpp indicate that only medium supports it.
tlsbug.ll
(629 bytes, application/octet-stream)