summaryrefslogtreecommitdiffstats
path: root/llvm/tools/bugpoint/ExtractFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-06-20 04:01:31 +0000
committerChris Lattner <sabre@nondot.org>2011-06-20 04:01:31 +0000
commitcc19efaa97b3e1c2988042d716577831e813fdb9 (patch)
tree3edc88953e56373d3c3f53af5360a45cc8da8156 /llvm/tools/bugpoint/ExtractFunction.cpp
parent789adbb3ed2dcbf4b8c481a86c3641b240b6425f (diff)
downloadbcm5719-llvm-cc19efaa97b3e1c2988042d716577831e813fdb9.tar.gz
bcm5719-llvm-cc19efaa97b3e1c2988042d716577831e813fdb9.zip
Revamp the "ConstantStruct::get" methods. Previously, these were scattered
all over the place in different styles and variants. Standardize on two preferred entrypoints: one that takes a StructType and ArrayRef, and one that takes StructType and varargs. In cases where there isn't a struct type convenient, we now add a ConstantStruct::getAnon method (whose name will make more sense after a few more patches land). It would be "really really nice" if the ConstantStruct::get and ConstantVector::get methods didn't make temporary std::vectors. llvm-svn: 133412
Diffstat (limited to 'llvm/tools/bugpoint/ExtractFunction.cpp')
-rw-r--r--llvm/tools/bugpoint/ExtractFunction.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/tools/bugpoint/ExtractFunction.cpp b/llvm/tools/bugpoint/ExtractFunction.cpp
index 593765cb70f..e22841aca48 100644
--- a/llvm/tools/bugpoint/ExtractFunction.cpp
+++ b/llvm/tools/bugpoint/ExtractFunction.cpp
@@ -175,13 +175,16 @@ void llvm::DeleteFunctionBody(Function *F) {
static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
assert(!TorList.empty() && "Don't create empty tor list!");
std::vector<Constant*> ArrayElts;
+ const Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext());
+
+ const StructType *STy =
+ StructType::get(Int32Ty, TorList[0].first->getType(), NULL);
for (unsigned i = 0, e = TorList.size(); i != e; ++i) {
- std::vector<Constant*> Elts;
- Elts.push_back(ConstantInt::get(
- Type::getInt32Ty(TorList[i].first->getContext()), TorList[i].second));
- Elts.push_back(TorList[i].first);
- ArrayElts.push_back(ConstantStruct::get(TorList[i].first->getContext(),
- Elts, false));
+ Constant *Elts[] = {
+ ConstantInt::get(Int32Ty, TorList[i].second),
+ TorList[i].first
+ };
+ ArrayElts.push_back(ConstantStruct::get(STy, Elts));
}
return ConstantArray::get(ArrayType::get(ArrayElts[0]->getType(),
ArrayElts.size()),
OpenPOWER on IntegriCloud