|
| 1 | +; REQUIRES: x86-registered-target |
| 2 | +; RUN: opt -O3 -S < %s | FileCheck %s |
| 3 | +; |
| 4 | +; Source code: |
| 5 | +; __attribute__((noinline)) static int is_absolute_path(const char *path) |
| 6 | +; { |
| 7 | +; return path[0] == '/'; |
| 8 | +; } |
| 9 | +; |
| 10 | +; int scpy(char *, const char *, int); |
| 11 | +; int quit(void); |
| 12 | +; const char *make_nonrelative_path(char *buf, int sz, const char *path) |
| 13 | +; { |
| 14 | +; if (is_absolute_path(path)) { |
| 15 | +; if (scpy(buf, path, sz) >= sz) |
| 16 | +; quit(); |
| 17 | +; } |
| 18 | +; return buf; |
| 19 | +; } |
| 20 | +; Compilation flag: |
| 21 | +; clang -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c |
| 22 | + |
| 23 | +; ModuleID = 'test.c' |
| 24 | +source_filename = "test.c" |
| 25 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
| 26 | +target triple = "x86_64-unknown-linux-gnu" |
| 27 | + |
| 28 | +; Function Attrs: nounwind uwtable |
| 29 | +define dso_local ptr @make_nonrelative_path(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 !dbg !9 { |
| 30 | + %4 = alloca ptr, align 8 |
| 31 | + %5 = alloca i32, align 4 |
| 32 | + %6 = alloca ptr, align 8 |
| 33 | + store ptr %0, ptr %4, align 8, !tbaa !21 |
| 34 | + #dbg_declare(ptr %4, !18, !DIExpression(), !26) |
| 35 | + store i32 %1, ptr %5, align 4, !tbaa !27 |
| 36 | + #dbg_declare(ptr %5, !19, !DIExpression(), !29) |
| 37 | + store ptr %2, ptr %6, align 8, !tbaa !21 |
| 38 | + #dbg_declare(ptr %6, !20, !DIExpression(), !30) |
| 39 | + %7 = load ptr, ptr %6, align 8, !dbg !31, !tbaa !21 |
| 40 | + %8 = call i32 @is_absolute_path(ptr noundef %7), !dbg !33 |
| 41 | + %9 = icmp ne i32 %8, 0, !dbg !33 |
| 42 | + br i1 %9, label %10, label %20, !dbg !33 |
| 43 | + |
| 44 | +10: ; preds = %3 |
| 45 | + %11 = load ptr, ptr %4, align 8, !dbg !34, !tbaa !21 |
| 46 | + %12 = load ptr, ptr %6, align 8, !dbg !37, !tbaa !21 |
| 47 | + %13 = load i32, ptr %5, align 4, !dbg !38, !tbaa !27 |
| 48 | + %14 = call i32 @scpy(ptr noundef %11, ptr noundef %12, i32 noundef %13), !dbg !39 |
| 49 | + %15 = load i32, ptr %5, align 4, !dbg !40, !tbaa !27 |
| 50 | + %16 = icmp sge i32 %14, %15, !dbg !41 |
| 51 | + br i1 %16, label %17, label %19, !dbg !41 |
| 52 | + |
| 53 | +17: ; preds = %10 |
| 54 | + %18 = call i32 @quit(), !dbg !42 |
| 55 | + br label %19, !dbg !42 |
| 56 | + |
| 57 | +19: ; preds = %17, %10 |
| 58 | + br label %20, !dbg !43 |
| 59 | + |
| 60 | +20: ; preds = %19, %3 |
| 61 | + %21 = load ptr, ptr %4, align 8, !dbg !44, !tbaa !21 |
| 62 | + ret ptr %21, !dbg !45 |
| 63 | +} |
| 64 | + |
| 65 | +; Function Attrs: noinline nounwind uwtable |
| 66 | +define internal i32 @is_absolute_path(ptr noundef %0) #1 !dbg !46 { |
| 67 | + %2 = alloca ptr, align 8 |
| 68 | + store ptr %0, ptr %2, align 8, !tbaa !21 |
| 69 | + #dbg_declare(ptr %2, !50, !DIExpression(), !51) |
| 70 | + %3 = load ptr, ptr %2, align 8, !dbg !52, !tbaa !21 |
| 71 | + %4 = getelementptr inbounds i8, ptr %3, i64 0, !dbg !52 |
| 72 | + %5 = load i8, ptr %4, align 1, !dbg !52, !tbaa !53 |
| 73 | + %6 = sext i8 %5 to i32, !dbg !52 |
| 74 | + %7 = icmp eq i32 %6, 47, !dbg !54 |
| 75 | + %8 = zext i1 %7 to i32, !dbg !54 |
| 76 | + ret i32 %8, !dbg !55 |
| 77 | +} |
| 78 | + |
| 79 | +; CHECK: define internal fastcc range(i32 0, 2) i32 @is_absolute_path(i8 {{.*}}) |
| 80 | + |
| 81 | +declare !dbg !56 i32 @scpy(ptr noundef, ptr noundef, i32 noundef) #2 |
| 82 | + |
| 83 | +declare !dbg !59 i32 @quit() #2 |
| 84 | + |
| 85 | +attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
| 86 | +attributes #1 = { noinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
| 87 | +attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
| 88 | + |
| 89 | +!llvm.dbg.cu = !{!0} |
| 90 | +!llvm.module.flags = !{!2, !3, !4, !5, !6, !7} |
| 91 | +!llvm.ident = !{!8} |
| 92 | + |
| 93 | +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git bbfd0a15ade80596f6d6dde8add7d50f4875dde1)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) |
| 94 | +!1 = !DIFile(filename: "test.c", directory: "/tmp/tests/sig-change/prom", checksumkind: CSK_MD5, checksum: "1befb35eb4507489630adb56cb20fe09") |
| 95 | +!2 = !{i32 7, !"Dwarf Version", i32 5} |
| 96 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 97 | +!4 = !{i32 1, !"wchar_size", i32 4} |
| 98 | +!5 = !{i32 8, !"PIC Level", i32 2} |
| 99 | +!6 = !{i32 7, !"PIE Level", i32 2} |
| 100 | +!7 = !{i32 7, !"uwtable", i32 2} |
| 101 | +!8 = !{! "clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git bbfd0a15ade80596f6d6dde8add7d50f4875dde1)"} |
| 102 | +!9 = distinct !DISubprogram(name: "make_nonrelative_path", scope: !1, file: !1, line: 8, type: !10, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !17) |
| 103 | +!10 = !DISubroutineType(types: !11) |
| 104 | +!11 = !{!12, !15, !16, !12} |
| 105 | +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) |
| 106 | +!13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14) |
| 107 | +!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) |
| 108 | +!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) |
| 109 | +!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 110 | +!17 = !{!18, !19, !20} |
| 111 | +!18 = !DILocalVariable(name: "buf", arg: 1, scope: !9, file: !1, line: 8, type: !15) |
| 112 | +!19 = !DILocalVariable(name: "sz", arg: 2, scope: !9, file: !1, line: 8, type: !16) |
| 113 | +!20 = !DILocalVariable(name: "path", arg: 3, scope: !9, file: !1, line: 8, type: !12) |
| 114 | +!21 = !{!22, !22, i64 0} |
| 115 | +!22 = !{!"p1 omnipotent char", !23, i64 0} |
| 116 | +!23 = !{!"any pointer", !24, i64 0} |
| 117 | +!24 = !{!"omnipotent char", !25, i64 0} |
| 118 | +!25 = !{!"Simple C/C++ TBAA"} |
| 119 | +!26 = !DILocation(line: 8, column: 41, scope: !9) |
| 120 | +!27 = !{!28, !28, i64 0} |
| 121 | +!28 = !{!"int", !24, i64 0} |
| 122 | +!29 = !DILocation(line: 8, column: 50, scope: !9) |
| 123 | +!30 = !DILocation(line: 8, column: 66, scope: !9) |
| 124 | +!31 = !DILocation(line: 10, column: 30, scope: !32) |
| 125 | +!32 = distinct !DILexicalBlock(scope: !9, file: !1, line: 10, column: 13) |
| 126 | +!33 = !DILocation(line: 10, column: 13, scope: !32) |
| 127 | +!34 = !DILocation(line: 11, column: 26, scope: !35) |
| 128 | +!35 = distinct !DILexicalBlock(scope: !36, file: !1, line: 11, column: 21) |
| 129 | +!36 = distinct !DILexicalBlock(scope: !32, file: !1, line: 10, column: 37) |
| 130 | +!37 = !DILocation(line: 11, column: 31, scope: !35) |
| 131 | +!38 = !DILocation(line: 11, column: 37, scope: !35) |
| 132 | +!39 = !DILocation(line: 11, column: 21, scope: !35) |
| 133 | +!40 = !DILocation(line: 11, column: 44, scope: !35) |
| 134 | +!41 = !DILocation(line: 11, column: 41, scope: !35) |
| 135 | +!42 = !DILocation(line: 12, column: 4, scope: !35) |
| 136 | +!43 = !DILocation(line: 13, column: 9, scope: !36) |
| 137 | +!44 = !DILocation(line: 14, column: 16, scope: !9) |
| 138 | +!45 = !DILocation(line: 14, column: 9, scope: !9) |
| 139 | +!46 = distinct !DISubprogram(name: "is_absolute_path", scope: !1, file: !1, line: 1, type: !47, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !49) |
| 140 | + |
| 141 | +; CHECK: distinct !DISubprogram(name: "is_absolute_path", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], scopeLine: [[#]], flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagArgChanged, unit: ![[#]], retainedNodes: ![[#]]) |
| 142 | + |
| 143 | +!47 = !DISubroutineType(types: !48) |
| 144 | +!48 = !{!16, !12} |
| 145 | +!49 = !{!50} |
| 146 | +!50 = !DILocalVariable(name: "path", arg: 1, scope: !46, file: !1, line: 1, type: !12) |
| 147 | +!51 = !DILocation(line: 1, column: 67, scope: !46) |
| 148 | +!52 = !DILocation(line: 3, column: 16, scope: !46) |
| 149 | +!53 = !{!24, !24, i64 0} |
| 150 | +!54 = !DILocation(line: 3, column: 24, scope: !46) |
| 151 | +!55 = !DILocation(line: 3, column: 9, scope: !46) |
| 152 | +!56 = !DISubprogram(name: "scpy", scope: !1, file: !1, line: 6, type: !57, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
| 153 | +!57 = !DISubroutineType(types: !58) |
| 154 | +!58 = !{!16, !15, !12, !16} |
| 155 | +!59 = !DISubprogram(name: "quit", scope: !1, file: !1, line: 7, type: !60, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
| 156 | +!60 = !DISubroutineType(types: !61) |
| 157 | +!61 = !{!16} |
0 commit comments