1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Use a lambda to reduce code duplication.

llvm-svn: 256050
This commit is contained in:
Rafael Espindola 2015-12-18 22:40:27 +00:00
parent 3db381761e
commit 914b00520f

View File

@ -222,35 +222,27 @@ int main(int argc, char **argv) {
}
}
// Materialize requisite global values.
if (!DeleteFn)
for (size_t i = 0, e = GVs.size(); i != e; ++i) {
GlobalValue *GV = GVs[i];
if (std::error_code EC = GV->materialize()) {
errs() << argv[0] << ": error reading input: " << EC.message() << "\n";
return 1;
}
auto Materialize = [&](GlobalValue &GV) {
if (std::error_code EC = GV.materialize()) {
errs() << argv[0] << ": error reading input: " << EC.message() << "\n";
exit(1);
}
else {
};
// Materialize requisite global values.
if (!DeleteFn) {
for (size_t i = 0, e = GVs.size(); i != e; ++i)
Materialize(*GVs[i]);
} else {
// Deleting. Materialize every GV that's *not* in GVs.
SmallPtrSet<GlobalValue *, 8> GVSet(GVs.begin(), GVs.end());
for (auto &G : M->globals()) {
if (!GVSet.count(&G)) {
if (std::error_code EC = G.materialize()) {
errs() << argv[0] << ": error reading input: " << EC.message()
<< "\n";
return 1;
}
}
if (!GVSet.count(&G))
Materialize(G);
}
for (auto &F : *M) {
if (!GVSet.count(&F)) {
if (std::error_code EC = F.materialize()) {
errs() << argv[0] << ": error reading input: " << EC.message()
<< "\n";
return 1;
}
}
if (!GVSet.count(&F))
Materialize(F);
}
}