File: nonintegral.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (66 lines) | stat: -rw-r--r-- 2,260 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' < %s | FileCheck %s
; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' -addr-sink-using-gep=false < %s | FileCheck %s

; This target data layout is modified to have a non-integral addrspace(1),
; in order to verify that codegenprepare does not try to introduce illegal
; inttoptrs.
target 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-s0:64:64-f80:128:128-ni:1"
target triple = "x86_64-unknown-linux-gnu"

define void @test_simple(i1 %cond, ptr addrspace(1) %base) {
; CHECK-LABEL: @test_simple
; CHECK-NOT: inttoptr {{.*}} to ptr addrspace(1)
entry:
  %addr = getelementptr inbounds i64, ptr addrspace(1) %base, i64 5
  br i1 %cond, label %if.then, label %fallthrough

if.then:
  %v = load i32, ptr addrspace(1) %addr, align 4
  br label %fallthrough

fallthrough:
  ret void
}


define void @test_inttoptr_base(i1 %cond, i64 %base) {
; CHECK-LABEL: @test_inttoptr_base
; CHECK-NOT: inttoptr {{.*}} to ptr addrspace(1)
entry:
; Doing the inttoptr in the integral addrspace(0) followed by an explicit
; (frontend-introduced) addrspacecast is fine. We cannot however introduce
; a direct inttoptr to addrspace(1)
  %baseptr = inttoptr i64 %base to ptr
  %baseptrni = addrspacecast ptr %baseptr to ptr addrspace(1)
  %addr = getelementptr inbounds i64, ptr addrspace(1) %baseptrni, i64 5
  br i1 %cond, label %if.then, label %fallthrough

if.then:
  %v = load i32, ptr addrspace(1) %addr, align 4
  br label %fallthrough

fallthrough:
  ret void
}

define void @test_ptrtoint_base(i1 %cond, ptr addrspace(1) %base) {
; CHECK-LABEL: @test_ptrtoint_base
; CHECK-NOT: ptrtoint addrspace(1)* {{.*}} to i64
entry:
; This one is inserted by the frontend, so it's fine. We're not allowed to
; directly ptrtoint %base ourselves though
  %baseptr0 = addrspacecast ptr addrspace(1) %base to ptr
  %toint = ptrtoint ptr %baseptr0 to i64
  %added = add i64 %toint, 8
  %toptr = inttoptr i64 %added to ptr
  %geped = getelementptr i64, ptr %toptr, i64 2
  br i1 %cond, label %if.then, label %fallthrough

if.then:
  %v = load i64, ptr %geped, align 4
  br label %fallthrough

fallthrough:
  ret void
}