[PATCH] D131572: [NFC][SeparateConstOffsetFromGEP] Small refactoring and reformatting
Elena Lepilkina via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 05:03:56 PDT 2022
eklepilkina updated this revision to Diff 456310.
eklepilkina added a comment.
Update
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131572/new/
https://reviews.llvm.org/D131572
Files:
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
Index: llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -160,6 +160,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/ScalarEvolution.h"
@@ -177,7 +178,6 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
-#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
@@ -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,10 @@
using namespace llvm;
using namespace llvm::PatternMatch;
+#define DEBUG_TYPE "separate-const-offset-from-gep"
+
+STATISTIC(NumSplittedGEPs, "Number of splitted GEPs");
+
static cl::opt<bool> DisableSeparateConstOffsetFromGEP(
"disable-separate-const-offset-from-gep", cl::init(false),
cl::desc("Do not separate the constant offset from a GEP instruction"),
@@ -992,6 +997,9 @@
/*BaseGV=*/nullptr, AccumulativeByteOffset,
/*HasBaseReg=*/true, /*Scale=*/0,
AddrSpace)) {
+ LLVM_DEBUG(
+ dbgs()
+ << "Don't optimize. The backend doesn't support the addressing mode\n");
return Changed;
}
}
@@ -1091,6 +1099,8 @@
Instruction *NewGEP = GEP->clone();
NewGEP->insertBefore(GEP);
+ LLVM_DEBUG(dbgs() << "Created new base GEP " << *NewGEP << "\n");
+
// Per ANSI C standard, signed / unsigned = unsigned and signed % unsigned =
// unsigned.. Therefore, we cast ElementTypeSizeOfGEP to signed because it is
// used with unsigned integers later.
@@ -1137,8 +1147,11 @@
}
GEP->replaceAllUsesWith(NewGEP);
+ LLVM_DEBUG(dbgs() << "Replaced GEP " << *GEP << " with new one " << *GEP << "\n");
GEP->eraseFromParent();
+ NumSplittedGEPs++;
+
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131572.456310.patch
Type: text/x-patch
Size: 2419 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220829/3bcb0002/attachment.bin>
More information about the llvm-commits
mailing list