Skip to content
This repository
Browse code

cache the llvm type for statics

  • Loading branch information...
commit daf0d085b6fdd93e1a3330e9654a300bc58cc9de 1 parent 3dff63b
Joe Groff authored

Showing 1 changed file with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +11 3 compiler/src/types.cpp
14 compiler/src/types.cpp
@@ -1010,6 +1010,16 @@ llvm::Type *llvmType(TypePtr t) {
1010 1010 return t->llType;
1011 1011 }
1012 1012
  1013 +llvm::StructType *llvmStaticType() {
  1014 + static llvm::StructType *theType = NULL;
  1015 + if (theType == NULL) {
  1016 + llvm::SmallVector<llvm::Type *, 2> llTypes;
  1017 + llTypes.push_back(llvmIntType(8));
  1018 + theType = llvm::StructType::get(llvm::getGlobalContext(), llTypes);
  1019 + }
  1020 + return theType;
  1021 +}
  1022 +
1013 1023 llvm::DIType llvmTypeDebugInfo(TypePtr t) {
1014 1024 if (t->llType == NULL)
1015 1025 declareLLVMType(t);
@@ -1242,9 +1252,7 @@ static void declareLLVMType(TypePtr t) {
1242 1252 break;
1243 1253 }
1244 1254 case STATIC_TYPE : {
1245   - vector<llvm::Type *> llTypes;
1246   - llTypes.push_back(llvmIntType(8));
1247   - t->llType = llvm::StructType::get(llvm::getGlobalContext(), llTypes);
  1255 + t->llType = llvmStaticType();
1248 1256 if (llvmDIBuilder != NULL)
1249 1257 t->debugInfo = (llvm::MDNode*)llvmDIBuilder->createBasicType(
1250 1258 typeName(t),

0 comments on commit daf0d08

Please sign in to comment.
Something went wrong with that request. Please try again.