Felix Berlakovich via llvm-dev
2020-Jun-12 07:34 UTC
[llvm-dev] signed vs unsigned CSSize in emitEpilogue
Hi everyone! While working on a research project I discovered a curiosity in emitEpilogue, line 1862 (https://github.com/llvm/llvm-project/blob/425c6f079b9c7a2b70407843e89eb67a7b32032d/llvm/lib/Target/X86/X86FrameLowering.cpp#L1862) in X86FrameLowering.cpp (X86 Target). In the case where IsWin64Prologue is false, the LEAAmount is equal to the negative CSSize (makes sense). However, as CSSize is an unsigned int, the negation leads to an overflow. IIUC the code just happens to work because the (now positive) LEAAmount is passed to addRegOffset which expects a signed integer and it is converted back to a signed value. While the code works, I find it slightly unintuitive and it bit me when I tried to use the LEAAmount in a different way. Am I missing some important insight here? Kind regards Felix -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200612/1f8787ff/attachment.html>