blob: 37f43e6f36f019729bc5b0db7acbda5b4dcb9c1b [file] [log] [blame]
Chris Lattner600f1752009-07-09 00:00:16 +00001; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s -check-prefix=CHECK-64
2; RUN: llvm-as < %s | llc -march=x86 -mtriple=i686-apple-darwin9 -relocation-model=pic | FileCheck %s -check-prefix=CHECK-32
Anton Korobeynikov573c92d2009-04-28 21:49:33 +00003; PR3379
4
5target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
6target triple = "x86_64-unknown-linux-gnu"
7@per_cpu__cpu_number = external global i32 ; <i32*> [#uses=1]
8
Chris Lattner600f1752009-07-09 00:00:16 +00009declare void @bar(...)
10
11define i32 @test1() nounwind {
Anton Korobeynikov573c92d2009-04-28 21:49:33 +000012entry:
Chris Lattnerab711cc2009-07-08 23:44:06 +000013; Should have a rip suffix.
Chris Lattner600f1752009-07-09 00:00:16 +000014; CHECK-64: test1:
15; CHECK-64: movl %gs:per_cpu__cpu_number(%rip),%eax
16
17; CHECK-32: test1:
18; CHECK-32: movl %gs:(%eax),%eax
19 %A = call i32 asm "movl %gs:$1,$0",
Chris Lattnerab711cc2009-07-08 23:44:06 +000020 "=r,*m"(i32* @per_cpu__cpu_number) nounwind
Chris Lattner600f1752009-07-09 00:00:16 +000021 ret i32 %A
Anton Korobeynikov573c92d2009-04-28 21:49:33 +000022}
Chris Lattnerab711cc2009-07-08 23:44:06 +000023
Chris Lattner600f1752009-07-09 00:00:16 +000024define i32 @test2() nounwind {
Chris Lattnerab711cc2009-07-08 23:44:06 +000025entry:
26; Should not have a rip suffix because of the P modifier.
Chris Lattner600f1752009-07-09 00:00:16 +000027; CHECK-64: test2:
28; CHECK-64: movl %gs:per_cpu__cpu_number,%eax
29
30; CHECK-32: test2:
Chris Lattner9f44b3a2009-07-09 00:27:29 +000031; CHECK-32: movl %gs:(%eax),%eax
Chris Lattner600f1752009-07-09 00:00:16 +000032
33 %A = call i32 asm "movl %gs:${1:P},$0",
Chris Lattnerab711cc2009-07-08 23:44:06 +000034 "=r,*m"(i32* @per_cpu__cpu_number) nounwind
Chris Lattner600f1752009-07-09 00:00:16 +000035 ret i32 %A
Chris Lattnerab711cc2009-07-08 23:44:06 +000036}
37
Chris Lattner600f1752009-07-09 00:00:16 +000038define void @test3() nounwind {
39entry:
40; CHECK-64: test3:
41; CHECK-64: call bar
42; CHECK-64: call test3
43
44; CHECK-32: test3:
45; CHECK-32: call _bar
46; CHECK-32: call _test3
47 tail call void asm sideeffect "call ${0:P}", "X"(void (...)* @bar) nounwind
48 tail call void asm sideeffect "call ${0:P}", "X"(void (...)* bitcast (void ()* @test3 to void (...)*)) nounwind
49 ret void
50}