[PATCH] Debug info: Support fragmented variables.

Adrian Prantl aprantl at apple.com
Thu Dec 18 13:52:35 PST 2014


================
Comment at: lib/Transforms/Scalar/SROA.cpp:3725-3726
@@ +3724,4 @@
+    else if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I))
+      if (isa<AllocaInst>(DDI->getAddress()))
+        DbgDeclares.insert(std::make_pair(cast<AllocaInst>(DDI->getAddress()),
+                                          DDI));
----------------
aprantl wrote:
> chandlerc wrote:
> > This should be a dyn_cast to AllocaInst and a re-use.
> > 
> > Also, getAddress can return null which seems like it would crash here. Unless the verifier rejects such an debug declare inst (and if it does, it would be nice to have an "unsafe" version of the method that returns null for the verifier and have this method assert for us that the result is non-null) this should handle the null case gracefully.
> > 
> > 
> > Somewhat separately (and apologies if this just is my ignorance of debug info) what cases would you expect where the address isn't directly an alloca inst?
> See the first testcase:
>   define i32 @foo(%struct.Outer* byval align 8 %outer) #0 {
>     call void @llvm.dbg.declare(metadata %struct.Outer* %outer, metadata !25, metadata !2), !dbg !26
> 
> it could be an argument.
No the verifier does not reject it, although an UndefValue would be preferred over of a nullptr. I'll change it to a dyn_cast_or_null.

http://reviews.llvm.org/D2680

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list