brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 05d92b0 Raw
72 lines · plain
1; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' < %s | FileCheck %s2;3; This test case was generated from the following source code:4; 5; long long foo(int *ptr, int cond) {6;   long long result = 3;7;   unsigned val = *ptr; // line 38;   switch (cond) {9;   case 3:10;     result = val;      // line 611;     break;12;   case 4:13;     result += 2;14;   }15; 16;   return result + val;17; };18;19; When CGP moves a zext Z of a load L to the block where L lives,  Z should not20; retain its original debug location. Instead, Z should reuse the debug location21; associated with L. Logically the zero extend will become part of the load; the22; code generator will attempt to fuse the two instructions into a zextload.23 24; CHECK-LABEL: @test25; CHECK:   [[LOADVAL:%[0-9]+]] = load i32, ptr %ptr, align 4, !dbg [[DEBUGLOC:![0-9]+]]26; CHECK-NEXT:                    zext i32 [[LOADVAL]] to i6427; CHECK:   [[DEBUGLOC]] = !DILocation(line: 328 29target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"30target triple = "x86_64-unknown-linux-gnu"31 32define i64 @test(ptr %ptr, i32 %cond) !dbg !5 {33entry:34  %0 = load i32, ptr %ptr, align 4, !dbg !735  switch i32 %cond, label %sw.epilog [36    i32 3, label %sw.bb37    i32 4, label %sw.bb138  ], !dbg !839 40sw.bb:                                            ; preds = %entry41  %conv = zext i32 %0 to i64, !dbg !942  br label %sw.epilog, !dbg !1043 44sw.bb1:                                           ; preds = %entry45  br label %sw.epilog, !dbg !1146 47sw.epilog:                                        ; preds = %sw.bb1, %entry, %sw.bb48  %result.0 = phi i64 [ 3, %entry ], [ 5, %sw.bb1 ], [ %conv, %sw.bb ]49  %conv2 = zext i32 %0 to i64, !dbg !1250  %add3 = add nuw nsw i64 %result.0, %conv2, !dbg !1351  ret i64 %add3, !dbg !1452}53 54!llvm.dbg.cu = !{!0}55!llvm.module.flags = !{!3, !4}56 57!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)58!1 = !DIFile(filename: "test.c", directory: "")59!2 = !{}60!3 = !{i32 2, !"Dwarf Version", i32 4}61!4 = !{i32 2, !"Debug Info Version", i32 3}62!5 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)63!6 = !DISubroutineType(types: !2)64!7 = !DILocation(line: 3, column: 18, scope: !5)65!8 = !DILocation(line: 4, column: 3, scope: !5)66!9 = !DILocation(line: 6, column: 14, scope: !5)67!10 = !DILocation(line: 7, column: 5, scope: !5)68!11 = !DILocation(line: 10, column: 3, scope: !5)69!12 = !DILocation(line: 12, column: 19, scope: !5)70!13 = !DILocation(line: 12, column: 17, scope: !5)71!14 = !DILocation(line: 12, column: 3, scope: !5)72