[llvm] [NFC][RemoveDIs] Switch constant-hoisting to insert with iterators (PR #84738)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 03:00:01 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 5b5c21d772d20320fd876edddfc204cca93fae0f aaaf4583cca106efe86f23c7d6f4eb462624288c -- llvm/include/llvm/IR/BasicBlock.h llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 1add4c2da9..86d0261263 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -22,7 +22,6 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/DebugProgramInstruction.h"
#include "llvm/IR/Instruction.h"
-#include "llvm/IR/DebugProgramInstruction.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Value.h"
#include <cassert>
@@ -778,8 +777,7 @@ inline void BasicBlock::validateInstrOrdering() const {}
// Specialize DenseMapInfo for iterators, so that ththey can be installed into
// maps and sets. The iterator is made up of its node pointer, and the
// debug-info "head" bit.
-template<>
-struct DenseMapInfo<BasicBlock::iterator> {
+template <> struct DenseMapInfo<BasicBlock::iterator> {
static inline BasicBlock::iterator getEmptyKey() {
return BasicBlock::iterator(nullptr);
}
@@ -791,10 +789,13 @@ struct DenseMapInfo<BasicBlock::iterator> {
}
static unsigned getHashValue(const BasicBlock::iterator &It) {
- return DenseMapInfo<void *>::getHashValue(reinterpret_cast<void *>(It.getNodePtr())) ^ It.getHeadBit();
+ return DenseMapInfo<void *>::getHashValue(
+ reinterpret_cast<void *>(It.getNodePtr())) ^
+ It.getHeadBit();
}
- static bool isEqual(const BasicBlock::iterator &LHS, const BasicBlock::iterator &RHS) {
+ static bool isEqual(const BasicBlock::iterator &LHS,
+ const BasicBlock::iterator &RHS) {
return LHS == RHS && LHS.getHeadBit() == RHS.getHeadBit();
}
};
diff --git a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
index e2c165365b..48f8421c18 100644
--- a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
+++ b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
@@ -173,10 +173,11 @@ private:
void collectMatInsertPts(
const consthoist::RebasedConstantListType &RebasedConstants,
SmallVectorImpl<BasicBlock::iterator> &MatInsertPts) const;
- BasicBlock::iterator findMatInsertPt(Instruction *Inst, unsigned Idx = ~0U) const;
- SetVector<BasicBlock::iterator>
- findConstantInsertionPoint(const consthoist::ConstantInfo &ConstInfo,
- const ArrayRef<BasicBlock::iterator> MatInsertPts) const;
+ BasicBlock::iterator findMatInsertPt(Instruction *Inst,
+ unsigned Idx = ~0U) const;
+ SetVector<BasicBlock::iterator> findConstantInsertionPoint(
+ const consthoist::ConstantInfo &ConstInfo,
+ const ArrayRef<BasicBlock::iterator> MatInsertPts) const;
void collectConstantCandidates(ConstCandMapType &ConstCandMap,
Instruction *Inst, unsigned Idx,
ConstantInt *ConstInt);
diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
index 6d1db436ec..4f9d9c84fe 100644
--- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
@@ -170,7 +170,7 @@ void ConstantHoistingPass::collectMatInsertPts(
/// Find the constant materialization insertion point.
BasicBlock::iterator ConstantHoistingPass::findMatInsertPt(Instruction *Inst,
- unsigned Idx) const {
+ unsigned Idx) const {
// If the operand is a cast instruction, then we have to materialize the
// constant before the cast instruction.
if (Idx != ~0U) {
@@ -314,7 +314,8 @@ static void findBestInsertionSet(DominatorTree &DT, BlockFrequencyInfo &BFI,
}
/// Find an insertion point that dominates all uses.
-SetVector<BasicBlock::iterator> ConstantHoistingPass::findConstantInsertionPoint(
+SetVector<BasicBlock::iterator>
+ConstantHoistingPass::findConstantInsertionPoint(
const ConstantInfo &ConstInfo,
const ArrayRef<BasicBlock::iterator> MatInsertPts) const {
assert(!ConstInfo.RebasedConstants.empty() && "Invalid constant info entry.");
@@ -761,11 +762,13 @@ void ConstantHoistingPass::emitBaseConstants(Instruction *Base,
Mat = GetElementPtrInst::Create(Type::getInt8Ty(*Ctx), Base, Adj->Offset,
"mat_gep", Adj->MatInsertPt);
// Hide it behind a bitcast.
- Mat = new BitCastInst(Mat, Adj->Ty, "mat_bitcast", Adj->MatInsertPt->getIterator());
+ Mat = new BitCastInst(Mat, Adj->Ty, "mat_bitcast",
+ Adj->MatInsertPt->getIterator());
} else
// Constant being rebased is a ConstantInt.
- Mat = BinaryOperator::Create(Instruction::Add, Base, Adj->Offset,
- "const_mat", Adj->MatInsertPt->getIterator());
+ Mat =
+ BinaryOperator::Create(Instruction::Add, Base, Adj->Offset,
+ "const_mat", Adj->MatInsertPt->getIterator());
LLVM_DEBUG(dbgs() << "Materialize constant (" << *Base->getOperand(0)
<< " + " << *Adj->Offset << ") in BB "
``````````
</details>
https://github.com/llvm/llvm-project/pull/84738
More information about the llvm-commits
mailing list