[PATCH] D153800: [ARM] Adjust strd/ldrd codegen alignment requirements

Maurice Heumann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 11:48:57 PDT 2023


momo5502 added a comment.

In D153800#4490477 <https://reviews.llvm.org/D153800#4490477>, @efriedma wrote:

>> It seems that the calling convention snprintf expects is all values in registers, so r0, r1, r2, r3. Meaning it expects the Value to be in r3.
>
> A "long long" can't fit into r3.
>
> The normal calling convention rules (https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#parameter-passing) require skipping r3 and storing the "long long" value on the stack.  So snprintf should ignore the value in r3 unless we're passing in a bad format string.  (Which is possible, I guess... it looks like the "llvm::format" function isn't marked with a format attribute, so the format string isn't checked anywhere.)

Oh you are absolutely right, I overlooked that :D

The first 3 arguments are passed in `r0`, `r1`, `r2` and only the value is passed on the stack as two 4 byte blocks.
snprintf seems to expect them in `r3` and `r4` then.

As the format string truncates the value, only the lower byte is relevant, which is probably the reason I overlooked it.

The way you describe it sounds like a bug in snprintf then, doesn't it?
It seems that gcc also puts them on the stack: https://godbolt.org/z/h1oY1o3vc

I used the Dockerfile @DavidSpickett linked. Does it contain a custom variant of the C-runtime? So could it be an issue only with that specific version of snprintf?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153800/new/

https://reviews.llvm.org/D153800



More information about the llvm-commits mailing list