From 9564d643d7b5ec2ea4068d7dadae88f285ae928e Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sun, 17 Nov 2013 18:48:57 +0000 Subject: [PATCH] Debug Info Verifier: fix when to find debug info nodes and when to verify them. We used to collect debug info MDNodes in doInitialization and verify them in doFinalization. That is incorrect since MDNodes can be modified by passes run between doInitialization and doFinalization. To fix the problem, we handle debug info MDNodes that can be reached from a function in runOnFunction (i.e we collect those nodes by calling processDeclare, processValue and processLocation, and then verify them in runOnFunction). We handle debug info MDNodes that can be reached from named metadata in doFinalization. This is in line with how Verifier handles module-level data (they are verified in doFinalization). rdar://15472296 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194974 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Verifier.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 32acfbd9ccc..3331a37defd 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -167,11 +167,8 @@ namespace { bool doInitialization(Module &M) { Mod = &M; Context = &M.getContext(); - Finder.reset(); DL = getAnalysisIfAvailable(); - if (!DisableDebugInfoVerifier) - Finder.processModule(M); // We must abort before returning back to the pass manager, or else the // pass manager may try to run other passes on the broken module. @@ -185,10 +182,15 @@ namespace { Mod = F.getParent(); if (!Context) Context = &F.getContext(); + Finder.reset(); visit(F); InstsInThisBlock.clear(); PersonalityFn = 0; + if (!DisableDebugInfoVerifier) + // Verify Debug Info. + verifyDebugInfo(); + // We must abort before returning back to the pass manager, or else the // pass manager may try to run other passes on the broken module. return abortIfBroken(); @@ -218,8 +220,12 @@ namespace { visitModuleFlags(M); visitModuleIdents(M); - // Verify Debug Info. - verifyDebugInfo(); + if (!DisableDebugInfoVerifier) { + Finder.reset(); + Finder.processModule(M); + // Verify Debug Info. + verifyDebugInfo(); + } // If the module is broken, abort at this time. return abortIfBroken(); -- 2.34.1