[llvm] [AIX][TLS] Optimize the small local-exec access sequence for non-zero offsets (PR #71485)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 15 08:26:35 PST 2024
================
@@ -1547,6 +1614,69 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
EmitToStreamer(*OutStreamer, TmpInst);
}
+// For non-TOC-based local-exec variables that have a non-zero offset,
+// we need to create a new MCExpr that adds the non-zero offset to the address
+// of the local-exec variable that will be used in either an addi, load or
+// store. However, the final displacement for these instructions must be
+// between [-32768, 32768), so if the TLS address + its non-zero offset is
+// greater than 32KB, a new MCExpr is produced to accommodate this situation.
+const MCExpr *PPCAsmPrinter::getAdjustedLocalExecExpr(const MachineOperand &MO,
+ int64_t Offset) {
+ assert(MO.isGlobal() && "Only expecting a global MachineOperand here!");
+ const GlobalValue *GValue = MO.getGlobal();
+ TLSModel::Model Model = TM.getTLSModel(GValue);
+ assert(Model == TLSModel::LocalExec &&
+ "Only local-exec accesses are handled!");
----------------
diggerlin wrote:
```
TLSModel::Model Model = TM.getTLSModel(GValue);
assert(Model == TLSModel::LocalExec &&
"Only local-exec accesses are handled!");
```
-->
```
assert(TM.getTLSModel(GValue) == TLSModel::LocalExec &&
"Only local-exec accesses are handled!");
```
https://github.com/llvm/llvm-project/pull/71485
More information about the llvm-commits
mailing list