[llvm] f2264eb - [ConstantFolding] Fix -Wunused-variable warning (NFC)

Yang Fan via llvm-commits llvm-commits at lists.llvm.org
Fri May 28 01:19:09 PDT 2021


Author: Yang Fan
Date: 2021-05-28T16:17:12+08:00
New Revision: f2264ebb087272d49e2216476a62f3208ba5a1ea

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

LOG: [ConstantFolding] Fix -Wunused-variable warning (NFC)

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)) {
      |                   ^~~~~~~~~~~~~
```

Added: 
    

Modified: 
    llvm/lib/Analysis/ConstantFolding.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 989379d22c61..39ef3fe9b89e 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -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(


        


More information about the llvm-commits mailing list