xref: /llvm-project/llvm/test/Transforms/InstCombine/malloc-free-mismatched.ll (revision 2caaec65c04ea7d0e9568b7895b7a46d6100cb75)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instcombine -S | FileCheck %s
3
4define dso_local i32 @_Z6answeri(i32 %0) {
5; CHECK-LABEL: @_Z6answeri(
6; CHECK-NEXT:    [[TMP2:%.*]] = call noalias nonnull dereferenceable(80) ptr @_Znam(i64 80) #[[ATTR2:[0-9]+]]
7; CHECK-NEXT:    call void @free(ptr [[TMP2]])
8; CHECK-NEXT:    ret i32 42
9;
10  %2 = call noalias nonnull ptr @_Znam(i64 80) #0
11  call void @free(ptr %2)
12  ret i32 42
13}
14
15; All we care about with this function is that LLVM doesn't crash
16; when optimizing it.
17define void @test_alloca() {
18; CHECK-LABEL: @test_alloca(
19; CHECK-NEXT:    [[TMP1:%.*]] = alloca i8, align 1
20; CHECK-NEXT:    call void @free(ptr [[TMP1]])
21; CHECK-NEXT:    ret void
22;
23  %1 = alloca i8
24  call void @free(ptr %1)
25  ret void
26}
27
28; Function Attrs: nobuiltin allocsize(0)
29declare dso_local nonnull ptr @_Znam(i64) #1
30
31; Function Attrs: nounwind
32declare dso_local void @free(ptr) allockind("free") "alloc-family"="malloc"
33
34attributes #0 = { builtin allocsize(0) }
35attributes #1 = { nobuiltin allocsize(0) allockind("alloc,uninitialized") "alloc-family"="_Znam" }
36