xref: /aosp_15_r20/external/clang/test/CodeGen/lifetime-debuginfo-2.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li // Inserting lifetime markers should not affect debuginfo: lifetime.end is not
4*67e74705SXin Li // a destructor, but instrumentation for the compiler. Ensure the debug info for
5*67e74705SXin Li // the return statement (in the IR) does not point to the function closing '}'
6*67e74705SXin Li // which is used to show some destructors have been called before leaving the
7*67e74705SXin Li // function.
8*67e74705SXin Li 
9*67e74705SXin Li extern int f(int);
10*67e74705SXin Li extern int g(int);
11*67e74705SXin Li 
12*67e74705SXin Li // CHECK-LABEL: define i32 @test
test(int a,int b)13*67e74705SXin Li int test(int a, int b) {
14*67e74705SXin Li   int res;
15*67e74705SXin Li 
16*67e74705SXin Li   if (a==2) {
17*67e74705SXin Li     int r = f(b);
18*67e74705SXin Li     res = r + b;
19*67e74705SXin Li     a += 2;
20*67e74705SXin Li   } else {
21*67e74705SXin Li     int r = f(a);
22*67e74705SXin Li     res = r + a;
23*67e74705SXin Li     b += 1;
24*67e74705SXin Li   }
25*67e74705SXin Li 
26*67e74705SXin Li   return res;
27*67e74705SXin Li // CHECK: ret i32 %{{.*}}, !dbg [[DI:![0-9]+]]
28*67e74705SXin Li // CHECK: [[DI]] = !DILocation(line: [[@LINE-2]]
29*67e74705SXin Li }
30