[Attributor][NFC] Move some trivial checks up
authorJohannes Doerfert <johannes@jdoerfert.de>
Mon, 1 Mar 2021 23:15:26 +0000 (17:15 -0600)
committerJohannes Doerfert <johannes@jdoerfert.de>
Thu, 4 Mar 2021 06:35:52 +0000 (00:35 -0600)
llvm/lib/Transforms/IPO/AttributorAttributes.cpp

index 77c34a1..4018cf1 100644 (file)
@@ -1600,6 +1600,19 @@ static int64_t getKnownNonNullAndDerefBytesForUse(
   if (!UseV->getType()->isPointerTy())
     return 0;
 
+  // We need to follow common pointer manipulation uses to the accesses they
+  // feed into. We can try to be smart to avoid looking through things we do not
+  // like for now, e.g., non-inbounds GEPs.
+  if (isa<CastInst>(I)) {
+    TrackUse = true;
+    return 0;
+  }
+
+  if (isa<GetElementPtrInst>(I)) {
+    TrackUse = true;
+    return 0;
+  }
+
   Type *PtrTy = UseV->getType();
   const Function *F = I->getFunction();
   bool NullPointerIsDefined =
@@ -1631,19 +1644,6 @@ static int64_t getKnownNonNullAndDerefBytesForUse(
     return DerefAA.getKnownDereferenceableBytes();
   }
 
-  // We need to follow common pointer manipulation uses to the accesses they
-  // feed into. We can try to be smart to avoid looking through things we do not
-  // like for now, e.g., non-inbounds GEPs.
-  if (isa<CastInst>(I)) {
-    TrackUse = true;
-    return 0;
-  }
-
-  if (isa<GetElementPtrInst>(I)) {
-    TrackUse = true;
-    return 0;
-  }
-
   int64_t Offset;
   const Value *Base =
       getMinimalBaseOfAccsesPointerOperand(A, QueryingAA, I, Offset, DL);