mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
[TypeShrinking] Fix styling issues
This commit is contained in:
committed by
Pietro Fezzardi
parent
750b326d24
commit
04085ecd99
@@ -25,8 +25,8 @@ concept same_as = std::is_same_v<T, U>;
|
||||
|
||||
template<typename LatticeElement>
|
||||
struct MFPResult {
|
||||
LatticeElement inValue;
|
||||
LatticeElement outValue;
|
||||
LatticeElement InValue;
|
||||
LatticeElement OutValue;
|
||||
};
|
||||
|
||||
/// GT is an instance of llvm::GraphTraits e.g. llvm::GraphTraits<GraphType>
|
||||
@@ -53,19 +53,19 @@ concept MonotoneFrameworkInstance = requires(typename MFI::LatticeElement E1,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
template<typename Label>
|
||||
template<typename ItemType>
|
||||
struct WorklistItem {
|
||||
size_t priority;
|
||||
Label label;
|
||||
size_t Priority;
|
||||
ItemType Item;
|
||||
|
||||
friend bool
|
||||
operator<(const WorklistItem<Label> &a, const WorklistItem<Label> &b) {
|
||||
return a.priority < b.priority;
|
||||
friend bool operator<(const WorklistItem<ItemType> &Lhs,
|
||||
const WorklistItem<ItemType> &Rhs) {
|
||||
return Lhs.Priority < Rhs.Priority;
|
||||
}
|
||||
|
||||
friend bool
|
||||
operator==(const WorklistItem<Label> &a, const WorklistItem<Label> &b) {
|
||||
return a.label < b.label;
|
||||
friend bool operator==(const WorklistItem<ItemType> &Lhs,
|
||||
const WorklistItem<ItemType> &Rhs) {
|
||||
return Lhs.Item < Rhs.Item;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -129,7 +129,7 @@ getMaximalFixedPoint(const typename MFI::GraphType &Flow,
|
||||
// Step 2 iteration
|
||||
while (!Worklist.empty()) {
|
||||
WorklistItem<Label> First = *Worklist.begin();
|
||||
Label Start = First.label;
|
||||
Label Start = First.Item;
|
||||
Worklist.erase(First);
|
||||
for (Label End : successors<GT>(Start)) {
|
||||
auto &PartialStart = PartialAnalysis.at(Start);
|
||||
|
||||
@@ -40,14 +40,20 @@ static llvm::RegisterPass<BitLivenessPass> X("bit-liveness",
|
||||
const uint32_t Top = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
bool isDataFlowSink(const Instruction *Ins) {
|
||||
if (Ins->mayHaveSideEffects() || Ins->getOpcode() == Instruction::Call
|
||||
|| Ins->getOpcode() == Instruction::CallBr
|
||||
|| Ins->getOpcode() == Instruction::Ret
|
||||
|| Ins->getOpcode() == Instruction::Store
|
||||
|| Ins->getOpcode() == Instruction::Br
|
||||
|| Ins->getOpcode() == Instruction::IndirectBr)
|
||||
if (Ins->mayHaveSideEffects()) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
switch (Ins->getOpcode()) {
|
||||
case Instruction::Call:
|
||||
case Instruction::CallBr:
|
||||
case Instruction::Ret:
|
||||
case Instruction::Store:
|
||||
case Instruction::Br:
|
||||
case Instruction::IndirectBr:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getMaxOperandSize(Instruction *Ins) {
|
||||
|
||||
@@ -84,7 +84,7 @@ bool TypeShrinking::runOnFunction(Function &F) {
|
||||
BitLivenessPass::AnalysisResult &FixedPoints = BitLiveness.getResult();
|
||||
bool HasChanges = false;
|
||||
|
||||
std::vector<uint32_t> Ranks = { 8, 16, 32, 64 };
|
||||
const std::array<uint32_t, 4> Ranks = { 8, 16, 32, 64 };
|
||||
|
||||
for (auto &[Label, Result] : FixedPoints) {
|
||||
auto *Ins = Label->Instruction;
|
||||
@@ -93,10 +93,10 @@ bool TypeShrinking::runOnFunction(Function &F) {
|
||||
// (the least significant bits of the result depend only on the least
|
||||
// significant bits of the operands) we can down cast the operands and then
|
||||
// upcast the result
|
||||
if (Result.outValue >= MinimumWidth.getValue() && isAddLike(Ins)) {
|
||||
if (Result.OutValue >= MinimumWidth.getValue() && isAddLike(Ins)) {
|
||||
auto ClosestRank = std::lower_bound(Ranks.begin(),
|
||||
Ranks.end(),
|
||||
Result.outValue);
|
||||
Result.OutValue);
|
||||
if (ClosestRank != Ranks.end()
|
||||
&& Ins->getType()->getScalarSizeInBits() > *ClosestRank) {
|
||||
auto Rank = *ClosestRank;
|
||||
|
||||
Reference in New Issue
Block a user