[llvm-commits] [PATCH] Fix emission of debug data for global variables

Devang Patel dpatel at apple.com
Mon Sep 26 10:19:00 PDT 2011


James,

Your patch looks good. Please apply (remove target datalayout and target triple from the test case because it is unnecessary).
Thanks!
-
Devang
On Sep 26, 2011, at 9:03 AM, James Molloy wrote:

> Hi,
> 
> With the new debug information changes, global variables aren't emitted properly to DWARF. The DW_AT_decl_file field is incorrect.
> 
> This stems from DwarfCompileUnit.cpp:138:
> 
>  unsigned FileID = DD->GetOrCreateSourceID(G.getContext().getFilename(),
>                                            G.getContext().getDirectory());
> 
> G.getContext() returns a NULL metadatum for the new metadata format (it used to return the CompileUnit). This causes a new SourceID to be generated for the "null" file, and the global is assigned this incorrect SourceID.
> 
> Attached is a testcase and proposed patch. It inlines getFilename() and getDirectory() into DIGlobalVariable, returning the original getContext().getFilename() for old versions of the debug info and getFieldAs<DIFile>(6).getFilename() for new versions.
> 
> I've implemented it this way so that the old code path is identical to before. I'm not sure if this is the most perfect fix - as getFieldAs<DIFile>(6) is valid (seemingly) for all debug info versions, perhaps the best idea would be to remove the conditionalization and always return getFieldAs<DIFile>(6).getFilename/getDirectory() ?
> 
> 
> Cheers,
> 
> James
> 
> 
> -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.<2011-09-26-GlobalVarContext.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list