xref: /llvm-project/llvm/test/Transforms/InstCombine/builtin-object-size-strdup-family.ll (revision 211cf8a384ebb29787367c8fd5858e2a5ed3c10f)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -passes=instcombine -S < %s | FileCheck %s
3
4
5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8declare dso_local noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr
9declare i64 @llvm.objectsize.i64.p0(ptr, i1 immarg, i1 immarg, i1 immarg)
10declare noalias ptr @strdup(ptr);
11declare noalias ptr @__strdup(ptr);
12declare noalias ptr @strndup(ptr, i64);
13declare noalias ptr @__strndup(ptr, i64);
14
15@str = dso_local constant [11 x i8] c"toulbroc'h\00"
16
17define dso_local i64 @check_strdup(i32 noundef %n) local_unnamed_addr {
18; CHECK-LABEL: @check_strdup(
19; CHECK-NEXT:    ret i64 11
20;
21  %ptr = call noalias ptr @strdup(ptr noundef @str)
22  %size = call i64 @llvm.objectsize.i64.p0(ptr %ptr, i1 false, i1 true, i1 false)
23  ret i64 %size
24}
25
26define dso_local i64 @check_dunder_strdup(i32 noundef %n) local_unnamed_addr {
27; CHECK-LABEL: @check_dunder_strdup(
28; CHECK-NEXT:    ret i64 11
29;
30  %ptr = call noalias ptr @__strdup(ptr noundef @str)
31  %size = call i64 @llvm.objectsize.i64.p0(ptr %ptr, i1 false, i1 true, i1 false)
32  ret i64 %size
33}
34
35define dso_local i64 @check_strndup(i32 noundef %n) local_unnamed_addr {
36; CHECK-LABEL: @check_strndup(
37; CHECK-NEXT:    ret i64 5
38;
39  %ptr = call noalias ptr @strndup(ptr noundef @str, i64 4)
40  %size = call i64 @llvm.objectsize.i64.p0(ptr %ptr, i1 false, i1 true, i1 false)
41  ret i64 %size
42}
43
44define dso_local i64 @check_dunder_strndup(i32 noundef %n) local_unnamed_addr {
45; CHECK-LABEL: @check_dunder_strndup(
46; CHECK-NEXT:    ret i64 5
47;
48  %ptr = call noalias ptr @__strndup(ptr noundef @str, i64 4)
49  %size = call i64 @llvm.objectsize.i64.p0(ptr %ptr, i1 false, i1 true, i1 false)
50  ret i64 %size
51}
52