[ConstantFolding] Fix -Wunused-variable warning (NFC)
authorYang Fan <nullptr.cpp@gmail.com>
Fri, 28 May 2021 08:15:12 +0000 (16:15 +0800)
committerYang Fan <nullptr.cpp@gmail.com>
Fri, 28 May 2021 08:17:12 +0000 (16:17 +0800)
GCC warning:
```
/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp: In function ‘llvm::Constant* llvm::ConstantFoldLoadFromConstPtr(llvm::Constant*, llvm::Type*, const llvm::DataLayout&)’:
/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:713:19: warning: unused variable ‘SimplifiedGEP’ [-Wunused-variable]
  713 |         if (auto *SimplifiedGEP = dyn_cast<GEPOperator>(Simplified)) {
      |                   ^~~~~~~~~~~~~
```

llvm/lib/Analysis/ConstantFolding.cpp

index 989379d..39ef3fe 100644 (file)
@@ -710,7 +710,7 @@ Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
         // fold it if the resulting pointer operand is a GlobalValue. Otherwise
         // there is nothing else to simplify since the GEP is already in the
         // most simplified form.
-        if (auto *SimplifiedGEP = dyn_cast<GEPOperator>(Simplified)) {
+        if (isa<GEPOperator>(Simplified)) {
           if (auto *GV = dyn_cast<GlobalVariable>(Simplified->getOperand(0))) {
             if (GV->isConstant() && GV->hasDefinitiveInitializer()) {
               if (Constant *V = ConstantFoldLoadThroughGEPConstantExpr(