brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · e5c9a32 Raw
131 lines · plain
1; RUN: opt -mtriple=aarch64-unknown-linux-gnu -S %s -passes=sroa -o - | FileCheck %s2 3; In this test we want to ensure that getMergedLocations uses common include4; location if incoming locations belong to different files.5; The location of phi instruction merged from locations of %mul3 and %mul106; should be the location of do-loop lexical block from y.c.7 8; Generated with clang from9;10; main.c:11;   int foo(int a) {12;     int i = 0;13;     if ((a & 1) == 1) {14;       a -= 1;15;   #define A16;   #include "y.c"17;    } else {18;       a += 3;19;   #undef A20;   #include "y.c"21;    }22;     return i;23;   }24;25; y.c:26;   # 300 "y.c" 127;   do {28;   #ifdef A29;   #include "z1.c"30;   #else31;   #include "z2.c"32;   #endif33;   } while (0);34;35; z1.c:36;   # 100 "z1.c" 137;   i += a;38;   i -= 10*a;39;   i *= a*a;40;41; z2.c:42;   # 200 "z1.c" 143;   i += a;44;   i -= 10*a;45;   i *= a*a;46;47; Preprocessed source:48;49; # 1 "main.c"50; int foo(int a) {51;   int i = 0;52;   if ((a & 1) == 1) {53;     a -= 1;54; # 300 "y.c" 155; do {56; # 100 "z1.c" 157; i += a;58; i -= 10*a;59; i *= a*a;60; # 303 "y.c" 261; } while (0);62; # 7 "main.c" 263;  } else {64;     a += 3;65; # 300 "y.c" 166; do {67; # 200 "z2.c" 168; i += a;69; i -= 10*a;70; i *= a*a;71; # 305 "y.c" 272; } while (0);73; # 11 "main.c" 274;  }75;   return i;76; }77 78target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"79target triple = "arm64-apple-macosx15.0.0"80 81define i32 @foo() !dbg !3 {82; CHECK:    phi i32 {{.*}}, !dbg [[PHILOC:![0-9]+]]83;84entry:85  %i = alloca i32, align 486  br i1 false, label %do.body, label %if.else87 88do.body:                                          ; preds = %entry89  store i32 1, ptr %i, align 4, !dbg !690  br label %if.end91 92if.else:                                          ; preds = %entry93  store i32 0, ptr %i, align 4, !dbg !1494  br label %if.end95 96if.end:                                           ; preds = %if.else, %do.body97  %0 = load i32, ptr %i, align 498  ret i32 099}100 101!llvm.dbg.cu = !{!0}102!llvm.module.flags = !{!2}103 104!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")105!1 = !DIFile(filename: "main.c", directory: "")106!2 = !{i32 2, !"Debug Info Version", i32 3}107!3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !4, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !5)108!4 = !DISubroutineType(types: !5)109!5 = !{}110!6 = !DILocation(line: 102, column: 3, scope: !7)111!7 = !DILexicalBlockFile(scope: !9, file: !8, discriminator: 0)112!8 = !DIFile(filename: "z1.c", directory: "")113!9 = distinct !DILexicalBlock(scope: !11, file: !10, line: 300, column: 4)114!10 = !DIFile(filename: "y.c", directory: "")115!11 = !DILexicalBlockFile(scope: !12, file: !10, discriminator: 0)116!12 = distinct !DILexicalBlock(scope: !13, file: !1, line: 3, column: 21)117!13 = distinct !DILexicalBlock(scope: !3, file: !1, line: 3, column: 7)118!14 = !DILocation(line: 202, column: 3, scope: !15)119!15 = !DILexicalBlockFile(scope: !17, file: !16, discriminator: 0)120!16 = !DIFile(filename: "z2.c", directory: "")121!17 = distinct !DILexicalBlock(scope: !18, file: !10, line: 300, column: 4)122!18 = !DILexicalBlockFile(scope: !19, file: !10, discriminator: 0)123!19 = distinct !DILexicalBlock(scope: !13, file: !1, line: 7, column: 9)124 125; CHECK: [[FILE_MAIN:![0-9]+]] = !DIFile(filename: "main.c"126; CHECK: [[SP:![0-9]+]] = distinct !DISubprogram(name: "foo", scope: [[FILE_MAIN]], file: [[FILE_MAIN]], line: 1127; CHECK: [[PHILOC]] = !DILocation(line: 300, column: 4, scope: [[BLOCK_Y:![0-9]+]])128; CHECK-NEXT: [[BLOCK_Y]] = !DILexicalBlock(scope: [[BLOCK_MAIN:![0-9]+]], file: [[FILE_Y:![0-9]+]], line: 300, column: 4)129; CHECK-NEXT: [[FILE_Y]] = !DIFile(filename: "y.c"130; CHECK: [[BLOCK_MAIN]] = distinct !DILexicalBlock(scope: [[SP]], file: [[FILE_MAIN]], line: 3, column: 7)131