diff --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp --- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp +++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp @@ -187,6 +187,7 @@ #include "llvm/Pass.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Scalar.h" @@ -198,6 +199,8 @@ using namespace llvm; using namespace llvm::PatternMatch; +#define DEBUG_TYPE "separate-const-offset-from-gep" + static cl::opt DisableSeparateConstOffsetFromGEP( "disable-separate-const-offset-from-gep", cl::init(false), cl::desc("Do not separate the constant offset from a GEP instruction"), @@ -254,15 +257,15 @@ /// successful, returns C and update UserChain as a def-use chain from C to V; /// otherwise, UserChain is empty. /// - /// \p V The given expression - /// \p SignExtended Whether V will be sign-extended in the computation of the - /// GEP index - /// \p ZeroExtended Whether V will be zero-extended in the computation of the - /// GEP index - /// \p NonNegative Whether V is guaranteed to be non-negative. For example, - /// an index of an inbounds GEP is guaranteed to be - /// non-negative. Levaraging this, we can better split - /// inbounds GEPs. + /// \p V The given expression + /// \p SignExtended Whether V will be sign-extended in the computation + /// of the GEP index + /// \p ZeroExtended Whether V will be zero-extended in the computation + /// of the GEP index + /// \p NonNegative Whether V is guaranteed to be non-negative. For + /// example, an index of an inbounds GEP is guaranteed + /// to be non-negative. Levaraging this, we can better + /// split inbounds GEPs. APInt find(Value *V, bool SignExtended, bool ZeroExtended, bool NonNegative); /// A helper function to look into both operands of a binary operator. @@ -1162,6 +1165,9 @@ DL = &F.getParent()->getDataLayout(); bool Changed = false; + + LLVM_DEBUG(dbgs() << "========= Function " << F.getName() << " =========\n"); + for (BasicBlock &B : F) { if (!DT->isReachableFromEntry(&B)) continue;