You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should reconsider the i64:64 part and consider adding f64:32:64.
My argument for doing this is that "ABI" alignment in LLVM is a little too overloaded. It is used for the alignment used in LLVM struct layout in addition to some other things like va_arg lowering.
The reality is that i64 arguments and stack allocations are generally not aligned, and you can't assume that any unadorned i64 load is really 8 byte aligned. However, in structs, 64-bit integers and doubles are naturally aligned. Since struct layout is mainly a frontend responsibility at this point, we should be able to lower LLVM's alignment without affecting clang.
This is similar to how we implemented -malign-double in clang without changing LLVM.
The text was updated successfully, but these errors were encountered:
Doesn't this issue reflect an ABI incompatibility between clang and MSVC? i64 arguments passed on the stack will be put in the wrong place -- MSVC 4-aligns them but clang 8-aligns them.
Most ABI compatibility issues are fully addressed: the parameter passing isn't affected by the ABI alignment here, and Clang packs its structs to achieve compatible layouts.
The problem you highlight, that LLVM will assume that pointers to i64 objects in MSVC stack frames will be 8 byte aligned while they are only 4 byte aligned, remains. It's not sound, but it usually doesn't cause issues because misaligned 8 byte loads don't trap on x86. There's no great way to fix this from LLVM, except perhaps globally lowering all load+store alignments from 8 to 4, while respecting all alignments of 16 or more. This issue really only affects double and i64.
Extended Description
This is my current triple and datalayout for x86 Windows:
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i386-pc-windows-msvc19.11.25508"
We should reconsider the i64:64 part and consider adding f64:32:64.
My argument for doing this is that "ABI" alignment in LLVM is a little too overloaded. It is used for the alignment used in LLVM struct layout in addition to some other things like va_arg lowering.
The reality is that i64 arguments and stack allocations are generally not aligned, and you can't assume that any unadorned i64 load is really 8 byte aligned. However, in structs, 64-bit integers and doubles are naturally aligned. Since struct layout is mainly a frontend responsibility at this point, we should be able to lower LLVM's alignment without affecting clang.
This is similar to how we implemented -malign-double in clang without changing LLVM.
The text was updated successfully, but these errors were encountered: