[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

Eric Astor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 14:48:47 PST 2019


epastor added a comment.

In D71677#1790458 <https://reviews.llvm.org/D71677#1790458>, @rnk wrote:

> Where is {0:P} actually documented? I don't see it in LangRef, but I do see it in the code.


https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers, under X86; specifically documented to be used on the operands of `call` instructions.



================
Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2871
+  // differently when referenced in MS-style inline assembly.
+  if (Name.startswith("call") || Name.startswith("lcall")) {
+    for (size_t i = 1; i < Operands.size(); ++i) {
----------------
rnk wrote:
> I'm trying to think of other edge cases where we'd want the same treatment. In theory, we'd want to do this for every control flow instruction that takes a PC-relative operand, jmp, jcc, jecxz, that might be all. You know, it actually seems reasonable to set up a naked function that contains an asm blob which conditionally branches to another function, so I guess we should support it. In that case, maybe this should be named something like "isBranchTarget" instead of isCallTarget.
That would be a valid option, but currently the "P" modifier is documented for LLVM as to-be-used on the operands of `call` instructions. [[ https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers | GNU as ]]) adds it more generally to be applied to functions - and occasionally constants, if you need a constant to avoid all syntax-specific prefixes.

We could use this for any branch target operand... but we'd need to restrict it to apply only to the specific PC-relative operand, which I think means augmenting the X86 target tables to annotate which operands of which instructions are PC-relative? Also, I'm not sure if that would break pre-existing code in enough cases to be worrying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677





More information about the llvm-commits mailing list