2008-07-30 03:18:29 +04:00
|
|
|
//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- C++ -*-===//
|
2007-07-11 21:01:13 +04:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 22:59:25 +03:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-07-11 21:01:13 +04:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-02-13 22:12:34 +03:00
|
|
|
// This is the internal per-translation-unit state used for llvm translation.
|
2007-07-11 21:01:13 +04:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-02-29 20:10:38 +03:00
|
|
|
#ifndef CLANG_CODEGEN_CODEGENMODULE_H
|
|
|
|
#define CLANG_CODEGEN_CODEGENMODULE_H
|
2007-07-11 21:01:13 +04:00
|
|
|
|
2009-04-14 10:00:08 +04:00
|
|
|
#include "clang/Basic/LangOptions.h"
|
2008-05-22 04:50:06 +04:00
|
|
|
#include "clang/AST/Attr.h"
|
2009-05-05 08:44:02 +04:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2009-09-11 04:07:24 +04:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2009-03-26 08:00:52 +03:00
|
|
|
#include "CGBlocks.h"
|
|
|
|
#include "CGCall.h"
|
2009-04-15 19:55:24 +04:00
|
|
|
#include "CGCXX.h"
|
2010-04-08 20:30:25 +04:00
|
|
|
#include "CGVTables.h"
|
2009-03-26 08:00:52 +03:00
|
|
|
#include "CodeGenTypes.h"
|
2009-11-13 07:25:07 +03:00
|
|
|
#include "GlobalDecl.h"
|
2009-10-07 05:06:45 +04:00
|
|
|
#include "Mangle.h"
|
2009-07-13 08:10:07 +04:00
|
|
|
#include "llvm/Module.h"
|
2007-07-11 21:01:13 +04:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2007-08-21 04:21:21 +04:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2009-02-19 02:53:56 +03:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2010-03-04 21:17:24 +03:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2009-04-01 02:37:52 +04:00
|
|
|
#include "llvm/Support/ValueHandle.h"
|
2009-01-04 05:08:04 +03:00
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
namespace llvm {
|
|
|
|
class Module;
|
|
|
|
class Constant;
|
|
|
|
class Function;
|
2008-04-19 08:17:09 +04:00
|
|
|
class GlobalValue;
|
2007-10-31 23:01:01 +03:00
|
|
|
class TargetData;
|
2008-06-01 19:54:49 +04:00
|
|
|
class FunctionType;
|
2009-08-11 21:46:57 +04:00
|
|
|
class LLVMContext;
|
2007-07-11 21:01:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace clang {
|
2010-01-10 15:58:08 +03:00
|
|
|
class TargetCodeGenInfo;
|
2007-07-11 21:01:13 +04:00
|
|
|
class ASTContext;
|
|
|
|
class FunctionDecl;
|
2008-08-25 10:18:57 +04:00
|
|
|
class IdentifierInfo;
|
2008-03-31 03:03:07 +04:00
|
|
|
class ObjCMethodDecl;
|
2008-06-01 18:13:53 +04:00
|
|
|
class ObjCImplementationDecl;
|
|
|
|
class ObjCCategoryImplDecl;
|
|
|
|
class ObjCProtocolDecl;
|
2009-02-25 01:18:39 +03:00
|
|
|
class ObjCEncodeExpr;
|
2009-02-12 20:55:02 +03:00
|
|
|
class BlockExpr;
|
2010-01-26 16:48:07 +03:00
|
|
|
class CharUnits;
|
2007-07-11 21:01:13 +04:00
|
|
|
class Decl;
|
2007-12-02 03:11:25 +03:00
|
|
|
class Expr;
|
2007-12-02 10:19:18 +03:00
|
|
|
class Stmt;
|
2008-08-11 00:25:57 +04:00
|
|
|
class StringLiteral;
|
2008-04-21 00:38:08 +04:00
|
|
|
class NamedDecl;
|
2008-07-30 03:18:29 +04:00
|
|
|
class ValueDecl;
|
2007-12-18 11:16:44 +03:00
|
|
|
class VarDecl;
|
2009-03-07 15:16:37 +03:00
|
|
|
class LangOptions;
|
2009-11-12 20:24:48 +03:00
|
|
|
class CodeGenOptions;
|
2007-12-02 04:40:18 +03:00
|
|
|
class Diagnostic;
|
2008-04-19 08:17:09 +04:00
|
|
|
class AnnotateAttr;
|
2009-04-17 05:58:57 +04:00
|
|
|
class CXXDestructorDecl;
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
namespace CodeGen {
|
|
|
|
|
2008-02-27 00:41:45 +03:00
|
|
|
class CodeGenFunction;
|
2010-08-31 11:33:07 +04:00
|
|
|
class CGCXXABI;
|
2008-05-08 12:54:20 +04:00
|
|
|
class CGDebugInfo;
|
2008-08-13 04:59:25 +04:00
|
|
|
class CGObjCRuntime;
|
2010-03-20 02:29:14 +03:00
|
|
|
class MangleBuffer;
|
2009-09-11 03:38:47 +04:00
|
|
|
|
2010-06-27 10:32:58 +04:00
|
|
|
struct OrderGlobalInits {
|
2010-06-22 01:27:42 +04:00
|
|
|
unsigned int priority;
|
|
|
|
unsigned int lex_order;
|
|
|
|
OrderGlobalInits(unsigned int p, unsigned int l)
|
2010-06-27 10:32:58 +04:00
|
|
|
: priority(p), lex_order(l) {}
|
|
|
|
|
|
|
|
bool operator==(const OrderGlobalInits &RHS) const {
|
|
|
|
return priority == RHS.priority &&
|
|
|
|
lex_order == RHS.lex_order;
|
2010-06-22 04:23:08 +04:00
|
|
|
}
|
|
|
|
|
2010-06-27 10:32:58 +04:00
|
|
|
bool operator<(const OrderGlobalInits &RHS) const {
|
|
|
|
if (priority < RHS.priority)
|
2010-06-22 04:23:08 +04:00
|
|
|
return true;
|
|
|
|
|
2010-06-27 10:32:58 +04:00
|
|
|
return priority == RHS.priority && lex_order < RHS.lex_order;
|
2010-06-22 04:23:08 +04:00
|
|
|
}
|
2010-06-27 10:32:58 +04:00
|
|
|
};
|
2010-06-22 01:27:42 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// CodeGenModule - This class organizes the cross-function state that is used
|
|
|
|
/// while generating LLVM code.
|
2009-03-04 21:17:45 +03:00
|
|
|
class CodeGenModule : public BlockModule {
|
2009-02-24 07:21:31 +03:00
|
|
|
CodeGenModule(const CodeGenModule&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const CodeGenModule&); // DO NOT IMPLEMENT
|
|
|
|
|
2009-09-13 02:45:21 +04:00
|
|
|
typedef std::vector<std::pair<llvm::Constant*, int> > CtorList;
|
2008-08-01 04:01:51 +04:00
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
ASTContext &Context;
|
2007-11-28 08:34:05 +03:00
|
|
|
const LangOptions &Features;
|
2009-11-12 20:24:48 +03:00
|
|
|
const CodeGenOptions &CodeGenOpts;
|
2007-07-11 21:01:13 +04:00
|
|
|
llvm::Module &TheModule;
|
2007-10-31 23:01:01 +03:00
|
|
|
const llvm::TargetData &TheTargetData;
|
2010-01-10 15:58:08 +03:00
|
|
|
mutable const TargetCodeGenInfo *TheTargetCodeGenInfo;
|
2007-12-02 04:40:18 +03:00
|
|
|
Diagnostic &Diags;
|
2010-08-23 01:01:12 +04:00
|
|
|
CGCXXABI &ABI;
|
2007-07-11 21:01:13 +04:00
|
|
|
CodeGenTypes Types;
|
2009-10-07 05:06:45 +04:00
|
|
|
|
2010-03-23 07:11:45 +03:00
|
|
|
/// VTables - Holds information about C++ vtables.
|
|
|
|
CodeGenVTables VTables;
|
2010-04-08 20:07:47 +04:00
|
|
|
friend class CodeGenVTables;
|
|
|
|
|
2008-08-05 22:50:11 +04:00
|
|
|
CGObjCRuntime* Runtime;
|
|
|
|
CGDebugInfo* DebugInfo;
|
2008-07-30 20:32:24 +04:00
|
|
|
|
2010-03-04 21:17:24 +03:00
|
|
|
// WeakRefReferences - A set of references that have only been seen via
|
|
|
|
// a weakref so far. This is used to remove the weak of the reference if we ever
|
|
|
|
// see a direct reference or a definition.
|
|
|
|
llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences;
|
|
|
|
|
2009-03-21 12:44:56 +03:00
|
|
|
/// DeferredDecls - This contains all the decls which have definitions but
|
|
|
|
/// which are deferred for emission and therefore should only be output if
|
|
|
|
/// they are actually used. If a decl is in this, then it is known to have
|
2010-03-20 02:29:14 +03:00
|
|
|
/// not been referenced yet.
|
|
|
|
llvm::StringMap<GlobalDecl> DeferredDecls;
|
2009-03-21 12:44:56 +03:00
|
|
|
|
|
|
|
/// DeferredDeclsToEmit - This is a list of deferred decls which we have seen
|
|
|
|
/// that *are* actually referenced. These get code generated when the module
|
|
|
|
/// is done.
|
2009-05-05 08:44:02 +04:00
|
|
|
std::vector<GlobalDecl> DeferredDeclsToEmit;
|
2009-04-16 02:08:45 +04:00
|
|
|
|
2009-02-13 23:29:50 +03:00
|
|
|
/// LLVMUsed - List of global values which are required to be
|
|
|
|
/// present in the object file; bitcast to i8*. This is used for
|
|
|
|
/// forcing visibility of symbols which may otherwise be optimized
|
|
|
|
/// out.
|
2009-04-01 02:37:52 +04:00
|
|
|
std::vector<llvm::WeakVH> LLVMUsed;
|
2009-02-13 22:12:34 +03:00
|
|
|
|
|
|
|
/// GlobalCtors - Store the list of global constructors and their respective
|
|
|
|
/// priorities to be emitted when the translation unit is complete.
|
2008-08-01 04:01:51 +04:00
|
|
|
CtorList GlobalCtors;
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GlobalDtors - Store the list of global destructors and their respective
|
|
|
|
/// priorities to be emitted when the translation unit is complete.
|
2008-08-01 04:01:51 +04:00
|
|
|
CtorList GlobalDtors;
|
|
|
|
|
2010-06-22 20:05:32 +04:00
|
|
|
/// MangledDeclNames - A map of canonical GlobalDecls to their mangled names.
|
|
|
|
llvm::DenseMap<GlobalDecl, llvm::StringRef> MangledDeclNames;
|
|
|
|
llvm::BumpPtrAllocator MangledNamesAllocator;
|
|
|
|
|
2008-04-19 03:43:57 +04:00
|
|
|
std::vector<llvm::Constant*> Annotations;
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2007-08-21 04:21:21 +04:00
|
|
|
llvm::StringMap<llvm::Constant*> CFConstantStringMap;
|
2007-11-28 08:34:05 +03:00
|
|
|
llvm::StringMap<llvm::Constant*> ConstantStringMap;
|
2010-04-19 01:01:23 +04:00
|
|
|
llvm::DenseMap<const Decl*, llvm::Value*> StaticLocalDeclMap;
|
2008-08-23 22:37:06 +04:00
|
|
|
|
2010-03-20 07:15:41 +03:00
|
|
|
/// CXXGlobalInits - Global variables with initializers that need to run
|
2009-08-09 03:24:23 +04:00
|
|
|
/// before main.
|
2010-01-08 03:50:11 +03:00
|
|
|
std::vector<llvm::Constant*> CXXGlobalInits;
|
2010-07-16 03:40:35 +04:00
|
|
|
|
|
|
|
/// When a C++ decl with an initializer is deferred, null is
|
|
|
|
/// appended to CXXGlobalInits, and the index of that null is placed
|
|
|
|
/// here so that the initializer will be performed in the correct
|
|
|
|
/// order.
|
|
|
|
llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
|
2010-06-21 22:45:05 +04:00
|
|
|
|
|
|
|
/// - Global variables with initializers whose order of initialization
|
|
|
|
/// is set by init_priority attribute.
|
2010-06-22 01:27:42 +04:00
|
|
|
|
2010-06-27 10:32:58 +04:00
|
|
|
llvm::SmallVector<std::pair<OrderGlobalInits, llvm::Function*>, 8>
|
2010-06-21 22:45:05 +04:00
|
|
|
PrioritizedCXXGlobalInits;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-03-20 07:15:41 +03:00
|
|
|
/// CXXGlobalDtors - Global destructor functions and arguments that need to
|
|
|
|
/// run on termination.
|
2010-06-19 09:52:45 +04:00
|
|
|
std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors;
|
2010-03-20 07:15:41 +03:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// CFConstantStringClassRef - Cached reference to the class for constant
|
|
|
|
/// strings. This value has type int * but is actually an Obj-C class pointer.
|
2007-08-21 04:21:21 +04:00
|
|
|
llvm::Constant *CFConstantStringClassRef;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-04-23 21:41:07 +04:00
|
|
|
/// NSConstantStringClassRef - Cached reference to the class for constant
|
|
|
|
/// strings. This value has type int * but is actually an Obj-C class pointer.
|
|
|
|
llvm::Constant *NSConstantStringClassRef;
|
|
|
|
|
2010-01-23 05:40:42 +03:00
|
|
|
/// Lazily create the Objective-C runtime
|
|
|
|
void createObjCRuntime();
|
|
|
|
|
2009-07-15 03:10:40 +04:00
|
|
|
llvm::LLVMContext &VMContext;
|
2010-07-16 04:00:15 +04:00
|
|
|
|
|
|
|
/// @name Cache for Blocks Runtime Globals
|
|
|
|
/// @{
|
|
|
|
|
2010-07-16 04:00:19 +04:00
|
|
|
const VarDecl *NSConcreteGlobalBlockDecl;
|
|
|
|
const VarDecl *NSConcreteStackBlockDecl;
|
2010-07-16 04:00:15 +04:00
|
|
|
llvm::Constant *NSConcreteGlobalBlock;
|
|
|
|
llvm::Constant *NSConcreteStackBlock;
|
2010-07-16 04:00:19 +04:00
|
|
|
|
|
|
|
const FunctionDecl *BlockObjectAssignDecl;
|
|
|
|
const FunctionDecl *BlockObjectDisposeDecl;
|
2010-07-16 04:00:15 +04:00
|
|
|
llvm::Constant *BlockObjectAssign;
|
|
|
|
llvm::Constant *BlockObjectDispose;
|
|
|
|
|
|
|
|
/// @}
|
2007-07-11 21:01:13 +04:00
|
|
|
public:
|
2009-11-12 20:24:48 +03:00
|
|
|
CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts,
|
2010-03-04 07:29:44 +03:00
|
|
|
llvm::Module &M, const llvm::TargetData &TD, Diagnostic &Diags);
|
2008-08-05 22:50:11 +04:00
|
|
|
|
2008-03-01 11:45:05 +03:00
|
|
|
~CodeGenModule();
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-05 22:50:11 +04:00
|
|
|
/// Release - Finalize LLVM code generation.
|
|
|
|
void Release();
|
2008-08-11 22:12:00 +04:00
|
|
|
|
|
|
|
/// getObjCRuntime() - Return a reference to the configured
|
|
|
|
/// Objective-C runtime.
|
2009-02-13 22:12:34 +03:00
|
|
|
CGObjCRuntime &getObjCRuntime() {
|
2010-01-23 05:40:42 +03:00
|
|
|
if (!Runtime) createObjCRuntime();
|
2009-02-13 22:12:34 +03:00
|
|
|
return *Runtime;
|
2008-08-11 22:12:00 +04:00
|
|
|
}
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-11 22:12:00 +04:00
|
|
|
/// hasObjCRuntime() - Return true iff an Objective-C runtime has
|
|
|
|
/// been configured.
|
|
|
|
bool hasObjCRuntime() { return !!Runtime; }
|
|
|
|
|
2010-08-23 01:01:12 +04:00
|
|
|
/// getCXXABI() - Return a reference to the configured C++ ABI.
|
|
|
|
CGCXXABI &getCXXABI() { return ABI; }
|
2010-05-25 23:52:27 +04:00
|
|
|
|
2010-04-19 22:15:02 +04:00
|
|
|
llvm::Value *getStaticLocalDeclAddress(const VarDecl *VD) {
|
2010-04-19 01:01:23 +04:00
|
|
|
return StaticLocalDeclMap[VD];
|
|
|
|
}
|
2010-04-19 22:15:02 +04:00
|
|
|
void setStaticLocalDeclAddress(const VarDecl *D,
|
2010-04-19 01:01:23 +04:00
|
|
|
llvm::GlobalVariable *GV) {
|
|
|
|
StaticLocalDeclMap[D] = GV;
|
|
|
|
}
|
|
|
|
|
2008-05-08 12:54:20 +04:00
|
|
|
CGDebugInfo *getDebugInfo() { return DebugInfo; }
|
2007-07-11 21:01:13 +04:00
|
|
|
ASTContext &getContext() const { return Context; }
|
2009-11-12 20:24:48 +03:00
|
|
|
const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
|
2007-11-28 08:34:05 +03:00
|
|
|
const LangOptions &getLangOptions() const { return Features; }
|
2007-07-11 21:01:13 +04:00
|
|
|
llvm::Module &getModule() const { return TheModule; }
|
|
|
|
CodeGenTypes &getTypes() { return Types; }
|
2010-03-23 07:11:45 +03:00
|
|
|
CodeGenVTables &getVTables() { return VTables; }
|
2007-12-02 04:40:18 +03:00
|
|
|
Diagnostic &getDiags() const { return Diags; }
|
2008-01-03 09:36:51 +03:00
|
|
|
const llvm::TargetData &getTargetData() const { return TheTargetData; }
|
2009-07-15 03:10:40 +04:00
|
|
|
llvm::LLVMContext &getLLVMContext() { return VMContext; }
|
2010-07-29 06:01:43 +04:00
|
|
|
const TargetCodeGenInfo &getTargetCodeGenInfo();
|
2010-03-06 03:35:14 +03:00
|
|
|
bool isTargetDarwin() const;
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2009-04-14 10:00:08 +04:00
|
|
|
/// getDeclVisibilityMode - Compute the visibility of the decl \arg D.
|
|
|
|
LangOptions::VisibilityMode getDeclVisibilityMode(const Decl *D) const;
|
|
|
|
|
|
|
|
/// setGlobalVisibility - Set the visibility for the given LLVM
|
|
|
|
/// GlobalValue.
|
|
|
|
void setGlobalVisibility(llvm::GlobalValue *GV, const Decl *D) const;
|
|
|
|
|
2010-08-04 12:34:44 +04:00
|
|
|
/// setTypeVisibility - Set the visibility for the given global
|
|
|
|
/// value which holds information about a type.
|
|
|
|
void setTypeVisibility(llvm::GlobalValue *GV, const CXXRecordDecl *D,
|
|
|
|
bool IsForRTTI) const;
|
|
|
|
|
2010-02-19 04:32:20 +03:00
|
|
|
llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) {
|
|
|
|
if (isa<CXXConstructorDecl>(GD.getDecl()))
|
|
|
|
return GetAddrOfCXXConstructor(cast<CXXConstructorDecl>(GD.getDecl()),
|
|
|
|
GD.getCtorType());
|
|
|
|
else if (isa<CXXDestructorDecl>(GD.getDecl()))
|
|
|
|
return GetAddrOfCXXDestructor(cast<CXXDestructorDecl>(GD.getDecl()),
|
|
|
|
GD.getDtorType());
|
|
|
|
else if (isa<FunctionDecl>(GD.getDecl()))
|
|
|
|
return GetAddrOfFunction(GD);
|
|
|
|
else
|
|
|
|
return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl()));
|
|
|
|
}
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfGlobalVar - Return the llvm::Constant for the address of the
|
2009-03-21 12:16:30 +03:00
|
|
|
/// given global variable. If Ty is non-null and if the global doesn't exist,
|
|
|
|
/// then it will be greated with the specified type instead of whatever the
|
|
|
|
/// normal requested type would be.
|
|
|
|
llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
|
|
|
|
const llvm::Type *Ty = 0);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2009-03-21 11:53:37 +03:00
|
|
|
/// GetAddrOfFunction - Return the address of the given function. If Ty is
|
|
|
|
/// non-null, then this function will use the specified type if it has to
|
|
|
|
/// create it.
|
2009-05-13 01:21:08 +04:00
|
|
|
llvm::Constant *GetAddrOfFunction(GlobalDecl GD,
|
2009-03-21 11:53:37 +03:00
|
|
|
const llvm::Type *Ty = 0);
|
2008-08-14 03:20:05 +04:00
|
|
|
|
2009-12-17 10:09:17 +03:00
|
|
|
/// GetAddrOfRTTIDescriptor - Get the address of the RTTI descriptor
|
|
|
|
/// for the given type.
|
2010-04-30 05:15:21 +04:00
|
|
|
llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
|
2009-12-11 05:46:30 +03:00
|
|
|
|
2010-03-23 20:17:29 +03:00
|
|
|
/// GetAddrOfThunk - Get the address of the thunk for the given global decl.
|
|
|
|
llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk);
|
|
|
|
|
2010-03-04 21:17:24 +03:00
|
|
|
/// GetWeakRefReference - Get a reference to the target of VD.
|
|
|
|
llvm::Constant *GetWeakRefReference(const ValueDecl *VD);
|
|
|
|
|
2010-01-31 04:36:53 +03:00
|
|
|
/// GetNonVirtualBaseClassOffset - Returns the offset from a derived class to
|
2010-04-25 01:27:51 +04:00
|
|
|
/// a class. Returns null if the offset is 0.
|
2010-04-25 01:23:59 +04:00
|
|
|
llvm::Constant *
|
|
|
|
GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
|
2010-08-07 10:22:56 +04:00
|
|
|
CastExpr::path_const_iterator PathBegin,
|
|
|
|
CastExpr::path_const_iterator PathEnd);
|
2010-04-25 01:23:59 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetStringForStringLiteral - Return the appropriate bytes for a string
|
|
|
|
/// literal, properly padded to match the literal type. If only the address of
|
|
|
|
/// a constant is needed consider using GetAddrOfConstantStringLiteral.
|
2008-08-14 03:20:05 +04:00
|
|
|
std::string GetStringForStringLiteral(const StringLiteral *E);
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfConstantCFString - Return a pointer to a constant CFString object
|
|
|
|
/// for the given string.
|
2009-04-01 17:55:36 +04:00
|
|
|
llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal);
|
2010-04-23 00:26:39 +04:00
|
|
|
|
|
|
|
/// GetAddrOfConstantNSString - Return a pointer to a constant NSString object
|
|
|
|
/// for the given string.
|
|
|
|
llvm::Constant *GetAddrOfConstantNSString(const StringLiteral *Literal);
|
2008-02-11 03:02:17 +03:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array
|
|
|
|
/// for the given string literal.
|
2008-08-14 03:20:05 +04:00
|
|
|
llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S);
|
2008-08-11 00:25:57 +04:00
|
|
|
|
2009-02-25 01:18:39 +03:00
|
|
|
/// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant
|
|
|
|
/// array for the given ObjCEncodeExpr node.
|
|
|
|
llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2008-08-14 03:20:05 +04:00
|
|
|
/// GetAddrOfConstantString - Returns a pointer to a character array
|
2009-02-13 22:12:34 +03:00
|
|
|
/// containing the literal. This contents are exactly that of the given
|
|
|
|
/// string, i.e. it will not be null terminated automatically; see
|
|
|
|
/// GetAddrOfConstantCString. Note that whether the result is actually a
|
|
|
|
/// pointer to an LLVM constant depends on Feature.WriteableStrings.
|
2008-08-14 03:20:05 +04:00
|
|
|
///
|
|
|
|
/// The result has pointer to array type.
|
2008-10-18 01:56:50 +04:00
|
|
|
///
|
|
|
|
/// \param GlobalName If provided, the name to use for the global
|
|
|
|
/// (if one is created).
|
|
|
|
llvm::Constant *GetAddrOfConstantString(const std::string& str,
|
|
|
|
const char *GlobalName=0);
|
2008-08-14 03:20:05 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfConstantCString - Returns a pointer to a character array
|
|
|
|
/// containing the literal and a terminating '\0' character. The result has
|
|
|
|
/// pointer to array type.
|
2008-10-18 01:56:50 +04:00
|
|
|
///
|
2009-02-13 22:12:34 +03:00
|
|
|
/// \param GlobalName If provided, the name to use for the global (if one is
|
|
|
|
/// created).
|
2008-10-18 01:56:50 +04:00
|
|
|
llvm::Constant *GetAddrOfConstantCString(const std::string &str,
|
|
|
|
const char *GlobalName=0);
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2009-04-17 03:57:24 +04:00
|
|
|
/// GetAddrOfCXXConstructor - Return the address of the constructor of the
|
|
|
|
/// given type.
|
2010-02-19 04:32:20 +03:00
|
|
|
llvm::GlobalValue *GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
|
|
|
|
CXXCtorType Type);
|
2009-04-17 05:58:57 +04:00
|
|
|
|
|
|
|
/// GetAddrOfCXXDestructor - Return the address of the constructor of the
|
|
|
|
/// given type.
|
2010-02-19 04:32:20 +03:00
|
|
|
llvm::GlobalValue *GetAddrOfCXXDestructor(const CXXDestructorDecl *D,
|
|
|
|
CXXDtorType Type);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2008-08-16 03:26:23 +04:00
|
|
|
/// getBuiltinLibFunction - Given a builtin id for a function like
|
|
|
|
/// "__builtin_fabsf", return a Function* for "fabsf".
|
2009-09-14 08:33:21 +04:00
|
|
|
llvm::Value *getBuiltinLibFunction(const FunctionDecl *FD,
|
|
|
|
unsigned BuiltinID);
|
2008-08-14 03:20:05 +04:00
|
|
|
|
2010-04-04 07:10:52 +04:00
|
|
|
llvm::Function *getMemCpyFn(const llvm::Type *DestType,
|
|
|
|
const llvm::Type *SrcType,
|
|
|
|
const llvm::Type *SizeType);
|
|
|
|
|
|
|
|
llvm::Function *getMemMoveFn(const llvm::Type *DestType,
|
|
|
|
const llvm::Type *SrcType,
|
|
|
|
const llvm::Type *SizeType);
|
|
|
|
|
|
|
|
llvm::Function *getMemSetFn(const llvm::Type *DestType,
|
|
|
|
const llvm::Type *SizeType);
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0,
|
2007-12-18 03:25:38 +03:00
|
|
|
unsigned NumTys = 0);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2008-08-16 03:26:23 +04:00
|
|
|
/// EmitTopLevelDecl - Emit code for a single top level declaration.
|
|
|
|
void EmitTopLevelDecl(Decl *D);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2009-02-13 23:29:50 +03:00
|
|
|
/// AddUsedGlobal - Add a global which should be forced to be
|
|
|
|
/// present in the object file; these are emitted to the llvm.used
|
|
|
|
/// metadata global.
|
|
|
|
void AddUsedGlobal(llvm::GlobalValue *GV);
|
|
|
|
|
2008-07-30 03:18:29 +04:00
|
|
|
void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); }
|
|
|
|
|
2010-03-20 07:15:41 +03:00
|
|
|
/// AddCXXDtorEntry - Add a destructor and object to add to the C++ global
|
|
|
|
/// destructor function.
|
2010-06-19 09:52:45 +04:00
|
|
|
void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object) {
|
|
|
|
CXXGlobalDtors.push_back(std::make_pair(DtorFn, Object));
|
|
|
|
}
|
2010-03-20 07:15:41 +03:00
|
|
|
|
2009-03-23 00:03:39 +03:00
|
|
|
/// CreateRuntimeFunction - Create a new runtime function with the specified
|
|
|
|
/// type and name.
|
|
|
|
llvm::Constant *CreateRuntimeFunction(const llvm::FunctionType *Ty,
|
2010-03-20 02:29:14 +03:00
|
|
|
llvm::StringRef Name);
|
2009-03-23 00:03:39 +03:00
|
|
|
/// CreateRuntimeVariable - Create a new runtime global variable with the
|
|
|
|
/// specified type and name.
|
|
|
|
llvm::Constant *CreateRuntimeVariable(const llvm::Type *Ty,
|
2010-03-20 02:29:14 +03:00
|
|
|
llvm::StringRef Name);
|
2008-10-01 04:49:24 +04:00
|
|
|
|
2010-07-16 04:00:15 +04:00
|
|
|
///@name Custom Blocks Runtime Interfaces
|
|
|
|
///@{
|
|
|
|
|
|
|
|
llvm::Constant *getNSConcreteGlobalBlock();
|
|
|
|
llvm::Constant *getNSConcreteStackBlock();
|
|
|
|
llvm::Constant *getBlockObjectAssign();
|
|
|
|
llvm::Constant *getBlockObjectDispose();
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
2009-04-01 06:08:13 +04:00
|
|
|
void UpdateCompletedType(const TagDecl *TD) {
|
|
|
|
// Make sure that this type is translated.
|
|
|
|
Types.UpdateCompletedType(TD);
|
|
|
|
}
|
2009-02-17 21:43:32 +03:00
|
|
|
|
|
|
|
/// EmitConstantExpr - Try to emit the given expression as a
|
|
|
|
/// constant; returns 0 if the expression cannot be emitted as a
|
|
|
|
/// constant.
|
2009-04-08 08:48:15 +04:00
|
|
|
llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType,
|
|
|
|
CodeGenFunction *CGF = 0);
|
2009-02-17 21:43:32 +03:00
|
|
|
|
2009-04-14 01:47:26 +04:00
|
|
|
/// EmitNullConstant - Return the result of value-initializing the given
|
|
|
|
/// type, i.e. a null expression of the given type. This is usually,
|
|
|
|
/// but not always, an LLVM null constant.
|
|
|
|
llvm::Constant *EmitNullConstant(QualType T);
|
|
|
|
|
2008-04-19 08:17:09 +04:00
|
|
|
llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
|
|
|
|
const AnnotateAttr *AA, unsigned LineNo);
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-16 04:56:44 +04:00
|
|
|
/// ErrorUnsupported - Print out an error that codegen doesn't support the
|
2008-09-04 07:43:08 +04:00
|
|
|
/// specified stmt yet.
|
2009-02-13 22:12:34 +03:00
|
|
|
/// \param OmitOnError - If true, then this error should only be emitted if no
|
|
|
|
/// other errors have been reported.
|
|
|
|
void ErrorUnsupported(const Stmt *S, const char *Type,
|
2008-09-04 07:43:08 +04:00
|
|
|
bool OmitOnError=false);
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-16 04:56:44 +04:00
|
|
|
/// ErrorUnsupported - Print out an error that codegen doesn't support the
|
2008-01-12 10:05:38 +03:00
|
|
|
/// specified decl yet.
|
2009-02-13 22:12:34 +03:00
|
|
|
/// \param OmitOnError - If true, then this error should only be emitted if no
|
|
|
|
/// other errors have been reported.
|
2008-09-04 07:43:08 +04:00
|
|
|
void ErrorUnsupported(const Decl *D, const char *Type,
|
|
|
|
bool OmitOnError=false);
|
2008-05-22 04:50:06 +04:00
|
|
|
|
2009-04-17 04:48:04 +04:00
|
|
|
/// SetInternalFunctionAttributes - Set the attributes on the LLVM
|
|
|
|
/// function for the given decl and function info. This applies
|
|
|
|
/// attributes necessary for handling the ABI as well as user
|
|
|
|
/// specified attributes like section.
|
|
|
|
void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F,
|
|
|
|
const CGFunctionInfo &FI);
|
2008-09-05 03:41:35 +04:00
|
|
|
|
2009-04-14 11:08:30 +04:00
|
|
|
/// SetLLVMFunctionAttributes - Set the LLVM function attributes
|
|
|
|
/// (sext, zext, etc).
|
|
|
|
void SetLLVMFunctionAttributes(const Decl *D,
|
|
|
|
const CGFunctionInfo &Info,
|
|
|
|
llvm::Function *F);
|
2008-09-10 04:41:16 +04:00
|
|
|
|
2009-04-14 12:05:55 +04:00
|
|
|
/// SetLLVMFunctionAttributesForDefinition - Set the LLVM function attributes
|
|
|
|
/// which only apply to a function definintion.
|
|
|
|
void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F);
|
|
|
|
|
2010-07-15 03:39:36 +04:00
|
|
|
/// ReturnTypeUsesSRet - Return true iff the given type uses 'sret' when used
|
2009-02-13 22:12:34 +03:00
|
|
|
/// as a return type.
|
2010-07-15 03:39:36 +04:00
|
|
|
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI);
|
|
|
|
|
|
|
|
/// ReturnTypeUsesSret - Return true iff the given type uses 'fpret' when used
|
|
|
|
/// as a return type.
|
|
|
|
bool ReturnTypeUsesFPRet(QualType ResultType);
|
2008-09-10 04:41:16 +04:00
|
|
|
|
2009-09-12 04:59:20 +04:00
|
|
|
/// ConstructAttributeList - Get the LLVM attributes and calling convention to
|
|
|
|
/// use for a particular function type.
|
|
|
|
///
|
|
|
|
/// \param Info - The function type information.
|
|
|
|
/// \param TargetDecl - The decl these attributes are being constructed
|
|
|
|
/// for. If supplied the attributes applied to this decl may contribute to the
|
|
|
|
/// function attributes and calling convention.
|
|
|
|
/// \param PAL [out] - On return, the attribute list to use.
|
|
|
|
/// \param CallingConv [out] - On return, the LLVM calling convention to use.
|
2009-02-03 01:03:45 +03:00
|
|
|
void ConstructAttributeList(const CGFunctionInfo &Info,
|
|
|
|
const Decl *TargetDecl,
|
2009-09-12 04:59:20 +04:00
|
|
|
AttributeListType &PAL,
|
|
|
|
unsigned &CallingConv);
|
2008-09-10 04:41:16 +04:00
|
|
|
|
2010-06-22 20:05:32 +04:00
|
|
|
llvm::StringRef getMangledName(GlobalDecl GD);
|
2010-06-24 04:08:06 +04:00
|
|
|
void getMangledName(GlobalDecl GD, MangleBuffer &Buffer, const BlockDecl *BD);
|
2009-04-21 21:11:58 +04:00
|
|
|
|
|
|
|
void EmitTentativeDefinition(const VarDecl *D);
|
2009-07-31 22:25:34 +04:00
|
|
|
|
Rework when and how vtables are emitted, by tracking where vtables are
"used" (e.g., we will refer to the vtable in the generated code) and
when they are defined (i.e., because we've seen the key function
definition). Previously, we were effectively tracking "potential
definitions" rather than uses, so we were a bit too eager about emitting
vtables for classes without key functions.
The new scheme:
- For every use of a vtable, Sema calls MarkVTableUsed() to indicate
the use. For example, this occurs when calling a virtual member
function of the class, defining a constructor of that class type,
dynamic_cast'ing from that type to a derived class, casting
to/through a virtual base class, etc.
- For every definition of a vtable, Sema calls MarkVTableUsed() to
indicate the definition. This happens at the end of the translation
unit for classes whose key function has been defined (so we can
delay computation of the key function; see PR6564), and will also
occur with explicit template instantiation definitions.
- For every vtable defined/used, we mark all of the virtual member
functions of that vtable as defined/used, unless we know that the key
function is in another translation unit. This instantiates virtual
member functions when needed.
- At the end of the translation unit, Sema tells CodeGen (via the
ASTConsumer) which vtables must be defined (CodeGen will define
them) and which may be used (for which CodeGen will define the
vtables lazily).
From a language perspective, both the old and the new schemes are
permissible: we're allowed to instantiate virtual member functions
whenever we want per the standard. However, all other C++ compilers
were more lazy than we were, and our eagerness was both a performance
issue (we instantiated too much) and a portability problem (we broke
Boost test cases, which now pass).
Notes:
(1) There's a ton of churn in the tests, because the order in which
vtables get emitted to IR has changed. I've tried to isolate some of
the larger tests from these issues.
(2) Some diagnostics related to
implicitly-instantiated/implicitly-defined virtual member functions
have moved to the point of first use/definition. It's better this
way.
(3) I could use a review of the places where we MarkVTableUsed, to
see if I missed any place where the language effectively requires a
vtable.
Fixes PR7114 and PR6564.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103718 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-13 20:44:06 +04:00
|
|
|
void EmitVTable(CXXRecordDecl *Class, bool DefinitionRequired);
|
|
|
|
|
2010-02-19 04:32:20 +03:00
|
|
|
llvm::GlobalVariable::LinkageTypes
|
|
|
|
getFunctionLinkage(const FunctionDecl *FD);
|
|
|
|
|
2010-05-25 08:30:21 +04:00
|
|
|
void setFunctionLinkage(const FunctionDecl *FD, llvm::GlobalValue *V) {
|
|
|
|
V->setLinkage(getFunctionLinkage(FD));
|
|
|
|
}
|
|
|
|
|
2010-04-18 00:15:18 +04:00
|
|
|
/// getVTableLinkage - Return the appropriate linkage for the vtable, VTT,
|
2010-01-06 23:27:16 +03:00
|
|
|
/// and type information of the given class.
|
2010-01-07 01:00:56 +03:00
|
|
|
static llvm::GlobalVariable::LinkageTypes
|
2010-04-18 00:15:18 +04:00
|
|
|
getVTableLinkage(const CXXRecordDecl *RD);
|
2010-01-26 16:48:07 +03:00
|
|
|
|
|
|
|
/// GetTargetTypeStoreSize - Return the store size, in character units, of
|
|
|
|
/// the given LLVM type.
|
|
|
|
CharUnits GetTargetTypeStoreSize(const llvm::Type *Ty) const;
|
2010-03-10 05:19:29 +03:00
|
|
|
|
2010-04-18 00:15:18 +04:00
|
|
|
std::vector<const CXXRecordDecl*> DeferredVTables;
|
2010-03-10 05:19:29 +03:00
|
|
|
|
2007-12-02 10:09:19 +03:00
|
|
|
private:
|
2010-03-20 02:29:14 +03:00
|
|
|
llvm::GlobalValue *GetGlobalValue(llvm::StringRef Ref);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-03-20 02:29:14 +03:00
|
|
|
llvm::Constant *GetOrCreateLLVMFunction(llvm::StringRef MangledName,
|
2009-03-23 00:03:39 +03:00
|
|
|
const llvm::Type *Ty,
|
2009-05-13 01:21:08 +04:00
|
|
|
GlobalDecl D);
|
2010-03-20 02:29:14 +03:00
|
|
|
llvm::Constant *GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
|
2009-03-23 00:03:39 +03:00
|
|
|
const llvm::PointerType *PTy,
|
|
|
|
const VarDecl *D);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-04-14 12:05:55 +04:00
|
|
|
/// SetCommonAttributes - Set attributes which are common to any
|
|
|
|
/// form of a global definition (alias, Objective-C method,
|
|
|
|
/// function, global variable).
|
2009-04-14 11:08:30 +04:00
|
|
|
///
|
2009-04-14 12:05:55 +04:00
|
|
|
/// NOTE: This should only be called for definitions.
|
|
|
|
void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV);
|
2008-09-05 03:41:35 +04:00
|
|
|
|
2009-04-14 12:05:55 +04:00
|
|
|
/// SetFunctionDefinitionAttributes - Set attributes for a global definition.
|
2009-09-09 19:08:12 +04:00
|
|
|
void SetFunctionDefinitionAttributes(const FunctionDecl *D,
|
2009-05-26 05:22:57 +04:00
|
|
|
llvm::GlobalValue *GV);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-04-14 11:08:30 +04:00
|
|
|
/// SetFunctionAttributes - Set function attributes for a function
|
|
|
|
/// declaration.
|
2010-02-06 05:44:09 +03:00
|
|
|
void SetFunctionAttributes(GlobalDecl GD,
|
2009-05-26 05:22:57 +04:00
|
|
|
llvm::Function *F,
|
|
|
|
bool IsIncompleteFunction);
|
2008-06-08 19:45:52 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// EmitGlobal - Emit code for a singal global function or var decl. Forward
|
|
|
|
/// declarations are emitted lazily.
|
2009-05-13 01:21:08 +04:00
|
|
|
void EmitGlobal(GlobalDecl D);
|
2008-08-16 03:26:23 +04:00
|
|
|
|
2009-05-13 01:21:08 +04:00
|
|
|
void EmitGlobalDefinition(GlobalDecl D);
|
2009-02-19 10:15:39 +03:00
|
|
|
|
2009-05-13 01:21:08 +04:00
|
|
|
void EmitGlobalFunctionDefinition(GlobalDecl GD);
|
2008-07-30 03:18:29 +04:00
|
|
|
void EmitGlobalVarDefinition(const VarDecl *D);
|
2010-03-20 02:29:14 +03:00
|
|
|
void EmitAliasDefinition(GlobalDecl GD);
|
2008-08-26 12:29:31 +04:00
|
|
|
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
|
2010-04-29 01:28:56 +04:00
|
|
|
void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
|
2009-04-15 19:55:24 +04:00
|
|
|
|
|
|
|
// C++ related functions.
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-19 04:32:20 +03:00
|
|
|
bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target);
|
2010-02-23 03:48:20 +03:00
|
|
|
bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
|
2010-02-19 04:32:20 +03:00
|
|
|
|
2009-04-01 04:58:25 +04:00
|
|
|
void EmitNamespace(const NamespaceDecl *D);
|
2009-04-02 09:55:18 +04:00
|
|
|
void EmitLinkageSpec(const LinkageSpecDecl *D);
|
2009-04-15 19:55:24 +04:00
|
|
|
|
|
|
|
/// EmitCXXConstructors - Emit constructors (base, complete) from a
|
|
|
|
/// C++ constructor Decl.
|
|
|
|
void EmitCXXConstructors(const CXXConstructorDecl *D);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-04-15 19:55:24 +04:00
|
|
|
/// EmitCXXConstructor - Emit a single constructor with the given type from
|
|
|
|
/// a C++ constructor Decl.
|
|
|
|
void EmitCXXConstructor(const CXXConstructorDecl *D, CXXCtorType Type);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
/// EmitCXXDestructors - Emit destructors (base, complete) from a
|
2009-04-17 05:58:57 +04:00
|
|
|
/// C++ destructor Decl.
|
|
|
|
void EmitCXXDestructors(const CXXDestructorDecl *D);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-04-17 05:58:57 +04:00
|
|
|
/// EmitCXXDestructor - Emit a single destructor with the given type from
|
|
|
|
/// a C++ destructor Decl.
|
|
|
|
void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-03-20 07:15:41 +03:00
|
|
|
/// EmitCXXGlobalInitFunc - Emit the function that initializes C++ globals.
|
2009-08-09 03:24:23 +04:00
|
|
|
void EmitCXXGlobalInitFunc();
|
2010-01-08 03:50:11 +03:00
|
|
|
|
2010-03-20 07:15:41 +03:00
|
|
|
/// EmitCXXGlobalDtorFunc - Emit the function that destroys C++ globals.
|
|
|
|
void EmitCXXGlobalDtorFunc();
|
|
|
|
|
2010-01-08 03:50:11 +03:00
|
|
|
void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D);
|
|
|
|
|
2008-08-01 04:01:51 +04:00
|
|
|
// FIXME: Hardcoding priority here is gross.
|
2009-05-13 01:21:08 +04:00
|
|
|
void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535);
|
|
|
|
void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535);
|
2008-08-01 04:01:51 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// EmitCtorList - Generates a global array of functions and priorities using
|
|
|
|
/// the given list and name. This array will have appending linkage and is
|
|
|
|
/// suitable for use as a LLVM constructor or destructor array.
|
2008-08-01 04:01:51 +04:00
|
|
|
void EmitCtorList(const CtorList &Fns, const char *GlobalName);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
|
|
|
void EmitAnnotations(void);
|
2009-02-13 23:29:50 +03:00
|
|
|
|
2010-03-27 05:52:14 +03:00
|
|
|
/// EmitFundamentalRTTIDescriptor - Emit the RTTI descriptors for the
|
|
|
|
/// given type.
|
|
|
|
void EmitFundamentalRTTIDescriptor(QualType Type);
|
|
|
|
|
|
|
|
/// EmitFundamentalRTTIDescriptors - Emit the RTTI descriptors for the
|
|
|
|
/// builtin types.
|
|
|
|
void EmitFundamentalRTTIDescriptors();
|
|
|
|
|
2009-03-10 02:53:08 +03:00
|
|
|
/// EmitDeferred - Emit any needed decls for which code generation
|
|
|
|
/// was deferred.
|
2009-02-13 23:29:50 +03:00
|
|
|
void EmitDeferred(void);
|
|
|
|
|
2009-03-10 02:53:08 +03:00
|
|
|
/// EmitLLVMUsed - Emit the llvm.used metadata used to force
|
|
|
|
/// references to global which may otherwise be optimized out.
|
2009-02-13 23:29:50 +03:00
|
|
|
void EmitLLVMUsed(void);
|
2008-10-01 04:49:24 +04:00
|
|
|
|
2010-07-07 03:57:41 +04:00
|
|
|
void EmitDeclMetadata();
|
|
|
|
|
2009-03-10 02:53:08 +03:00
|
|
|
/// MayDeferGeneration - Determine if the given decl can be emitted
|
|
|
|
/// lazily; this is only relevant for definitions. The given decl
|
|
|
|
/// must be either a function or var decl.
|
2009-02-14 00:18:01 +03:00
|
|
|
bool MayDeferGeneration(const ValueDecl *D);
|
2010-09-16 10:16:50 +04:00
|
|
|
|
|
|
|
/// SimplifyPersonality - Check whether we can use a "simpler", more
|
|
|
|
/// core exceptions personality function.
|
|
|
|
void SimplifyPersonality();
|
2007-07-11 21:01:13 +04:00
|
|
|
};
|
|
|
|
} // end namespace CodeGen
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|