mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[DebugInfo] Move the findDbg* functions into DebugInfo.cpp
Move the findDbg* functions into lib/IR/DebugInfo.cpp from lib/Transforms/Utils/Local.cpp. D99169 adds a call to a function (findDbgUsers) that lives in lib/Transforms/Utils/Local.cpp (LLVMTransformUtils) from lib/IR/Value.cpp (LLVMCore). The Core lib doesn't include TransformUtils. The builtbots caught this here: https://lab.llvm.org/buildbot/#/builders/109/builds/12664. This patch moves the function, and the 3 similar ones for consistency, into DebugInfo.cpp which is part of LLVMCore. Reviewed By: dblaikie, rnk Differential Revision: https://reviews.llvm.org/D100632
This commit is contained in:
parent
09f6560512
commit
fbe80b0c21
@ -19,15 +19,33 @@
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/TinyPtrVector.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/IR/DebugInfoMetadata.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class DbgDeclareInst;
|
||||
class DbgValueInst;
|
||||
class DbgVariableIntrinsic;
|
||||
class Instruction;
|
||||
class Module;
|
||||
|
||||
/// Finds all intrinsics declaring local variables as living in the memory that
|
||||
/// 'V' points to. This may include a mix of dbg.declare and
|
||||
/// dbg.addr intrinsics.
|
||||
TinyPtrVector<DbgVariableIntrinsic *> FindDbgAddrUses(Value *V);
|
||||
|
||||
/// Like \c FindDbgAddrUses, but only returns dbg.declare intrinsics, not
|
||||
/// dbg.addr.
|
||||
TinyPtrVector<DbgDeclareInst *> FindDbgDeclareUses(Value *V);
|
||||
|
||||
/// Finds the llvm.dbg.value intrinsics describing a value.
|
||||
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V);
|
||||
|
||||
/// Finds the debug info intrinsics describing a value.
|
||||
void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V);
|
||||
|
||||
/// Find subprogram that is enclosing this scope.
|
||||
DISubprogram *getDISubprogram(const MDNode *Scope);
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/TinyPtrVector.h"
|
||||
#include "llvm/Analysis/Utils/Local.h"
|
||||
#include "llvm/IR/Constant.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
@ -264,21 +263,6 @@ bool LowerDbgDeclare(Function &F);
|
||||
void insertDebugValuesForPHIs(BasicBlock *BB,
|
||||
SmallVectorImpl<PHINode *> &InsertedPHIs);
|
||||
|
||||
/// Finds all intrinsics declaring local variables as living in the memory that
|
||||
/// 'V' points to. This may include a mix of dbg.declare and
|
||||
/// dbg.addr intrinsics.
|
||||
TinyPtrVector<DbgVariableIntrinsic *> FindDbgAddrUses(Value *V);
|
||||
|
||||
/// Like \c FindDbgAddrUses, but only returns dbg.declare intrinsics, not
|
||||
/// dbg.addr.
|
||||
TinyPtrVector<DbgDeclareInst *> FindDbgDeclareUses(Value *V);
|
||||
|
||||
/// Finds the llvm.dbg.value intrinsics describing a value.
|
||||
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V);
|
||||
|
||||
/// Finds the debug info intrinsics describing a value.
|
||||
void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V);
|
||||
|
||||
/// Replaces llvm.dbg.declare instruction when the address it
|
||||
/// describes is replaced with a new value. If Deref is true, an
|
||||
/// additional DW_OP_deref is prepended to the expression. If Offset
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "llvm/IR/Constant.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
|
@ -40,6 +40,92 @@
|
||||
using namespace llvm;
|
||||
using namespace llvm::dwarf;
|
||||
|
||||
/// Finds all intrinsics declaring local variables as living in the memory that
|
||||
/// 'V' points to. This may include a mix of dbg.declare and
|
||||
/// dbg.addr intrinsics.
|
||||
TinyPtrVector<DbgVariableIntrinsic *> llvm::FindDbgAddrUses(Value *V) {
|
||||
// This function is hot. Check whether the value has any metadata to avoid a
|
||||
// DenseMap lookup.
|
||||
if (!V->isUsedByMetadata())
|
||||
return {};
|
||||
auto *L = LocalAsMetadata::getIfExists(V);
|
||||
if (!L)
|
||||
return {};
|
||||
auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L);
|
||||
if (!MDV)
|
||||
return {};
|
||||
|
||||
TinyPtrVector<DbgVariableIntrinsic *> Declares;
|
||||
for (User *U : MDV->users()) {
|
||||
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||
if (DII->isAddressOfVariable())
|
||||
Declares.push_back(DII);
|
||||
}
|
||||
|
||||
return Declares;
|
||||
}
|
||||
|
||||
TinyPtrVector<DbgDeclareInst *> llvm::FindDbgDeclareUses(Value *V) {
|
||||
TinyPtrVector<DbgDeclareInst *> DDIs;
|
||||
for (DbgVariableIntrinsic *DVI : FindDbgAddrUses(V))
|
||||
if (auto *DDI = dyn_cast<DbgDeclareInst>(DVI))
|
||||
DDIs.push_back(DDI);
|
||||
return DDIs;
|
||||
}
|
||||
|
||||
void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V) {
|
||||
// This function is hot. Check whether the value has any metadata to avoid a
|
||||
// DenseMap lookup.
|
||||
if (!V->isUsedByMetadata())
|
||||
return;
|
||||
// TODO: If this value appears multiple times in a DIArgList, we should still
|
||||
// only add the owning DbgValueInst once; use this set to track ArgListUsers.
|
||||
// This behaviour can be removed when we can automatically remove duplicates.
|
||||
SmallPtrSet<DbgValueInst *, 4> EncounteredDbgValues;
|
||||
if (auto *L = LocalAsMetadata::getIfExists(V)) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))
|
||||
DbgValues.push_back(DVI);
|
||||
}
|
||||
for (Metadata *AL : L->getAllArgListUsers()) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), AL)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))
|
||||
if (EncounteredDbgValues.insert(DVI).second)
|
||||
DbgValues.push_back(DVI);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,
|
||||
Value *V) {
|
||||
// This function is hot. Check whether the value has any metadata to avoid a
|
||||
// DenseMap lookup.
|
||||
if (!V->isUsedByMetadata())
|
||||
return;
|
||||
// TODO: If this value appears multiple times in a DIArgList, we should still
|
||||
// only add the owning DbgValueInst once; use this set to track ArgListUsers.
|
||||
// This behaviour can be removed when we can automatically remove duplicates.
|
||||
SmallPtrSet<DbgVariableIntrinsic *, 4> EncounteredDbgValues;
|
||||
if (auto *L = LocalAsMetadata::getIfExists(V)) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||
DbgUsers.push_back(DII);
|
||||
}
|
||||
for (Metadata *AL : L->getAllArgListUsers()) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), AL)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||
if (EncounteredDbgValues.insert(DII).second)
|
||||
DbgUsers.push_back(DII);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {
|
||||
if (auto *LocalScope = dyn_cast_or_null<DILocalScope>(Scope))
|
||||
return LocalScope->getSubprogram();
|
||||
|
@ -13,10 +13,9 @@
|
||||
#include "llvm/Transforms/Utils/AutoInitRemark.h"
|
||||
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/IR/DebugInfoMetadata.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::ore;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "llvm/Analysis/ScalarEvolution.h"
|
||||
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
@ -48,7 +49,6 @@
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Transforms/Utils.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
#include "llvm/Transforms/Utils/LoopUtils.h"
|
||||
#include "llvm/Transforms/Utils/SSAUpdater.h"
|
||||
using namespace llvm;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/TinyPtrVector.h"
|
||||
#include "llvm/Analysis/AssumeBundleQueries.h"
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/Analysis/DomTreeUpdater.h"
|
||||
@ -1658,92 +1657,6 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB,
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds all intrinsics declaring local variables as living in the memory that
|
||||
/// 'V' points to. This may include a mix of dbg.declare and
|
||||
/// dbg.addr intrinsics.
|
||||
TinyPtrVector<DbgVariableIntrinsic *> llvm::FindDbgAddrUses(Value *V) {
|
||||
// This function is hot. Check whether the value has any metadata to avoid a
|
||||
// DenseMap lookup.
|
||||
if (!V->isUsedByMetadata())
|
||||
return {};
|
||||
auto *L = LocalAsMetadata::getIfExists(V);
|
||||
if (!L)
|
||||
return {};
|
||||
auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L);
|
||||
if (!MDV)
|
||||
return {};
|
||||
|
||||
TinyPtrVector<DbgVariableIntrinsic *> Declares;
|
||||
for (User *U : MDV->users()) {
|
||||
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||
if (DII->isAddressOfVariable())
|
||||
Declares.push_back(DII);
|
||||
}
|
||||
|
||||
return Declares;
|
||||
}
|
||||
|
||||
TinyPtrVector<DbgDeclareInst *> llvm::FindDbgDeclareUses(Value *V) {
|
||||
TinyPtrVector<DbgDeclareInst *> DDIs;
|
||||
for (DbgVariableIntrinsic *DVI : FindDbgAddrUses(V))
|
||||
if (auto *DDI = dyn_cast<DbgDeclareInst>(DVI))
|
||||
DDIs.push_back(DDI);
|
||||
return DDIs;
|
||||
}
|
||||
|
||||
void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V) {
|
||||
// This function is hot. Check whether the value has any metadata to avoid a
|
||||
// DenseMap lookup.
|
||||
if (!V->isUsedByMetadata())
|
||||
return;
|
||||
// TODO: If this value appears multiple times in a DIArgList, we should still
|
||||
// only add the owning DbgValueInst once; use this set to track ArgListUsers.
|
||||
// This behaviour can be removed when we can automatically remove duplicates.
|
||||
SmallPtrSet<DbgValueInst *, 4> EncounteredDbgValues;
|
||||
if (auto *L = LocalAsMetadata::getIfExists(V)) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))
|
||||
DbgValues.push_back(DVI);
|
||||
}
|
||||
for (Metadata *AL : L->getAllArgListUsers()) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), AL)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))
|
||||
if (EncounteredDbgValues.insert(DVI).second)
|
||||
DbgValues.push_back(DVI);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,
|
||||
Value *V) {
|
||||
// This function is hot. Check whether the value has any metadata to avoid a
|
||||
// DenseMap lookup.
|
||||
if (!V->isUsedByMetadata())
|
||||
return;
|
||||
// TODO: If this value appears multiple times in a DIArgList, we should still
|
||||
// only add the owning DbgValueInst once; use this set to track ArgListUsers.
|
||||
// This behaviour can be removed when we can automatically remove duplicates.
|
||||
SmallPtrSet<DbgVariableIntrinsic *, 4> EncounteredDbgValues;
|
||||
if (auto *L = LocalAsMetadata::getIfExists(V)) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||
DbgUsers.push_back(DII);
|
||||
}
|
||||
for (Metadata *AL : L->getAllArgListUsers()) {
|
||||
if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), AL)) {
|
||||
for (User *U : MDV->users())
|
||||
if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
|
||||
if (EncounteredDbgValues.insert(DII).second)
|
||||
DbgUsers.push_back(DII);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress,
|
||||
DIBuilder &Builder, uint8_t DIExprFlags,
|
||||
int Offset) {
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/IR/CFG.h"
|
||||
#include "llvm/IR/DebugInfoMetadata.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
|
Loading…
Reference in New Issue
Block a user