From 3cc2ae8384c4b27905c10f96829b83fbc887d3c5 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Thu, 15 Feb 2018 21:28:38 +0000 Subject: [PATCH] [Debugify] Don't check functions which were skipped If no debug info was applied to a function, its debug info shouldn't be checked (it doesn't have any :). llvm-svn: 325297 --- test/DebugInfo/debugify.ll | 4 ++++ tools/opt/Debugify.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/DebugInfo/debugify.ll b/test/DebugInfo/debugify.ll index d506a20d200..9747c88def8 100644 --- a/test/DebugInfo/debugify.ll +++ b/test/DebugInfo/debugify.ll @@ -19,6 +19,8 @@ ; RUN: opt -enable-debugify -strip -S -o - < %s | \ ; RUN: FileCheck %s -check-prefix=CHECK-FAIL +; RUN: opt -enable-debugify -S -o - < %s | FileCheck %s -check-prefix=PASS + ; CHECK-LABEL: define void @foo define void @foo() { ; CHECK: ret void, !dbg ![[RET1:.*]] @@ -79,3 +81,5 @@ define weak_odr zeroext i1 @baz() { ; CHECK-FAIL: WARNING: Missing line 4 ; CHECK-FAIL: ERROR: Missing variable 1 ; CHECK-FAIL: CheckDebugify: FAIL + +; PASS: CheckDebugify: PASS diff --git a/tools/opt/Debugify.cpp b/tools/opt/Debugify.cpp index 50b142b3240..441fec36765 100644 --- a/tools/opt/Debugify.cpp +++ b/tools/opt/Debugify.cpp @@ -35,6 +35,10 @@ using namespace llvm; namespace { +bool isFunctionSkipped(Function &F) { + return F.isDeclaration() || !F.hasExactDefinition(); +} + bool applyDebugifyMetadata(Module &M) { // Skip modules with debug info. if (M.getNamedMetadata("llvm.dbg.cu")) { @@ -67,7 +71,7 @@ bool applyDebugifyMetadata(Module &M) { // Visit each instruction. for (Function &F : M) { - if (F.isDeclaration() || !F.hasExactDefinition()) + if (isFunctionSkipped(F)) continue; auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None)); @@ -134,6 +138,9 @@ void checkDebugifyMetadata(Module &M) { // Find missing lines. BitVector MissingLines{OriginalNumLines, true}; for (Function &F : M) { + if (isFunctionSkipped(F)) + continue; + for (Instruction &I : instructions(F)) { if (isa(&I)) continue; @@ -156,6 +163,9 @@ void checkDebugifyMetadata(Module &M) { // Find missing variables. BitVector MissingVars{OriginalNumVars, true}; for (Function &F : M) { + if (isFunctionSkipped(F)) + continue; + for (Instruction &I : instructions(F)) { auto *DVI = dyn_cast(&I); if (!DVI)