[LLVMdev] Question about program debugging after code duplication

Devang Patel devang.patel at gmail.com
Wed Nov 18 16:35:51 PST 2009


On Wed, Nov 18, 2009 at 8:52 AM, Yun Zhang <yunzhang at princeton.edu> wrote:
> Hi,
>
> I am not sure where I should submit the question to. But I think it is llvm related.
>
> I ran into a problem when debugging my code. Here is the problem:
> my optimization (a pass in LLVM) takes bitcode file as input, duplicate part of the original code, put the duplicated code in a separate function, then run both of them. I took the steps:
> 1. use llvm-gcc to compile .c files to bitcode files .bc, using -g flag
> 2. use opt from llvm to duplicate part of the code

How do you duplicate part of the code here ?

> 3. use llc, compile the output of opt to assembly file .s
> 4. use llvm-gcc to link and generate the final binary, using -g flag
>
> When I tried to debug the generated binary using gdb, the debug information it contains is not sufficient enough to pinpoint where the problem is, so I switched to clang. I replaced all uses of llvm-gcc to clang. Then The final step aborts because clang finds several identical labels in the program.

Would it be possible for you to provide the bitcode file that reports
identical labels ?
-
Devang

> I examined the .s file, there is no identical labels in assembly(output of step 3). The duplicated labels, which caused errors, are like ".Ldebug_frame_endl" etc, inserted by clang. I suspect that it is because the original code was annotated with debug information, and after the code was duplicated, debug information is copied over as well, at the final step, the same label is generated for both. Is that right?
>
> My *question* is: if that is a correct speculation, how do I solve this problem? Should I
> (and, can I) access and modify the debug information at the second step
> (opt of llvm)?
>
> I tried to use llvm-gcc for Step 1, and clang for Step 4. I am able to debug this way, but only at assembly level (.s files), which is not as convenient as debugging at bitcode level.
>
>
> Thank you very much for any suggestion.
>
> Thanks,
> Yun
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 
-
Devang




More information about the llvm-dev mailing list