[llvm] [AArch64] Refactor @plt, @gotpcrel, and @AUTH to use parseDataExpr (PR #134202)

David Benjamin via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 08:07:05 PDT 2025


davidben wrote:

I'm now not so sure this syntax is invalid. Here's what Xcode's clang outputs:
```
% clang --version
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: arm64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
% cat foo.c
static int x[20];

int *get_ptr() {
    return x + 5;
}
% clang -S -O2 foo.c
% cat foo.s
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 15, 0	sdk_version 15, 4
	.globl	_get_ptr                        ; -- Begin function get_ptr
	.p2align	2
_get_ptr:                               ; @get_ptr
	.cfi_startproc
; %bb.0:
Lloh0:
	adrp	x0, _x at PAGE+20
Lloh1:
	add	x0, x0, _x at PAGEOFF+20
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.cfi_endproc
                                        ; -- End function
.zerofill __DATA,__bss,_x,80,2          ; @x
.subsections_via_symbols
```

That is definitely not the syntax I would have expected, given that `@PAGE` and `@PAGEOFF` are presumably intended to modify the whole argument, but it seems Clang also prefers to emit this funny interleaved version.

https://github.com/llvm/llvm-project/pull/134202


More information about the llvm-commits mailing list