Hi,
I ran into a problem when running clang on my code. The problem is, 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 step:
1. use clang to compile .c files to bitcode files .bc, using -g flag
2. use opt from llvm to duplicate part of the code
3. use llc, compile the output of opt to assembly file .s
4. use clang to link and generate the final binary, using -g flag
The final step will abort because clang finds several identical labels in the program. I examined the .s file, there is no identical labels in assembly(output of step 3). The duplicated labels are mostly ".Ldebug_fram_endl" etc, inserted by clang. I suspect that it is because the original code was annotated with debug information, 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?
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)? I tried to use llvm-gcc for the first step. The program compiles, but when I tried to debug, clang only allowed me to debug at assembly level (.s files).
I could have used llvm-gcc for everything, not clang, but I like clang for providing precise and accurate debug support. If I use llvm-gcc, I cannot debug the generate program at all.....
Thank you very much for any suggestion that anyone may have.
Thanks,
Yun