[llvm-commits] [llvm] r76665 - /llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp

Richard Osborne richard at xmos.com
Wed Jul 22 03:44:51 PDT 2009


Chris Lattner wrote:
> Author: lattner
> Date: Tue Jul 21 17:37:38 2009
> New Revision: 76665
>
> URL: http://llvm.org/viewvc/llvm-project?rev=76665&view=rev
> Log:
> if Xcore doesn't support TLS, it doesn't have to worry about thread local LLVM IR, it should be rejected by a front-end.
>
> Modified:
>     llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp?rev=76665&r1=76664&r2=76665&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp Tue Jul 21 17:37:38 2009
> @@ -72,7 +72,7 @@
>  SectionFlagsForGlobal(const GlobalValue *GV, const char* Name) const {
>    unsigned Flags = ELFTargetAsmInfo::SectionFlagsForGlobal(GV, Name);
>    // Mask out unsupported flags
> -  Flags &= ~(SectionFlags::Small | SectionFlags::TLS);
> +  Flags &= ~SectionFlags::Small;
>  
>    // Set CP / DP relative flags
>    if (GV) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>   
On the XCore there is no OS and at most 8 hardware threads. Thread local 
storage is dealt with entirely by lowering in the backend.

__thread int x = 1;
void f() { x = 2; }

is transformed to:

int x[8] = {1, 1, 1, 1, 1, 1, 1, 1}
void f() { x[__builtin_getid()] = 2; }

The getid instruction returns the current thread id in the range 0-7. 
This lowering is done in LowerGlobalTLSAddress in XCoreTargetLowering 
and emitGlobal in XCoreAsmPrinter.

Because TLS is dealt with entirely in the backend the section for TLS 
globals should be identical to those for non TLS globals which is why it 
was being masked off here. However this could equally be done by setting 
TLSDataSection and TLSBSSSection to be identical to data and bss sections.



More information about the llvm-commits mailing list