[llvm] r372270 - llvm-reduce: Fix inconsistencies between int/unsigned usage (standardize on int)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 15:30:25 PDT 2019
Author: dblaikie
Date: Wed Sep 18 15:30:25 2019
New Revision: 372270
URL: http://llvm.org/viewvc/llvm-project?rev=372270&view=rev
Log:
llvm-reduce: Fix inconsistencies between int/unsigned usage (standardize on int)
Modified:
llvm/trunk/tools/llvm-reduce/deltas/Delta.cpp
llvm/trunk/tools/llvm-reduce/deltas/Delta.h
llvm/trunk/tools/llvm-reduce/deltas/ReduceArguments.cpp
llvm/trunk/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
llvm/trunk/tools/llvm-reduce/deltas/ReduceFunctions.cpp
llvm/trunk/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp
llvm/trunk/tools/llvm-reduce/deltas/ReduceMetadata.cpp
Modified: llvm/trunk/tools/llvm-reduce/deltas/Delta.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-reduce/deltas/Delta.cpp?rev=372270&r1=372269&r2=372270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-reduce/deltas/Delta.cpp (original)
+++ llvm/trunk/tools/llvm-reduce/deltas/Delta.cpp Wed Sep 18 15:30:25 2019
@@ -44,8 +44,8 @@ bool IsReduced(Module &M, TestRunner &Te
}
/// Counts the amount of lines for a given file
-static unsigned getLines(StringRef Filepath) {
- unsigned Lines = 0;
+static int getLines(StringRef Filepath) {
+ int Lines = 0;
std::string CurrLine;
std::ifstream FileStream(Filepath);
@@ -66,7 +66,7 @@ static bool increaseGranularity(std::vec
if (C.end - C.begin == 0)
NewChunks.push_back(C);
else {
- unsigned Half = (C.begin + C.end) / 2;
+ int Half = (C.begin + C.end) / 2;
NewChunks.push_back({C.begin, Half});
NewChunks.push_back({Half + 1, C.end});
SplitOne = true;
@@ -88,9 +88,10 @@ static bool increaseGranularity(std::vec
/// reduces the amount of chunks that are considered interesting by the
/// given test.
void llvm::runDeltaPass(
- TestRunner &Test, unsigned Targets,
+ TestRunner &Test, int Targets,
std::function<void(const std::vector<Chunk> &, Module *)>
ExtractChunksFromModule) {
+ assert(Targets >= 0);
if (!Targets) {
errs() << "\nNothing to reduce\n";
return;
Modified: llvm/trunk/tools/llvm-reduce/deltas/Delta.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-reduce/deltas/Delta.h?rev=372270&r1=372269&r2=372270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-reduce/deltas/Delta.h (original)
+++ llvm/trunk/tools/llvm-reduce/deltas/Delta.h Wed Sep 18 15:30:25 2019
@@ -23,11 +23,11 @@
namespace llvm {
struct Chunk {
- unsigned begin;
- unsigned end;
+ int begin;
+ int end;
/// Helper function to verify if a given Target-index is inside the Chunk
- bool contains(unsigned Index) const { return Index >= begin && Index <= end; }
+ bool contains(int Index) const { return Index >= begin && Index <= end; }
void print() const {
errs() << "[" << begin;
@@ -68,7 +68,7 @@ struct Chunk {
///
/// Other implementations of the Delta Debugging algorithm can also be found in
/// the CReduce, Delta, and Lithium projects.
-void runDeltaPass(TestRunner &Test, unsigned Targets,
+void runDeltaPass(TestRunner &Test, int Targets,
std::function<void(const std::vector<Chunk> &, Module *)>
ExtractChunksFromModule);
} // namespace llvm
Modified: llvm/trunk/tools/llvm-reduce/deltas/ReduceArguments.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-reduce/deltas/ReduceArguments.cpp?rev=372270&r1=372269&r2=372270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-reduce/deltas/ReduceArguments.cpp (original)
+++ llvm/trunk/tools/llvm-reduce/deltas/ReduceArguments.cpp Wed Sep 18 15:30:25 2019
@@ -42,7 +42,7 @@ static void replaceFunctionCalls(Functio
/// accordingly. It also removes allocations of out-of-chunk arguments.
static void extractArgumentsFromModule(std::vector<Chunk> ChunksToKeep,
Module *Program) {
- unsigned I = 0, ArgCount = 0;
+ int I = 0, ArgCount = 0;
std::set<Argument *> ArgsToKeep;
std::vector<Function *> Funcs;
// Get inside-chunk arguments, as well as their parent function
@@ -50,7 +50,7 @@ static void extractArgumentsFromModule(s
if (!F.isDeclaration()) {
Funcs.push_back(&F);
for (auto &A : F.args())
- if (I < ChunksToKeep.size()) {
+ if (I < (int)ChunksToKeep.size()) {
if (ChunksToKeep[I].contains(++ArgCount))
ArgsToKeep.insert(&A);
if (ChunksToKeep[I].end == ArgCount)
@@ -120,6 +120,6 @@ static int countArguments(Module *Progra
void llvm::reduceArgumentsDeltaPass(TestRunner &Test) {
outs() << "*** Reducing Arguments...\n";
- unsigned ArgCount = countArguments(Test.getProgram());
+ int ArgCount = countArguments(Test.getProgram());
runDeltaPass(Test, ArgCount, extractArgumentsFromModule);
}
Modified: llvm/trunk/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp?rev=372270&r1=372269&r2=372270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp (original)
+++ llvm/trunk/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp Wed Sep 18 15:30:25 2019
@@ -78,12 +78,12 @@ static void removeUninterestingBBsFromSw
/// @returns the Module stripped of out-of-chunk functions
static void extractBasicBlocksFromModule(std::vector<Chunk> ChunksToKeep,
Module *Program) {
- unsigned I = 0, BBCount = 0;
+ int I = 0, BBCount = 0;
std::set<BasicBlock *> BBsToKeep;
for (auto &F : *Program)
for (auto &BB : F)
- if (I < ChunksToKeep.size()) {
+ if (I < (int)ChunksToKeep.size()) {
if (ChunksToKeep[I].contains(++BBCount))
BBsToKeep.insert(&BB);
if (ChunksToKeep[I].end == BBCount)
@@ -120,7 +120,7 @@ static void extractBasicBlocksFromModule
}
/// Counts the amount of basic blocks and prints their name & respective index
-static unsigned countBasicBlocks(Module *Program) {
+static int countBasicBlocks(Module *Program) {
// TODO: Silence index with --quiet flag
outs() << "----------------------------\n";
int BBCount = 0;
@@ -137,6 +137,6 @@ static unsigned countBasicBlocks(Module
void llvm::reduceBasicBlocksDeltaPass(TestRunner &Test) {
outs() << "*** Reducing Basic Blocks...\n";
- unsigned BBCount = countBasicBlocks(Test.getProgram());
+ int BBCount = countBasicBlocks(Test.getProgram());
runDeltaPass(Test, BBCount, extractBasicBlocksFromModule);
}
Modified: llvm/trunk/tools/llvm-reduce/deltas/ReduceFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-reduce/deltas/ReduceFunctions.cpp?rev=372270&r1=372269&r2=372270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-reduce/deltas/ReduceFunctions.cpp (original)
+++ llvm/trunk/tools/llvm-reduce/deltas/ReduceFunctions.cpp Wed Sep 18 15:30:25 2019
@@ -25,9 +25,9 @@ static void extractFunctionsFromModule(c
Module *Program) {
// Get functions inside desired chunks
std::set<Function *> FuncsToKeep;
- unsigned I = 0, FunctionCount = 0;
+ int I = 0, FunctionCount = 0;
for (auto &F : *Program)
- if (I < ChunksToKeep.size()) {
+ if (I < (int)ChunksToKeep.size()) {
if (ChunksToKeep[I].contains(++FunctionCount))
FuncsToKeep.insert(&F);
if (FunctionCount == ChunksToKeep[I].end)
@@ -57,11 +57,11 @@ static void extractFunctionsFromModule(c
/// Counts the amount of non-declaration functions and prints their
/// respective name & index
-static unsigned countFunctions(Module *Program) {
+static int countFunctions(Module *Program) {
// TODO: Silence index with --quiet flag
errs() << "----------------------------\n";
errs() << "Function Index Reference:\n";
- unsigned FunctionCount = 0;
+ int FunctionCount = 0;
for (auto &F : *Program)
errs() << "\t" << ++FunctionCount << ": " << F.getName() << "\n";
@@ -71,7 +71,7 @@ static unsigned countFunctions(Module *P
void llvm::reduceFunctionsDeltaPass(TestRunner &Test) {
errs() << "*** Reducing Functions...\n";
- unsigned Functions = countFunctions(Test.getProgram());
+ int Functions = countFunctions(Test.getProgram());
runDeltaPass(Test, Functions, extractFunctionsFromModule);
errs() << "----------------------------\n";
}
Modified: llvm/trunk/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp?rev=372270&r1=372269&r2=372270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp (original)
+++ llvm/trunk/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp Wed Sep 18 15:30:25 2019
@@ -21,9 +21,9 @@ static void extractGVsFromModule(std::ve
Module *Program) {
// Get GVs inside desired chunks
std::set<GlobalVariable *> GVsToKeep;
- unsigned I = 0, GVCount = 0;
+ int I = 0, GVCount = 0;
for (auto &GV : Program->globals())
- if (GV.hasInitializer() && I < ChunksToKeep.size()) {
+ if (GV.hasInitializer() && I < (int)ChunksToKeep.size()) {
if (ChunksToKeep[I].contains(++GVCount))
GVsToKeep.insert(&GV);
if (GVCount == ChunksToKeep[I].end)
@@ -69,6 +69,6 @@ static int countGVs(Module *Program) {
void llvm::reduceGlobalsDeltaPass(TestRunner &Test) {
outs() << "*** Reducing GVs...\n";
- unsigned GVCount = countGVs(Test.getProgram());
+ int GVCount = countGVs(Test.getProgram());
runDeltaPass(Test, GVCount, extractGVsFromModule);
}
Modified: llvm/trunk/tools/llvm-reduce/deltas/ReduceMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-reduce/deltas/ReduceMetadata.cpp?rev=372270&r1=372269&r2=372270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-reduce/deltas/ReduceMetadata.cpp (original)
+++ llvm/trunk/tools/llvm-reduce/deltas/ReduceMetadata.cpp Wed Sep 18 15:30:25 2019
@@ -21,7 +21,7 @@ using namespace llvm;
/// Adds all Unnamed Metadata Nodes that are inside desired Chunks to set
template <class T>
-static void getChunkMetadataNodes(T &MDUser, unsigned &I,
+static void getChunkMetadataNodes(T &MDUser, int &I,
const std::vector<Chunk> &ChunksToKeep,
std::set<MDNode *> &SeenNodes,
std::set<MDNode *> &NodesToKeep) {
@@ -29,10 +29,10 @@ static void getChunkMetadataNodes(T &MDU
MDUser.getAllMetadata(MDs);
for (auto &MD : MDs) {
SeenNodes.insert(MD.second);
- if (I < ChunksToKeep.size()) {
+ if (I < (int)ChunksToKeep.size()) {
if (ChunksToKeep[I].contains(SeenNodes.size()))
NodesToKeep.insert(MD.second);
- if (ChunksToKeep[I].end == SeenNodes.size())
+ if (ChunksToKeep[I].end == (int)SeenNodes.size())
++I;
}
}
@@ -55,7 +55,7 @@ static void extractMetadataFromModule(co
Module *Program) {
std::set<MDNode *> SeenNodes;
std::set<MDNode *> NodesToKeep;
- unsigned I = 0;
+ int I = 0;
// Add chunk MDNodes used by GVs, Functions, and Instructions to set
for (auto &GV : Program->globals())
@@ -84,10 +84,10 @@ static void extractMetadataFromModule(co
unsigned MetadataCount = SeenNodes.size();
std::vector<NamedMDNode *> NamedNodesToDelete;
for (auto &MD : Program->named_metadata()) {
- if (I < ChunksToKeep.size()) {
+ if (I < (int)ChunksToKeep.size()) {
if (!ChunksToKeep[I].contains(++MetadataCount))
NamedNodesToDelete.push_back(&MD);
- if (ChunksToKeep[I].end == SeenNodes.size())
+ if (ChunksToKeep[I].end == (int)SeenNodes.size())
++I;
} else
NamedNodesToDelete.push_back(&MD);
@@ -111,7 +111,7 @@ static void addMetadataToSet(T &MDUser,
}
/// Returns the amount of Named and Unnamed Metadata Nodes
-static unsigned countMetadataTargets(Module *Program) {
+static int countMetadataTargets(Module *Program) {
std::set<MDNode *> UnnamedNodes;
int NamedMetadataNodes = Program->named_metadata_size();
@@ -132,7 +132,7 @@ static unsigned countMetadataTargets(Mod
void llvm::reduceMetadataDeltaPass(TestRunner &Test) {
outs() << "*** Reducing Metadata...\n";
- unsigned MDCount = countMetadataTargets(Test.getProgram());
+ int MDCount = countMetadataTargets(Test.getProgram());
runDeltaPass(Test, MDCount, extractMetadataFromModule);
outs() << "----------------------------\n";
}
More information about the llvm-commits
mailing list