xref: /llvm-project/llvm/test/Transforms/Util/libcalls-opt-remarks.ll (revision 1c8cd1941c4178585e04feb1267f647716865ecd)
1; RUN: opt < %s -passes=instcombine -o /dev/null  -pass-remarks-output=%t -S \
2; RUN:     -pass-remarks=instcombine 2>&1 | FileCheck %s
3; RUN: cat %t | FileCheck -check-prefix=YAML %s
4; RUN: opt < %s -passes='require<opt-remark-emit>,instcombine' -o /dev/null \
5; RUN:     -pass-remarks-output=%t -S -pass-remarks=instcombine 2>&1 | FileCheck %s
6; RUN: cat %t | FileCheck -check-prefix=YAML %s
7
8; CHECK:      remark: libcalls-opt-remarks.c:10:10: folded strlen(select) to select of constants{{$}}
9; CHECK-NOT:  remark:
10
11; YAML:      --- !Passed
12; YAML-NEXT: Pass:            instcombine
13; YAML-NEXT: Name:            simplify-libcalls
14; YAML-NEXT: DebugLoc:        { File: libcalls-opt-remarks.c, Line: 10, Column: 10 }
15; YAML-NEXT: Function:        f1
16; YAML-NEXT: Args:
17; YAML-NEXT:   - String:          'folded strlen(select) to select of constants'
18; YAML-NEXT: ...
19
20target 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"
21
22declare i32 @strlen(ptr)
23
24@hello = constant [6 x i8] c"hello\00"
25@longer = constant [7 x i8] c"longer\00"
26
27define i32 @f1(i1) !dbg !7 {
28  %2 = select i1 %0, ptr @hello, ptr @longer, !dbg !9
29  %3 = call i32 @strlen(ptr %2), !dbg !14
30  ret i32 %3, !dbg !16
31}
32
33
34
35!llvm.dbg.cu = !{!0}
36!llvm.module.flags = !{!3, !4, !5}
37!llvm.ident = !{!6}
38
39!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Apple LLVM version 8.1.0 (clang-802.0.42)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
40!1 = !DIFile(filename: "libcalls-opt-remarks.c", directory: "/tmp")
41!2 = !{}
42!3 = !{i32 2, !"Dwarf Version", i32 4}
43!4 = !{i32 2, !"Debug Info Version", i32 3}
44!5 = !{i32 1, !"PIC Level", i32 2}
45!6 = !{!"Apple LLVM version 8.1.0 (clang-802.0.42)"}
46!7 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 9, type: !8, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
47!8 = !DISubroutineType(types: !2)
48!9 = !DILocation(line: 10, column: 17, scope: !7)
49!10 = !DILocation(line: 10, column: 24, scope: !11)
50!11 = !DILexicalBlockFile(scope: !7, file: !1, discriminator: 1)
51!12 = !DILocation(line: 10, column: 32, scope: !13)
52!13 = !DILexicalBlockFile(scope: !7, file: !1, discriminator: 2)
53!14 = !DILocation(line: 10, column: 10, scope: !15)
54!15 = !DILexicalBlockFile(scope: !7, file: !1, discriminator: 3)
55!16 = !DILocation(line: 10, column: 3, scope: !15)
56