summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-11-30 00:27:08 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-11-30 00:27:08 +0000
commit9e3175bb6b2c9d3d9bbb46f64c6a4e416d794e57 (patch)
tree314fff74b47d1d9631800e689a5d0db0cb6b3eea /llvm/lib
parenta5d07a79e4f4e28e0b0a09f1ad009c5053836cfc (diff)
downloadbcm5719-llvm-9e3175bb6b2c9d3d9bbb46f64c6a4e416d794e57.tar.gz
bcm5719-llvm-9e3175bb6b2c9d3d9bbb46f64c6a4e416d794e57.zip
LowerTypeTests: Deduplicate code. NFC.
llvm-svn: 319390
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/LowerTypeTests.cpp47
1 files changed, 17 insertions, 30 deletions
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index b5d0f6dd64e..8db7e1e142d 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1480,38 +1480,25 @@ void LowerTypeTestsModule::buildBitSetsFromDisjointSet(
for (auto &&MemSet : TypeMembers)
GLB.addFragment(MemSet);
- // Build the bitsets from this disjoint set.
- if (Globals.empty() || isa<GlobalVariable>(Globals[0]->getGlobal())) {
- // Build a vector of global variables with the computed layout.
- std::vector<GlobalTypeMember *> OrderedGVs(Globals.size());
- auto OGI = OrderedGVs.begin();
- for (auto &&F : GLB.Fragments) {
- for (auto &&Offset : F) {
- auto GV = dyn_cast<GlobalVariable>(Globals[Offset]->getGlobal());
- if (!GV)
- report_fatal_error("Type identifier may not contain both global "
- "variables and functions");
- *OGI++ = Globals[Offset];
- }
- }
-
- buildBitSetsFromGlobalVariables(TypeIds, OrderedGVs);
- } else {
- // Build a vector of functions with the computed layout.
- std::vector<GlobalTypeMember *> OrderedFns(Globals.size());
- auto OFI = OrderedFns.begin();
- for (auto &&F : GLB.Fragments) {
- for (auto &&Offset : F) {
- auto Fn = dyn_cast<Function>(Globals[Offset]->getGlobal());
- if (!Fn)
- report_fatal_error("Type identifier may not contain both global "
- "variables and functions");
- *OFI++ = Globals[Offset];
- }
+ // Build a vector of globals with the computed layout.
+ bool IsGlobalSet =
+ Globals.empty() || isa<GlobalVariable>(Globals[0]->getGlobal());
+ std::vector<GlobalTypeMember *> OrderedGTMs(Globals.size());
+ auto OGTMI = OrderedGTMs.begin();
+ for (auto &&F : GLB.Fragments) {
+ for (auto &&Offset : F) {
+ if (IsGlobalSet != isa<GlobalVariable>(Globals[Offset]->getGlobal()))
+ report_fatal_error("Type identifier may not contain both global "
+ "variables and functions");
+ *OGTMI++ = Globals[Offset];
}
-
- buildBitSetsFromFunctions(TypeIds, OrderedFns);
}
+
+ // Build the bitsets from this disjoint set.
+ if (IsGlobalSet)
+ buildBitSetsFromGlobalVariables(TypeIds, OrderedGTMs);
+ else
+ buildBitSetsFromFunctions(TypeIds, OrderedGTMs);
}
/// Lower all type tests in this module.
OpenPOWER on IntegriCloud