xref: /llvm-project/llvm/test/CodeGen/X86/semantic-interposition-asm.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64 -relocation-model=static < %s | \
3; RUN:   FileCheck --check-prefixes=COMMON,STATIC %s
4; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | \
5; RUN:   FileCheck --check-prefixes=COMMON,CHECK %s
6
7;; Test that we use the local alias for dso_local functions in inline assembly.
8
9@gv0 = dso_local global i32 0
10@gv1 = dso_preemptable global i32 1
11
12define i64 @test_var() nounwind {
13; STATIC-LABEL: test_var:
14; STATIC:       # %bb.0: # %entry
15; STATIC-NEXT:    movq gv1@GOTPCREL(%rip), %rax
16; STATIC-NEXT:    #APP
17; STATIC-NEXT:    movq gv0(%rip), %rax
18; STATIC-NEXT:    movq (%rax), %rax
19; STATIC-NEXT:    #NO_APP
20; STATIC-NEXT:    retq
21;
22; CHECK-LABEL: test_var:
23; CHECK:       # %bb.0: # %entry
24; CHECK-NEXT:    movq gv1@GOTPCREL(%rip), %rax
25; CHECK-NEXT:    #APP
26; CHECK-NEXT:    movq .Lgv0$local(%rip), %rax
27; CHECK-NEXT:    movq (%rax), %rax
28; CHECK-NEXT:    #NO_APP
29; CHECK-NEXT:    retq
30entry:
31  %0 = tail call i64 asm "movq $1, $0\0Amovq $2, $0", "=r,*m,*m"(ptr elementtype(i32) @gv0, ptr elementtype(i32) @gv1)
32  ret i64 %0
33}
34
35define dso_local void @fun0() nounwind {
36; COMMON-LABEL: fun0:
37; COMMON:       # %bb.0: # %entry
38; COMMON-NEXT:    retq
39entry:
40  ret void
41}
42
43define dso_preemptable void @fun1() nounwind {
44; COMMON-LABEL: fun1:
45; COMMON:       # %bb.0: # %entry
46; COMMON-NEXT:    retq
47entry:
48  ret void
49}
50
51define i64 @test_fun() nounwind {
52; STATIC-LABEL: test_fun:
53; STATIC:       # %bb.0: # %entry
54; STATIC-NEXT:    movq fun1@GOTPCREL(%rip), %rax
55; STATIC-NEXT:    #APP
56; STATIC-NEXT:    movq fun0(%rip), %rax
57; STATIC-NEXT:    movq (%rax), %rax
58; STATIC-NEXT:    #NO_APP
59; STATIC-NEXT:    retq
60;
61; CHECK-LABEL: test_fun:
62; CHECK:       # %bb.0: # %entry
63; CHECK-NEXT:    movq fun1@GOTPCREL(%rip), %rax
64; CHECK-NEXT:    #APP
65; CHECK-NEXT:    movq .Lfun0$local(%rip), %rax
66; CHECK-NEXT:    movq (%rax), %rax
67; CHECK-NEXT:    #NO_APP
68; CHECK-NEXT:    retq
69entry:
70  %0 = tail call i64 asm "movq $1, $0\0Amovq $2, $0", "=r,*m,*m"(ptr elementtype(void ()) nonnull @fun0, ptr elementtype(void ()) nonnull @fun1)
71  ret i64 %0
72}
73