diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-10-01 00:49:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-10-01 00:49:24 +0000 |
commit | f1968f28869f4e0675450ae39c478a37c5b9abd6 (patch) | |
tree | 897c9408e26e67fe467db0719932983976914af9 /lib/CodeGen/CodeGenModule.h | |
parent | 60a6e0ce72a24d6247602625c631fc3dc7bfd8d4 (diff) |
Add simple interface for protecting runtime functions from name
collisions.
- Provide CodeGenModule::CreateRuntimeFunction which guarantees that
the function it creates will have the provided name in the final
module. This allows the runtime to have its functions protected
from declarations of the same name in the source code.
- One could argue that this is a reason to abuse the llvm::Module
namespace for dealing with function redeclarations. However, that
approach seems conceptually flawed to me. This one also happens to
be somewhat more efficient.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | lib/CodeGen/CodeGenModule.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 0a4a78d33c..6a201be376 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -73,6 +73,12 @@ class CodeGenModule { llvm::Function *MemMoveFn; llvm::Function *MemSetFn; + /// RuntimeFunctions - List of runtime functions whose names must be + /// protected from introducing conflicts. These functions should be + /// created unnamed, we will name them and patch up conflicts when + /// we release the module. + std::vector< std::pair<llvm::Function*, std::string> > RuntimeFunctions; + /// GlobalDeclMap - Mapping of decl names global variables we have /// already emitted. Note that the entries in this map are the /// actual globals and therefore may not be of the same type as the @@ -195,6 +201,11 @@ public: void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); } + /// CreateRuntimeFunction - Create a new runtime function whose name + /// must be protected from collisions. + llvm::Function *CreateRuntimeFunction(const llvm::FunctionType *Ty, + const std::string &Name); + void UpdateCompletedType(const TagDecl *D); llvm::Constant *EmitConstantExpr(const Expr *E, CodeGenFunction *CGF = 0); llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV, @@ -263,6 +274,8 @@ private: void EmitAliases(void); void EmitAnnotations(void); void EmitStatics(void); + + void BindRuntimeFunctions(); }; } // end namespace CodeGen } // end namespace clang |