[clang] 053bf86 - MS inline asm: remove obsolete code adding AOK_SizeDirective (e.g. dword ptr)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Thu May 4 09:42:30 PDT 2023
Author: Fangrui Song
Date: 2023-05-04T09:42:25-07:00
New Revision: 053bf8640aa85911823c2fc98538474c42d33b7a
URL: https://github.com/llvm/llvm-project/commit/053bf8640aa85911823c2fc98538474c42d33b7a
DIFF: https://github.com/llvm/llvm-project/commit/053bf8640aa85911823c2fc98538474c42d33b7a.diff
LOG: MS inline asm: remove obsolete code adding AOK_SizeDirective (e.g. dword ptr)
The AOK_SizeDirective part from 5b37c181291210bedfbb7a6af5d51229f3652ef0
(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
Added:
Modified:
clang/test/CodeGen/mozilla-ms-inline-asm.c
clang/test/CodeGen/ms-inline-asm-64.c
clang/test/CodeGen/ms-inline-asm.c
clang/test/CodeGen/ms-inline-asm.cpp
clang/test/CodeGen/ms_this.cpp
clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Removed:
################################################################################
diff --git a/clang/test/CodeGen/mozilla-ms-inline-asm.c b/clang/test/CodeGen/mozilla-ms-inline-asm.c
index f01e9200852f3..2e379c1bb8a23 100644
--- a/clang/test/CodeGen/mozilla-ms-inline-asm.c
+++ b/clang/test/CodeGen/mozilla-ms-inline-asm.c
@@ -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
diff --git a/clang/test/CodeGen/ms-inline-asm-64.c b/clang/test/CodeGen/ms-inline-asm-64.c
index 7c9a9f2e2bb2e..d688c10ca7080 100644
--- a/clang/test/CodeGen/ms-inline-asm-64.c
+++ b/clang/test/CodeGen/ms-inline-asm-64.c
@@ -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)
}
diff --git a/clang/test/CodeGen/ms-inline-asm.c b/clang/test/CodeGen/ms-inline-asm.c
index 32e9fb0d47139..9498be1034768 100644
--- a/clang/test/CodeGen/ms-inline-asm.c
+++ b/clang/test/CodeGen/ms-inline-asm.c
@@ -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) {
diff --git a/clang/test/CodeGen/ms-inline-asm.cpp b/clang/test/CodeGen/ms-inline-asm.cpp
index da55176071247..a1fb19f3f640c 100644
--- a/clang/test/CodeGen/ms-inline-asm.cpp
+++ b/clang/test/CodeGen/ms-inline-asm.cpp
@@ -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_)
}
diff --git a/clang/test/CodeGen/ms_this.cpp b/clang/test/CodeGen/ms_this.cpp
index 655fcdf9ab549..24d134b3404be 100644
--- a/clang/test/CodeGen/ms_this.cpp
+++ b/clang/test/CodeGen/ms_this.cpp
@@ -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;
diff --git a/clang/test/CodeGenCXX/ms-inline-asm-fields.cpp b/clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
index 9f79fd6e2a17b..403e9c8427760 100644
--- a/clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
+++ b/clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
@@ -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]])
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 56a82f9144a98..2c18966ac0fce 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -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,
More information about the cfe-commits
mailing list