File: arm-widen-strings-ptrtoint.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 (54 lines) | stat: -rw-r--r-- 2,771 bytes parent folder | download | duplicates (3)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -mtriple=arm-none-eabi -passes=globalopt -S | FileCheck %s

@f.string1 = private unnamed_addr constant [45 x i8] c"The quick brown dog jumps over the lazy fox.\00", align 1

; Function Attrs: nounwind
define  i32 @f() {
; CHECK-LABEL: define i32 @f() local_unnamed_addr {
; CHECK-NEXT:  [[ENTRY:.*:]]
; CHECK-NEXT:    [[STRING1:%.*]] = alloca [48 x i8], align 1
; CHECK-NEXT:    [[POS:%.*]] = alloca i32, align 4
; CHECK-NEXT:    [[TOKEN:%.*]] = alloca ptr, align 4
; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 45, ptr [[STRING1]])
; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 1 [[STRING1]], ptr align 1 @f.string1, i32 48, i1 false)
; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 4, ptr [[POS]])
; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 4, ptr [[TOKEN]])
; CHECK-NEXT:    [[CALL:%.*]] = call ptr @strchr(ptr [[STRING1]], i32 101)
; CHECK-NEXT:    store ptr [[CALL]], ptr [[TOKEN]], align 4
; CHECK-NEXT:    [[TMP1:%.*]] = load ptr, ptr [[TOKEN]], align 4
; CHECK-NEXT:    [[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[TMP1]] to i32
; CHECK-NEXT:    [[SUB_PTR_RHS_CAST:%.*]] = ptrtoint ptr [[STRING1]] to i32
; CHECK-NEXT:    [[SUB_PTR_SUB:%.*]] = sub i32 [[SUB_PTR_LHS_CAST]], [[SUB_PTR_RHS_CAST]]
; CHECK-NEXT:    [[ADD:%.*]] = add nsw i32 [[SUB_PTR_SUB]], 1
; CHECK-NEXT:    store i32 [[ADD]], ptr [[POS]], align 4
; CHECK-NEXT:    [[TMP2:%.*]] = load i32, ptr [[POS]], align 4
; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 4, ptr [[TOKEN]])
; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 4, ptr [[POS]])
; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 45, ptr [[STRING1]])
; CHECK-NEXT:    ret i32 [[TMP2]]
;
entry:
  %string1 = alloca [45 x i8], align 1
  %pos = alloca i32, align 4
  %token = alloca ptr, align 4
  call void @llvm.lifetime.start.p0i8(i64 45, ptr %string1)
  call void @llvm.memcpy.p0i8.p0i8.i32(ptr align 1 %string1, ptr align 1 @f.string1, i32 45, i1 false)
  call void @llvm.lifetime.start.p0i8(i64 4, ptr %pos)
  call void @llvm.lifetime.start.p0i8(i64 4, ptr %token)
  %call = call ptr @strchr(ptr %string1, i32 101)
  store ptr %call, ptr %token, align 4
  %0 = load ptr, ptr %token, align 4
  %sub.ptr.lhs.cast = ptrtoint ptr %0 to i32
  %sub.ptr.rhs.cast = ptrtoint ptr %string1 to i32
  %sub.ptr.sub = sub i32 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast
  %add = add nsw i32 %sub.ptr.sub, 1
  store i32 %add, ptr %pos, align 4
  %1 = load i32, ptr %pos, align 4
  call void @llvm.lifetime.end.p0i8(i64 4, ptr %token)
  call void @llvm.lifetime.end.p0i8(i64 4, ptr %pos)
  call void @llvm.lifetime.end.p0i8(i64 45, ptr %string1)
  ret i32 %1
}

declare ptr @strchr(ptr, i32)