[PATCH] D149722: [AIX][TLS] Generate 64-bit local-exec access code sequence

Amy Kwan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 12:12:41 PDT 2023


amyk added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/MCTargetDesc/PPCXCOFFObjectWriter.cpp:112
+    case MCSymbolRefExpr::VK_PPC_AIX_TLSLE:
+      return {XCOFF::RelocationType::R_TLS_LE, SignAndSizeForFKData};
     case MCSymbolRefExpr::VK_None:
----------------
amyk wrote:
> Verify if this change is appropriate for `SignAndSizeForFKData`.
I talked to @DiggerLin and I think this change is appropriate and should be something we expect. 

For the TLS relocations, we don't expect them to have the sign bit set (and XL doesn't appear to set them for the `R_TLS*` relocations either). The `SignAndSizeForFKData` should correspond to the relocations that we emit in the `llvm-readobj --relocs --expand-relocs` output for `IsSigned` and `Length`:
```
; RELOC-NEXT:     Relocation {
; RELOC-NEXT:       Virtual Address: 0x68
; RELOC-NEXT:       Symbol: IThreadLocalVarUninit (27)
; RELOC-NEXT:       IsSigned: No
; RELOC-NEXT:       FixupBitValue: 0
; RELOC-NEXT:       Length: 64
; RELOC-NEXT:       Type: R_TLS_LE (0x23)
; RELOC-NEXT:     }
```
like in these tests:
```
llvm/test/CodeGen/PowerPC/aix-tls-le-xcoff-reloc-large.ll
llvm/test/CodeGen/PowerPC/aix-tls-le-xcoff-reloc.ll
```
The `IsSigned` and `Length` values appear correct and match what XL emits.


Also, according to the AIX documentation for the `Relocation Information for XCOFF File`, it states that the relocation sign and size contents:
```
0x80 (1 bit) - Indicates whether the relocation reference is signed (1) or unsigned (0).
0x40 (1 bit) - If this field is one, it indicates that the binder replaced the original instruction with a modified instruction.
0x3F(6 bits) - Specifies the bit length of the relocatable reference minus one. The current architecture allows for fields of up to 32 bits (XCOFF32) or 64 bits (XCOFF64) to be relocated.
```
I believe this is mainly consistent to what is currently implemented in the file - we are not using `IsSigned` for the `R_TLS_LE` relocation, and we are ensuring the length is 32 for XCOFF32, and 64 for XCOFF64, like what XL does.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149722/new/

https://reviews.llvm.org/D149722



More information about the llvm-commits mailing list