xref: /llvm-project/llvm/test/Transforms/InstCombine/strncpy-2.ll (revision dc2b66b8d6032dbc5e5dd7ee86e4fa7dd9cf0b9b)
1; Test that the strncpy folder avoids simplifying a call to the function
2; declared with an incompatible type.
3;
4; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
5; Test that the strncpy library call simplifier works correctly.
6;
7; RUN: opt < %s -passes=instcombine -S | FileCheck %s
8
9target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
10
11@hello = constant [6 x i8] c"hello\00"
12@a = common global [32 x i8] zeroinitializer, align 1
13
14declare i16 @strncpy(ptr, ptr, i32)
15
16; Check that 'strncpy' functions with the wrong prototype aren't simplified.
17
18define void @test_no_simplify1() {
19; CHECK-LABEL: @test_no_simplify1(
20; CHECK-NEXT:    [[TMP1:%.*]] = call i16 @strncpy(ptr nonnull @a, ptr nonnull @hello, i32 6)
21; CHECK-NEXT:    ret void
22;
23
24  call i16 @strncpy(ptr @a, ptr @hello, i32 6)
25  ret void
26}
27