Hui Zhang via llvm-dev
2015-Nov-03 16:26 UTC
[llvm-dev] how to add the location debug info for each instruction
Hello, For some reason, I have to stick on llvm 3.3 for a language compiler, I find that the location debug info is attached to each instruction using !dbg, however, I found some of that information is mis-attched and need to be changed, so I want to *know what functions(I checked all funcs in DIBuilder.h but didn't find a appropriate one) are used to attach those !dbg nodes to each instruction ?* It would be even better if you can points to the places that clang uses to create those nodes. Thanks ! -- Best regards Hui Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151103/caa08fb4/attachment.html>
Adrian Prantl via llvm-dev
2015-Nov-03 17:21 UTC
[llvm-dev] how to add the location debug info for each instruction
> On Nov 3, 2015, at 8:26 AM, Hui Zhang via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello, > > For some reason, I have to stick on llvm 3.3 for a language compiler, I find that the location debug info is attached to each instruction using !dbg, however, I found some of that information is mis-attched and need to be changed, so I want to know what functions(I checked all funcs in DIBuilder.h but didn't find a appropriate one) are used to attach those !dbg nodes to each instruction ? It would be even better if you can points to the places that clang uses to create those nodes. >Have a look at IRBuilder instead: void SetCurrentDebugLocation <http://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html#a63fc74646456a3bed261512f21efe29c> (DebugLoc <http://llvm.org/doxygen/classllvm_1_1DebugLoc.html> L) Set location information used by debugging information. <http://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html#a63fc74646456a3bed261512f21efe29c> const <http://llvm.org/doxygen/AArch64PromoteConstant_8cpp.html#a90f8350fecae261c25be85d38b451bff> DebugLoc <http://llvm.org/doxygen/classllvm_1_1DebugLoc.html> & getCurrentDebugLocation <http://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html#a2514366416ab188b68243c19a765603e> () const <http://llvm.org/doxygen/AArch64PromoteConstant_8cpp.html#a90f8350fecae261c25be85d38b451bff> Get location information used by debugging information. -- adrian PS: Isn’t it nice how we consistently name accessor functions? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151103/a9113c70/attachment.html>
Hui Zhang via llvm-dev
2015-Nov-04 01:00 UTC
[llvm-dev] how to add the location debug info for each instruction
Hello, I found a weird thing in llvm 3.3: For exactly the same MDNode *space, if I cast it to DILocation loc(space) and call loc.getFileName(), or I cast it to DIScope sco(space) and call sco.getFilename(), the return value would be different ! Totally two different files I don't know if it's a bug or why it is happening like this, and what's the conceptual difference between these two classes: DIScope and DILocation ? Thanks ! On Tue, Nov 3, 2015 at 12:43 PM, Hui Zhang <wayne.huizhang at gmail.com> wrote:> Thank you ! > > Yes, it's very nice > > On Tue, Nov 3, 2015 at 12:21 PM, Adrian Prantl <aprantl at apple.com> wrote: > >> >> On Nov 3, 2015, at 8:26 AM, Hui Zhang via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >> Hello, >> >> For some reason, I have to stick on llvm 3.3 for a language compiler, I >> find that the location debug info is attached to each instruction using >> !dbg, however, I found some of that information is mis-attched and need to >> be changed, so I want to *know what functions(I checked all funcs in >> DIBuilder.h but didn't find a appropriate one) are used to attach those >> !dbg nodes to each instruction ?* It would be even better if you can >> points to the places that clang uses to create those nodes. >> >> >> Have a look at IRBuilder instead: >> >> void SetCurrentDebugLocation >> <http://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html#a63fc74646456a3bed261512f21efe29c> >> (DebugLoc <http://llvm.org/doxygen/classllvm_1_1DebugLoc.html> L) Set >> location information used by debugging information. >> <http://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html#a63fc74646456a3bed261512f21efe29c> >> const >> <http://llvm.org/doxygen/AArch64PromoteConstant_8cpp.html#a90f8350fecae261c25be85d38b451bff> >> DebugLoc <http://llvm.org/doxygen/classllvm_1_1DebugLoc.html> & >> getCurrentDebugLocation >> <http://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html#a2514366416ab188b68243c19a765603e> >> () const >> <http://llvm.org/doxygen/AArch64PromoteConstant_8cpp.html#a90f8350fecae261c25be85d38b451bff> >> Get location information used by debugging information. >> >> -- adrian >> >> PS: Isn’t it nice how we consistently name accessor functions? >> >> > > > -- > Best regards > > > Hui Zhang >-- Best regards Hui Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151103/62a55893/attachment.html>
Adrian Prantl via llvm-dev
2015-Nov-04 16:01 UTC
[llvm-dev] how to add the location debug info for each instruction
> On Nov 3, 2015, at 5:00 PM, Hui Zhang <wayne.huizhang at gmail.com> wrote: > > Hello, > > I found a weird thing in llvm 3.3: > > For exactly the same MDNode *space, if I cast it to DILocation loc(space) and call loc.getFileName(), or I cast it to DIScope sco(space) and call sco.getFilename(), the return value would be different ! Totally two different files > > I don't know if it's a bug or why it is happening like this, and what's the conceptual difference between these two classes: DIScope and DILocation ? >In the old llvm 3.3 representation, the DI* classes are just wrappers around generic MDNodes. You can look at the implementation of the various DI* classes (or even better at the source level debugging with LLVM document in the tree) to learn about their layout and how they relate to each other. -- adrian> Thanks ! > > On Tue, Nov 3, 2015 at 12:43 PM, Hui Zhang <wayne.huizhang at gmail.com> wrote: > Thank you ! > > Yes, it's very nice > > On Tue, Nov 3, 2015 at 12:21 PM, Adrian Prantl <aprantl at apple.com> wrote: > >> On Nov 3, 2015, at 8:26 AM, Hui Zhang via llvm-dev <llvm-dev at lists.llvm.org> wrote: >> >> Hello, >> >> For some reason, I have to stick on llvm 3.3 for a language compiler, I find that the location debug info is attached to each instruction using !dbg, however, I found some of that information is mis-attched and need to be changed, so I want to know what functions(I checked all funcs in DIBuilder.h but didn't find a appropriate one) are used to attach those !dbg nodes to each instruction ? It would be even better if you can points to the places that clang uses to create those nodes. >> > > Have a look at IRBuilder instead: > > void SetCurrentDebugLocation (DebugLoc L) > Set location information used by debugging information. > const DebugLoc & getCurrentDebugLocation () const > Get location information used by debugging information. > > -- adrian > > PS: Isn’t it nice how we consistently name accessor functions? > > > > > -- > Best regards > > > Hui Zhang > > > > -- > Best regards > > > Hui Zhang