[llvm] r311081 - [Verifier] Avoid visiting DIGlobalVariables twice.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 17 04:32:21 PDT 2017


Author: davide
Date: Thu Aug 17 04:32:21 2017
New Revision: 311081

URL: http://llvm.org/viewvc/llvm-project?rev=311081&view=rev
Log:
[Verifier] Avoid visiting DIGlobalVariables twice.

We currently visit them twice.
Once, through `visitMDNode()` -> (the code generated by)
  `../include/llvm/IR/Metadata.def:109` -> `visitDIGlobalVariable()`
Then, through `visitMDNode()` -> `visitDIGlobalVariableExpression()`
  -> `visitDIGlobalVariable()`

This results in verification failures printed twice, e.g.:

  $ ./opt -verify ../../test/DebugInfo/pr34186.ll
  missing global variable type
  !4 = distinct !DIGlobalVariable(name: "pat", scope: !0,
    file: !1, line: 27, isLocal: true, isDefinition: true)
  missing global variable type
  !4 = distinct !DIGlobalVariable(name: "pat", scope: !0,
    file: !1, line: 27, isLocal: true, isDefinition: true)
  ./opt: ../../test/DebugInfo/pr34186.ll: error: input module is broken!

The patch removes one call so we ensure each GV is visited exactly once.

Differential Revision:  https://reviews.llvm.org/D36797

Modified:
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/test/DebugInfo/pr34186.ll

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=311081&r1=311080&r2=311081&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Thu Aug 17 04:32:21 2017
@@ -1173,8 +1173,6 @@ void Verifier::visitDIExpression(const D
 void Verifier::visitDIGlobalVariableExpression(
     const DIGlobalVariableExpression &GVE) {
   AssertDI(GVE.getVariable(), "missing variable");
-  if (auto *Var = GVE.getVariable())
-    visitDIGlobalVariable(*Var);
   if (auto *Expr = GVE.getExpression())
     visitDIExpression(*Expr);
 }

Modified: llvm/trunk/test/DebugInfo/pr34186.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/pr34186.ll?rev=311081&r1=311080&r2=311081&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/pr34186.ll (original)
+++ llvm/trunk/test/DebugInfo/pr34186.ll Thu Aug 17 04:32:21 2017
@@ -1,5 +1,7 @@
+; Make sure we reject GVs without a type and we verify each exactly once.
 ; RUN: not llc %s 2>&1 | FileCheck %s
 ; CHECK: missing global variable type
+; CHECK-NOT: missing global variable type
 
 !llvm.dbg.cu = !{!2}
 !llvm.module.flags = !{!63, !64}




More information about the llvm-commits mailing list