[llvm] 09984be - X86,test: Improve asm modifier tests
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 00:22:15 PDT 2025
Author: Fangrui Song
Date: 2025-05-08T00:22:10-07:00
New Revision: 09984be7d9c8b4ccb8fc27b0533c049f384a898f
URL: https://github.com/llvm/llvm-project/commit/09984be7d9c8b4ccb8fc27b0533c049f384a898f
DIFF: https://github.com/llvm/llvm-project/commit/09984be7d9c8b4ccb8fc27b0533c049f384a898f.diff
LOG: X86,test: Improve asm modifier tests
Added:
Modified:
llvm/test/CodeGen/X86/asm-modifier-macho.ll
llvm/test/CodeGen/X86/asm-modifier.ll
Removed:
llvm/test/CodeGen/X86/2010-07-06-asm-RIP.ll
llvm/test/CodeGen/X86/pr19752.ll
################################################################################
diff --git a/llvm/test/CodeGen/X86/2010-07-06-asm-RIP.ll b/llvm/test/CodeGen/X86/2010-07-06-asm-RIP.ll
deleted file mode 100644
index 8b82d0ec78fa9..0000000000000
--- a/llvm/test/CodeGen/X86/2010-07-06-asm-RIP.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; RUN: llc < %s -mtriple=x86_64-apple-darwin -no-integrated-as | FileCheck %s
-; PR 4752
-
- at n = global i32 0 ; <ptr> [#uses=2]
-
-define void @f(ptr) nounwind ssp {
- ret void
-}
-
-define void @g() nounwind ssp {
-entry:
-; CHECK: _g:
-; CHECK: push $_f$_f
-; CHECK: call _f(%rip)
- call void asm sideeffect "push\09$1$1\0A\09call\09${1:a}\0A\09pop\09%edx", "imr,i,~{dirflag},~{fpsr},~{flags},~{memory},~{cc},~{edi},~{esi},~{edx},~{ecx},~{ebx},~{eax}"(ptr @n, ptr @f) nounwind
- br label %return
-
-return: ; preds = %entry
- ret void
-}
-
diff --git a/llvm/test/CodeGen/X86/asm-modifier-macho.ll b/llvm/test/CodeGen/X86/asm-modifier-macho.ll
index 4f9124d8e225f..b8da424bbacca 100644
--- a/llvm/test/CodeGen/X86/asm-modifier-macho.ll
+++ b/llvm/test/CodeGen/X86/asm-modifier-macho.ll
@@ -1,21 +1,39 @@
-; RUN: llc < %s | FileCheck %s
-; ModuleID = 'asm.c'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
-target triple = "i386-apple-darwin9.6"
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -mtriple=i386-apple-darwin9.6 < %s | FileCheck %s --check-prefixes=CHECK,X86
+; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s --check-prefixes=CHECK,X64
define i32 @test1() nounwind {
-entry:
; CHECK-LABEL: test1:
-; CHECK: movw %gs:6, %ax
+; CHECK: ## %bb.0: ## %entry
+; CHECK-NEXT: ## InlineAsm Start
+; CHECK-NEXT: movw %gs:6, %ax
+; CHECK-NEXT: ## InlineAsm End
+; CHECK-NEXT: movzwl %ax, %eax
+; CHECK-NEXT: ret{{[l|q]}}
+entry:
%asmtmp.i = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 6) nounwind ; <i16> [#uses=1]
%0 = zext i16 %asmtmp.i to i32 ; <i32> [#uses=1]
ret i32 %0
}
define zeroext i16 @test2(i32 %address) nounwind {
+; X86-LABEL: test2:
+; X86: ## %bb.0: ## %entry
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: ## InlineAsm Start
+; X86-NEXT: movw %gs:(%eax), %ax
+; X86-NEXT: ## InlineAsm End
+; X86-NEXT: movzwl %ax, %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test2:
+; X64: ## %bb.0: ## %entry
+; X64-NEXT: ## InlineAsm Start
+; X64-NEXT: movw %gs:(%edi), %ax
+; X64-NEXT: ## InlineAsm End
+; X64-NEXT: movzwl %ax, %eax
+; X64-NEXT: retq
entry:
-; CHECK-LABEL: test2:
-; CHECK: movw %gs:(%eax), %ax
%asmtmp = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 %address) nounwind ; <i16> [#uses=1]
ret i16 %asmtmp
}
@@ -24,18 +42,41 @@ entry:
@y = common global i32 0 ; <ptr> [#uses=3]
define void @test3() nounwind {
+; X86-LABEL: test3:
+; X86: ## %bb.0: ## %entry
+; X86-NEXT: ## InlineAsm Start
+; X86-NEXT: movl _n, %eax
+; X86-NEXT: ## InlineAsm End
+; X86-NEXT: retl
+;
+; X64-LABEL: test3:
+; X64: ## %bb.0: ## %entry
+; X64-NEXT: ## InlineAsm Start
+; X64-NEXT: movl _n(%rip), %eax
+; X64-NEXT: ## InlineAsm End
+; X64-NEXT: retq
entry:
-; CHECK-LABEL: test3:
-; CHECK: movl _n, %eax
call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @n) nounwind
ret void
}
define void @test4() nounwind {
+; X86-LABEL: test4:
+; X86: ## %bb.0: ## %entry
+; X86-NEXT: movl L_y$non_lazy_ptr, %ecx
+; X86-NEXT: ## InlineAsm Start
+; X86-NEXT: movl (%ecx), %eax
+; X86-NEXT: ## InlineAsm End
+; X86-NEXT: retl
+;
+; X64-LABEL: test4:
+; X64: ## %bb.0: ## %entry
+; X64-NEXT: movq _y at GOTPCREL(%rip), %rcx
+; X64-NEXT: ## InlineAsm Start
+; X64-NEXT: movl (%rcx), %eax
+; X64-NEXT: ## InlineAsm End
+; X64-NEXT: retq
entry:
-; CHECK-LABEL: test4:
-; CHECK: movl L_y$non_lazy_ptr, %ecx
-; CHECK: movl (%ecx), %eax
call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @y) nounwind
ret void
}
diff --git a/llvm/test/CodeGen/X86/asm-modifier.ll b/llvm/test/CodeGen/X86/asm-modifier.ll
index 9a69402d22168..6bc800da04b48 100644
--- a/llvm/test/CodeGen/X86/asm-modifier.ll
+++ b/llvm/test/CodeGen/X86/asm-modifier.ll
@@ -4,6 +4,17 @@
@var = internal global i32 0, align 4
+define dso_local void @test_a() nounwind {
+; CHECK-LABEL: test_a:
+; CHECK: # %bb.0:
+; CHECK-NEXT: #APP
+; CHECK-NEXT: #TEST var#
+; CHECK-NEXT: #NO_APP
+; CHECK-NEXT: ret{{[l|q]}}
+ tail call void asm sideeffect "#TEST ${0:c}#", "i"(ptr nonnull @var)
+ ret void
+}
+
define dso_local void @test_c() nounwind {
; CHECK-LABEL: test_c:
; CHECK: # %bb.0:
@@ -19,6 +30,16 @@ define dso_local void @test_c() nounwind {
ret void
}
+define dso_local void @test_k() nounwind {
+; CHECK-LABEL: test_k:
+; CHECK: # %bb.0:
+; CHECK-NEXT: #APP
+; CHECK-NEXT: movl %fs:0, %eax
+; CHECK-NEXT: #NO_APP
+ %tmp = tail call i64 asm "movl %fs:${1:a}, ${0:k}", "=q,irm,~{dirflag},~{fpsr},~{flags}"(i64 0)
+ unreachable
+}
+
define dso_local void @test_n() nounwind {
; CHECK-LABEL: test_n:
; CHECK: # %bb.0:
diff --git a/llvm/test/CodeGen/X86/pr19752.ll b/llvm/test/CodeGen/X86/pr19752.ll
deleted file mode 100644
index 0dd6895ecb4be..0000000000000
--- a/llvm/test/CodeGen/X86/pr19752.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s | FileCheck %s
-
-target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
-target triple = "i386---elf"
-
-define void @test() {
-; CHECK-LABEL: test:
-; CHECK: # %bb.0:
-; CHECK-NEXT: #APP
-; CHECK-NEXT: movl %fs:0, %eax
-; CHECK-NEXT: #NO_APP
- %tmp = tail call i64 asm "movl %fs:${1:a}, ${0:k}", "=q,irm,~{dirflag},~{fpsr},~{flags}"(i64 0)
- unreachable
-}
More information about the llvm-commits
mailing list