; RUN: llc -fast-isel-sink-local-values -O0 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s ; RUN: llc -fast-isel-sink-local-values -O0 -mtriple=x86_64-unknown-linux-gnu -filetype=obj < %s \ ; RUN: | llvm-dwarfdump -debug-info - | FileCheck %s --check-prefix=DWARF ; Verify that we have correct debug info for local variables in code ; instrumented with AddressSanitizer. ; Generated from the source file test.cc: ; int bar(int y) { ; return y + 2; ; } ; with "clang++ -S -emit-llvm -mllvm -asan-skip-promotable-allocas=0 -fsanitize=address -O0 -g test.cc" ; The address of the (potentially now malloc'ed) alloca ends up ; in rdi, after which it is spilled to the stack. We record the ; spill OFFSET on the stack for checking the debug info below. ; CHECK: #DEBUG_VALUE: bar:y <- [DW_OP_deref] [$rcx+0] ; CHECK: movq %rcx, [[OFFSET:[0-9]+]](%rsp) ; CHECK-NEXT: [[START_LABEL:.Ltmp[0-9]+]] ; CHECK-NEXT: #DEBUG_VALUE: bar:y <- [DW_OP_plus_uconst [[OFFSET]], DW_OP_deref, DW_OP_deref] ; This location should be valid until the end of the function. ; CHECK: movq %rbp, %rsp ; CHECK-NEXT: [[END_LABEL:.Ltmp[0-9]+]]: ; CHECK: .Ldebug_loc{{[0-9]+}}: ; We expect two location ranges for the variable. ; First, its address is stored in %rcx: ; CHECK: .quad .Lfunc_begin0-.Lfunc_begin0 ; CHECK-NEXT: .quad [[START_LABEL]]-.Lfunc_begin0 ; CHECK: DW_OP_breg2 ; DWARF: DW_TAG_formal_parameter ; DWARF: DW_AT_location ; DWARF-NEXT: [{{.*}}, {{.*}}): DW_OP_breg2 RCX+0, DW_OP_deref ; Then it's addressed via %rsp: ; CHECK: .quad [[START_LABEL]]-.Lfunc_begin0 ; CHECK-NEXT: .quad [[END_LABEL]]-.Lfunc_begin0 ; CHECK: DW_OP_breg7 ; CHECK-NEXT: [[OFFSET]] ; CHECK: DW_OP_deref ; DWARF-NEXT: [{{.*}}, {{.*}}): DW_OP_breg7 RSP+{{[0-9]+}}, DW_OP_deref, DW_OP_deref) ; ModuleID = 'test.cc' target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 1, void ()* @asan.module_ctor }] @__asan_option_detect_stack_use_after_return = external global i32 @___asan_gen_ = private unnamed_addr constant [16 x i8] c"1 32 4 6 y.addr\00", align 1 ; Function Attrs: nounwind sanitize_address uwtable define i32 @_Z3bari(i32 %y) #0 !dbg !4 { entry: %MyAlloca = alloca [64 x i8], align 32 %0 = ptrtoint [64 x i8]* %MyAlloca to i64 %1 = load i32, i32* @__asan_option_detect_stack_use_after_return %2 = icmp ne i32 %1, 0 br i1 %2, label %3, label %5 ;