From 686d9975b6cea7d31d632ae6a691ef916fb3b1a2 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 4 Oct 2011 15:46:17 -0700 Subject: [PATCH] Add Symbol::exportedFunction member to hold llvm::Function * for app-callable version of function. --- module.cpp | 5 ++++- sym.cpp | 2 +- sym.h | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/module.cpp b/module.cpp index 4531bfd2..4744c7b4 100644 --- a/module.cpp +++ b/module.cpp @@ -497,7 +497,6 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) { } LLVM_TYPE_CONST llvm::Type *llvmType = decl->sym->type->LLVMType(g->ctx); - llvm::GlobalValue::LinkageTypes linkage = (ds->storageClass == SC_STATIC) ? llvm::GlobalValue::InternalLinkage : llvm::GlobalValue::ExternalLinkage; @@ -551,6 +550,9 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) { } bool isConst = (ds->typeQualifier & TYPEQUAL_CONST) != 0; + llvm::GlobalValue::LinkageTypes linkage = + (ds->storageClass == SC_STATIC) ? llvm::GlobalValue::InternalLinkage : + llvm::GlobalValue::ExternalLinkage; decl->sym->storagePtr = new llvm::GlobalVariable(*module, llvmType, isConst, linkage, llvmInitializer, decl->sym->name.c_str()); @@ -843,6 +845,7 @@ Module::AddFunction(DeclSpecs *ds, Declarator *decl, Stmt *code) { firstStmtPos); lEmitFunctionCode(&ec, appFunction, functionType, funSym, decl, code); if (errorCount == 0) { + funSym->exportedFunction = appFunction; if (llvm::verifyFunction(*appFunction, llvm::ReturnStatusAction) == true) { if (g->debugPrint) { diff --git a/sym.cpp b/sym.cpp index fff6a1ac..a13f8885 100644 --- a/sym.cpp +++ b/sym.cpp @@ -47,7 +47,7 @@ Symbol::Symbol(const std::string &n, SourcePos p, const Type *t, StorageClass sc) : pos(p), name(n) { storagePtr = NULL; - function = NULL; + function = exportedFunction = NULL; type = t; constValue = NULL; storageClass = sc; diff --git a/sym.h b/sym.h index 58a07b2f..33a3ff5a 100644 --- a/sym.h +++ b/sym.h @@ -83,6 +83,11 @@ public: llvm::Function *function; /*!< For symbols that represent functions, this stores the LLVM Function value for the symbol once it has been created. */ + llvm::Function *exportedFunction; + /*!< For symbols that represent functions with + 'export' qualifiers, this points to the LLVM + Function for the application-callable version + of the function. */ const Type *type; /*!< The type of the symbol; if not set by the constructor, this is set after the declaration around the symbol has been parsed. */