[llvm] Fix stack layout for frames larger than 2gb (PR #84114)
Wesley Wiser via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 8 08:21:19 PST 2024
================
@@ -1419,7 +1419,7 @@ class DarwinX86AsmBackend : public X86AsmBackend {
unsigned Reg = *MRI.getLLVMRegNum(Inst.getRegister(), true);
SavedRegs[SavedRegIdx++] = Reg;
StackAdjust += OffsetSize;
- MinAbsOffset = std::min(MinAbsOffset, abs(Inst.getOffset()));
+ MinAbsOffset = std::min<int64_t>(MinAbsOffset, llabs(Inst.getOffset()));
----------------
wesleywiser wrote:
I think so but advice would be appreciated! My understanding is that on *nix, `long` is a 64-bit signed integer while on Windows, `long` is a 32-bit signed integer. Therefore `labs` is sufficient on *nix where `int64_t` and `long` are both 64-bit but will cause incorrect results on Windows as the `int64_t` will be shortened to a 32-bit `long`.
Using `llabs` will work correctly on Windows as `long long` is a 64-bit signed integer but on *nix will cause a promotion from `int64_t` to a 128-bit integer and then subsequent conversion back to 64-bit. I think this is ~fine but inefficient.
I looked briefly to see if there was an LLVM utility function somewhere with an implementation of `abs` for `int64_t` but didn't find anything. Is there a better way to handle this?
https://github.com/llvm/llvm-project/pull/84114
More information about the llvm-commits
mailing list