89 lines · plain
1; RUN: opt -S -passes=jump-threading < %s | FileCheck %s2 3;; Check that when we simplify the load of %p by replacing it with 0 when coming4;; from %left, the inttoptr cast instruction is assigned the DILocation from the5;; load instruction.6 7; CHECK-LABEL: define void @foo(8 9; CHECK-NEXT: [[ENTRY:.*:]]10; CHECK-NEXT: [[P:%.*]] = alloca i32, align 811; CHECK-NEXT: br i1 {{.*}}, label %[[LEFT:.*]], label %[[RIGHT:.*]]12 13;; Cast in "left" should have the load's debug location.14; CHECK: [[LEFT]]:15; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr [[P]], i8 0, i64 8, i1 false)16; CHECK-NEXT: [[TMP0:%.*]] = inttoptr i64 0 to ptr, !dbg [[LOAD_LOC:![0-9]+]]17; CHECK-NEXT: br label %[[END:.*]]18 19; CHECK: [[RIGHT]]:20; CHECK-NEXT: br i1 {{.*}}, label %[[RIGHT_LEFT:.*]], label %[[ENDTHREAD_PRE_SPLIT:.*]]21 22;; Cast in "right.left" should not have a debug location, as we are not23;; guaranteed to reach the load's original position.24; CHECK: [[RIGHT_LEFT]]:25; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr [[P]], i8 0, i64 8, i1 false)26; CHECK-NEXT: [[TMP1:%.*]] = inttoptr i64 0 to ptr27; CHECK-NEXT: br i1 {{.*}}, label %[[END]], label %[[EXIT:.*]]28 29;; Load in "right.right" should have the load's debug location.30; CHECK: [[ENDTHREAD_PRE_SPLIT]]:31; CHECK-NEXT: [[DOTPR:%.*]] = load ptr, ptr [[P]], align 8, !dbg [[LOAD_LOC]]32; CHECK-NEXT: br label %[[END]], !dbg [[LOAD_LOC]]33 34;; Finally, the PHI node should also have the load's debug location.35; CHECK: [[END]]:36; CHECK-NEXT: [[TMP2:%.*]] = phi ptr [ [[DOTPR]], %[[ENDTHREAD_PRE_SPLIT]] ], [ [[TMP1]], %[[RIGHT_LEFT]] ], [ [[TMP0]], %[[LEFT]] ], !dbg [[LOAD_LOC]]37 38; CHECK: [[LOAD_LOC]] = !DILocation(line: 1, column: 1,39 40define void @foo(i1 %b, i1 %c, i1 %d) !dbg !5 {41entry:42 %p = alloca i32, align 843 br i1 %b, label %left, label %right44 45left:46 call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 8, i1 false)47 br label %end48 49right:50 br i1 %c, label %right.left, label %right.right51 52right.left:53 call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 8, i1 false)54 br i1 %d, label %end, label %exit55 56right.right:57 br label %end58 59end:60 %0 = load ptr, ptr %p, align 8, !dbg !861 %isnull = icmp eq ptr %0, null62 br i1 %isnull, label %exit, label %notnull63 64notnull:65 br label %exit66 67exit:68 ret void69}70 71; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)72declare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg) #073 74attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }75 76!llvm.dbg.cu = !{!0}77!llvm.debugify = !{!2, !3}78!llvm.module.flags = !{!4}79 80!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)81!1 = !DIFile(filename: "simplify-partially-redundant-load-debugloc.ll", directory: "/")82!2 = !{i32 13}83!3 = !{i32 0}84!4 = !{i32 2, !"Debug Info Version", i32 3}85!5 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)86!6 = !DISubroutineType(types: !7)87!7 = !{}88!8 = !DILocation(line: 1, column: 1, scope: !5)89