Avoid repeated calls to CE->getOperand(0). No functionality change.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 12 Mar 2014 18:08:14 +0000 (18:08 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 12 Mar 2014 18:08:14 +0000 (18:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203686 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp

index 4bdc1c13d03f393137666392a911e45b4dcb3f32..fcdbac2f9f6f0a81e93afc2b538cbd559eb40e94 100644 (file)
@@ -479,20 +479,21 @@ void Verifier::visitGlobalAlias(const GlobalAlias &GA) {
   Assert1(!GA.getAlignment(), "Alias connot have an alignment", &GA);
 
   const Constant *Aliasee = GA.getAliasee();
+  const GlobalValue *GV = dyn_cast<GlobalValue>(Aliasee);
 
-  if (!isa<GlobalValue>(Aliasee)) {
+  if (!GV) {
     const ConstantExpr *CE = dyn_cast<ConstantExpr>(Aliasee);
-    Assert1(CE &&
-            (CE->getOpcode() == Instruction::BitCast ||
-             CE->getOpcode() == Instruction::AddrSpaceCast ||
-             CE->getOpcode() == Instruction::GetElementPtr) &&
-            isa<GlobalValue>(CE->getOperand(0)),
-            "Aliasee should be either GlobalValue, bitcast or "
-             "addrspacecast of GlobalValue",
+    if (CE && (CE->getOpcode() == Instruction::BitCast ||
+               CE->getOpcode() == Instruction::AddrSpaceCast ||
+               CE->getOpcode() == Instruction::GetElementPtr))
+      GV = dyn_cast<GlobalValue>(CE->getOperand(0));
+
+    Assert1(GV, "Aliasee should be either GlobalValue, bitcast or "
+                "addrspacecast of GlobalValue",
             &GA);
 
     if (CE->getOpcode() == Instruction::BitCast) {
-      unsigned SrcAS = CE->getOperand(0)->getType()->getPointerAddressSpace();
+      unsigned SrcAS = GV->getType()->getPointerAddressSpace();
       unsigned DstAS = CE->getType()->getPointerAddressSpace();
 
       Assert1(SrcAS == DstAS,