1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 2; RUN: opt < %s -p=gvn -S | FileCheck %s 3;; Check that when GVN replaces a load of a select with a select of the values 4;; that would be loaded, we propagate the debug location from the load to the 5;; select, since the select is a replacement that produces the same value. 6 7target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 8target triple = "x86_64-unknown-linux-gnu" 9 10define void @loadtree(ptr %topol, i1 %cmp168) { 11; CHECK-LABEL: define void @loadtree( 12; CHECK-SAME: ptr [[TOPOL:%.*]], i1 [[CMP168:%.*]]) { 13; CHECK-NEXT: [[ENTRY:.*:]] 14; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4 15; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[TOPOL]], align 4 16; CHECK-NEXT: [[CMP1681:%.*]] = icmp sgt i32 [[TMP0]], [[TMP1]] 17; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[CMP168]], i32 [[TMP1]], i32 [[TMP0]], !dbg [[DBG3:![0-9]+]] 18; CHECK-NEXT: [[DOT:%.*]] = select i1 [[CMP168]], ptr [[TOPOL]], ptr null, !dbg [[DBG9:![0-9]+]] 19; CHECK-NEXT: [[CMP174_NOT473:%.*]] = icmp eq i32 [[TMP2]], 0 20; CHECK-NEXT: ret void 21; 22entry: 23 %0 = load i32, ptr null, align 4 24 %1 = load i32, ptr %topol, align 4 25 %cmp1681 = icmp sgt i32 %0, %1 26 %. = select i1 %cmp168, ptr %topol, ptr null, !dbg !9 27 %2 = load i32, ptr %., align 4, !dbg !3 28 %cmp174.not473 = icmp eq i32 %2, 0 29 ret void 30} 31 32!llvm.dbg.cu = !{!0} 33!llvm.module.flags = !{!2} 34 35!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.0.0git") 36!1 = !DIFile(filename: "/tmp/mltaln9.c", directory: "/tmp") 37!2 = !{i32 2, !"Debug Info Version", i32 3} 38!3 = !DILocation(line: 4, column: 22, scope: !5) 39!4 = !DIFile(filename: "mltaln9.c", directory: "/tmp") 40!5 = distinct !DISubprogram(name: "loadtree", scope: !4, file: !4, line: 869, type: !6, scopeLine: 870, unit: !0, retainedNodes: !8) 41!6 = distinct !DISubroutineType(types: !7) 42!7 = !{null} 43!8 = !{} 44!9 = !DILocation(line: 9, column: 22, scope: !5) 45;. 46; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug) 47; CHECK: [[META1]] = !DIFile(filename: "/tmp/mltaln9.c", directory: {{.*}}) 48; CHECK: [[DBG3]] = !DILocation(line: 4, column: 22, scope: [[META4:![0-9]+]]) 49; CHECK: [[META4]] = distinct !DISubprogram(name: "loadtree", scope: [[META5:![0-9]+]], file: [[META5]], line: 869, type: [[META6:![0-9]+]], scopeLine: 870, spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META8:![0-9]+]]) 50; CHECK: [[META5]] = !DIFile(filename: "mltaln9.c", directory: {{.*}}) 51; CHECK: [[META6]] = distinct !DISubroutineType(types: [[META7:![0-9]+]]) 52; CHECK: [[META7]] = !{null} 53; CHECK: [[META8]] = !{} 54; CHECK: [[DBG9]] = !DILocation(line: 9, column: 22, scope: [[META4]]) 55;. 56