mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-29 05:01:11 +00:00
Store EscapeMap as Value* instead of AllocInst
This currently does not change the behavior in Polly, but it allows us to later also overwrite the EscapeMap with our GlobalMap. llvm-svn: 247970
This commit is contained in:
parent
dd0eadce7d
commit
b09455dee0
@ -68,7 +68,7 @@ public:
|
||||
///@{
|
||||
|
||||
/// @see The ScalarMap and PHIOpMap member.
|
||||
using ScalarAllocaMapTy = DenseMap<Value *, AllocaInst *>;
|
||||
using ScalarAllocaMapTy = DenseMap<Value *, Value *>;
|
||||
|
||||
/// @brief Simple vector of instructions to store escape users.
|
||||
using EscapeUserVectorTy = SmallVector<Instruction *, 4>;
|
||||
@ -77,7 +77,7 @@ public:
|
||||
///
|
||||
/// @see The EscapeMap member.
|
||||
using EscapeUsersAllocaMapTy =
|
||||
DenseMap<Instruction *, std::pair<AllocaInst *, EscapeUserVectorTy>>;
|
||||
DenseMap<Instruction *, std::pair<Value *, EscapeUserVectorTy>>;
|
||||
|
||||
///@}
|
||||
|
||||
@ -388,7 +388,7 @@ protected:
|
||||
/// SCoP.
|
||||
/// @param Address If given it is used as the escape address for @p Inst.
|
||||
void handleOutsideUsers(const Region &R, Instruction *Inst, Value *InstCopy,
|
||||
AllocaInst *Address = nullptr);
|
||||
Value *Address = nullptr);
|
||||
|
||||
/// @brief Initialize the memory of demoted scalars.
|
||||
///
|
||||
|
@ -333,14 +333,15 @@ Value *BlockGenerator::getOrCreateAlloca(Value *ScalarBase,
|
||||
ScalarAllocaMapTy &Map,
|
||||
const char *NameExt) {
|
||||
// Check if an alloca was cached for the base instruction.
|
||||
AllocaInst *&Addr = Map[ScalarBase];
|
||||
Value *&Addr = Map[ScalarBase];
|
||||
|
||||
// If no alloca was found create one and insert it in the entry block.
|
||||
if (!Addr) {
|
||||
auto *Ty = ScalarBase->getType();
|
||||
Addr = new AllocaInst(Ty, ScalarBase->getName() + NameExt);
|
||||
auto NewAddr = new AllocaInst(Ty, ScalarBase->getName() + NameExt);
|
||||
EntryBB = &Builder.GetInsertBlock()->getParent()->getEntryBlock();
|
||||
Addr->insertBefore(EntryBB->getFirstInsertionPt());
|
||||
NewAddr->insertBefore(EntryBB->getFirstInsertionPt());
|
||||
Addr = NewAddr;
|
||||
}
|
||||
|
||||
if (GlobalMap.count(Addr))
|
||||
@ -365,7 +366,7 @@ Value *BlockGenerator::getOrCreatePHIAlloca(Value *ScalarBase) {
|
||||
}
|
||||
|
||||
void BlockGenerator::handleOutsideUsers(const Region &R, Instruction *Inst,
|
||||
Value *InstCopy, AllocaInst *Address) {
|
||||
Value *InstCopy, Value *Address) {
|
||||
// If there are escape users we get the alloca for this instruction and put it
|
||||
// in the EscapeMap for later finalization. Lastly, if the instruction was
|
||||
// copied multiple times we already did this and can exit.
|
||||
@ -391,8 +392,7 @@ void BlockGenerator::handleOutsideUsers(const Region &R, Instruction *Inst,
|
||||
return;
|
||||
|
||||
// Get or create an escape alloca for this instruction.
|
||||
auto *ScalarAddr =
|
||||
Address ? Address : cast<AllocaInst>(getOrCreateScalarAlloca(Inst));
|
||||
auto *ScalarAddr = Address ? Address : getOrCreateScalarAlloca(Inst);
|
||||
|
||||
// Remember that this instruction has escape uses and the escape alloca.
|
||||
EscapeMap[Inst] = std::make_pair(ScalarAddr, std::move(EscapeUsers));
|
||||
|
Loading…
x
Reference in New Issue
Block a user