-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed as not planned
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugmiscompilation
Description
When targeting arm64e (but not arm64) with -O1 or higher, clang assumes functions are aligned to 8 bytes rather than 4 bytes, generating wrong code that might not work.
Minimal reproducing code:
extern void external_func(void);
unsigned long get_func(void)
{
return ((unsigned long)(external_func) & 0xFFFFFFFFFFF);
}
Output from Apple clang version 17.0.0 (clang-1700.0.13.3):
clang -O0 -arch arm64e
_get_func: ; @get_func
adrp x16, _external_func@GOTPAGE
ldr x16, [x16, _external_func@GOTPAGEOFF]
paciza x16
and x0, x16, #0xfffffffffff ; Correct
ret
clang -O1 -arch arm64e
_get_func: ; @get_func
adrp x16, _external_func@GOTPAGE
ldr x16, [x16, _external_func@GOTPAGEOFF]
paciza x16
and x0, x16, #0xffffffffff8 ; Incorrect
ret
clang -O1 -arch arm64
_get_func: ; @get_func
adrp x8, _external_func@GOTPAGE
ldr x8, [x8, _external_func@GOTPAGEOFF]
and x0, x8, #0xffffffffffc ; Correct, but why bother changing the immediate here?
ret
Metadata
Metadata
Assignees
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugmiscompilation