[LLVMdev] !dbg metadata not generated for if.else->if.end branch

Bendersky, Eli eli.bendersky at intel.com
Mon Jul 16 05:48:42 PDT 2012


Hello,

For this C code:

int func(int foo, char bar) {
    int result = foo + bar;

    if (foo > bar)
        result += 100 - foo;
    else
        result += 221 - bar;

    return result;
}

Compiled with -O0 -g, the following IR represents the relevant parts of the if/else statement:

  %0 = load i32* %foo.addr, align 4, !dbg !49
  %1 = load i8* %bar.addr, align 1, !dbg !49
  %conv = sext i8 %1 to i32, !dbg !49
  %add = add nsw i32 %0, %conv, !dbg !49
  store i32 %add, i32* %result, align 4, !dbg !49
  %2 = load i32* %foo.addr, align 4, !dbg !50
  %3 = load i8* %bar.addr, align 1, !dbg !50
  %conv1 = sext i8 %3 to i32, !dbg !50
  %cmp = icmp sgt i32 %2, %conv1, !dbg !50
  br i1 %cmp, label %if.then, label %if.else, !dbg !50

if.then:                                          ; preds = %entry
  %4 = load i32* %foo.addr, align 4, !dbg !51
  %sub = sub nsw i32 100, %4, !dbg !51
  %5 = load i32* %result, align 4, !dbg !51
  %add3 = add nsw i32 %5, %sub, !dbg !51
  store i32 %add3, i32* %result, align 4, !dbg !51
  br label %if.end, !dbg !51

if.else:                                          ; preds = %entry
  %6 = load i8* %bar.addr, align 1, !dbg !52
  %conv4 = sext i8 %6 to i32, !dbg !52
  %sub5 = sub nsw i32 221, %conv4, !dbg !52
  %7 = load i32* %result, align 4, !dbg !52
  %add6 = add nsw i32 %7, %sub5, !dbg !52
  store i32 %add6, i32* %result, align 4, !dbg !52
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  %8 = load i32* %result, align 4, !dbg !53

----

Note that for the branch from if.else to if.end (br label %if.end), no !dbg metadata is generated.
Is there a good reason for this, or should I open a bug? [I guess this would be for Clang then?]

Eli




---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120716/2bd64a70/attachment.html>


More information about the llvm-dev mailing list