[llvm] 5ecf218 - [instsimplify] Add a comment hinting how compares involving two globals are handled [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 18 08:41:38 PST 2022


Author: Philip Reames
Date: 2022-02-18T08:41:30-08:00
New Revision: 5ecf218eca3558aa647bbc8120dfa734a233953c

URL: https://github.com/llvm/llvm-project/commit/5ecf218eca3558aa647bbc8120dfa734a233953c
DIFF: https://github.com/llvm/llvm-project/commit/5ecf218eca3558aa647bbc8120dfa734a233953c.diff

LOG: [instsimplify] Add a comment hinting how compares involving two globals are handled [NFC]

Added: 
    

Modified: 
    llvm/lib/Analysis/InstructionSimplify.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 5fa6b69c1014f..54895def7970b 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2512,8 +2512,12 @@ static Value *ExtractEquivalentCondition(Value *V, CmpInst::Predicate Pred,
 /// *are* possible, and that zero sized regions do not overlap with any other.
 static bool HaveNonOverlappingStorage(const Value *V1, const Value *V2) {
   // Global variables always exist, so they always exist during the lifetime
-  // of each other and all allocas. Two 
diff erent allocas usually have
-  // 
diff erent addresses...
+  // of each other and all allocas.  Global variables themselves usually have
+  // non-overlapping storage, but since their addresses are constants, the
+  // case involving two globals does not reach here and is instead handled in
+  // constant folding.
+  //
+  // Two 
diff erent allocas usually have 
diff erent addresses...
   //
   // However, if there's an @llvm.stackrestore dynamically in between two
   // allocas, they may have the same address. It's tempting to reduce the
@@ -2532,7 +2536,6 @@ static bool HaveNonOverlappingStorage(const Value *V1, const Value *V2) {
   //
   // So, we'll assume that two non-empty allocas have 
diff erent addresses
   // for now.
-  //
   return isa<AllocaInst>(V1) &&
     (isa<AllocaInst>(V2) || isa<GlobalVariable>(V2));
 }


        


More information about the llvm-commits mailing list