[llvm-dev] Reg. llvm.dbg.declare

Akash Banerjee via llvm-dev llvm-dev at lists.llvm.org
Sat Mar 30 06:51:56 PDT 2019


Hi all,

I'm trying to generate IR with debug option (-g) for the following code
snippet.

int func(int i) {
        return i+1;
}

The corresponding IR for the function definition is:

define i32 @func(i32 %i) #0 !dbg !7 {
entry:
  %i.addr = alloca i32, align 4
  store i32 %i, i32* %i.addr, align 4
  call void @llvm.dbg.declare(metadata i32* %i.addr, metadata !11, metadata
!12), !dbg !13
  %0 = load i32, i32* %i.addr, align 4, !dbg !14
  %add = add nsw i32 %0, 1, !dbg !15
  ret i32 %add, !dbg !16
}

I'm confused about why the "*call void @llvm.dbg.declare(metadata i32*
%i.addr, metadata !11, metadata !12), !dbg !13*" appears after an usage of
*%i.addr* (*store i32 %i, i32* %i.addr, align 4*)*. *Should the use of*
%i.addr* happen after llvm.dbg.declare or does it have any specific reason
for this? Am I missing something here?

Thank you very much,
Akash Banerjee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190330/18853168/attachment.html>


More information about the llvm-dev mailing list