MS inline asm: remove obsolete code adding AOK_SizeDirective (e.g. dword ptr)

The AOK_SizeDirective part from 5b37c18129
(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
This commit is contained in:
Fangrui Song
2023-05-04 09:42:25 -07:00
parent f09807ca9d
commit 053bf8640a
7 changed files with 10 additions and 16 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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) {
@@ -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) {

View File

@@ -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_)
}

View File

@@ -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
};
@@ -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
};
@@ -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;

View File

@@ -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]])

View File

@@ -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,