Skip to content

Commit

Permalink
MS inline asm: remove obsolete code adding AOK_SizeDirective (e.g. dw…
Browse files Browse the repository at this point in the history
…ord ptr)

The AOK_SizeDirective part from 5b37c18
(2014-08) seems unneeded nowadays (the root cause has likely been fixed
elsewhere). The part abuses that `call dword ptr foo` assembles the same way as `call
foo` in Intel syntax, which is going to be fixed (changed) by D149579.

The generated object files for
CodeGen/ms-inline-asm{,-functions,-variables,-static-variable}.c and
CodeGenCXX/ms-inline-asm-fields.cpp are unchanged
(-mno-incremental-linker-compatible) with just this patch. When D149579 is
subsequently applied, the FIXME part of `kptr` in
CodeGen/ms-inline-asm-functions.c will be fixed.

Differential Revision: https://reviews.llvm.org/D149695
  • Loading branch information
MaskRay committed May 4, 2023
1 parent f09807c commit 053bf86
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion clang/test/CodeGen/mozilla-ms-inline-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void invoke(void* that, unsigned methodIndex,
// CHECK-SAME: sub esp,eax
// CHECK-SAME: mov ecx,esp
// CHECK-SAME: push $0
// CHECK-SAME: call dword ptr ${2:P}
// CHECK-SAME: call ${2:P}
// CHECK-SAME: {{.*}}__MSASMLABEL_.${:uid}__noparams:
// CHECK-SAME: mov ecx,$3
// CHECK-SAME: push ecx
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGen/ms-inline-asm-64.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void t5(void) {
}
// CHECK: t5
// CHECK: call void asm sideeffect inteldialect
// CHECK-SAME: call qword ptr ${0:P}
// CHECK-SAME: jmp qword ptr ${1:P}
// CHECK-SAME: call ${0:P}
// CHECK-SAME: jmp ${1:P}
// CHECK-SAME: "*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void (...)) @bar, ptr elementtype(void (...)) @bar)
}
4 changes: 2 additions & 2 deletions clang/test/CodeGen/ms-inline-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void t24_helper(void) {}
void t24(void) {
__asm call t24_helper
// CHECK: t24
// CHECK: call void asm sideeffect inteldialect "call dword ptr ${0:P}", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void ()) @t24_helper)
// CHECK: call void asm sideeffect inteldialect "call ${0:P}", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void ()) @t24_helper)
}

void t25(void) {
Expand Down Expand Up @@ -684,7 +684,7 @@ void dot_operator(void){
void call_clobber(void) {
__asm call t41
// CHECK-LABEL: define{{.*}} void @call_clobber
// CHECK: call void asm sideeffect inteldialect "call dword ptr ${0:P}", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void (i16)) @t41)
// CHECK: call void asm sideeffect inteldialect "call ${0:P}", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void (i16)) @t41)
}

void xgetbv(void) {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/ms-inline-asm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void test5() {
__asm mov x, eax
// CHECK: call void asm sideeffect inteldialect
// CHECK-SAME: push $0
// CHECK-SAME: call dword ptr ${2:P}
// CHECK-SAME: call ${2:P}
// CHECK-SAME: mov $1, eax
// CHECK-SAME: "=*m,=*m,*m,~{esp},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %y, ptr elementtype(i32) %x, ptr elementtype(i32 (float)) @_ZN2T5IiE6createIfEEiT_)
}
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGen/ms_this.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void t2::runc() {
mov rax,[this]
// CHECK: [[THIS_ADDR_T2:%.+]] = alloca ptr
// CHECK: [[THIS1_T2:%.+]] = load ptr, ptr [[THIS_ADDR_T2]],
// CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr $1{{.*}}ptr [[THIS1_T2]]
// CHECK: call void asm sideeffect inteldialect "mov rax,$1\0A\09mov rbx,[rax]\0A\09mov $0, rbx", "=*m,m,~{rax},~{rbx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(double) %num, ptr [[THIS1_T2]])
mov rbx,[rax]
mov num, rbx
};
Expand All @@ -33,7 +33,7 @@ void t1::runc() {
mov rax,[this]
// CHECK: [[THIS_ADDR_T1:%.+]] = alloca ptr
// CHECK: [[THIS1_T1:%.+]] = load ptr, ptr [[THIS_ADDR_T1]],
// CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr $1{{.*}}ptr [[THIS1_T1]]
// CHECK: call void asm sideeffect inteldialect "mov rax,$1{{.*}}ptr [[THIS1_T1]]
mov rbx,[rax]
mov num, rbx
};
Expand All @@ -46,7 +46,7 @@ struct s {
__asm mov rax, [this]
// CHECK: [[THIS_ADDR_S:%.+]] = alloca ptr
// CHECK: [[THIS1_S:%.+]] = load ptr, ptr [[THIS_ADDR_S]],
// CHECK: call void asm sideeffect inteldialect "mov rax, qword ptr $0{{.*}}ptr [[THIS1_S]]
// CHECK: call void asm sideeffect inteldialect "mov rax, $0{{.*}}ptr [[THIS1_S]]
}
} f3;

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ template void msvc_dcas_x86<false>::store();
// CHECK: %[[P:.*]] = alloca %"struct.make_storage_type<false>::type", align 4
// CHECK: %[[B:.*]] = getelementptr inbounds %"struct.make_storage_type<false>::type", ptr %[[P]], i32 0, i32 0
// CHECK: %[[X:.*]] = getelementptr inbounds %"struct.make_storage_type<false>::type::B", ptr %[[B]], i32 0, i32 1
// CHECK: call void asm sideeffect inteldialect "mov edx, dword ptr $0", "*m,~{edx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %[[X]])
// CHECK: call void asm sideeffect inteldialect "mov edx, $0", "*m,~{edx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %[[X]])
6 changes: 0 additions & 6 deletions llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1748,12 +1748,6 @@ bool X86AsmParser::CreateMemForMSInlineAsm(
// If we found a decl other than a VarDecl, then assume it is a FuncDecl or
// some other label reference.
if (Info.isKind(InlineAsmIdentifierInfo::IK_Label)) {
// Insert an explicit size if the user didn't have one.
if (!Size) {
Size = getPointerWidth();
InstInfo->AsmRewrites->emplace_back(AOK_SizeDirective, Start,
/*Len=*/0, Size);
}
// Create an absolute memory reference in order to match against
// instructions taking a PC relative operand.
Operands.push_back(X86Operand::CreateMem(getPointerWidth(), Disp, Start,
Expand Down

0 comments on commit 053bf86

Please sign in to comment.