xref: /llvm-project/llvm/test/CodeGen/X86/inline-asm-pic.ll (revision 6b0e2fa6f0b1045ed616e263c75ee59768e9f7f8)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i386-apple-darwin -relocation-model=pic | FileCheck %s
3
4@main_q = internal global ptr null		; <ptr> [#uses=1]
5
6define void @func2() nounwind {
7; CHECK-LABEL: func2:
8; CHECK:       ## %bb.0: ## %entry
9; CHECK-NEXT:    calll L0$pb
10; CHECK-NEXT:  L0$pb:
11; CHECK-NEXT:    popl %eax
12; CHECK-NEXT:    leal _main_q-L0$pb(%eax), %eax
13; CHECK-NEXT:    ## InlineAsm Start
14; CHECK-NEXT:    movl %eax, %gs:152
15; CHECK-NEXT:    ## InlineAsm End
16; CHECK-NEXT:    retl
17entry:
18	tail call void asm "mov $1,%gs:$0", "=*m,ri,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(ptr) inttoptr (i32 152 to ptr), ptr @main_q) nounwind
19	ret void
20}
21
22; The intent of this test is to ensure that we handle blockaddress' correctly
23; with "i" constraints for -m32 -fPIC.
24
25define void @x() {
26; CHECK-LABEL: x:
27; CHECK:       ## %bb.0:
28; CHECK-NEXT:    ## InlineAsm Start
29; CHECK-NEXT:    ## LBB1_1
30; CHECK-EMPTY:
31; CHECK-NEXT:    ## InlineAsm End
32; CHECK-NEXT:  ## %bb.2: ## %return
33; CHECK-NEXT:    retl
34; CHECK-NEXT:  Ltmp0: ## Block address taken
35; CHECK-NEXT:  LBB1_1: ## %overflow
36; CHECK-NEXT:    ## Label of block must be emitted
37; CHECK-NEXT:    retl
38  callbr void asm "#  ${0:l}\0A", "!i"()
39          to label %return [label %overflow]
40
41overflow:
42  br label %return
43
44return:
45  ret void
46}
47
48; Test unusual case of blockaddress from @x in @y's asm.
49define void @y() {
50; CHECK-LABEL: y:
51; CHECK:       ## %bb.0:
52; CHECK-NEXT:    ## InlineAsm Start
53; CHECK-NEXT:    ## Ltmp0
54; CHECK-EMPTY:
55; CHECK-NEXT:    ## InlineAsm End
56; CHECK-NEXT:    retl
57  call void asm "# ${0:l}\0A", "i"(ptr blockaddress(@x, %overflow))
58  ret void
59}
60