Created attachment 8410 [details] C reproduction Small testcase: (attached) ------------------------------ $ cat tls-test.c static __thread int sock = -1; int main(void) { return sock; } ------------------------------ With a PPC-configured Clang I get $ clang tls-test.c TLS not implemented for PPC UNREACHABLE executed at PPCISelLowering.cpp:4562! 0 clang 0x0000000002438fc9 1 clang 0x0000000002438dbc 2 libpthread.so.0 0x000000375a80eb70 3 libc.so.6 0x0000003759c30265 gsignal + 53 4 libc.so.6 0x0000003759c31d10 abort + 272 5 clang 0x00000000024206f1 6 clang 0x0000000001b7ed10 llvm::PPCTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const + 306 7 clang 0x0000000001cbd894 8 clang 0x0000000001cb74d2 9 clang 0x0000000001cdcbf2 llvm::SelectionDAG::Legalize() + 58 10 clang 0x0000000001c71d48 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 2772 11 clang 0x0000000001c70f16 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 258 12 clang 0x0000000001c73cba llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 2918 13 clang 0x0000000001c703f8 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 902
I am working on this: http://lev.vlakno.cz/~rdivacky/llvm-ppc64-tls.patch Implementes working local exec TLS
As of r158307. Compiling a file with Clang containing a static __thread int variable, I get this crash now: only local-exec TLS mode supported UNREACHABLE executed at PPCISelLowering.cpp:1244! 0 clang 0x0000000001ad1d8f 1 clang 0x0000000001ad3ff2 2 libpthread.so.0 0x0000003d6220eb70 3 libc.so.6 0x0000003d61630265 gsignal + 53 4 libc.so.6 0x0000003d61631d10 abort + 272 5 clang 0x0000000001aba702 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 354 6 clang 0x000000000134861c 7 clang 0x000000000136ef8e llvm::PPCTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const + 894 8 clang 0x000000000148493c 9 clang 0x0000000001488ead llvm::SelectionDAG::Legalize() + 269 10 clang 0x0000000001434924 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 1076 11 clang 0x00000000014358a1 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 273 12 clang 0x000000000143793f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 2079 13 clang 0x0000000001438d9f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1151 14 clang 0x0000000001341a16 15 clang 0x0000000001a2ff0d llvm::FPPassManager::runOnFunction(llvm::Function&) + 557 16 clang 0x0000000001a2fff3 llvm::FPPassManager::runOnModule(llvm::Module&) + 51 17 clang 0x0000000001a308e1 llvm::MPPassManager::runOnModule(llvm::Module&) + 497 18 clang 0x0000000001a30c7b llvm::PassManagerImpl::run(llvm::Module&) + 171 19 clang 0x000000000075ee28 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 1560 20 clang 0x000000000075c389 21 clang 0x00000000008c3099 clang::ParseAST(clang::Sema&, bool, bool) + 857 22 clang 0x000000000075adb4 clang::CodeGenAction::ExecuteAction() + 68 23 clang 0x0000000000624e41 clang::FrontendAction::Execute() + 145 24 clang 0x0000000000602dd1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 337 25 clang 0x00000000005ec194 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1348 26 clang 0x00000000005e18d8 cc1_main(char const**, char const**, char const*, void*) + 648 27 clang 0x00000000005eb0ae main + 7214 28 libc.so.6 0x0000003d6161d994 __libc_start_main + 244 29 clang 0x00000000005dfef9 Any idea how I can specify that TLS mode, and why does it matter?
This is fixed. All TLS modes are supported now.
(In reply to comment #3) > This is fixed. All TLS modes are supported now. Just a hint, for 32-bit PPC this doesn't seem to work as of r178888. At the moment I cannot try HEAD, but I strongly suspect that this PR has been closed prematurely. (r178888 is well after 2013-02-18) Just a heads-up :-)