diff options
author | Fangrui Song <i@maskray.me> | 2023-05-05 15:32:32 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2023-05-05 15:32:32 -0700 |
commit | 8afd831b456a46677e638cdf00dd649fbd5ca0a1 (patch) | |
tree | 3874c4cad02e7c77e51934ac020632a29e29271e /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | dc91a55b2c8fe71077b3131e93afe46a532bcc93 (diff) | |
download | llvm-8afd831b456a46677e638cdf00dd649fbd5ca0a1.zip llvm-8afd831b456a46677e638cdf00dd649fbd5ca0a1.tar.gz llvm-8afd831b456a46677e638cdf00dd649fbd5ca0a1.tar.bz2 |
ms inline asm: recognize case-insensitive JMP and CALL as TargetLowering::C_Address
In a `__asm` block, a symbol reference is usually a memory constraint
(indirect TargetLowering::C_Memory) [LOOP]. CALL and JUMP instructions are special
that `__asm call k` can be an address constraint, if `k` is a function.
Clang always gives us indirect TargetLowering::C_Memory and need to convert it
to direct TargetLowering::C_Address. D133914 implements this conversion, but
does not consider JMP or case-insensitive CALL. This patch implements the missing
cases, so that `__asm jmp k` (`jmp ${0:P}`) will correctly lower to `jmp _k`
instead of `jmp dword ptr [_k]`.
(`__asm call k` lowered to `call dword ptr ${0:P}` and is fixed by D149695 to
lower to `call ${0:P}` instead.)
[LOOP]: Some instructions like LOOP{,E,NE} and Jcc always use an address
constraint (`loop _k` instead of `loop dword ptr [_k]`).
After this patch and D149579, all the following cases will be correct.
```
int k(int);
int (*kptr)(int);
...
__asm call k; // correct without this patch
__asm CALL k; // correct, but needs this patch to be compatible with D149579
__asm jmp k; // correct, but needs this patch to be compatible with D149579
__asm call kptr; // will be fixed by D149579. "Broken case" in clang/test/CodeGen/ms-inline-asm-functions.c
__asm jmp kptr; // will be fixed by this patch and D149579
```
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D149920
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
0 files changed, 0 insertions, 0 deletions