Revert "Add a mark_dependence while emitting SIL for uninitialized array allocation "

This commit is contained in:
Mishal Shah
2023-11-12 09:43:13 -08:00
committed by GitHub
parent 89d8b2301c
commit e8de333daf
27 changed files with 227 additions and 378 deletions

View File

@@ -122,9 +122,6 @@ bool ArrayAllocation::replacementsAreValid() {
/// Recursively look at all uses of this definition. Abort if the array value
/// could escape or be changed. Collect all uses that are calls to array.count.
bool ArrayAllocation::recursivelyCollectUses(ValueBase *Def) {
LLVM_DEBUG(llvm::dbgs() << "Collecting uses of:");
LLVM_DEBUG(Def->dump());
for (auto *Opd : Def->getUses()) {
auto *User = Opd->getUser();
// Ignore reference counting and debug instructions.
@@ -151,12 +148,6 @@ bool ArrayAllocation::recursivelyCollectUses(ValueBase *Def) {
continue;
}
if (auto *MDI = dyn_cast<MarkDependenceInst>(User)) {
if (Def != MDI->getBase())
return false;
continue;
}
// Check array semantic calls.
ArraySemanticsCall ArrayOp(User);
switch (ArrayOp.getKind()) {
@@ -190,28 +181,17 @@ bool ArrayAllocation::analyze(ApplyInst *Alloc) {
if (!Uninitialized)
return false;
LLVM_DEBUG(llvm::dbgs() << "Found array allocation: ");
LLVM_DEBUG(Alloc->dump());
ArrayValue = Uninitialized.getArrayValue();
if (!ArrayValue) {
LLVM_DEBUG(llvm::dbgs() << "Did not find array value\n");
if (!ArrayValue)
return false;
}
LLVM_DEBUG(llvm::dbgs() << "ArrayValue: ");
LLVM_DEBUG(ArrayValue->dump());
// Figure out all stores to the array.
if (!mapInitializationStores(Uninitialized)) {
LLVM_DEBUG(llvm::dbgs() << "Could not map initializing stores\n");
if (!mapInitializationStores(Uninitialized))
return false;
}
// Check if the array value was stored or has escaped.
if (!recursivelyCollectUses(ArrayValue)) {
LLVM_DEBUG(llvm::dbgs() << "Array value stored or escaped\n");
if (!recursivelyCollectUses(ArrayValue))
return false;
}
return true;
}
@@ -348,9 +328,7 @@ public:
auto &Fn = *getFunction();
bool Changed = false;
LLVM_DEBUG(llvm::dbgs() << "ArrayElementPropagation looking at function: "
<< Fn.getName() << "\n");
for (auto &BB : Fn) {
for (auto &BB :Fn) {
for (auto &Inst : BB) {
if (auto *Apply = dyn_cast<ApplyInst>(&Inst)) {
ArrayAllocation ALit;