[llvm] r267301 - DebugInfo: Change DIBuilder to make distinct DIGlobalVariables

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 23 15:29:09 PDT 2016


Author: dexonsmith
Date: Sat Apr 23 17:29:09 2016
New Revision: 267301

URL: http://llvm.org/viewvc/llvm-project?rev=267301&view=rev
Log:
DebugInfo: Change DIBuilder to make distinct DIGlobalVariables

A long overdue change to make DIGlobalVariable distinct.  Much like
DISubprogram definitions (changed in r246098), it isn't logical to
unique DIGlobalVariable definitions from two different compile units.

(Longer-term, we should also find a way to reverse the link between
GlobalVariable and DIGlobalVariable, and between DIGlobalVariable and
DICompileUnit, so that debug info to do with optimized-out globals
disappears.  Admittedly it's harder than with Function/DISubprogram,
since global variables may be constant-folded and the debug info should
still describe that somehow.)

Modified:
    llvm/trunk/lib/IR/DIBuilder.cpp

Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=267301&r1=267300&r2=267301&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Sat Apr 23 17:29:09 2016
@@ -560,10 +560,10 @@ DIGlobalVariable *DIBuilder::createGloba
     MDNode *Decl) {
   checkGlobalVariableScope(Context);
 
-  auto *N =
-      DIGlobalVariable::get(VMContext, cast_or_null<DIScope>(Context), Name,
-                            LinkageName, F, LineNumber, Ty, isLocalToUnit, true,
-                            Val, cast_or_null<DIDerivedType>(Decl));
+  auto *N = DIGlobalVariable::getDistinct(
+      VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
+      LineNumber, Ty, isLocalToUnit, true, Val,
+      cast_or_null<DIDerivedType>(Decl));
   AllGVs.push_back(N);
   return N;
 }




More information about the llvm-commits mailing list