[cfe-dev] Debug information for unconditional branches

Eric Christopher echristo at gmail.com
Tue Mar 26 13:19:02 PDT 2013


I'm not necessarily against reverting r128471 and the restricting patch on
it, or identifying cases when we might like to more accurately model line
info in debug metadata.

I'm curious what you're trying to do with using line number information to
identify loop latches. Can you provide a bit of background on what you're
trying to do? It might make it easier to identify things that will help.

Thanks!

-eric


On Mon, Mar 25, 2013 at 4:15 AM, Tim Besard <tim.besard at elis.ugent.be>wrote:

> Hi all,
>
> Since revisions 128471 and 128513 (March 2011) Clang does not emit debug
> information for unconditional branches anymore, for example when
> branching from the end of an else{} to the continuation block
> (CodeGen/CGStmt.cpp line 459 in r177848). Why exactly is this?
>
> I'm running into this because I'm identifying loop latches based on
> their lexical scope. Normally, loop latches always have debug metadata
> attached to them. However, in some cases -simplifycfg can merge the loop
> latch with a branch which has no debug metadata attached to it (due to
> aforementioned reason) causing the final latch not to have debug
> metadata either.
>
> Specifically, I have this testcase:
>   while (while_test()) {
>     if (if_test()) {
>       foo();
>     } else {
>       bar();
>     }
>   }
>
> Clang emits the following bytecode for this:
>   while.cond:
>     %call = call zeroext i1 (...)* @while_test(), !dbg !9
>     br i1 %call, label %while.body, label %while.end, !dbg !9
>   while.body:
>     %call1 = call zeroext i1 (...)* @if_test(), !dbg !10
>     br i1 %call1, label %if.then, label %if.else, !dbg !10
>   if.then:
>     call void (...)* @foo(), !dbg !12
>     br label %if.end, !dbg !14
>   if.else:
>     call void (...)* @bar(), !dbg !15
>     br label %if.end
>   if.end:
>     br label %while.cond, !dbg !17
>   while.end:
>     ret i32 0, !dbg !18
> Note that the unconditional branch at the end of if.else does not have
> debug metadata attached to it.
>
> When running -simplifycfg, LLVM merges if.else and if.end as follows:
>   if.else:
>     call void (...)* @bar(), !dbg !15
>     br label %while.cond
>
> The end result of all this is that the loop latch does not have any
> metadata attached to it, not only breaking my loop identification, but
> presumable also making it impossible to stop at the end of the while
> body (something which was possible before running -simplifycfg).
>
> How should this be fixed? Should -simplifycfg have support for
> 'properly' merging these statements, or should Clang emit debug
> statements despite the branch being unconditional?
>
> Sincerely,
> --
> Tim Besard
> Computer Systems Lab
> Department of Electronics & Information Systems
> Ghent University
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130326/23e07f6e/attachment.html>


More information about the cfe-dev mailing list