|
| 1 | +; RUN: opt -S -passes='default<O3>,argpromotion' < %s | FileCheck %s |
| 2 | +; |
| 3 | +; Source code: |
| 4 | +; __attribute__((noinline)) static int is_absolute_path(const char *path) |
| 5 | +; { |
| 6 | +; return path[0] == '/'; |
| 7 | +; } |
| 8 | +; |
| 9 | +; void quit(char *buf); |
| 10 | +; const char *make_nonrelative_path(char *buf, const char *path) |
| 11 | +; { |
| 12 | +; if (is_absolute_path(path)) |
| 13 | +; quit(buf); |
| 14 | +; return buf; |
| 15 | +; } |
| 16 | + |
| 17 | +define dso_local ptr @make_nonrelative_path(ptr noundef %buf, ptr noundef %path) local_unnamed_addr #0 !dbg !10 { |
| 18 | + #dbg_value(ptr %buf, !18, !DIExpression(), !20) |
| 19 | + #dbg_value(ptr %path, !19, !DIExpression(), !20) |
| 20 | + %3 = call fastcc i32 @is_absolute_path(ptr noundef %path), !dbg !21 |
| 21 | + %4 = icmp eq i32 %3, 0, !dbg !21 |
| 22 | + br i1 %4, label %6, label %5, !dbg !21 |
| 23 | + |
| 24 | +5: ; preds = %2 |
| 25 | + call void @quit(ptr noundef %buf), !dbg !23 |
| 26 | + br label %6, !dbg !23 |
| 27 | + |
| 28 | +6: ; preds = %5, %2 |
| 29 | + ret ptr %buf, !dbg !24 |
| 30 | +} |
| 31 | + |
| 32 | +; Function Attrs: noinline nounwind uwtable |
| 33 | +define internal fastcc range(i32 0, 2) i32 @is_absolute_path(ptr noundef %path) unnamed_addr #1 !dbg !25 { |
| 34 | + #dbg_value(ptr %path, !30, !DIExpression(), !31) |
| 35 | + %2 = load i8, ptr %path, align 1, !dbg !32, !tbaa !33 |
| 36 | + %3 = icmp eq i8 %2, 47, !dbg !36 |
| 37 | + %4 = zext i1 %3 to i32, !dbg !36 |
| 38 | + ret i32 %4, !dbg !37 |
| 39 | +} |
| 40 | + |
| 41 | +; CHECK: define internal fastcc range(i32 0, 2) i32 @is_absolute_path(i8 {{.*}}) |
| 42 | + |
| 43 | +declare !dbg !38 void @quit(ptr noundef) local_unnamed_addr |
| 44 | + |
| 45 | +attributes #0 = { nounwind } |
| 46 | +attributes #1 = { noinline nounwind } |
| 47 | + |
| 48 | +!llvm.dbg.cu = !{!0} |
| 49 | +!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8} |
| 50 | +!llvm.ident = !{!9} |
| 51 | + |
| 52 | +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git 25cfee009e78194d1f7ca70779d63ef1936cc7b9)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) |
| 53 | +!1 = !DIFile(filename: "test.c", directory: "/tmp/tests/sig-change/prom", checksumkind: CSK_MD5, checksum: "bcc8cf18726713f5d2ab6d82e8ff459d") |
| 54 | +!2 = !{i32 7, !"Dwarf Version", i32 5} |
| 55 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 56 | +!4 = !{i32 1, !"wchar_size", i32 4} |
| 57 | +!5 = !{i32 8, !"PIC Level", i32 2} |
| 58 | +!6 = !{i32 7, !"PIE Level", i32 2} |
| 59 | +!7 = !{i32 7, !"uwtable", i32 2} |
| 60 | +!8 = !{i32 7, !"debug-info-assignment-tracking", i1 true} |
| 61 | +!9 = !{! "clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git 25cfee009e78194d1f7ca70779d63ef1936cc7b9)"} |
| 62 | +!10 = distinct !DISubprogram(name: "make_nonrelative_path", scope: !1, file: !1, line: 7, type: !11, scopeLine: 8, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !17) |
| 63 | +!11 = !DISubroutineType(types: !12) |
| 64 | +!12 = !{!13, !16, !13} |
| 65 | +!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) |
| 66 | +!14 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !15) |
| 67 | +!15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) |
| 68 | +!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64) |
| 69 | +!17 = !{!18, !19} |
| 70 | +!18 = !DILocalVariable(name: "buf", arg: 1, scope: !10, file: !1, line: 7, type: !16) |
| 71 | +!19 = !DILocalVariable(name: "path", arg: 2, scope: !10, file: !1, line: 7, type: !13) |
| 72 | +!20 = !DILocation(line: 0, scope: !10) |
| 73 | +!21 = !DILocation(line: 9, column: 7, scope: !22) |
| 74 | +!22 = distinct !DILexicalBlock(scope: !10, file: !1, line: 9, column: 7) |
| 75 | +!23 = !DILocation(line: 10, column: 5, scope: !22) |
| 76 | +!24 = !DILocation(line: 11, column: 3, scope: !10) |
| 77 | +!25 = distinct !DISubprogram(name: "is_absolute_path", scope: !1, file: !1, line: 1, type: !26, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !29) |
| 78 | + |
| 79 | +; CHECK: distinct !DISubprogram(name: "is_absolute_path", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], scopeLine: [[#]], flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagArgChanged, unit: ![[#]], retainedNodes: ![[#]]) |
| 80 | + |
| 81 | +!26 = !DISubroutineType(types: !27) |
| 82 | +!27 = !{!28, !13} |
| 83 | +!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 84 | +!29 = !{!30} |
| 85 | +!30 = !DILocalVariable(name: "path", arg: 1, scope: !25, file: !1, line: 1, type: !13) |
| 86 | +!31 = !DILocation(line: 0, scope: !25) |
| 87 | +!32 = !DILocation(line: 3, column: 10, scope: !25) |
| 88 | +!33 = !{!34, !34, i64 0} |
| 89 | +!34 = !{!"omnipotent char", !35, i64 0} |
| 90 | +!35 = !{!"Simple C/C++ TBAA"} |
| 91 | +!36 = !DILocation(line: 3, column: 18, scope: !25) |
| 92 | +!37 = !DILocation(line: 3, column: 3, scope: !25) |
| 93 | +!38 = !DISubprogram(name: "quit", scope: !1, file: !1, line: 6, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
| 94 | +!39 = !DISubroutineType(types: !40) |
| 95 | +!40 = !{null, !16} |
0 commit comments