Skip to content

Commit

Permalink
Fix some Clang-tidy modernize and Include What You Use warnings.
Browse files Browse the repository at this point in the history
Differential revision: https://reviews.llvm.org/D23291


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278364 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
EugeneZelenko committed Aug 11, 2016
1 parent 7a1d8e4 commit c986ab2
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 50 deletions.
58 changes: 42 additions & 16 deletions lib/CodeGen/MachinePipeliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,61 @@
//
//===----------------------------------------------------------------------===//

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/PriorityQueue.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/DFAPacketizer.h"
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/RegisterClassInfo.h"
#include "llvm/CodeGen/RegisterPressure.h"
#include "llvm/CodeGen/ScheduleDAG.h"
#include "llvm/CodeGen/ScheduleDAGInstrs.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInstrItineraries.h"
#include "llvm/PassAnalysisSupport.h"
#include "llvm/PassRegistry.h"
#include "llvm/PassSupport.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdint>
#include <deque>
#include <functional>
#include <iterator>
#include <map>
#include <tuple>
#include <utility>
#include <vector>

using namespace llvm;

Expand Down Expand Up @@ -175,9 +199,9 @@ class MachinePipeliner : public MachineFunctionPass {
initializeMachinePipelinerPass(*PassRegistry::getPassRegistry());
}

virtual bool runOnMachineFunction(MachineFunction &MF);
bool runOnMachineFunction(MachineFunction &MF) override;

virtual void getAnalysisUsage(AnalysisUsage &AU) const {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<AAResultsWrapperPass>();
AU.addPreserved<AAResultsWrapperPass>();
AU.addRequired<MachineLoopInfo>();
Expand Down Expand Up @@ -265,8 +289,8 @@ class SwingSchedulerDAG : public ScheduleDAGInstrs {
Scheduled(false), Loop(L), LIS(lis), RegClassInfo(rci),
Topo(SUnits, &ExitSU) {}

void schedule();
void finishBlock();
void schedule() override;
void finishBlock() override;

/// Return true if the loop kernel has been scheduled.
bool hasNewSchedule() { return Scheduled; }
Expand Down Expand Up @@ -1099,7 +1123,7 @@ void SwingSchedulerDAG::updatePhiDependences() {
UI != UE; ++UI) {
MachineInstr *UseMI = &*UI;
SUnit *SU = getSUnit(UseMI);
if (SU != 0 && UseMI->isPHI()) {
if (SU != nullptr && UseMI->isPHI()) {
if (!MI->isPHI()) {
SDep Dep(SU, SDep::Anti, Reg);
I.addPred(Dep);
Expand All @@ -1115,10 +1139,10 @@ void SwingSchedulerDAG::updatePhiDependences() {
} else if (MOI->isUse()) {
// If the register is defined by a Phi, then create a true dependence.
MachineInstr *DefMI = MRI.getUniqueVRegDef(Reg);
if (DefMI == 0)
if (DefMI == nullptr)
continue;
SUnit *SU = getSUnit(DefMI);
if (SU != 0 && DefMI->isPHI()) {
if (SU != nullptr && DefMI->isPHI()) {
if (!MI->isPHI()) {
SDep Dep(SU, SDep::Data, Reg);
Dep.setLatency(0);
Expand Down Expand Up @@ -1218,6 +1242,7 @@ void SwingSchedulerDAG::changeDependences() {
}

namespace {

// FuncUnitSorter - Comparison operator used to sort instructions by
// the number of functional unit choices.
struct FuncUnitSorter {
Expand Down Expand Up @@ -1270,7 +1295,8 @@ struct FuncUnitSorter {
return MFUs1 > MFUs2;
}
};
}

} // end anonymous namespace

/// Calculate the resource constrained minimum initiation interval for the
/// specified loop. We use the DFA to model the resources needed for
Expand Down Expand Up @@ -2009,7 +2035,7 @@ void SwingSchedulerDAG::computeNodeOrder(NodeSetType &NodeSets) {
while (!R.empty()) {
SUnit *maxHeight = nullptr;
for (SUnit *I : R) {
if (maxHeight == 0 || getHeight(I) > getHeight(maxHeight))
if (maxHeight == nullptr || getHeight(I) > getHeight(maxHeight))
maxHeight = I;
else if (getHeight(I) == getHeight(maxHeight) &&
getMOV(I) < getMOV(maxHeight) &&
Expand Down Expand Up @@ -2053,7 +2079,7 @@ void SwingSchedulerDAG::computeNodeOrder(NodeSetType &NodeSets) {
while (!R.empty()) {
SUnit *maxDepth = nullptr;
for (SUnit *I : R) {
if (maxDepth == 0 || getDepth(I) > getDepth(maxDepth))
if (maxDepth == nullptr || getDepth(I) > getDepth(maxDepth))
maxDepth = I;
else if (getDepth(I) == getDepth(maxDepth) &&
getMOV(I) < getMOV(maxDepth) &&
Expand Down Expand Up @@ -2340,7 +2366,7 @@ void SwingSchedulerDAG::generateProlog(SMSchedule &Schedule, unsigned LastStage,
unsigned numBranches = TII->RemoveBranch(*PreheaderBB);
if (numBranches) {
SmallVector<MachineOperand, 0> Cond;
TII->InsertBranch(*PreheaderBB, PrologBBs[0], 0, Cond, DebugLoc());
TII->InsertBranch(*PreheaderBB, PrologBBs[0], nullptr, Cond, DebugLoc());
}
}

Expand Down Expand Up @@ -2432,7 +2458,7 @@ void SwingSchedulerDAG::generateEpilog(SMSchedule &Schedule, unsigned LastStage,
if (EpilogBBs.size() > 0) {
MachineBasicBlock *LastEpilogBB = EpilogBBs.back();
SmallVector<MachineOperand, 4> Cond1;
TII->InsertBranch(*LastEpilogBB, LoopExitBB, 0, Cond1, DebugLoc());
TII->InsertBranch(*LastEpilogBB, LoopExitBB, nullptr, Cond1, DebugLoc());
}
}

Expand Down Expand Up @@ -2994,7 +3020,7 @@ void SwingSchedulerDAG::addBranches(MBBVectorTy &PrologBBs,
Prolog->addSuccessor(Epilog);
Prolog->removeSuccessor(LastPro);
LastEpi->removeSuccessor(Epilog);
numAdded = TII->InsertBranch(*Prolog, Epilog, 0, Cond, DebugLoc());
numAdded = TII->InsertBranch(*Prolog, Epilog, nullptr, Cond, DebugLoc());
removePhis(Epilog, LastEpi);
// Remove the blocks that are no longer referenced.
if (LastPro != LastEpi) {
Expand All @@ -3004,7 +3030,7 @@ void SwingSchedulerDAG::addBranches(MBBVectorTy &PrologBBs,
LastPro->clear();
LastPro->eraseFromParent();
} else {
numAdded = TII->InsertBranch(*Prolog, LastPro, 0, Cond, DebugLoc());
numAdded = TII->InsertBranch(*Prolog, LastPro, nullptr, Cond, DebugLoc());
removePhis(Epilog, Prolog);
}
LastPro = Prolog;
Expand Down
19 changes: 16 additions & 3 deletions lib/ProfileData/InstrProfWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
//===----------------------------------------------------------------------===//

#include "llvm/ProfileData/InstrProfWriter.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/ProfileSummary.h"
#include "llvm/ProfileData/ProfileCommon.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace llvm;

Expand All @@ -29,6 +37,7 @@ struct PatchItem {
};

namespace llvm {

// A wrapper class to abstract writer stream with support of bytes
// back patching.
class ProfOStream {
Expand All @@ -40,6 +49,7 @@ class ProfOStream {

uint64_t tell() { return OS.tell(); }
void write(uint64_t V) { LE.write<uint64_t>(V); }

// \c patch can only be called when all data is written and flushed.
// For raw_string_ostream, the patch is done on the target string
// directly and it won't be reflected in the stream's internal buffer.
Expand All @@ -65,6 +75,7 @@ class ProfOStream {
}
}
}

// If \c OS is an instance of \c raw_fd_ostream, this field will be
// true. Otherwise, \c OS will be an raw_string_ostream.
bool IsFDOStream;
Expand Down Expand Up @@ -139,7 +150,8 @@ class InstrProfRecordWriterTrait {
}
}
};
}

} // end namespace llvm

InstrProfWriter::InstrProfWriter(bool Sparse)
: Sparse(Sparse), FunctionData(), ProfileKind(PF_Unknown),
Expand All @@ -152,6 +164,7 @@ void InstrProfWriter::setValueProfDataEndianness(
support::endianness Endianness) {
InfoObj->ValueProfDataEndianness = Endianness;
}

void InstrProfWriter::setOutputSparse(bool Sparse) {
this->Sparse = Sparse;
}
Expand Down Expand Up @@ -269,7 +282,7 @@ void InstrProfWriter::writeImpl(ProfOStream &OS) {
// structure to be serialized out (to disk or buffer).
std::unique_ptr<ProfileSummary> PS = ISB.getSummary();
setSummary(TheSummary.get(), *PS);
InfoObj->SummaryBuilder = 0;
InfoObj->SummaryBuilder = nullptr;

// Now do the final patch:
PatchItem PatchItems[] = {
Expand Down
36 changes: 28 additions & 8 deletions lib/Transforms/IPO/WholeProgramDevirt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,43 @@

#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/TypeMetadataUtils.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/PassRegistry.h"
#include "llvm/PassSupport.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/Evaluator.h"
#include "llvm/Transforms/Utils/Local.h"

#include <algorithm>
#include <cstddef>
#include <map>
#include <set>
#include <string>

using namespace llvm;
using namespace wholeprogramdevirt;
Expand Down Expand Up @@ -179,7 +197,7 @@ struct VTableSlot {
uint64_t ByteOffset;
};

}
} // end anonymous namespace

namespace llvm {

Expand All @@ -202,7 +220,7 @@ template <> struct DenseMapInfo<VTableSlot> {
}
};

}
} // end namespace llvm

namespace {

Expand Down Expand Up @@ -292,18 +310,20 @@ struct DevirtModule {

struct WholeProgramDevirt : public ModulePass {
static char ID;

WholeProgramDevirt() : ModulePass(ID) {
initializeWholeProgramDevirtPass(*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) {

bool runOnModule(Module &M) override {
if (skipModule(M))
return false;

return DevirtModule(M).run();
}
};

} // anonymous namespace
} // end anonymous namespace

INITIALIZE_PASS(WholeProgramDevirt, "wholeprogramdevirt",
"Whole program devirtualization", false, false)
Expand Down Expand Up @@ -462,7 +482,7 @@ bool DevirtModule::tryUniqueRetValOpt(
MutableArrayRef<VirtualCallSite> CallSites) {
// IsOne controls whether we look for a 0 or a 1.
auto tryUniqueRetValOptFor = [&](bool IsOne) {
const TypeMemberInfo *UniqueMember = 0;
const TypeMemberInfo *UniqueMember = nullptr;
for (const VirtualCallTarget &Target : TargetsForSlot) {
if (Target.RetVal == (IsOne ? 1 : 0)) {
if (UniqueMember)
Expand Down
Loading

0 comments on commit c986ab2

Please sign in to comment.