[llvm] r270268 - [BasicAA] Turn DecomposeGEPExpression runtime checks into asserts.

Michael Kuperstein via llvm-commits llvm-commits at lists.llvm.org
Fri May 20 13:26:50 PDT 2016


Author: mkuper
Date: Fri May 20 15:26:50 2016
New Revision: 270268

URL: http://llvm.org/viewvc/llvm-project?rev=270268&view=rev
Log:
[BasicAA] Turn DecomposeGEPExpression runtime checks into asserts.

When it has a DataLayout, DecomposeGEPExpression() should return the same object
as GetUnderlyingObject(). Per the FIXME, it currently always has a DL, so the
runtime check is redundant and can become an assert.


Modified:
    llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=270268&r1=270267&r2=270268&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Fri May 20 15:26:50 2016
@@ -991,13 +991,10 @@ AliasResult BasicAAResult::aliasGEP(cons
         const Value *GEP1BasePtr =
             DecomposeGEPExpression(GEP1, GEP1BaseOffset, GEP1VariableIndices,
                                    GEP1MaxLookupReached, DL, &AC, DT);
-        // DecomposeGEPExpression and GetUnderlyingObject should return the
-        // same result except when DecomposeGEPExpression has no DataLayout.
-        // FIXME: They always have a DataLayout, so this should become an
-        // assert.
-        if (GEP1BasePtr != UnderlyingV1 || GEP2BasePtr != UnderlyingV2) {
-          return MayAlias;
-        }
+
+        assert(GEP1BasePtr == UnderlyingV1 && GEP2BasePtr == UnderlyingV2 &&
+               "DecomposeGEPExpression returned a result different from "
+               "GetUnderlyingObject");
         // If the max search depth is reached the result is undefined
         if (GEP2MaxLookupReached || GEP1MaxLookupReached)
           return MayAlias;
@@ -1029,12 +1026,10 @@ AliasResult BasicAAResult::aliasGEP(cons
         DecomposeGEPExpression(GEP2, GEP2BaseOffset, GEP2VariableIndices,
                                GEP2MaxLookupReached, DL, &AC, DT);
 
-    // DecomposeGEPExpression and GetUnderlyingObject should return the
-    // same result except when DecomposeGEPExpression has no DataLayout.
-    // FIXME: They always have a DataLayout, so this should become an assert.
-    if (GEP1BasePtr != UnderlyingV1 || GEP2BasePtr != UnderlyingV2) {
-      return MayAlias;
-    }
+    assert(GEP1BasePtr == UnderlyingV1 && GEP2BasePtr == UnderlyingV2 &&
+           "DecomposeGEPExpression returned a result different from "
+           "GetUnderlyingObject");
+
 
     // If we know the two GEPs are based off of the exact same pointer (and not
     // just the same underlying object), see if that tells us anything about
@@ -1081,10 +1076,10 @@ AliasResult BasicAAResult::aliasGEP(cons
 
     // DecomposeGEPExpression and GetUnderlyingObject should return the
     // same result except when DecomposeGEPExpression has no DataLayout.
-    // FIXME: They always have a DataLayout, so this should become an assert.
-    if (GEP1BasePtr != UnderlyingV1) {
-      return MayAlias;
-    }
+    assert(GEP1BasePtr == UnderlyingV1 &&
+           "DecomposeGEPExpression returned a result different from "
+           "GetUnderlyingObject");
+
     // If the max search depth is reached the result is undefined
     if (GEP1MaxLookupReached)
       return MayAlias;




More information about the llvm-commits mailing list