From 50d9bb6b39c56f394eba63f4b8473a7e5a021e85 Mon Sep 17 00:00:00 2001 From: OCHyams Date: Thu, 20 Oct 2022 15:26:40 +0100 Subject: [PATCH] [NFC] Add DebugVariable constructor that takes DbgVariableIntrinsic pointer Note: The constructor definition cannot be inline without some refactoring as it introduces a circular dependency between the headers llvm/IR/DebugInfoMetadata.h (this file) and llvm/IR/IntrinsicInst.h (where DbgVariableIntrinsic is defined). Reviewed By: jryans Differential Revision: https://reviews.llvm.org/D133286 --- llvm/include/llvm/IR/DebugInfoMetadata.h | 4 ++++ llvm/lib/IR/DebugInfoMetadata.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index db1d031..8fc3f54 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -64,6 +64,8 @@ namespace dwarf { enum Tag : uint16_t; } +class DbgVariableIntrinsic; + extern cl::opt EnableFSDiscriminator; class DITypeRefArray { @@ -3629,6 +3631,8 @@ class DebugVariable { static const FragmentInfo DefaultFragment; public: + DebugVariable(const DbgVariableIntrinsic *DII); + DebugVariable(const DILocalVariable *Var, Optional FragmentInfo, const DILocation *InlinedAt) : Variable(Var), Fragment(FragmentInfo), InlinedAt(InlinedAt) {} diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index e8d8eaf..b29daeb 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -17,6 +17,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/IR/Function.h" +#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" @@ -34,6 +35,11 @@ cl::opt EnableFSDiscriminator( const DIExpression::FragmentInfo DebugVariable::DefaultFragment = { std::numeric_limits::max(), std::numeric_limits::min()}; +DebugVariable::DebugVariable(const DbgVariableIntrinsic *DII) + : Variable(DII->getVariable()), + Fragment(DII->getExpression()->getFragmentInfo()), + InlinedAt(DII->getDebugLoc().getInlinedAt()) {} + DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line, unsigned Column, ArrayRef MDs, bool ImplicitCode) -- 2.7.4