summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/ShadowStackGC.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/lib/CodeGen/ShadowStackGC.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/lib/CodeGen/ShadowStackGC.cpp')
-rw-r--r--llvm/lib/CodeGen/ShadowStackGC.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/ShadowStackGC.cpp b/llvm/lib/CodeGen/ShadowStackGC.cpp
index 6ab0cb03c06..94dc3ed4755 100644
--- a/llvm/lib/CodeGen/ShadowStackGC.cpp
+++ b/llvm/lib/CodeGen/ShadowStackGC.cpp
@@ -194,7 +194,7 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
// Truncate the ShadowStackDescriptor if some metadata is null.
unsigned NumMeta = 0;
- SmallVector<Constant*,16> Metadata;
+ SmallVector<Constant*, 16> Metadata;
for (unsigned I = 0; I != Roots.size(); ++I) {
Constant *C = cast<Constant>(Roots[I].first->getArgOperand(1));
if (!C->isNullValue())
@@ -202,19 +202,23 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
Metadata.push_back(ConstantExpr::getBitCast(C, VoidPtr));
}
+ const Type *Int32Ty = Type::getInt32Ty(F.getContext());
+
Constant *BaseElts[] = {
- ConstantInt::get(Type::getInt32Ty(F.getContext()), Roots.size(), false),
- ConstantInt::get(Type::getInt32Ty(F.getContext()), NumMeta, false),
+ ConstantInt::get(Int32Ty, Roots.size(), false),
+ ConstantInt::get(Int32Ty, NumMeta, false),
};
Constant *DescriptorElts[] = {
- ConstantStruct::get(F.getContext(), BaseElts, 2, false),
+ ConstantStruct::get(StructType::get(Int32Ty, Int32Ty, NULL), BaseElts),
ConstantArray::get(ArrayType::get(VoidPtr, NumMeta),
Metadata.begin(), NumMeta)
};
- Constant *FrameMap = ConstantStruct::get(F.getContext(), DescriptorElts, 2,
- false);
+ Constant *FrameMap =
+ ConstantStruct::get(StructType::get(DescriptorElts[0]->getType(),
+ DescriptorElts[1]->getType(), NULL),
+ DescriptorElts);
std::string TypeName("gc_map.");
TypeName += utostr(NumMeta);
OpenPOWER on IntegriCloud