summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-reduce
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2019-09-18 22:30:25 +0000
committerDavid Blaikie <dblaikie@gmail.com>2019-09-18 22:30:25 +0000
commitc4da7eeccde607dc7a0d9efe0ddf299aee54ef01 (patch)
tree55cad5249c06657ebf2d93d9ea53dfd1950512d9 /llvm/tools/llvm-reduce
parentb8ac93c73b618dd9bec20dc2d94ec9afb0140780 (diff)
downloadbcm5719-llvm-c4da7eeccde607dc7a0d9efe0ddf299aee54ef01.tar.gz
bcm5719-llvm-c4da7eeccde607dc7a0d9efe0ddf299aee54ef01.zip
llvm-reduce: Fix inconsistencies between int/unsigned usage (standardize on int)
llvm-svn: 372270
Diffstat (limited to 'llvm/tools/llvm-reduce')
-rw-r--r--llvm/tools/llvm-reduce/deltas/Delta.cpp9
-rw-r--r--llvm/tools/llvm-reduce/deltas/Delta.h8
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp6
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp8
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp10
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp6
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp16
7 files changed, 32 insertions, 31 deletions
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.cpp b/llvm/tools/llvm-reduce/deltas/Delta.cpp
index 0b5571f74de..0642241ddeb 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -44,8 +44,8 @@ bool IsReduced(Module &M, TestRunner &Test, SmallString<128> &CurrentFilepath) {
}
/// 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::vector<Chunk> &Chunks) {
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::vector<Chunk> &Chunks) {
/// 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;
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.h b/llvm/tools/llvm-reduce/deltas/Delta.h
index d6cf52f8d63..dbb18e4bd07 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.h
+++ b/llvm/tools/llvm-reduce/deltas/Delta.h
@@ -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
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
index 34977f33a90..f5f14b83f42 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -42,7 +42,7 @@ static void replaceFunctionCalls(Function &OldF, Function &NewF,
/// 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(std::vector<Chunk> ChunksToKeep,
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 *Program) {
void llvm::reduceArgumentsDeltaPass(TestRunner &Test) {
outs() << "*** Reducing Arguments...\n";
- unsigned ArgCount = countArguments(Test.getProgram());
+ int ArgCount = countArguments(Test.getProgram());
runDeltaPass(Test, ArgCount, extractArgumentsFromModule);
}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp b/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
index 538394eb879..1f5957ef911 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
@@ -78,12 +78,12 @@ static void removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
/// @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(std::vector<Chunk> ChunksToKeep,
}
/// 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 *Program) {
void llvm::reduceBasicBlocksDeltaPass(TestRunner &Test) {
outs() << "*** Reducing Basic Blocks...\n";
- unsigned BBCount = countBasicBlocks(Test.getProgram());
+ int BBCount = countBasicBlocks(Test.getProgram());
runDeltaPass(Test, BBCount, extractBasicBlocksFromModule);
}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp b/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
index 84dc842d972..3382f35a945 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
@@ -25,9 +25,9 @@ static void extractFunctionsFromModule(const std::vector<Chunk> &ChunksToKeep,
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(const std::vector<Chunk> &ChunksToKeep,
/// 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 *Program) {
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";
}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp b/llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp
index b2c78d17078..5732208ee0a 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp
@@ -21,9 +21,9 @@ static void extractGVsFromModule(std::vector<Chunk> ChunksToKeep,
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);
}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
index 56e69ce873d..4ea223546ef 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
@@ -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 &MDUser, unsigned &I,
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(const std::vector<Chunk> &ChunksToKeep,
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(const std::vector<Chunk> &ChunksToKeep,
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, std::set<MDNode *> &UnnamedNodes) {
}
/// 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(Module *Program) {
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";
}
OpenPOWER on IntegriCloud