blob: 60df54e38f48bd6efb654b7aaa8e3a667a2fc362 (
plain)
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
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
declare i32 @strlen(i8* nocapture)
declare noalias i8* @calloc(i32, i32)
declare noalias i8* @malloc(i32)
define i32 @calloc_strlen() {
; CHECK-LABEL: @calloc_strlen(
; CHECK-NEXT: ret i32 0
;
%call = tail call noalias i8* @calloc(i32 10, i32 1)
%call1 = tail call i32 @strlen(i8* %call)
ret i32 %call1
}
define i32 @calloc_strlen_not_const_nmemb(i32 %n) {
; CHECK-LABEL: @calloc_strlen_not_const_nmemb(
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @calloc(i32 [[N:%.*]], i32 10)
; CHECK-NEXT: [[CALL1:%.*]] = tail call i32 @strlen(i8* [[CALL]])
; CHECK-NEXT: ret i32 [[CALL1]]
;
%call = tail call noalias i8* @calloc(i32 %n, i32 10)
%call1 = tail call i32 @strlen(i8* %call) #4
ret i32 %call1
}
define i32 @calloc_strlen_not_const_size(i32 %size) {
; CHECK-LABEL: @calloc_strlen_not_const_size(
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @calloc(i32 1, i32 [[SIZE:%.*]])
; CHECK-NEXT: [[CALL1:%.*]] = tail call i32 @strlen(i8* [[CALL]])
; CHECK-NEXT: ret i32 [[CALL1]]
;
%call = tail call noalias i8* @calloc(i32 1, i32 %size)
%call1 = tail call i32 @strlen(i8* %call) #4
ret i32 %call1
}
define i32 @calloc_strlen_not_const_args(i32 %n, i32 %size) {
; CHECK-LABEL: @calloc_strlen_not_const_args(
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @calloc(i32 [[N:%.*]], i32 [[SIZE:%.*]])
; CHECK-NEXT: [[CALL1:%.*]] = tail call i32 @strlen(i8* [[CALL]])
; CHECK-NEXT: ret i32 [[CALL1]]
;
%call = tail call noalias i8* @calloc(i32 %n, i32 %size)
%call1 = tail call i32 @strlen(i8* %call) #4
ret i32 %call1
}
define i32 @malloc_strlen() {
; CHECK-LABEL: @malloc_strlen(
; CHECK-NEXT: [[CALL:%.*]] = tail call noalias i8* @malloc(i32 10)
; CHECK-NEXT: [[CALL1:%.*]] = tail call i32 @strlen(i8* [[CALL]])
; CHECK-NEXT: ret i32 [[CALL1]]
;
%call = tail call noalias i8* @malloc(i32 10)
%call1 = tail call i32 @strlen(i8* %call)
ret i32 %call1
}
|