This is documented as the appropriate template modifier for call operands.
Fixes PR44272, and adds a regression test.
Also adds support for operand modifiers in Intel-style inline assembly.
| Paths 
 |  Differential  D71677  
[ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly. ClosedPublic Authored by epastor on Dec 18 2019, 1:47 PM. 
Details Summary This is documented as the appropriate template modifier for call operands. Also adds support for operand modifiers in Intel-style inline assembly. 
Diff Detail 
 Event TimelineHerald added projects: Restricted Project, Restricted Project.  ·  View Herald TranscriptDec 18 2019, 1:47 PM epastor retitled this revision from Summary:
Use "P" modifier on operands to call instructions in inline X86 assembly. to [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly..Dec 18 2019, 1:52 PM Comment Actions Unit tests: pass. 60853 tests passed, 0 failed and 726 were skipped. clang-tidy: fail. Please fix clang-tidy findings. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Comment Actions Where is {0:P} actually documented? I don't see it in LangRef, but I do see it in the code. 
 Comment Actions 
 https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers, under X86; specifically documented to be used on the operands of call instructions. 
 Comment Actions lgtm 
 This revision is now accepted and ready to land.Dec 21 2019, 3:21 PM epastor marked an inline comment as done.Comment Actions Fix test; missing anchor meant the previous version would not catch a regression. Comment Actions Unit tests: pass. 61087 tests passed, 0 failed and 728 were skipped. clang-tidy: fail. Please fix clang-tidy findings. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Closed by commit rGdc5b614fa9a1: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86… (authored by epastor).  ·  Explain WhyDec 22 2019, 6:48 AM This revision was automatically updated to reflect the committed changes. 
Revision Contents 
 
 
Diff 235035 clang/lib/CodeGen/TargetInfo.cpp
 
 clang/test/CodeGen/mozilla-ms-inline-asm.cclang/test/CodeGen/ms-inline-asm.c
 clang/test/CodeGen/ms-inline-asm.cpp
 llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
 llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
 llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
 llvm/lib/MC/MCParser/AsmParser.cpp
 llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
 llvm/lib/Target/X86/AsmParser/X86Operand.h
 llvm/lib/Target/X86/X86AsmPrinter.h
 llvm/lib/Target/X86/X86AsmPrinter.cpp
 llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clang-format: please reformat the code
-// CHECK: @invoke -// CHECK: %5 = alloca i8*, align 4 -// CHECK: %6 = alloca i32, align 4 -// CHECK: %7 = alloca i32, align 4 -// CHECK: %8 = alloca i8*, align 4 -// CHECK: store i8* %0, i8** %5, align 4 -// CHECK: store i32 %1, i32* %6, align 4 -// CHECK: store i32 %2, i32* %7, align 4 -// CHECK: store i8* %3, i8** %8, align 4 -// CHECK: call void asm sideeffect inteldialect -// CHECK-SAME: mov edx,$1 -// CHECK-SAME: test edx,edx -// CHECK-SAME: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams -// ^ Can't use {{.*}} here because the matching is greedy. -// CHECK-SAME: mov eax,edx -// CHECK-SAME: shl eax,$$3 -// CHECK-SAME: sub esp,eax -// CHECK-SAME: mov ecx,esp -// CHECK-SAME: push $0 -// CHECK-SAME: call dword ptr ${2:P} -// CHECK-SAME: {{.*}}__MSASMLABEL_.${:uid}__noparams: -// CHECK-SAME: mov ecx,$3 -// CHECK-SAME: push ecx -// CHECK-SAME: mov edx,[ecx] -// CHECK-SAME: mov eax,$4 -// CHECK-SAME: call dword ptr[edx + eax * $$4] -// CHECK-SAME: mov esp,ebp -// CHECK-SAME: pop ebp -// CHECK-SAME: ret -// CHECK: "=*m,*m,*m,*m,*m,~{eax},~{ebp},~{ecx},~{edx},~{flags},~{esp},~{dirflag},~{fpsr},~{flags}" -// CHECK: (i8** %8, i32* %7, void (...)* bitcast (void ()* @invoke_copy_to_stack to void (...)*), i8** %5, i32* %6) -// CHECK: ret void - __asm { + // CHECK: @invoke + // CHECK: %5 = alloca i8*, align 4 + // CHECK: %6 = alloca i32, align 4 + // CHECK: %7 = alloca i32, align 4 + // CHECK: %8 = alloca i8*, align 4 + // CHECK: store i8* %0, i8** %5, align 4 + // CHECK: store i32 %1, i32* %6, align 4 + // CHECK: store i32 %2, i32* %7, align 4 + // CHECK: store i8* %3, i8** %8, align 4 + // CHECK: call void asm sideeffect inteldialect + // CHECK-SAME: mov edx,$1 + // CHECK-SAME: test edx,edx + // CHECK-SAME: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams + // ^ Can't use {{.*}} here because the matching is greedy. + // CHECK-SAME: mov eax,edx + // CHECK-SAME: shl eax,$$3 + // CHECK-SAME: sub esp,eax + // CHECK-SAME: mov ecx,esp + // CHECK-SAME: push $0 + // CHECK-SAME: call dword ptr ${2:P} + // CHECK-SAME: {{.*}}__MSASMLABEL_.${:uid}__noparams: + // CHECK-SAME: mov ecx,$3 + // CHECK-SAME: push ecx + // CHECK-SAME: mov edx,[ecx] + // CHECK-SAME: mov eax,$4 + // CHECK-SAME: call dword ptr[edx + eax * $$4] + // CHECK-SAME: mov esp,ebp + // CHECK-SAME: pop ebp + // CHECK-SAME: ret + // CHECK: + // "=*m,*m,*m,*m,*m,~{eax},~{ebp},~{ecx},~{edx},~{flags},~{esp},~{dirflag},~{fpsr},~{flags}" + // CHECK: (i8** %8, i32* %7, void (...)* bitcast (void ()* + // @invoke_copy_to_stack to void (...)*), i8** %5, i32* %6) CHECK: ret void + __asm {