[PATCH] D40512: [Debugify] Add a pass to test debug info preservation

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 15:58:51 PST 2017


probinson added inline comments.


================
Comment at: lib/Transforms/Utils/Debugify.cpp:60-62
+    auto CU = DIB.createCompileUnit(dwarf::DW_LANG_C_plus_plus_11,
+                                    DIB.createFile(M.getName(), "/"),
+                                    "debugify", /*isOptimized=*/true, "", 0);
----------------
vsk wrote:
> davide wrote:
> > vsk wrote:
> > > davide wrote:
> > > > ehm, are you sure this is right?
> > > > This will break for code emitted by another frontend.
> > > I really want to say "pick any language" here. This pass ignores IR which already has debug info, so I'm not sure what breaks -- could you clarify?
> > The scenario I have in mind is the one where you have rust emitting an IR module  without debug info and then running this pass on it (where you get a C++11 compile unit).
> > I guess there's no real to understand which frontend is emitting the IR unless the frontend emits enough metadata for the mid-level optimizer to find out which language is this IR derived from.
> > 
> > Another example is, what if you have code compiled with `-std=c++98/-std=c++03`, without debuginfo on which you call this pass?
> > I think in that case is setting  `C_plus_plus_11` always correct? I'm not sure myself, so please correct me if I'm wrong.
> I don't think there's any correct language value we could use here due to the issue you point out. In practice, it shouldn't matter unless you actually try to load a debugified module in a debugger, which is a non-goal. I can keep things simple here by just using DW_LANG_C.
The pass is not adding true source information, e.g. types, so the language is irrelevant.  The goal is to see whether info attached to the IR is preserved, not to emit anything useful.  No debugger will ever see this output, and probably not even llvm-dwarfdump.
You could do something more obviously bogus, like DW_LANG_Ada83.  We don't have a language code for IR.


================
Comment at: test/Transforms/LoopStrengthReduce/debug-info.ll:1
+; XFAIL: *
+; RUN: opt < %s -debugify -loop-reduce -gvn -check-debugify -S 2>&1 | FileCheck %s
----------------
This doesn't seem very useful.


https://reviews.llvm.org/D40512





More information about the llvm-commits mailing list