mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
Refactor into a separate utility function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127832 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -21,12 +21,15 @@ class User;
|
|||||||
class BasicBlock;
|
class BasicBlock;
|
||||||
class BranchInst;
|
class BranchInst;
|
||||||
class Instruction;
|
class Instruction;
|
||||||
|
class DbgDeclareInst;
|
||||||
|
class StoreInst;
|
||||||
class Value;
|
class Value;
|
||||||
class Pass;
|
class Pass;
|
||||||
class PHINode;
|
class PHINode;
|
||||||
class AllocaInst;
|
class AllocaInst;
|
||||||
class ConstantExpr;
|
class ConstantExpr;
|
||||||
class TargetData;
|
class TargetData;
|
||||||
|
class DIBuilder;
|
||||||
|
|
||||||
template<typename T> class SmallVectorImpl;
|
template<typename T> class SmallVectorImpl;
|
||||||
|
|
||||||
@@ -157,6 +160,15 @@ static inline unsigned getKnownAlignment(Value *V, const TargetData *TD = 0) {
|
|||||||
return getOrEnforceKnownAlignment(V, 0, TD);
|
return getOrEnforceKnownAlignment(V, 0, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///===---------------------------------------------------------------------===//
|
||||||
|
/// Dbg Intrinsic utilities
|
||||||
|
///
|
||||||
|
|
||||||
|
/// Inserts a llvm.dbg.value instrinsic before the stores to an alloca'd value
|
||||||
|
/// that has an associated llvm.dbg.decl intrinsic.
|
||||||
|
bool ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
|
||||||
|
StoreInst *SI, DIBuilder &Builder);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
#include "llvm/IntrinsicInst.h"
|
#include "llvm/IntrinsicInst.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
|
#include "llvm/Analysis/DebugInfo.h"
|
||||||
|
#include "llvm/Analysis/DIBuilder.h"
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
#include "llvm/Analysis/ConstantFolding.h"
|
#include "llvm/Analysis/ConstantFolding.h"
|
||||||
#include "llvm/Analysis/InstructionSimplify.h"
|
#include "llvm/Analysis/InstructionSimplify.h"
|
||||||
@@ -755,3 +757,29 @@ unsigned llvm::getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
|
|||||||
return Align;
|
return Align;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///===---------------------------------------------------------------------===//
|
||||||
|
/// Dbg Intrinsic utilities
|
||||||
|
///
|
||||||
|
|
||||||
|
/// Inserts a llvm.dbg.value instrinsic before the stores to an alloca'd value
|
||||||
|
/// that has an associated llvm.dbg.decl intrinsic.
|
||||||
|
bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
|
||||||
|
StoreInst *SI, DIBuilder &Builder) {
|
||||||
|
DIVariable DIVar(DDI->getVariable());
|
||||||
|
if (!DIVar.Verify())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Instruction *DbgVal =
|
||||||
|
Builder.insertDbgValueIntrinsic(SI->getOperand(0), 0,
|
||||||
|
DIVar, SI);
|
||||||
|
|
||||||
|
// Propagate any debug metadata from the store onto the dbg.value.
|
||||||
|
DebugLoc SIDL = SI->getDebugLoc();
|
||||||
|
if (!SIDL.isUnknown())
|
||||||
|
DbgVal->setDebugLoc(SIDL);
|
||||||
|
// Otherwise propagate debug metadata from dbg.declare.
|
||||||
|
else
|
||||||
|
DbgVal->setDebugLoc(DDI->getDebugLoc());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include "llvm/Analysis/DIBuilder.h"
|
#include "llvm/Analysis/DIBuilder.h"
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
#include "llvm/Analysis/InstructionSimplify.h"
|
#include "llvm/Analysis/InstructionSimplify.h"
|
||||||
|
#include "llvm/Transforms/Utils/Local.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
@@ -273,8 +274,6 @@ namespace {
|
|||||||
LargeBlockInfo &LBI);
|
LargeBlockInfo &LBI);
|
||||||
void PromoteSingleBlockAlloca(AllocaInst *AI, AllocaInfo &Info,
|
void PromoteSingleBlockAlloca(AllocaInst *AI, AllocaInfo &Info,
|
||||||
LargeBlockInfo &LBI);
|
LargeBlockInfo &LBI);
|
||||||
void ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, StoreInst *SI);
|
|
||||||
|
|
||||||
|
|
||||||
void RenamePass(BasicBlock *BB, BasicBlock *Pred,
|
void RenamePass(BasicBlock *BB, BasicBlock *Pred,
|
||||||
RenamePassData::ValVector &IncVals,
|
RenamePassData::ValVector &IncVals,
|
||||||
@@ -391,7 +390,9 @@ void PromoteMem2Reg::run() {
|
|||||||
if (Info.UsingBlocks.empty()) {
|
if (Info.UsingBlocks.empty()) {
|
||||||
// Record debuginfo for the store and remove the declaration's debuginfo.
|
// Record debuginfo for the store and remove the declaration's debuginfo.
|
||||||
if (DbgDeclareInst *DDI = Info.DbgDeclare) {
|
if (DbgDeclareInst *DDI = Info.DbgDeclare) {
|
||||||
ConvertDebugDeclareToDebugValue(DDI, Info.OnlyStore);
|
if (!DIB)
|
||||||
|
DIB = new DIBuilder(*DDI->getParent()->getParent()->getParent());
|
||||||
|
ConvertDebugDeclareToDebugValue(DDI, Info.OnlyStore, *DIB);
|
||||||
DDI->eraseFromParent();
|
DDI->eraseFromParent();
|
||||||
}
|
}
|
||||||
// Remove the (now dead) store and alloca.
|
// Remove the (now dead) store and alloca.
|
||||||
@@ -423,8 +424,11 @@ void PromoteMem2Reg::run() {
|
|||||||
while (!AI->use_empty()) {
|
while (!AI->use_empty()) {
|
||||||
StoreInst *SI = cast<StoreInst>(AI->use_back());
|
StoreInst *SI = cast<StoreInst>(AI->use_back());
|
||||||
// Record debuginfo for the store before removing it.
|
// Record debuginfo for the store before removing it.
|
||||||
if (DbgDeclareInst *DDI = Info.DbgDeclare)
|
if (DbgDeclareInst *DDI = Info.DbgDeclare) {
|
||||||
ConvertDebugDeclareToDebugValue(DDI, SI);
|
if (!DIB)
|
||||||
|
DIB = new DIBuilder(*SI->getParent()->getParent()->getParent());
|
||||||
|
ConvertDebugDeclareToDebugValue(DDI, SI, *DIB);
|
||||||
|
}
|
||||||
SI->eraseFromParent();
|
SI->eraseFromParent();
|
||||||
LBI.deleteValue(SI);
|
LBI.deleteValue(SI);
|
||||||
}
|
}
|
||||||
@@ -944,28 +948,6 @@ void PromoteMem2Reg::PromoteSingleBlockAlloca(AllocaInst *AI, AllocaInfo &Info,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inserts a llvm.dbg.value instrinsic before the stores to an alloca'd value
|
|
||||||
// that has an associated llvm.dbg.decl intrinsic.
|
|
||||||
void PromoteMem2Reg::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
|
|
||||||
StoreInst *SI) {
|
|
||||||
DIVariable DIVar(DDI->getVariable());
|
|
||||||
if (!DIVar.Verify())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!DIB)
|
|
||||||
DIB = new DIBuilder(*SI->getParent()->getParent()->getParent());
|
|
||||||
Instruction *DbgVal = DIB->insertDbgValueIntrinsic(SI->getOperand(0), 0,
|
|
||||||
DIVar, SI);
|
|
||||||
|
|
||||||
// Propagate any debug metadata from the store onto the dbg.value.
|
|
||||||
DebugLoc SIDL = SI->getDebugLoc();
|
|
||||||
if (!SIDL.isUnknown())
|
|
||||||
DbgVal->setDebugLoc(SIDL);
|
|
||||||
// Otherwise propagate debug metadata from dbg.declare.
|
|
||||||
else
|
|
||||||
DbgVal->setDebugLoc(DDI->getDebugLoc());
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueuePhiNode - queues a phi-node to be added to a basic-block for a specific
|
// QueuePhiNode - queues a phi-node to be added to a basic-block for a specific
|
||||||
// Alloca returns true if there wasn't already a phi-node for that variable
|
// Alloca returns true if there wasn't already a phi-node for that variable
|
||||||
//
|
//
|
||||||
@@ -1076,8 +1058,11 @@ NextIteration:
|
|||||||
// what value were we writing?
|
// what value were we writing?
|
||||||
IncomingVals[ai->second] = SI->getOperand(0);
|
IncomingVals[ai->second] = SI->getOperand(0);
|
||||||
// Record debuginfo for the store before removing it.
|
// Record debuginfo for the store before removing it.
|
||||||
if (DbgDeclareInst *DDI = AllocaDbgDeclares[ai->second])
|
if (DbgDeclareInst *DDI = AllocaDbgDeclares[ai->second]) {
|
||||||
ConvertDebugDeclareToDebugValue(DDI, SI);
|
if (!DIB)
|
||||||
|
DIB = new DIBuilder(*SI->getParent()->getParent()->getParent());
|
||||||
|
ConvertDebugDeclareToDebugValue(DDI, SI, *DIB);
|
||||||
|
}
|
||||||
BB->getInstList().erase(SI);
|
BB->getInstList().erase(SI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user