From 3dbfeaffe7a9c26b463c577feb650e0f32da36cc Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Wed, 27 Jun 2018 00:47:52 +0000 Subject: [PATCH] [Debugify] Handle failure to get fragment size when checking dbg.values It's not possible to get the fragment size of some dbg.values. Teach the mis-sized dbg.value diagnostic to detect this scenario and bail out. Tested with: $ find test/Transforms -print -exec opt -debugify-each -instcombine {} \; git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335695 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/SCCP/ipsccp-basic.ll | 1 + tools/opt/Debugify.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/Transforms/SCCP/ipsccp-basic.ll b/test/Transforms/SCCP/ipsccp-basic.ll index 4db5c4478d3..b7db8689115 100644 --- a/test/Transforms/SCCP/ipsccp-basic.ll +++ b/test/Transforms/SCCP/ipsccp-basic.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -ipsccp -S | FileCheck %s +; RUN: opt < %s -enable-debugify -ipsccp -debugify-quiet -disable-output ;;======================== test1 diff --git a/tools/opt/Debugify.cpp b/tools/opt/Debugify.cpp index 54ff00849b0..e8437016d94 100644 --- a/tools/opt/Debugify.cpp +++ b/tools/opt/Debugify.cpp @@ -184,12 +184,15 @@ bool diagnoseMisSizedDbgValue(Module &M, DbgValueInst *DVI) { Type *Ty = V->getType(); uint64_t ValueOperandSize = getAllocSizeInBits(M, Ty); - uint64_t DbgVarSize = *DVI->getFragmentSizeInBits(); - bool HasBadSize = Ty->isIntegerTy() ? (ValueOperandSize < DbgVarSize) - : (ValueOperandSize != DbgVarSize); + Optional DbgVarSize = DVI->getFragmentSizeInBits(); + if (!ValueOperandSize || !DbgVarSize) + return false; + + bool HasBadSize = Ty->isIntegerTy() ? (ValueOperandSize < *DbgVarSize) + : (ValueOperandSize != *DbgVarSize); if (HasBadSize) { dbg() << "ERROR: dbg.value operand has size " << ValueOperandSize - << ", but its variable has size " << DbgVarSize << ": "; + << ", but its variable has size " << *DbgVarSize << ": "; DVI->print(dbg()); dbg() << "\n"; }