[llvm] 34a9642 - Revert "[instsimplify] Simplify HaveNonOverlappingStorage per review suggestion on D120133 [NFC]"
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 18 15:36:34 PST 2022
Author: Philip Reames
Date: 2022-02-18T15:36:15-08:00
New Revision: 34a9642af8b4d29545d41824412bd3a5abee3f24
URL: https://github.com/llvm/llvm-project/commit/34a9642af8b4d29545d41824412bd3a5abee3f24
DIFF: https://github.com/llvm/llvm-project/commit/34a9642af8b4d29545d41824412bd3a5abee3f24.diff
LOG: Revert "[instsimplify] Simplify HaveNonOverlappingStorage per review suggestion on D120133 [NFC]"
This reverts commit 3a6be124cc01191ec52192017791bb04a6c7295a. This appears to have caused a stage2 build failure: https://lab.llvm.org/buildbot/#/builders/168/builds/4813
Will investigate further on Monday and recommit.
Added:
Modified:
llvm/lib/Analysis/InstructionSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 7475b995cbd86..b3459b5ffb013 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2555,24 +2555,20 @@ static bool HaveNonOverlappingStorage(const Value *V1, const Value *V2) {
//
// So, we'll assume that two non-empty allocas have
diff erent addresses
// for now.
-
- auto isByValArgOrGlobalVarOrAlloca = [](const Value *V) {
- if (const Argument *A = dyn_cast<Argument>(V))
- return A->hasByValAttr();
- return isa<AllocaInst>(V) || isa<GlobalVariable>(V);
+ auto isByValArg = [](const Value *V) {
+ const Argument *A = dyn_cast<Argument>(V);
+ return A && A->hasByValAttr();
};
- if (!isByValArgOrGlobalVarOrAlloca(V1) ||
- !isByValArgOrGlobalVarOrAlloca(V2))
- return false;
+ // Byval args are backed by store which does not overlap with each other,
+ // allocas, or globals.
+ if (isByValArg(V1))
+ return isa<AllocaInst>(V2) || isa<GlobalVariable>(V2) || isByValArg(V2);
+ if (isByValArg(V2))
+ return isa<AllocaInst>(V1) || isa<GlobalVariable>(V1) || isByValArg(V1);
- // Both sides being globals shouldn't reach here - as the resulting compare
- // is a constantexpr - but we want to guard against it to be safe. The
- // semantics of globals are complicated by e.g. unnamed_addr. The assumption
- // in this code is that while two globals could end up overlapping, they'll
- // never overlap with any alloca or byval, and thus we can still reason about
- // *one* global and one *non* global as disjoint storage.
- return !isa<GlobalVariable>(V1) || !isa<GlobalVariable>(V2);
+ return isa<AllocaInst>(V1) &&
+ (isa<AllocaInst>(V2) || isa<GlobalVariable>(V2));
}
// A significant optimization not implemented here is assuming that alloca
More information about the llvm-commits
mailing list