Daniel Dunbar | 9c42652 | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 1 | //===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- C++ -*-===// |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 5b12ab8 | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 10 | // This is the internal per-translation-unit state used for llvm translation. |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | 2f5db8b | 2014-08-13 16:25:19 +0000 | [diff] [blame] | 14 | #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H |
| 15 | #define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 16 | |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 17 | #include "CGVTables.h" |
| 18 | #include "CodeGenTypes.h" |
Alexey Samsonov | 4b8de11 | 2014-08-01 21:35:28 +0000 | [diff] [blame] | 19 | #include "SanitizerMetadata.h" |
Dan Gohman | 75d69da | 2008-05-22 00:50:06 +0000 | [diff] [blame] | 20 | #include "clang/AST/Attr.h" |
Anders Carlsson | dae1abc | 2009-05-05 04:44:02 +0000 | [diff] [blame] | 21 | #include "clang/AST/DeclCXX.h" |
Anders Carlsson | 73fcc95 | 2009-09-11 00:07:24 +0000 | [diff] [blame] | 22 | #include "clang/AST/DeclObjC.h" |
Peter Collingbourne | ee781d5 | 2011-06-14 04:02:39 +0000 | [diff] [blame] | 23 | #include "clang/AST/GlobalDecl.h" |
Peter Collingbourne | 0ff0b37 | 2011-01-13 18:57:25 +0000 | [diff] [blame] | 24 | #include "clang/AST/Mangle.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 25 | #include "clang/Basic/ABI.h" |
| 26 | #include "clang/Basic/LangOptions.h" |
Douglas Gregor | 6ddfca9 | 2013-01-14 17:21:00 +0000 | [diff] [blame] | 27 | #include "clang/Basic/Module.h" |
Alexey Samsonov | 8d043e8 | 2014-10-15 19:57:45 +0000 | [diff] [blame] | 28 | #include "clang/Basic/SanitizerBlacklist.h" |
Chris Lattner | b6984c4 | 2007-06-20 04:44:43 +0000 | [diff] [blame] | 29 | #include "llvm/ADT/DenseMap.h" |
Douglas Gregor | 6ddfca9 | 2013-01-14 17:21:00 +0000 | [diff] [blame] | 30 | #include "llvm/ADT/SetVector.h" |
Rafael Espindola | 2e42fec | 2010-03-04 18:17:24 +0000 | [diff] [blame] | 31 | #include "llvm/ADT/SmallPtrSet.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 32 | #include "llvm/ADT/StringMap.h" |
John McCall | 882987f | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 33 | #include "llvm/IR/CallingConv.h" |
Chandler Carruth | ffd5551 | 2013-01-02 11:45:17 +0000 | [diff] [blame] | 34 | #include "llvm/IR/Module.h" |
Chandler Carruth | 61743af | 2014-03-04 11:18:19 +0000 | [diff] [blame] | 35 | #include "llvm/IR/ValueHandle.h" |
Anders Carlsson | 762e162 | 2009-01-04 02:08:04 +0000 | [diff] [blame] | 36 | |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 37 | namespace llvm { |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 38 | class Module; |
| 39 | class Constant; |
| 40 | class ConstantInt; |
| 41 | class Function; |
| 42 | class GlobalValue; |
| 43 | class DataLayout; |
| 44 | class FunctionType; |
| 45 | class LLVMContext; |
| 46 | class IndexedInstrProfReader; |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 47 | } |
Chris Lattner | 23b7eb6 | 2007-06-15 23:05:46 +0000 | [diff] [blame] | 48 | |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 49 | namespace clang { |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 50 | class TargetCodeGenInfo; |
| 51 | class ASTContext; |
| 52 | class AtomicType; |
| 53 | class FunctionDecl; |
| 54 | class IdentifierInfo; |
| 55 | class ObjCMethodDecl; |
| 56 | class ObjCImplementationDecl; |
| 57 | class ObjCCategoryImplDecl; |
| 58 | class ObjCProtocolDecl; |
| 59 | class ObjCEncodeExpr; |
| 60 | class BlockExpr; |
| 61 | class CharUnits; |
| 62 | class Decl; |
| 63 | class Expr; |
| 64 | class Stmt; |
| 65 | class InitListExpr; |
| 66 | class StringLiteral; |
| 67 | class NamedDecl; |
| 68 | class ValueDecl; |
| 69 | class VarDecl; |
| 70 | class LangOptions; |
| 71 | class CodeGenOptions; |
| 72 | class DiagnosticsEngine; |
| 73 | class AnnotateAttr; |
| 74 | class CXXDestructorDecl; |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 75 | class Module; |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 76 | class CoverageSourceInfo; |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 77 | |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 78 | namespace CodeGen { |
| 79 | |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 80 | class CallArgList; |
| 81 | class CodeGenFunction; |
| 82 | class CodeGenTBAA; |
| 83 | class CGCXXABI; |
| 84 | class CGDebugInfo; |
| 85 | class CGObjCRuntime; |
| 86 | class CGOpenCLRuntime; |
| 87 | class CGOpenMPRuntime; |
| 88 | class CGCUDARuntime; |
| 89 | class BlockFieldFlags; |
| 90 | class FunctionArgList; |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 91 | class CoverageMappingModuleGen; |
Justin Bogner | ef512b9 | 2014-01-06 22:27:43 +0000 | [diff] [blame] | 92 | |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 93 | struct OrderGlobalInits { |
| 94 | unsigned int priority; |
| 95 | unsigned int lex_order; |
| 96 | OrderGlobalInits(unsigned int p, unsigned int l) |
Chris Lattner | e000907 | 2010-06-27 06:32:58 +0000 | [diff] [blame] | 97 | : priority(p), lex_order(l) {} |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 98 | |
| 99 | bool operator==(const OrderGlobalInits &RHS) const { |
| 100 | return priority == RHS.priority && lex_order == RHS.lex_order; |
| 101 | } |
| 102 | |
| 103 | bool operator<(const OrderGlobalInits &RHS) const { |
| 104 | return std::tie(priority, lex_order) < |
| 105 | std::tie(RHS.priority, RHS.lex_order); |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | struct CodeGenTypeCache { |
| 110 | /// void |
| 111 | llvm::Type *VoidTy; |
| 112 | |
| 113 | /// i8, i16, i32, and i64 |
| 114 | llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty; |
| 115 | /// float, double |
| 116 | llvm::Type *FloatTy, *DoubleTy; |
| 117 | |
| 118 | /// int |
| 119 | llvm::IntegerType *IntTy; |
| 120 | |
| 121 | /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size. |
| 122 | union { |
| 123 | llvm::IntegerType *IntPtrTy; |
| 124 | llvm::IntegerType *SizeTy; |
| 125 | llvm::IntegerType *PtrDiffTy; |
Chris Lattner | e000907 | 2010-06-27 06:32:58 +0000 | [diff] [blame] | 126 | }; |
John McCall | e3dc170 | 2011-02-15 09:22:45 +0000 | [diff] [blame] | 127 | |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 128 | /// void* in address space 0 |
| 129 | union { |
| 130 | llvm::PointerType *VoidPtrTy; |
| 131 | llvm::PointerType *Int8PtrTy; |
John McCall | e3dc170 | 2011-02-15 09:22:45 +0000 | [diff] [blame] | 132 | }; |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 133 | |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 134 | /// void** in address space 0 |
| 135 | union { |
| 136 | llvm::PointerType *VoidPtrPtrTy; |
| 137 | llvm::PointerType *Int8PtrPtrTy; |
| 138 | }; |
| 139 | |
| 140 | /// The width of a pointer into the generic address space. |
| 141 | unsigned char PointerWidthInBits; |
| 142 | |
| 143 | /// The size and alignment of a pointer into the generic address |
| 144 | /// space. |
| 145 | union { |
| 146 | unsigned char PointerAlignInBytes; |
| 147 | unsigned char PointerSizeInBytes; |
| 148 | unsigned char SizeSizeInBytes; // sizeof(size_t) |
| 149 | }; |
| 150 | |
| 151 | llvm::CallingConv::ID RuntimeCC; |
| 152 | llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; } |
Anton Korobeynikov | d90dd79 | 2014-12-02 16:04:58 +0000 | [diff] [blame] | 153 | llvm::CallingConv::ID BuiltinCC; |
| 154 | llvm::CallingConv::ID getBuiltinCC() const { return BuiltinCC; } |
Rafael Espindola | 42ae745 | 2014-05-09 00:57:59 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 157 | struct RREntrypoints { |
| 158 | RREntrypoints() { memset(this, 0, sizeof(*this)); } |
| 159 | /// void objc_autoreleasePoolPop(void*); |
| 160 | llvm::Constant *objc_autoreleasePoolPop; |
| 161 | |
| 162 | /// void *objc_autoreleasePoolPush(void); |
| 163 | llvm::Constant *objc_autoreleasePoolPush; |
| 164 | }; |
| 165 | |
| 166 | struct ARCEntrypoints { |
| 167 | ARCEntrypoints() { memset(this, 0, sizeof(*this)); } |
| 168 | |
| 169 | /// id objc_autorelease(id); |
| 170 | llvm::Constant *objc_autorelease; |
| 171 | |
| 172 | /// id objc_autoreleaseReturnValue(id); |
| 173 | llvm::Constant *objc_autoreleaseReturnValue; |
| 174 | |
| 175 | /// void objc_copyWeak(id *dest, id *src); |
| 176 | llvm::Constant *objc_copyWeak; |
| 177 | |
| 178 | /// void objc_destroyWeak(id*); |
| 179 | llvm::Constant *objc_destroyWeak; |
| 180 | |
| 181 | /// id objc_initWeak(id*, id); |
| 182 | llvm::Constant *objc_initWeak; |
| 183 | |
| 184 | /// id objc_loadWeak(id*); |
| 185 | llvm::Constant *objc_loadWeak; |
| 186 | |
| 187 | /// id objc_loadWeakRetained(id*); |
| 188 | llvm::Constant *objc_loadWeakRetained; |
| 189 | |
| 190 | /// void objc_moveWeak(id *dest, id *src); |
| 191 | llvm::Constant *objc_moveWeak; |
| 192 | |
| 193 | /// id objc_retain(id); |
| 194 | llvm::Constant *objc_retain; |
| 195 | |
| 196 | /// id objc_retainAutorelease(id); |
| 197 | llvm::Constant *objc_retainAutorelease; |
| 198 | |
| 199 | /// id objc_retainAutoreleaseReturnValue(id); |
| 200 | llvm::Constant *objc_retainAutoreleaseReturnValue; |
| 201 | |
| 202 | /// id objc_retainAutoreleasedReturnValue(id); |
| 203 | llvm::Constant *objc_retainAutoreleasedReturnValue; |
| 204 | |
| 205 | /// id objc_retainBlock(id); |
| 206 | llvm::Constant *objc_retainBlock; |
| 207 | |
| 208 | /// void objc_release(id); |
| 209 | llvm::Constant *objc_release; |
| 210 | |
| 211 | /// id objc_storeStrong(id*, id); |
| 212 | llvm::Constant *objc_storeStrong; |
| 213 | |
| 214 | /// id objc_storeWeak(id*, id); |
| 215 | llvm::Constant *objc_storeWeak; |
| 216 | |
| 217 | /// A void(void) inline asm to use to mark that the return value of |
| 218 | /// a call will be immediately retain. |
| 219 | llvm::InlineAsm *retainAutoreleasedReturnValueMarker; |
John McCall | eff1884 | 2013-03-23 02:35:54 +0000 | [diff] [blame] | 220 | |
| 221 | /// void clang.arc.use(...); |
| 222 | llvm::Constant *clang_arc_use; |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 223 | }; |
Will Dietz | f54319c | 2013-01-18 11:30:38 +0000 | [diff] [blame] | 224 | |
Justin Bogner | e2ef2a0 | 2014-04-15 21:22:35 +0000 | [diff] [blame] | 225 | /// This class records statistics on instrumentation based profiling. |
Justin Bogner | 40b8ba1 | 2014-06-26 01:45:07 +0000 | [diff] [blame] | 226 | class InstrProfStats { |
| 227 | uint32_t VisitedInMainFile; |
| 228 | uint32_t MissingInMainFile; |
Justin Bogner | e2ef2a0 | 2014-04-15 21:22:35 +0000 | [diff] [blame] | 229 | uint32_t Visited; |
| 230 | uint32_t Missing; |
| 231 | uint32_t Mismatched; |
Justin Bogner | 40b8ba1 | 2014-06-26 01:45:07 +0000 | [diff] [blame] | 232 | |
| 233 | public: |
| 234 | InstrProfStats() |
| 235 | : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0), |
| 236 | Mismatched(0) {} |
| 237 | /// Record that we've visited a function and whether or not that function was |
| 238 | /// in the main source file. |
| 239 | void addVisited(bool MainFile) { |
| 240 | if (MainFile) |
| 241 | ++VisitedInMainFile; |
| 242 | ++Visited; |
| 243 | } |
| 244 | /// Record that a function we've visited has no profile data. |
| 245 | void addMissing(bool MainFile) { |
| 246 | if (MainFile) |
| 247 | ++MissingInMainFile; |
| 248 | ++Missing; |
| 249 | } |
| 250 | /// Record that a function we've visited has mismatched profile data. |
| 251 | void addMismatched(bool MainFile) { ++Mismatched; } |
| 252 | /// Whether or not the stats we've gathered indicate any potential problems. |
| 253 | bool hasDiagnostics() { return Missing || Mismatched; } |
| 254 | /// Report potential problems we've found to \c Diags. |
| 255 | void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile); |
Justin Bogner | e2ef2a0 | 2014-04-15 21:22:35 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 258 | /// This class organizes the cross-function state that is used while generating |
| 259 | /// LLVM code. |
John McCall | e3dc170 | 2011-02-15 09:22:45 +0000 | [diff] [blame] | 260 | class CodeGenModule : public CodeGenTypeCache { |
Aaron Ballman | abc1892 | 2015-02-15 22:54:08 +0000 | [diff] [blame] | 261 | CodeGenModule(const CodeGenModule &) = delete; |
| 262 | void operator=(const CodeGenModule &) = delete; |
Anders Carlsson | 729a820 | 2009-02-24 04:21:31 +0000 | [diff] [blame] | 263 | |
Keno Fischer | 76f4ab0 | 2014-12-30 08:12:39 +0000 | [diff] [blame] | 264 | public: |
Reid Kleckner | 563f0e8 | 2014-05-23 21:13:45 +0000 | [diff] [blame] | 265 | struct Structor { |
| 266 | Structor() : Priority(0), Initializer(nullptr), AssociatedData(nullptr) {} |
| 267 | Structor(int Priority, llvm::Constant *Initializer, |
| 268 | llvm::Constant *AssociatedData) |
| 269 | : Priority(Priority), Initializer(Initializer), |
| 270 | AssociatedData(AssociatedData) {} |
| 271 | int Priority; |
| 272 | llvm::Constant *Initializer; |
| 273 | llvm::Constant *AssociatedData; |
| 274 | }; |
| 275 | |
| 276 | typedef std::vector<Structor> CtorList; |
Daniel Dunbar | 74aa7e1 | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 277 | |
Keno Fischer | 76f4ab0 | 2014-12-30 08:12:39 +0000 | [diff] [blame] | 278 | private: |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 279 | ASTContext &Context; |
David Blaikie | bbafb8a | 2012-03-11 07:00:24 +0000 | [diff] [blame] | 280 | const LangOptions &LangOpts; |
Chandler Carruth | bc55fe2 | 2009-11-12 17:24:48 +0000 | [diff] [blame] | 281 | const CodeGenOptions &CodeGenOpts; |
Chris Lattner | 23b7eb6 | 2007-06-15 23:05:46 +0000 | [diff] [blame] | 282 | llvm::Module &TheModule; |
David Blaikie | 9c902b5 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 283 | DiagnosticsEngine &Diags; |
John McCall | c8e0170 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 284 | const llvm::DataLayout &TheDataLayout; |
| 285 | const TargetInfo &Target; |
Ahmed Charles | b898432 | 2014-03-07 20:03:18 +0000 | [diff] [blame] | 286 | std::unique_ptr<CGCXXABI> ABI; |
John McCall | c8e0170 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 287 | llvm::LLVMContext &VMContext; |
Anders Carlsson | ff971e8 | 2009-10-07 01:06:45 +0000 | [diff] [blame] | 288 | |
John McCall | c8e0170 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 289 | CodeGenTBAA *TBAA; |
| 290 | |
| 291 | mutable const TargetCodeGenInfo *TheTargetCodeGenInfo; |
| 292 | |
| 293 | // This should not be moved earlier, since its initialization depends on some |
| 294 | // of the previous reference members being already initialized and also checks |
| 295 | // if TheTargetCodeGenInfo is NULL |
| 296 | CodeGenTypes Types; |
| 297 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 298 | /// Holds information about C++ vtables. |
Anders Carlsson | a864caf | 2010-03-23 04:11:45 +0000 | [diff] [blame] | 299 | CodeGenVTables VTables; |
Douglas Gregor | bc6a434 | 2010-04-08 16:07:47 +0000 | [diff] [blame] | 300 | |
Peter Collingbourne | e1d2099 | 2011-07-27 20:29:46 +0000 | [diff] [blame] | 301 | CGObjCRuntime* ObjCRuntime; |
Peter Collingbourne | 2dbb708 | 2011-09-19 21:14:35 +0000 | [diff] [blame] | 302 | CGOpenCLRuntime* OpenCLRuntime; |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 303 | CGOpenMPRuntime* OpenMPRuntime; |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 304 | CGCUDARuntime* CUDARuntime; |
Ted Kremenek | 2c674f6 | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 305 | CGDebugInfo* DebugInfo; |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 306 | ARCEntrypoints *ARCData; |
Dan Gohman | 515a60d | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 307 | llvm::MDNode *NoObjCARCExceptionsMetadata; |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 308 | RREntrypoints *RRData; |
Justin Bogner | 837a6f6 | 2014-04-18 21:52:00 +0000 | [diff] [blame] | 309 | std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader; |
Justin Bogner | e2ef2a0 | 2014-04-15 21:22:35 +0000 | [diff] [blame] | 310 | InstrProfStats PGOStats; |
Daniel Dunbar | e49df9b5 | 2008-07-30 16:32:24 +0000 | [diff] [blame] | 311 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 312 | // A set of references that have only been seen via a weakref so far. This is |
| 313 | // used to remove the weak of the reference if we ever see a direct reference |
| 314 | // or a definition. |
Rafael Espindola | 2e42fec | 2010-03-04 18:17:24 +0000 | [diff] [blame] | 315 | llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences; |
| 316 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 317 | /// This contains all the decls which have definitions but/ which are deferred |
| 318 | /// for emission and therefore should only be output if they are actually |
| 319 | /// used. If a decl is in this, then it is known to have not been referenced |
| 320 | /// yet. |
Alp Toker | fb8d02b | 2014-06-05 22:10:59 +0000 | [diff] [blame] | 321 | std::map<StringRef, GlobalDecl> DeferredDecls; |
Daniel Dunbar | 08b26a0 | 2009-02-13 20:29:50 +0000 | [diff] [blame] | 322 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 323 | /// This is a list of deferred decls which we have seen that *are* actually |
| 324 | /// referenced. These get code generated when the module is done. |
Rafael Espindola | c0ff744 | 2013-12-09 14:59:08 +0000 | [diff] [blame] | 325 | struct DeferredGlobal { |
| 326 | DeferredGlobal(llvm::GlobalValue *GV, GlobalDecl GD) : GV(GV), GD(GD) {} |
Rafael Espindola | 6565e92 | 2015-01-23 05:26:38 +0000 | [diff] [blame] | 327 | llvm::TrackingVH<llvm::GlobalValue> GV; |
Rafael Espindola | c0ff744 | 2013-12-09 14:59:08 +0000 | [diff] [blame] | 328 | GlobalDecl GD; |
| 329 | }; |
| 330 | std::vector<DeferredGlobal> DeferredDeclsToEmit; |
| 331 | void addDeferredDeclToEmit(llvm::GlobalValue *GV, GlobalDecl GD) { |
Benjamin Kramer | 3204b15 | 2015-05-29 19:42:19 +0000 | [diff] [blame] | 332 | DeferredDeclsToEmit.emplace_back(GV, GD); |
Rafael Espindola | c0ff744 | 2013-12-09 14:59:08 +0000 | [diff] [blame] | 333 | } |
Daniel Dunbar | 7dd749e | 2009-04-15 22:08:45 +0000 | [diff] [blame] | 334 | |
Rafael Espindola | 208b5c0 | 2013-10-22 19:26:13 +0000 | [diff] [blame] | 335 | /// List of alias we have emitted. Used to make sure that what they point to |
| 336 | /// is defined once we get to the end of the of the translation unit. |
| 337 | std::vector<GlobalDecl> Aliases; |
| 338 | |
Rafael Espindola | 2e2995b | 2013-11-05 21:37:29 +0000 | [diff] [blame] | 339 | typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy; |
| 340 | ReplacementsTy Replacements; |
| 341 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 342 | /// A queue of (optional) vtables to consider emitting. |
John McCall | 6bd2a89 | 2013-01-25 22:31:03 +0000 | [diff] [blame] | 343 | std::vector<const CXXRecordDecl*> DeferredVTables; |
| 344 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 345 | /// List of global values which are required to be present in the object file; |
| 346 | /// bitcast to i8*. This is used for forcing visibility of symbols which may |
| 347 | /// otherwise be optimized out. |
Chris Lattner | f41e87f | 2009-03-31 22:37:52 +0000 | [diff] [blame] | 348 | std::vector<llvm::WeakVH> LLVMUsed; |
Rafael Espindola | 060062a | 2014-03-06 22:15:10 +0000 | [diff] [blame] | 349 | std::vector<llvm::WeakVH> LLVMCompilerUsed; |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 350 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 351 | /// Store the list of global constructors and their respective priorities to |
| 352 | /// be emitted when the translation unit is complete. |
Daniel Dunbar | 74aa7e1 | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 353 | CtorList GlobalCtors; |
| 354 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 355 | /// Store the list of global destructors and their respective priorities to be |
| 356 | /// emitted when the translation unit is complete. |
Daniel Dunbar | 74aa7e1 | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 357 | CtorList GlobalDtors; |
| 358 | |
Robert Lytton | 57765d5 | 2014-07-03 09:30:33 +0000 | [diff] [blame] | 359 | /// An ordered map of canonical GlobalDecls to their mangled names. |
| 360 | llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames; |
Alp Toker | fb8d02b | 2014-06-05 22:10:59 +0000 | [diff] [blame] | 361 | llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings; |
| 362 | |
Julien Lerouge | 5a6b698 | 2011-09-09 22:41:49 +0000 | [diff] [blame] | 363 | /// Global annotations. |
Nate Begeman | 7fab578 | 2008-04-18 23:43:57 +0000 | [diff] [blame] | 364 | std::vector<llvm::Constant*> Annotations; |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 365 | |
Julien Lerouge | 5a6b698 | 2011-09-09 22:41:49 +0000 | [diff] [blame] | 366 | /// Map used to get unique annotation strings. |
| 367 | llvm::StringMap<llvm::Constant*> AnnotationStrings; |
| 368 | |
David Blaikie | 2e80428 | 2015-04-05 22:47:07 +0000 | [diff] [blame] | 369 | llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap; |
David Majnemer | 58e5bee | 2014-03-24 21:43:36 +0000 | [diff] [blame] | 370 | |
Richard Smith | 00db2f1 | 2014-07-29 21:20:12 +0000 | [diff] [blame] | 371 | llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap; |
Eli Friedman | 1c8d2ca | 2012-03-09 03:27:46 +0000 | [diff] [blame] | 372 | llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap; |
John McCall | b88a566 | 2012-03-30 21:00:39 +0000 | [diff] [blame] | 373 | llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap; |
Richard Smith | e6c0144 | 2013-06-05 00:46:14 +0000 | [diff] [blame] | 374 | llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap; |
| 375 | |
Fariborz Jahanian | 1bed413 | 2012-01-08 19:13:23 +0000 | [diff] [blame] | 376 | llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap; |
| 377 | llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap; |
Daniel Dunbar | d644ad6 | 2008-08-23 18:37:06 +0000 | [diff] [blame] | 378 | |
Will Dietz | 949ec54 | 2013-11-08 01:09:22 +0000 | [diff] [blame] | 379 | /// Map used to get unique type descriptor constants for sanitizers. |
| 380 | llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap; |
| 381 | |
Richard Smith | df931ce | 2013-04-06 05:00:46 +0000 | [diff] [blame] | 382 | /// Map used to track internal linkage functions declared within |
| 383 | /// extern "C" regions. |
Richard Smith | f21c961 | 2013-04-13 01:28:18 +0000 | [diff] [blame] | 384 | typedef llvm::MapVector<IdentifierInfo *, |
| 385 | llvm::GlobalValue *> StaticExternCMap; |
Richard Smith | df931ce | 2013-04-06 05:00:46 +0000 | [diff] [blame] | 386 | StaticExternCMap StaticExternCValues; |
| 387 | |
Richard Smith | 2fd1d7a | 2013-04-19 16:42:07 +0000 | [diff] [blame] | 388 | /// \brief thread_local variables defined or used in this TU. |
| 389 | std::vector<std::pair<const VarDecl *, llvm::GlobalVariable *> > |
| 390 | CXXThreadLocals; |
| 391 | |
| 392 | /// \brief thread_local variables with initializers that need to run |
| 393 | /// before any thread_local variable in this TU is odr-used. |
David Majnemer | b3341ea | 2014-10-05 05:05:40 +0000 | [diff] [blame] | 394 | std::vector<llvm::Function *> CXXThreadLocalInits; |
| 395 | std::vector<llvm::GlobalVariable *> CXXThreadLocalInitVars; |
Richard Smith | 2fd1d7a | 2013-04-19 16:42:07 +0000 | [diff] [blame] | 396 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 397 | /// Global variables with initializers that need to run before main. |
David Majnemer | b3341ea | 2014-10-05 05:05:40 +0000 | [diff] [blame] | 398 | std::vector<llvm::Function *> CXXGlobalInits; |
John McCall | 70013b6 | 2010-07-15 23:40:35 +0000 | [diff] [blame] | 399 | |
| 400 | /// When a C++ decl with an initializer is deferred, null is |
| 401 | /// appended to CXXGlobalInits, and the index of that null is placed |
| 402 | /// here so that the initializer will be performed in the correct |
Reid Kleckner | e07140e | 2015-04-15 01:08:06 +0000 | [diff] [blame] | 403 | /// order. Once the decl is emitted, the index is replaced with ~0U to ensure |
| 404 | /// that we don't re-emit the initializer. |
John McCall | 70013b6 | 2010-07-15 23:40:35 +0000 | [diff] [blame] | 405 | llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition; |
Fariborz Jahanian | 9f2a4ee | 2010-06-21 18:45:05 +0000 | [diff] [blame] | 406 | |
Anton Korobeynikov | abed749 | 2012-11-06 22:44:45 +0000 | [diff] [blame] | 407 | typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData; |
| 408 | |
| 409 | struct GlobalInitPriorityCmp { |
| 410 | bool operator()(const GlobalInitData &LHS, |
| 411 | const GlobalInitData &RHS) const { |
| 412 | return LHS.first.priority < RHS.first.priority; |
| 413 | } |
| 414 | }; |
| 415 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 416 | /// Global variables with initializers whose order of initialization is set by |
| 417 | /// init_priority attribute. |
Anton Korobeynikov | abed749 | 2012-11-06 22:44:45 +0000 | [diff] [blame] | 418 | SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 419 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 420 | /// Global destructor functions and arguments that need to run on termination. |
Chris Lattner | 87233f7 | 2010-06-19 05:52:45 +0000 | [diff] [blame] | 421 | std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors; |
Daniel Dunbar | fe06df4 | 2010-03-20 04:15:41 +0000 | [diff] [blame] | 422 | |
Douglas Gregor | 6ddfca9 | 2013-01-14 17:21:00 +0000 | [diff] [blame] | 423 | /// \brief The complete set of modules that has been imported. |
| 424 | llvm::SetVector<clang::Module *> ImportedModules; |
| 425 | |
Reid Kleckner | e43f0fe | 2013-05-08 13:44:39 +0000 | [diff] [blame] | 426 | /// \brief A vector of metadata strings. |
Duncan P. N. Exon Smith | fb49491 | 2014-12-09 18:39:32 +0000 | [diff] [blame] | 427 | SmallVector<llvm::Metadata *, 16> LinkerOptionsMetadata; |
Reid Kleckner | e43f0fe | 2013-05-08 13:44:39 +0000 | [diff] [blame] | 428 | |
Douglas Gregor | abf4e0d | 2011-08-09 15:54:21 +0000 | [diff] [blame] | 429 | /// @name Cache for Objective-C runtime types |
| 430 | /// @{ |
| 431 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 432 | /// Cached reference to the class for constant strings. This value has type |
| 433 | /// int * but is actually an Obj-C class pointer. |
Fariborz Jahanian | d1b6778 | 2013-04-16 15:25:39 +0000 | [diff] [blame] | 434 | llvm::WeakVH CFConstantStringClassRef; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 435 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 436 | /// Cached reference to the class for constant strings. This value has type |
| 437 | /// int * but is actually an Obj-C class pointer. |
Fariborz Jahanian | d1b6778 | 2013-04-16 15:25:39 +0000 | [diff] [blame] | 438 | llvm::WeakVH ConstantStringClassRef; |
Fariborz Jahanian | e804c28 | 2010-04-23 17:41:07 +0000 | [diff] [blame] | 439 | |
Douglas Gregor | abf4e0d | 2011-08-09 15:54:21 +0000 | [diff] [blame] | 440 | /// \brief The LLVM type corresponding to NSConstantString. |
| 441 | llvm::StructType *NSConstantStringType; |
| 442 | |
Douglas Gregor | 636e200 | 2011-08-09 17:23:49 +0000 | [diff] [blame] | 443 | /// \brief The type used to describe the state of a fast enumeration in |
| 444 | /// Objective-C's for..in loop. |
| 445 | QualType ObjCFastEnumerationStateType; |
| 446 | |
Douglas Gregor | abf4e0d | 2011-08-09 15:54:21 +0000 | [diff] [blame] | 447 | /// @} |
| 448 | |
David Chisnall | 481e3a8 | 2010-01-23 02:40:42 +0000 | [diff] [blame] | 449 | /// Lazily create the Objective-C runtime |
| 450 | void createObjCRuntime(); |
| 451 | |
Peter Collingbourne | 2dbb708 | 2011-09-19 21:14:35 +0000 | [diff] [blame] | 452 | void createOpenCLRuntime(); |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 453 | void createOpenMPRuntime(); |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 454 | void createCUDARuntime(); |
Peter Collingbourne | 2dbb708 | 2011-09-19 21:14:35 +0000 | [diff] [blame] | 455 | |
Rafael Espindola | 4fdc175 | 2011-12-19 14:41:01 +0000 | [diff] [blame] | 456 | bool isTriviallyRecursive(const FunctionDecl *F); |
Peter Collingbourne | 4d90dba | 2013-06-05 17:49:37 +0000 | [diff] [blame] | 457 | bool shouldEmitFunction(GlobalDecl GD); |
Daniel Dunbar | 900546d | 2010-07-16 00:00:15 +0000 | [diff] [blame] | 458 | |
| 459 | /// @name Cache for Blocks Runtime Globals |
| 460 | /// @{ |
| 461 | |
| 462 | llvm::Constant *NSConcreteGlobalBlock; |
| 463 | llvm::Constant *NSConcreteStackBlock; |
Daniel Dunbar | 3348e2d | 2010-07-16 00:00:19 +0000 | [diff] [blame] | 464 | |
Daniel Dunbar | 900546d | 2010-07-16 00:00:15 +0000 | [diff] [blame] | 465 | llvm::Constant *BlockObjectAssign; |
| 466 | llvm::Constant *BlockObjectDispose; |
| 467 | |
Chris Lattner | a5f58b0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 468 | llvm::Type *BlockDescriptorType; |
| 469 | llvm::Type *GenericBlockLiteralType; |
John McCall | ad7c5c1 | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 470 | |
| 471 | struct { |
| 472 | int GlobalUniqueCount; |
| 473 | } Block; |
Will Dietz | f54319c | 2013-01-18 11:30:38 +0000 | [diff] [blame] | 474 | |
Nadav Rotem | 1da3094 | 2013-03-23 06:43:35 +0000 | [diff] [blame] | 475 | /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>) |
| 476 | llvm::Constant *LifetimeStartFn; |
| 477 | |
| 478 | /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>) |
| 479 | llvm::Constant *LifetimeEndFn; |
| 480 | |
Fariborz Jahanian | 6362803 | 2012-06-26 16:06:38 +0000 | [diff] [blame] | 481 | GlobalDecl initializedGlobalDecl; |
John McCall | ad7c5c1 | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 482 | |
Alexey Samsonov | 4b8de11 | 2014-08-01 21:35:28 +0000 | [diff] [blame] | 483 | std::unique_ptr<SanitizerMetadata> SanitizerMD; |
| 484 | |
Daniel Dunbar | 900546d | 2010-07-16 00:00:15 +0000 | [diff] [blame] | 485 | /// @} |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 486 | |
| 487 | llvm::DenseMap<const Decl *, bool> DeferredEmptyCoverageMappingDecls; |
| 488 | |
| 489 | std::unique_ptr<CoverageMappingModuleGen> CoverageMapping; |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 490 | public: |
Chandler Carruth | bc55fe2 | 2009-11-12 17:24:48 +0000 | [diff] [blame] | 491 | CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts, |
John McCall | 568d410 | 2013-04-16 22:48:20 +0000 | [diff] [blame] | 492 | llvm::Module &M, const llvm::DataLayout &TD, |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 493 | DiagnosticsEngine &Diags, |
| 494 | CoverageSourceInfo *CoverageInfo = nullptr); |
Ted Kremenek | 2c674f6 | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 495 | |
Chris Lattner | a087ff9 | 2008-03-01 08:45:05 +0000 | [diff] [blame] | 496 | ~CodeGenModule(); |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 497 | |
Rafael Espindola | c0ff744 | 2013-12-09 14:59:08 +0000 | [diff] [blame] | 498 | void clear(); |
| 499 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 500 | /// Finalize LLVM code generation. |
Ted Kremenek | 2c674f6 | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 501 | void Release(); |
Daniel Dunbar | 8d48059 | 2008-08-11 18:12:00 +0000 | [diff] [blame] | 502 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 503 | /// Return a reference to the configured Objective-C runtime. |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 504 | CGObjCRuntime &getObjCRuntime() { |
Peter Collingbourne | e1d2099 | 2011-07-27 20:29:46 +0000 | [diff] [blame] | 505 | if (!ObjCRuntime) createObjCRuntime(); |
| 506 | return *ObjCRuntime; |
Daniel Dunbar | 8d48059 | 2008-08-11 18:12:00 +0000 | [diff] [blame] | 507 | } |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 508 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 509 | /// Return true iff an Objective-C runtime has been configured. |
Peter Collingbourne | e1d2099 | 2011-07-27 20:29:46 +0000 | [diff] [blame] | 510 | bool hasObjCRuntime() { return !!ObjCRuntime; } |
Daniel Dunbar | 8d48059 | 2008-08-11 18:12:00 +0000 | [diff] [blame] | 511 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 512 | /// Return a reference to the configured OpenCL runtime. |
Peter Collingbourne | 2dbb708 | 2011-09-19 21:14:35 +0000 | [diff] [blame] | 513 | CGOpenCLRuntime &getOpenCLRuntime() { |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 514 | assert(OpenCLRuntime != nullptr); |
Peter Collingbourne | 2dbb708 | 2011-09-19 21:14:35 +0000 | [diff] [blame] | 515 | return *OpenCLRuntime; |
| 516 | } |
| 517 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 518 | /// Return a reference to the configured OpenMP runtime. |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 519 | CGOpenMPRuntime &getOpenMPRuntime() { |
| 520 | assert(OpenMPRuntime != nullptr); |
| 521 | return *OpenMPRuntime; |
| 522 | } |
| 523 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 524 | /// Return a reference to the configured CUDA runtime. |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 525 | CGCUDARuntime &getCUDARuntime() { |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 526 | assert(CUDARuntime != nullptr); |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 527 | return *CUDARuntime; |
| 528 | } |
| 529 | |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 530 | ARCEntrypoints &getARCEntrypoints() const { |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 531 | assert(getLangOpts().ObjCAutoRefCount && ARCData != nullptr); |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 532 | return *ARCData; |
| 533 | } |
| 534 | |
| 535 | RREntrypoints &getRREntrypoints() const { |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 536 | assert(RRData != nullptr); |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 537 | return *RRData; |
| 538 | } |
| 539 | |
Justin Bogner | 837a6f6 | 2014-04-18 21:52:00 +0000 | [diff] [blame] | 540 | InstrProfStats &getPGOStats() { return PGOStats; } |
| 541 | llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); } |
Justin Bogner | ef512b9 | 2014-01-06 22:27:43 +0000 | [diff] [blame] | 542 | |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 543 | CoverageMappingModuleGen *getCoverageMapping() const { |
| 544 | return CoverageMapping.get(); |
| 545 | } |
| 546 | |
Eli Friedman | 1c8d2ca | 2012-03-09 03:27:46 +0000 | [diff] [blame] | 547 | llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) { |
| 548 | return StaticLocalDeclMap[D]; |
Fariborz Jahanian | 3fef72f | 2010-04-18 21:01:23 +0000 | [diff] [blame] | 549 | } |
Fariborz Jahanian | 4d55b2d | 2010-04-19 18:15:02 +0000 | [diff] [blame] | 550 | void setStaticLocalDeclAddress(const VarDecl *D, |
Eli Friedman | 1c8d2ca | 2012-03-09 03:27:46 +0000 | [diff] [blame] | 551 | llvm::Constant *C) { |
| 552 | StaticLocalDeclMap[D] = C; |
Fariborz Jahanian | 3fef72f | 2010-04-18 21:01:23 +0000 | [diff] [blame] | 553 | } |
| 554 | |
Reid Kleckner | 453e056 | 2014-10-08 01:07:54 +0000 | [diff] [blame] | 555 | llvm::Constant * |
| 556 | getOrCreateStaticVarDecl(const VarDecl &D, |
| 557 | llvm::GlobalValue::LinkageTypes Linkage); |
| 558 | |
John McCall | b88a566 | 2012-03-30 21:00:39 +0000 | [diff] [blame] | 559 | llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) { |
| 560 | return StaticLocalDeclGuardMap[D]; |
| 561 | } |
| 562 | void setStaticLocalDeclGuardAddress(const VarDecl *D, |
| 563 | llvm::GlobalVariable *C) { |
| 564 | StaticLocalDeclGuardMap[D] = C; |
| 565 | } |
| 566 | |
Alp Toker | fb8d02b | 2014-06-05 22:10:59 +0000 | [diff] [blame] | 567 | bool lookupRepresentativeDecl(StringRef MangledName, |
| 568 | GlobalDecl &Result) const; |
| 569 | |
Fariborz Jahanian | 1bed413 | 2012-01-08 19:13:23 +0000 | [diff] [blame] | 570 | llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) { |
| 571 | return AtomicSetterHelperFnMap[Ty]; |
Fariborz Jahanian | 7ff610b | 2012-01-06 22:33:54 +0000 | [diff] [blame] | 572 | } |
Fariborz Jahanian | 1bed413 | 2012-01-08 19:13:23 +0000 | [diff] [blame] | 573 | void setAtomicSetterHelperFnMap(QualType Ty, |
Fariborz Jahanian | 7ff610b | 2012-01-06 22:33:54 +0000 | [diff] [blame] | 574 | llvm::Constant *Fn) { |
Fariborz Jahanian | 1bed413 | 2012-01-08 19:13:23 +0000 | [diff] [blame] | 575 | AtomicSetterHelperFnMap[Ty] = Fn; |
| 576 | } |
| 577 | |
| 578 | llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) { |
| 579 | return AtomicGetterHelperFnMap[Ty]; |
| 580 | } |
| 581 | void setAtomicGetterHelperFnMap(QualType Ty, |
| 582 | llvm::Constant *Fn) { |
| 583 | AtomicGetterHelperFnMap[Ty] = Fn; |
Fariborz Jahanian | 7ff610b | 2012-01-06 22:33:54 +0000 | [diff] [blame] | 584 | } |
| 585 | |
Warren Hunt | 5c2b4ea | 2014-05-23 16:07:43 +0000 | [diff] [blame] | 586 | llvm::Constant *getTypeDescriptorFromMap(QualType Ty) { |
Will Dietz | 949ec54 | 2013-11-08 01:09:22 +0000 | [diff] [blame] | 587 | return TypeDescriptorMap[Ty]; |
| 588 | } |
Warren Hunt | 5c2b4ea | 2014-05-23 16:07:43 +0000 | [diff] [blame] | 589 | void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C) { |
Will Dietz | 949ec54 | 2013-11-08 01:09:22 +0000 | [diff] [blame] | 590 | TypeDescriptorMap[Ty] = C; |
| 591 | } |
| 592 | |
Devang Patel | d6ffebb | 2011-03-07 18:45:56 +0000 | [diff] [blame] | 593 | CGDebugInfo *getModuleDebugInfo() { return DebugInfo; } |
Devang Patel | e65982c | 2011-03-07 18:29:53 +0000 | [diff] [blame] | 594 | |
Dan Gohman | 515a60d | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 595 | llvm::MDNode *getNoObjCARCExceptionsMetadata() { |
| 596 | if (!NoObjCARCExceptionsMetadata) |
Duncan P. N. Exon Smith | fb49491 | 2014-12-09 18:39:32 +0000 | [diff] [blame] | 597 | NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), None); |
Dan Gohman | 515a60d | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 598 | return NoObjCARCExceptionsMetadata; |
| 599 | } |
| 600 | |
Chris Lattner | d1af2d2 | 2007-05-29 23:17:50 +0000 | [diff] [blame] | 601 | ASTContext &getContext() const { return Context; } |
David Blaikie | bbafb8a | 2012-03-11 07:00:24 +0000 | [diff] [blame] | 602 | const LangOptions &getLangOpts() const { return LangOpts; } |
John McCall | c8e0170 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 603 | const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } |
Chris Lattner | 23b7eb6 | 2007-06-15 23:05:46 +0000 | [diff] [blame] | 604 | llvm::Module &getModule() const { return TheModule; } |
David Blaikie | 9c902b5 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 605 | DiagnosticsEngine &getDiags() const { return Diags; } |
Micah Villmow | dd31ca1 | 2012-10-08 16:25:52 +0000 | [diff] [blame] | 606 | const llvm::DataLayout &getDataLayout() const { return TheDataLayout; } |
John McCall | c8e0170 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 607 | const TargetInfo &getTarget() const { return Target; } |
Rafael Espindola | 9f83473 | 2014-09-19 01:54:22 +0000 | [diff] [blame] | 608 | const llvm::Triple &getTriple() const; |
| 609 | bool supportsCOMDAT() const; |
Rafael Espindola | dbee8a7 | 2015-01-15 21:36:08 +0000 | [diff] [blame] | 610 | void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO); |
Rafael Espindola | 9f83473 | 2014-09-19 01:54:22 +0000 | [diff] [blame] | 611 | |
Alp Toker | 8286225 | 2013-12-28 21:58:40 +0000 | [diff] [blame] | 612 | CGCXXABI &getCXXABI() const { return *ABI; } |
Owen Anderson | 170229f | 2009-07-14 23:10:40 +0000 | [diff] [blame] | 613 | llvm::LLVMContext &getLLVMContext() { return VMContext; } |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 614 | |
| 615 | bool shouldUseTBAA() const { return TBAA != nullptr; } |
John McCall | 53fcbd2 | 2011-02-26 08:07:02 +0000 | [diff] [blame] | 616 | |
John McCall | c8e0170 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 617 | const TargetCodeGenInfo &getTargetCodeGenInfo(); |
| 618 | |
| 619 | CodeGenTypes &getTypes() { return Types; } |
| 620 | |
| 621 | CodeGenVTables &getVTables() { return VTables; } |
Timur Iskhodzhanov | 88fd439 | 2013-08-21 06:25:03 +0000 | [diff] [blame] | 622 | |
Timur Iskhodzhanov | 5877663 | 2013-11-05 15:54:58 +0000 | [diff] [blame] | 623 | ItaniumVTableContext &getItaniumVTableContext() { |
| 624 | return VTables.getItaniumVTableContext(); |
Timur Iskhodzhanov | e1ebc5f | 2013-10-09 11:33:51 +0000 | [diff] [blame] | 625 | } |
John McCall | c8e0170 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 626 | |
Timur Iskhodzhanov | 5877663 | 2013-11-05 15:54:58 +0000 | [diff] [blame] | 627 | MicrosoftVTableContext &getMicrosoftVTableContext() { |
| 628 | return VTables.getMicrosoftVTableContext(); |
Timur Iskhodzhanov | 88fd439 | 2013-08-21 06:25:03 +0000 | [diff] [blame] | 629 | } |
| 630 | |
Keno Fischer | 76f4ab0 | 2014-12-30 08:12:39 +0000 | [diff] [blame] | 631 | CtorList &getGlobalCtors() { return GlobalCtors; } |
| 632 | CtorList &getGlobalDtors() { return GlobalDtors; } |
| 633 | |
Dan Gohman | 947c9af | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 634 | llvm::MDNode *getTBAAInfo(QualType QTy); |
Kostya Serebryany | 141e46f | 2012-03-26 17:03:51 +0000 | [diff] [blame] | 635 | llvm::MDNode *getTBAAInfoForVTablePtr(); |
Dan Gohman | 22695fc | 2012-09-28 21:58:29 +0000 | [diff] [blame] | 636 | llvm::MDNode *getTBAAStructInfo(QualType QTy); |
Manman Ren | c451e57 | 2013-04-04 21:53:22 +0000 | [diff] [blame] | 637 | /// Return the MDNode in the type DAG for the given struct type. |
| 638 | llvm::MDNode *getTBAAStructTypeInfo(QualType QTy); |
| 639 | /// Return the path-aware tag for given base type, access node and offset. |
| 640 | llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, |
| 641 | uint64_t O); |
Dan Gohman | 947c9af | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 642 | |
Richard Smith | e070fd2 | 2012-02-17 06:48:11 +0000 | [diff] [blame] | 643 | bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); |
| 644 | |
John McCall | a8ec7eb | 2013-03-07 21:37:17 +0000 | [diff] [blame] | 645 | bool isPaddedAtomicType(QualType type); |
| 646 | bool isPaddedAtomicType(const AtomicType *type); |
| 647 | |
Manman Ren | e1ad74e | 2013-04-11 23:02:56 +0000 | [diff] [blame] | 648 | /// Decorate the instruction with a TBAA tag. For scalar TBAA, the tag |
| 649 | /// is the same as the type. For struct-path aware TBAA, the tag |
| 650 | /// is different from the type: base type, access type and offset. |
| 651 | /// When ConvertTypeToTag is true, we create a tag based on the scalar type. |
| 652 | void DecorateInstruction(llvm::Instruction *Inst, |
| 653 | llvm::MDNode *TBAAInfo, |
| 654 | bool ConvertTypeToTag = true); |
Dan Gohman | 947c9af | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 655 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 656 | /// Emit the given number of characters as a value of type size_t. |
John McCall | 23c29fe | 2011-06-24 21:55:10 +0000 | [diff] [blame] | 657 | llvm::ConstantInt *getSize(CharUnits numChars); |
| 658 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 659 | /// Set the visibility for the given LLVM GlobalValue. |
Anders Carlsson | c6a4789 | 2011-01-29 19:39:23 +0000 | [diff] [blame] | 660 | void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const; |
Daniel Dunbar | f5f359f | 2009-04-14 06:00:08 +0000 | [diff] [blame] | 661 | |
David Majnemer | bb525f7c | 2014-10-15 22:38:23 +0000 | [diff] [blame] | 662 | /// Set the TLS mode for the given LLVM GlobalValue for the thread-local |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 663 | /// variable declaration D. |
David Majnemer | bb525f7c | 2014-10-15 22:38:23 +0000 | [diff] [blame] | 664 | void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const; |
Hans Wennborg | f60f6af | 2012-06-28 08:01:44 +0000 | [diff] [blame] | 665 | |
Anders Carlsson | 537fdce | 2011-01-29 20:59:35 +0000 | [diff] [blame] | 666 | static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) { |
| 667 | switch (V) { |
| 668 | case DefaultVisibility: return llvm::GlobalValue::DefaultVisibility; |
| 669 | case HiddenVisibility: return llvm::GlobalValue::HiddenVisibility; |
| 670 | case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility; |
| 671 | } |
| 672 | llvm_unreachable("unknown visibility!"); |
Anders Carlsson | 537fdce | 2011-01-29 20:59:35 +0000 | [diff] [blame] | 673 | } |
| 674 | |
John McCall | d432414 | 2010-02-19 01:32:20 +0000 | [diff] [blame] | 675 | llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) { |
| 676 | if (isa<CXXConstructorDecl>(GD.getDecl())) |
Rafael Espindola | 1ac0ec8 | 2014-09-11 15:42:06 +0000 | [diff] [blame] | 677 | return getAddrOfCXXStructor(cast<CXXConstructorDecl>(GD.getDecl()), |
| 678 | getFromCtorType(GD.getCtorType())); |
John McCall | d432414 | 2010-02-19 01:32:20 +0000 | [diff] [blame] | 679 | else if (isa<CXXDestructorDecl>(GD.getDecl())) |
Rafael Espindola | 1ac0ec8 | 2014-09-11 15:42:06 +0000 | [diff] [blame] | 680 | return getAddrOfCXXStructor(cast<CXXDestructorDecl>(GD.getDecl()), |
| 681 | getFromDtorType(GD.getDtorType())); |
John McCall | d432414 | 2010-02-19 01:32:20 +0000 | [diff] [blame] | 682 | else if (isa<FunctionDecl>(GD.getDecl())) |
| 683 | return GetAddrOfFunction(GD); |
| 684 | else |
| 685 | return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl())); |
| 686 | } |
| 687 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 688 | /// Will return a global variable of the given type. If a variable with a |
| 689 | /// different type already exists then a new variable with the right type |
| 690 | /// will be created and all uses of the old variable will be replaced with a |
| 691 | /// bitcast to the new variable. |
Anders Carlsson | da80af3 | 2011-01-29 18:20:20 +0000 | [diff] [blame] | 692 | llvm::GlobalVariable * |
Chris Lattner | 01cf8db | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 693 | CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, |
Anders Carlsson | da80af3 | 2011-01-29 18:20:20 +0000 | [diff] [blame] | 694 | llvm::GlobalValue::LinkageTypes Linkage); |
| 695 | |
Alexey Samsonov | 1444bb9 | 2014-10-17 00:20:19 +0000 | [diff] [blame] | 696 | llvm::Function * |
| 697 | CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name, |
| 698 | SourceLocation Loc = SourceLocation(), |
| 699 | bool TLS = false); |
David Majnemer | b3341ea | 2014-10-05 05:05:40 +0000 | [diff] [blame] | 700 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 701 | /// Return the address space of the underlying global variable for D, as |
| 702 | /// determined by its declaration. Normally this is the same as the address |
| 703 | /// space of D's type, but in CUDA, address spaces are associated with |
| 704 | /// declarations, not types. |
Peter Collingbourne | f44bdf9 | 2012-05-20 21:08:35 +0000 | [diff] [blame] | 705 | unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace); |
| 706 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 707 | /// Return the llvm::Constant for the address of the given global variable. |
| 708 | /// If Ty is non-null and if the global doesn't exist, then it will be greated |
| 709 | /// with the specified type instead of whatever the normal requested type |
| 710 | /// would be. |
Chris Lattner | 149927c | 2009-03-21 09:16:30 +0000 | [diff] [blame] | 711 | llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D, |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 712 | llvm::Type *Ty = nullptr); |
Daniel Dunbar | 9c42652 | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 713 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 714 | /// Return the address of the given function. If Ty is non-null, then this |
| 715 | /// function will use the specified type if it has to create it. |
Rafael Espindola | 94abb8f | 2013-12-09 04:29:47 +0000 | [diff] [blame] | 716 | llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = 0, |
| 717 | bool ForVTable = false, |
| 718 | bool DontDefer = false); |
Daniel Dunbar | c4baa06 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 719 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 720 | /// Get the address of the RTTI descriptor for the given type. |
John McCall | 48bf349 | 2010-04-30 01:15:21 +0000 | [diff] [blame] | 721 | llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false); |
Anders Carlsson | fd7dfeb | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 722 | |
David Majnemer | 37b417f | 2015-03-29 21:55:10 +0000 | [diff] [blame] | 723 | llvm::Constant *getAddrOfCXXCatchHandlerType(QualType Ty, |
| 724 | QualType CatchHandlerType); |
David Majnemer | 443250f | 2015-03-17 20:35:00 +0000 | [diff] [blame] | 725 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 726 | /// Get the address of a uuid descriptor . |
Nico Weber | cf4ff586 | 2012-10-11 10:13:44 +0000 | [diff] [blame] | 727 | llvm::Constant *GetAddrOfUuidDescriptor(const CXXUuidofExpr* E); |
| 728 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 729 | /// Get the address of the thunk for the given global decl. |
Anders Carlsson | fe8a993 | 2011-02-06 17:15:43 +0000 | [diff] [blame] | 730 | llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk); |
Anders Carlsson | cd836f0 | 2010-03-23 17:17:29 +0000 | [diff] [blame] | 731 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 732 | /// Get a reference to the target of VD. |
Rafael Espindola | 2e42fec | 2010-03-04 18:17:24 +0000 | [diff] [blame] | 733 | llvm::Constant *GetWeakRefReference(const ValueDecl *VD); |
| 734 | |
David Majnemer | c1709d3 | 2015-06-23 07:31:11 +0000 | [diff] [blame^] | 735 | CharUnits |
| 736 | computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass, |
| 737 | CastExpr::path_const_iterator Start, |
| 738 | CastExpr::path_const_iterator End); |
| 739 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 740 | /// Returns the offset from a derived class to a class. Returns null if the |
| 741 | /// offset is 0. |
Anders Carlsson | 8a64c1c | 2010-04-24 21:23:59 +0000 | [diff] [blame] | 742 | llvm::Constant * |
| 743 | GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, |
John McCall | cf14216 | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 744 | CastExpr::path_const_iterator PathBegin, |
| 745 | CastExpr::path_const_iterator PathEnd); |
John McCall | ad7c5c1 | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 746 | |
John McCall | f9b056b | 2011-03-31 08:03:29 +0000 | [diff] [blame] | 747 | /// A pair of helper functions for a __block variable. |
| 748 | class ByrefHelpers : public llvm::FoldingSetNode { |
| 749 | public: |
| 750 | llvm::Constant *CopyHelper; |
| 751 | llvm::Constant *DisposeHelper; |
| 752 | |
| 753 | /// The alignment of the field. This is important because |
| 754 | /// different offsets to the field within the byref struct need to |
| 755 | /// have different helper functions. |
| 756 | CharUnits Alignment; |
| 757 | |
| 758 | ByrefHelpers(CharUnits alignment) : Alignment(alignment) {} |
| 759 | virtual ~ByrefHelpers(); |
| 760 | |
| 761 | void Profile(llvm::FoldingSetNodeID &id) const { |
| 762 | id.AddInteger(Alignment.getQuantity()); |
| 763 | profileImpl(id); |
| 764 | } |
| 765 | virtual void profileImpl(llvm::FoldingSetNodeID &id) const = 0; |
| 766 | |
| 767 | virtual bool needsCopy() const { return true; } |
| 768 | virtual void emitCopy(CodeGenFunction &CGF, |
| 769 | llvm::Value *dest, llvm::Value *src) = 0; |
| 770 | |
| 771 | virtual bool needsDispose() const { return true; } |
| 772 | virtual void emitDispose(CodeGenFunction &CGF, llvm::Value *field) = 0; |
| 773 | }; |
| 774 | |
| 775 | llvm::FoldingSet<ByrefHelpers> ByrefHelpersCache; |
John McCall | ad7c5c1 | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 776 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 777 | /// Fetches the global unique block count. |
John McCall | 147d021 | 2011-02-22 22:38:33 +0000 | [diff] [blame] | 778 | int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; } |
Fariborz Jahanian | 6362803 | 2012-06-26 16:06:38 +0000 | [diff] [blame] | 779 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 780 | /// Fetches the type of a generic block descriptor. |
Chris Lattner | a5f58b0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 781 | llvm::Type *getBlockDescriptorType(); |
John McCall | ad7c5c1 | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 782 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 783 | /// The type of a generic block literal. |
Chris Lattner | a5f58b0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 784 | llvm::Type *getGenericBlockLiteralType(); |
John McCall | ad7c5c1 | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 785 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 786 | /// Gets the address of a block which requires no captures. |
John McCall | ad7c5c1 | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 787 | llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *); |
Anders Carlsson | 8a64c1c | 2010-04-24 21:23:59 +0000 | [diff] [blame] | 788 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 789 | /// Return a pointer to a constant CFString object for the given string. |
Steve Naroff | e14b368 | 2009-04-01 13:55:36 +0000 | [diff] [blame] | 790 | llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal); |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 791 | |
| 792 | /// Return a pointer to a constant NSString object for the given string. Or a |
| 793 | /// user defined String object as defined via |
Fariborz Jahanian | 50c925f | 2010-10-19 17:19:29 +0000 | [diff] [blame] | 794 | /// -fconstant-string-class=class_name option. |
David Blaikie | 1ed728c | 2015-04-05 22:45:47 +0000 | [diff] [blame] | 795 | llvm::GlobalVariable *GetAddrOfConstantString(const StringLiteral *Literal); |
Chris Lattner | 36fc879 | 2008-02-11 00:02:17 +0000 | [diff] [blame] | 796 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 797 | /// Return a constant array for the given string. |
Eli Friedman | fcec630 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 798 | llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E); |
| 799 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 800 | /// Return a pointer to a constant array for the given string literal. |
Alexey Samsonov | b2cc23d | 2014-07-10 22:18:36 +0000 | [diff] [blame] | 801 | llvm::GlobalVariable * |
Alexey Bataev | ec47478 | 2014-10-09 08:45:04 +0000 | [diff] [blame] | 802 | GetAddrOfConstantStringFromLiteral(const StringLiteral *S, |
| 803 | StringRef Name = ".str"); |
Daniel Dunbar | 6dfdf8c | 2008-08-10 20:25:57 +0000 | [diff] [blame] | 804 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 805 | /// Return a pointer to a constant array for the given ObjCEncodeExpr node. |
Alexey Samsonov | b2cc23d | 2014-07-10 22:18:36 +0000 | [diff] [blame] | 806 | llvm::GlobalVariable * |
| 807 | GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 808 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 809 | /// Returns a pointer to a character array containing the literal and a |
| 810 | /// terminating '\0' character. The result has pointer to array type. |
Daniel Dunbar | dfcf599 | 2008-10-17 21:56:50 +0000 | [diff] [blame] | 811 | /// |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 812 | /// \param GlobalName If provided, the name to use for the global (if one is |
| 813 | /// created). |
Alexey Samsonov | b2cc23d | 2014-07-10 22:18:36 +0000 | [diff] [blame] | 814 | llvm::GlobalVariable * |
| 815 | GetAddrOfConstantCString(const std::string &Str, |
| 816 | const char *GlobalName = nullptr, |
| 817 | unsigned Alignment = 0); |
Richard Smith | 2d988f0 | 2011-11-22 22:48:32 +0000 | [diff] [blame] | 818 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 819 | /// Returns a pointer to a constant global variable for the given file-scope |
| 820 | /// compound literal expression. |
Richard Smith | 2d988f0 | 2011-11-22 22:48:32 +0000 | [diff] [blame] | 821 | llvm::Constant *GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr*E); |
Richard Smith | e6c0144 | 2013-06-05 00:46:14 +0000 | [diff] [blame] | 822 | |
| 823 | /// \brief Returns a pointer to a global variable representing a temporary |
| 824 | /// with static or thread storage duration. |
| 825 | llvm::Constant *GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, |
| 826 | const Expr *Inner); |
| 827 | |
Douglas Gregor | 636e200 | 2011-08-09 17:23:49 +0000 | [diff] [blame] | 828 | /// \brief Retrieve the record type that describes the state of an |
| 829 | /// Objective-C fast enumeration loop (for..in). |
| 830 | QualType getObjCFastEnumerationStateType(); |
Rafael Espindola | 8d2a19b | 2014-09-08 16:01:27 +0000 | [diff] [blame] | 831 | |
Rafael Espindola | 5368618 | 2014-09-15 19:34:18 +0000 | [diff] [blame] | 832 | // Produce code for this constructor/destructor. This method doesn't try |
| 833 | // to apply any ABI rules about which other constructors/destructors |
| 834 | // are needed or if they are alias to each other. |
| 835 | llvm::Function *codegenCXXStructor(const CXXMethodDecl *MD, |
| 836 | StructorType Type); |
| 837 | |
Rafael Espindola | 1ac0ec8 | 2014-09-11 15:42:06 +0000 | [diff] [blame] | 838 | /// Return the address of the constructor/destructor of the given type. |
Rafael Espindola | 8d2a19b | 2014-09-08 16:01:27 +0000 | [diff] [blame] | 839 | llvm::GlobalValue * |
| 840 | getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type, |
| 841 | const CGFunctionInfo *FnInfo = nullptr, |
| 842 | llvm::FunctionType *FnType = nullptr, |
| 843 | bool DontDefer = false); |
| 844 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 845 | /// Given a builtin id for a function like "__builtin_fabsf", return a |
| 846 | /// Function* for "fabsf". |
Daniel Dunbar | ff0553e | 2009-09-14 04:33:21 +0000 | [diff] [blame] | 847 | llvm::Value *getBuiltinLibFunction(const FunctionDecl *FD, |
| 848 | unsigned BuiltinID); |
Daniel Dunbar | c4baa06 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 849 | |
Dmitri Gribenko | 44ebbd5 | 2013-05-05 00:41:58 +0000 | [diff] [blame] | 850 | llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type*> Tys = None); |
Daniel Dunbar | 9c42652 | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 851 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 852 | /// Emit code for a single top level declaration. |
Daniel Dunbar | fce4be8 | 2008-08-15 23:26:23 +0000 | [diff] [blame] | 853 | void EmitTopLevelDecl(Decl *D); |
Daniel Dunbar | 9c42652 | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 854 | |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 855 | /// \brief Stored a deferred empty coverage mapping for an unused |
| 856 | /// and thus uninstrumented top level declaration. |
| 857 | void AddDeferredUnusedCoverageMapping(Decl *D); |
| 858 | |
| 859 | /// \brief Remove the deferred empty coverage mapping as this |
| 860 | /// declaration is actually instrumented. |
| 861 | void ClearUnusedCoverageMapping(const Decl *D); |
| 862 | |
| 863 | /// \brief Emit all the deferred coverage mappings |
| 864 | /// for the uninstrumented functions. |
| 865 | void EmitDeferredUnusedCoverageMappings(); |
| 866 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 867 | /// Tell the consumer that this variable has been instantiated. |
Rafael Espindola | df88f6f | 2012-03-08 15:51:03 +0000 | [diff] [blame] | 868 | void HandleCXXStaticMemberVarInstantiation(VarDecl *VD); |
Rafael Espindola | 189fa74 | 2012-03-05 10:54:55 +0000 | [diff] [blame] | 869 | |
Richard Smith | df931ce | 2013-04-06 05:00:46 +0000 | [diff] [blame] | 870 | /// \brief If the declaration has internal linkage but is inside an |
| 871 | /// extern "C" linkage specification, prepare to emit an alias for it |
| 872 | /// to the expected name. |
| 873 | template<typename SomeDecl> |
| 874 | void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV); |
| 875 | |
Rafael Espindola | 060062a | 2014-03-06 22:15:10 +0000 | [diff] [blame] | 876 | /// Add a global to a list to be added to the llvm.used metadata. |
| 877 | void addUsedGlobal(llvm::GlobalValue *GV); |
| 878 | |
| 879 | /// Add a global to a list to be added to the llvm.compiler.used metadata. |
| 880 | void addCompilerUsedGlobal(llvm::GlobalValue *GV); |
Daniel Dunbar | 08b26a0 | 2009-02-13 20:29:50 +0000 | [diff] [blame] | 881 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 882 | /// Add a destructor and object to add to the C++ global destructor function. |
Chris Lattner | 87233f7 | 2010-06-19 05:52:45 +0000 | [diff] [blame] | 883 | void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object) { |
Benjamin Kramer | 3204b15 | 2015-05-29 19:42:19 +0000 | [diff] [blame] | 884 | CXXGlobalDtors.emplace_back(DtorFn, Object); |
Chris Lattner | 87233f7 | 2010-06-19 05:52:45 +0000 | [diff] [blame] | 885 | } |
Daniel Dunbar | fe06df4 | 2010-03-20 04:15:41 +0000 | [diff] [blame] | 886 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 887 | /// Create a new runtime function with the specified type and name. |
Chris Lattner | 2192fe5 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 888 | llvm::Constant *CreateRuntimeFunction(llvm::FunctionType *Ty, |
Chris Lattner | 01cf8db | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 889 | StringRef Name, |
Bill Wendling | 8594fcb | 2013-01-31 00:30:05 +0000 | [diff] [blame] | 890 | llvm::AttributeSet ExtraAttrs = |
| 891 | llvm::AttributeSet()); |
Anton Korobeynikov | d90dd79 | 2014-12-02 16:04:58 +0000 | [diff] [blame] | 892 | /// Create a new compiler builtin function with the specified type and name. |
| 893 | llvm::Constant *CreateBuiltinFunction(llvm::FunctionType *Ty, |
| 894 | StringRef Name, |
| 895 | llvm::AttributeSet ExtraAttrs = |
| 896 | llvm::AttributeSet()); |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 897 | /// Create a new runtime global variable with the specified type and name. |
Chris Lattner | 2192fe5 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 898 | llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty, |
Chris Lattner | 01cf8db | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 899 | StringRef Name); |
Daniel Dunbar | 23fd462 | 2008-10-01 00:49:24 +0000 | [diff] [blame] | 900 | |
Daniel Dunbar | 900546d | 2010-07-16 00:00:15 +0000 | [diff] [blame] | 901 | ///@name Custom Blocks Runtime Interfaces |
| 902 | ///@{ |
| 903 | |
| 904 | llvm::Constant *getNSConcreteGlobalBlock(); |
| 905 | llvm::Constant *getNSConcreteStackBlock(); |
| 906 | llvm::Constant *getBlockObjectAssign(); |
| 907 | llvm::Constant *getBlockObjectDispose(); |
| 908 | |
| 909 | ///@} |
| 910 | |
Nadav Rotem | 1da3094 | 2013-03-23 06:43:35 +0000 | [diff] [blame] | 911 | llvm::Constant *getLLVMLifetimeStartFn(); |
| 912 | llvm::Constant *getLLVMLifetimeEndFn(); |
| 913 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 914 | // Make sure that this type is translated. |
Devang Patel | 945b8ae | 2011-03-23 16:29:39 +0000 | [diff] [blame] | 915 | void UpdateCompletedType(const TagDecl *TD); |
Daniel Dunbar | 38ad1e6 | 2009-02-17 18:43:32 +0000 | [diff] [blame] | 916 | |
John McCall | f3a8860 | 2011-02-03 08:15:49 +0000 | [diff] [blame] | 917 | llvm::Constant *getMemberPointerConstant(const UnaryOperator *e); |
| 918 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 919 | /// Try to emit the initializer for the given declaration as a constant; |
| 920 | /// returns 0 if the expression cannot be emitted as a constant. |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 921 | llvm::Constant *EmitConstantInit(const VarDecl &D, |
| 922 | CodeGenFunction *CGF = nullptr); |
Richard Smith | dafff94 | 2012-01-14 04:30:29 +0000 | [diff] [blame] | 923 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 924 | /// Try to emit the given expression as a constant; returns 0 if the |
| 925 | /// expression cannot be emitted as a constant. |
Anders Carlsson | 80f97ab | 2009-04-08 04:48:15 +0000 | [diff] [blame] | 926 | llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType, |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 927 | CodeGenFunction *CGF = nullptr); |
Daniel Dunbar | 38ad1e6 | 2009-02-17 18:43:32 +0000 | [diff] [blame] | 928 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 929 | /// Emit the given constant value as a constant, in the type's scalar |
| 930 | /// representation. |
Richard Smith | dafff94 | 2012-01-14 04:30:29 +0000 | [diff] [blame] | 931 | llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType, |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 932 | CodeGenFunction *CGF = nullptr); |
Richard Smith | dafff94 | 2012-01-14 04:30:29 +0000 | [diff] [blame] | 933 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 934 | /// Emit the given constant value as a constant, in the type's memory |
| 935 | /// representation. |
Richard Smith | bc638767 | 2012-03-02 23:27:11 +0000 | [diff] [blame] | 936 | llvm::Constant *EmitConstantValueForMemory(const APValue &Value, |
| 937 | QualType DestType, |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 938 | CodeGenFunction *CGF = nullptr); |
Richard Smith | bc638767 | 2012-03-02 23:27:11 +0000 | [diff] [blame] | 939 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 940 | /// Return the result of value-initializing the given type, i.e. a null |
| 941 | /// expression of the given type. This is usually, but not always, an LLVM |
| 942 | /// null constant. |
Eli Friedman | 20bb5e0 | 2009-04-13 21:47:26 +0000 | [diff] [blame] | 943 | llvm::Constant *EmitNullConstant(QualType T); |
| 944 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 945 | /// Return a null constant appropriate for zero-initializing a base class with |
| 946 | /// the given type. This is usually, but not always, an LLVM null constant. |
Eli Friedman | fde961d | 2011-10-14 02:27:24 +0000 | [diff] [blame] | 947 | llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record); |
| 948 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 949 | /// Emit a general error that something can't be done. |
Chandler Carruth | 8453795 | 2012-03-30 19:44:53 +0000 | [diff] [blame] | 950 | void Error(SourceLocation loc, StringRef error); |
John McCall | 7ef5cb3 | 2011-03-18 02:56:14 +0000 | [diff] [blame] | 951 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 952 | /// Print out an error that codegen doesn't support the specified stmt yet. |
David Blaikie | 4a9ec7b | 2013-08-19 21:02:26 +0000 | [diff] [blame] | 953 | void ErrorUnsupported(const Stmt *S, const char *Type); |
Mike Stump | 1676c5b | 2009-02-13 19:12:34 +0000 | [diff] [blame] | 954 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 955 | /// Print out an error that codegen doesn't support the specified decl yet. |
David Blaikie | 4a9ec7b | 2013-08-19 21:02:26 +0000 | [diff] [blame] | 956 | void ErrorUnsupported(const Decl *D, const char *Type); |
Dan Gohman | 75d69da | 2008-05-22 00:50:06 +0000 | [diff] [blame] | 957 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 958 | /// Set the attributes on the LLVM function for the given decl and function |
| 959 | /// info. This applies attributes necessary for handling the ABI as well as |
| 960 | /// user specified attributes like section. |
Daniel Dunbar | c3e7cff | 2009-04-17 00:48:04 +0000 | [diff] [blame] | 961 | void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, |
| 962 | const CGFunctionInfo &FI); |
Daniel Dunbar | 449a339 | 2008-09-04 23:41:35 +0000 | [diff] [blame] | 963 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 964 | /// Set the LLVM function attributes (sext, zext, etc). |
Daniel Dunbar | aeddffc | 2009-04-14 07:08:30 +0000 | [diff] [blame] | 965 | void SetLLVMFunctionAttributes(const Decl *D, |
| 966 | const CGFunctionInfo &Info, |
| 967 | llvm::Function *F); |
Daniel Dunbar | c68897d | 2008-09-10 00:41:16 +0000 | [diff] [blame] | 968 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 969 | /// Set the LLVM function attributes which only apply to a function |
James Dennett | 64fa123 | 2014-08-15 20:04:40 +0000 | [diff] [blame] | 970 | /// definition. |
Daniel Dunbar | 3893257 | 2009-04-14 08:05:55 +0000 | [diff] [blame] | 971 | void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F); |
| 972 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 973 | /// Return true iff the given type uses 'sret' when used as a return type. |
Daniel Dunbar | 6f2e839 | 2010-07-14 23:39:36 +0000 | [diff] [blame] | 974 | bool ReturnTypeUsesSRet(const CGFunctionInfo &FI); |
| 975 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 976 | /// Return true iff the given type uses an argument slot when 'sret' is used |
| 977 | /// as a return type. |
Tim Northover | e77cc39 | 2014-03-29 13:28:05 +0000 | [diff] [blame] | 978 | bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI); |
| 979 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 980 | /// Return true iff the given type uses 'fpret' when used as a return type. |
Daniel Dunbar | 6f2e839 | 2010-07-14 23:39:36 +0000 | [diff] [blame] | 981 | bool ReturnTypeUsesFPRet(QualType ResultType); |
Daniel Dunbar | c68897d | 2008-09-10 00:41:16 +0000 | [diff] [blame] | 982 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 983 | /// Return true iff the given type uses 'fp2ret' when used as a return type. |
Anders Carlsson | 2f1a6c3 | 2011-10-31 16:27:11 +0000 | [diff] [blame] | 984 | bool ReturnTypeUsesFP2Ret(QualType ResultType); |
| 985 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 986 | /// Get the LLVM attributes and calling convention to use for a particular |
| 987 | /// function type. |
Daniel Dunbar | 0ef3479 | 2009-09-12 00:59:20 +0000 | [diff] [blame] | 988 | /// |
| 989 | /// \param Info - The function type information. |
| 990 | /// \param TargetDecl - The decl these attributes are being constructed |
| 991 | /// for. If supplied the attributes applied to this decl may contribute to the |
| 992 | /// function attributes and calling convention. |
| 993 | /// \param PAL [out] - On return, the attribute list to use. |
| 994 | /// \param CallingConv [out] - On return, the LLVM calling convention to use. |
Daniel Dunbar | d931a87 | 2009-02-02 22:03:45 +0000 | [diff] [blame] | 995 | void ConstructAttributeList(const CGFunctionInfo &Info, |
| 996 | const Decl *TargetDecl, |
Daniel Dunbar | 0ef3479 | 2009-09-12 00:59:20 +0000 | [diff] [blame] | 997 | AttributeListType &PAL, |
Bill Wendling | f4d64cb | 2013-02-22 00:13:35 +0000 | [diff] [blame] | 998 | unsigned &CallingConv, |
| 999 | bool AttrOnCallSite); |
Daniel Dunbar | c68897d | 2008-09-10 00:41:16 +0000 | [diff] [blame] | 1000 | |
Chris Lattner | 01cf8db | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 1001 | StringRef getMangledName(GlobalDecl GD); |
Alp Toker | fb8d02b | 2014-06-05 22:10:59 +0000 | [diff] [blame] | 1002 | StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD); |
Douglas Gregor | beecd58 | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 1003 | |
| 1004 | void EmitTentativeDefinition(const VarDecl *D); |
Mike Stump | bc78a72 | 2009-07-31 18:25:34 +0000 | [diff] [blame] | 1005 | |
Nico Weber | b6a5d05 | 2015-01-15 04:07:35 +0000 | [diff] [blame] | 1006 | void EmitVTable(CXXRecordDecl *Class); |
Douglas Gregor | 88d292c | 2010-05-13 16:44:06 +0000 | [diff] [blame] | 1007 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1008 | /// Emit the RTTI descriptors for the builtin types. |
Timur Iskhodzhanov | 8b5987e | 2013-09-27 14:48:01 +0000 | [diff] [blame] | 1009 | void EmitFundamentalRTTIDescriptors(); |
| 1010 | |
Reid Kleckner | e43f0fe | 2013-05-08 13:44:39 +0000 | [diff] [blame] | 1011 | /// \brief Appends Opts to the "Linker Options" metadata value. |
| 1012 | void AppendLinkerOptions(StringRef Opts); |
| 1013 | |
Benjamin Kramer | 82dfc97 | 2013-06-04 09:13:21 +0000 | [diff] [blame] | 1014 | /// \brief Appends a detect mismatch command to the linker options. |
Aaron Ballman | 5d041be | 2013-06-04 02:07:14 +0000 | [diff] [blame] | 1015 | void AddDetectMismatch(StringRef Name, StringRef Value); |
| 1016 | |
Reid Kleckner | e43f0fe | 2013-05-08 13:44:39 +0000 | [diff] [blame] | 1017 | /// \brief Appends a dependent lib to the "Linker Options" metadata value. |
| 1018 | void AddDependentLib(StringRef Lib); |
| 1019 | |
Peter Collingbourne | 4d90dba | 2013-06-05 17:49:37 +0000 | [diff] [blame] | 1020 | llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD); |
John McCall | d432414 | 2010-02-19 01:32:20 +0000 | [diff] [blame] | 1021 | |
Rafael Espindola | 6492636 | 2014-05-08 14:46:46 +0000 | [diff] [blame] | 1022 | void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) { |
| 1023 | F->setLinkage(getFunctionLinkage(GD)); |
John McCall | 7cb0220 | 2010-05-25 04:30:21 +0000 | [diff] [blame] | 1024 | } |
| 1025 | |
Hans Wennborg | bb4f962 | 2015-05-28 17:44:56 +0000 | [diff] [blame] | 1026 | /// Set the DLL storage class on F. |
| 1027 | void setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function *F); |
| 1028 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1029 | /// Return the appropriate linkage for the vtable, VTT, and type information |
| 1030 | /// of the given class. |
Anders Carlsson | 68d3424 | 2011-01-24 02:04:33 +0000 | [diff] [blame] | 1031 | llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD); |
Ken Dyck | 98ca794 | 2010-01-26 13:48:07 +0000 | [diff] [blame] | 1032 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1033 | /// Return the store size, in character units, of the given LLVM type. |
Chris Lattner | 2192fe5 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1034 | CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const; |
Fariborz Jahanian | 1518a5ec | 2010-10-27 16:21:54 +0000 | [diff] [blame] | 1035 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1036 | /// Returns LLVM linkage for a declarator. |
David Majnemer | 27d69db | 2014-04-28 22:17:59 +0000 | [diff] [blame] | 1037 | llvm::GlobalValue::LinkageTypes |
Hans Wennborg | 1a3a074 | 2014-05-14 19:54:53 +0000 | [diff] [blame] | 1038 | getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage, |
Hans Wennborg | 275efb9 | 2014-05-28 01:52:23 +0000 | [diff] [blame] | 1039 | bool IsConstantVariable); |
David Majnemer | 27d69db | 2014-04-28 22:17:59 +0000 | [diff] [blame] | 1040 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1041 | /// Returns LLVM linkage for a declarator. |
David Majnemer | 27d69db | 2014-04-28 22:17:59 +0000 | [diff] [blame] | 1042 | llvm::GlobalValue::LinkageTypes |
| 1043 | getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant); |
| 1044 | |
Julien Lerouge | 5a6b698 | 2011-09-09 22:41:49 +0000 | [diff] [blame] | 1045 | /// Emit all the global annotations. |
| 1046 | void EmitGlobalAnnotations(); |
| 1047 | |
| 1048 | /// Emit an annotation string. |
Dmitri Gribenko | f857950 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 1049 | llvm::Constant *EmitAnnotationString(StringRef Str); |
Julien Lerouge | 5a6b698 | 2011-09-09 22:41:49 +0000 | [diff] [blame] | 1050 | |
| 1051 | /// Emit the annotation's translation unit. |
| 1052 | llvm::Constant *EmitAnnotationUnit(SourceLocation Loc); |
| 1053 | |
| 1054 | /// Emit the annotation line number. |
| 1055 | llvm::Constant *EmitAnnotationLineNo(SourceLocation L); |
| 1056 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1057 | /// Generate the llvm::ConstantStruct which contains the annotation |
| 1058 | /// information for a given GlobalValue. The annotation struct is |
Julien Lerouge | 5a6b698 | 2011-09-09 22:41:49 +0000 | [diff] [blame] | 1059 | /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the |
| 1060 | /// GlobalValue being annotated. The second field is the constant string |
| 1061 | /// created from the AnnotateAttr's annotation. The third field is a constant |
| 1062 | /// string containing the name of the translation unit. The fourth field is |
| 1063 | /// the line number in the file of the annotated value declaration. |
| 1064 | llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV, |
| 1065 | const AnnotateAttr *AA, |
| 1066 | SourceLocation L); |
| 1067 | |
| 1068 | /// Add global annotations that are set on D, for the global GV. Those |
| 1069 | /// annotations are emitted during finalization of the LLVM code. |
| 1070 | void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV); |
| 1071 | |
Alexey Samsonov | 1444bb9 | 2014-10-17 00:20:19 +0000 | [diff] [blame] | 1072 | bool isInSanitizerBlacklist(llvm::Function *Fn, SourceLocation Loc) const; |
Will Dietz | f54319c | 2013-01-18 11:30:38 +0000 | [diff] [blame] | 1073 | |
Alexey Samsonov | a0ac3c2 | 2014-10-17 22:37:33 +0000 | [diff] [blame] | 1074 | bool isInSanitizerBlacklist(llvm::GlobalVariable *GV, SourceLocation Loc, |
| 1075 | QualType Ty, |
| 1076 | StringRef Category = StringRef()) const; |
| 1077 | |
Alexey Samsonov | 4b8de11 | 2014-08-01 21:35:28 +0000 | [diff] [blame] | 1078 | SanitizerMetadata *getSanitizerMetadata() { |
| 1079 | return SanitizerMD.get(); |
| 1080 | } |
Alexey Samsonov | 4f319cc | 2014-07-02 16:54:41 +0000 | [diff] [blame] | 1081 | |
John McCall | 6bd2a89 | 2013-01-25 22:31:03 +0000 | [diff] [blame] | 1082 | void addDeferredVTable(const CXXRecordDecl *RD) { |
| 1083 | DeferredVTables.push_back(RD); |
| 1084 | } |
| 1085 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1086 | /// Emit code for a singal global function or var decl. Forward declarations |
| 1087 | /// are emitted lazily. |
Reid Kleckner | e7de47e | 2013-07-22 13:51:44 +0000 | [diff] [blame] | 1088 | void EmitGlobal(GlobalDecl D); |
| 1089 | |
Rafael Espindola | 02b77f4 | 2014-09-15 18:46:13 +0000 | [diff] [blame] | 1090 | bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target, |
| 1091 | bool InEveryTU); |
| 1092 | bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D); |
| 1093 | |
| 1094 | /// Set attributes for a global definition. |
| 1095 | void setFunctionDefinitionAttributes(const FunctionDecl *D, |
| 1096 | llvm::Function *F); |
| 1097 | |
Chris Lattner | 01cf8db | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 1098 | llvm::GlobalValue *GetGlobalValue(StringRef Ref); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1099 | |
Rafael Espindola | 1e4df92 | 2014-09-16 15:18:21 +0000 | [diff] [blame] | 1100 | /// Set attributes which are common to any form of a global definition (alias, |
| 1101 | /// Objective-C method, function, global variable). |
| 1102 | /// |
| 1103 | /// NOTE: This should only be called for definitions. |
| 1104 | void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV); |
| 1105 | |
Dario Domizioli | c4fb8ca7 | 2014-09-19 22:06:24 +0000 | [diff] [blame] | 1106 | /// Set attributes which must be preserved by an alias. This includes common |
| 1107 | /// attributes (i.e. it includes a call to SetCommonAttributes). |
| 1108 | /// |
| 1109 | /// NOTE: This should only be called for definitions. |
| 1110 | void setAliasAttributes(const Decl *D, llvm::GlobalValue *GV); |
| 1111 | |
Rafael Espindola | 1e4df92 | 2014-09-16 15:18:21 +0000 | [diff] [blame] | 1112 | void addReplacement(StringRef Name, llvm::Constant *C); |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 1113 | |
| 1114 | /// \brief Emit a code for threadprivate directive. |
| 1115 | /// \param D Threadprivate declaration. |
| 1116 | void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D); |
| 1117 | |
Peter Collingbourne | a4ccff3 | 2015-02-20 20:30:56 +0000 | [diff] [blame] | 1118 | /// Emit bit set entries for the given vtable using the given layout if |
| 1119 | /// vptr CFI is enabled. |
| 1120 | void EmitVTableBitSetEntries(llvm::GlobalVariable *VTable, |
| 1121 | const VTableLayout &VTLayout); |
| 1122 | |
Peter Collingbourne | 86d34a7 | 2015-06-17 19:08:05 +0000 | [diff] [blame] | 1123 | /// Create a bitset entry for the given vtable. |
| 1124 | llvm::MDTuple *CreateVTableBitSetEntry(llvm::GlobalVariable *VTable, |
| 1125 | CharUnits Offset, |
| 1126 | const CXXRecordDecl *RD); |
| 1127 | |
Reid Kleckner | fff8e7f | 2015-03-03 19:21:04 +0000 | [diff] [blame] | 1128 | /// \breif Get the declaration of std::terminate for the platform. |
| 1129 | llvm::Constant *getTerminateFn(); |
| 1130 | |
Rafael Espindola | 1e4df92 | 2014-09-16 15:18:21 +0000 | [diff] [blame] | 1131 | private: |
Rafael Espindola | 94abb8f | 2013-12-09 04:29:47 +0000 | [diff] [blame] | 1132 | llvm::Constant * |
| 1133 | GetOrCreateLLVMFunction(StringRef MangledName, llvm::Type *Ty, GlobalDecl D, |
| 1134 | bool ForVTable, bool DontDefer = false, |
David Majnemer | b9bd6fb | 2014-11-01 05:42:23 +0000 | [diff] [blame] | 1135 | bool IsThunk = false, |
Rafael Espindola | 94abb8f | 2013-12-09 04:29:47 +0000 | [diff] [blame] | 1136 | llvm::AttributeSet ExtraAttrs = llvm::AttributeSet()); |
| 1137 | |
Chris Lattner | 01cf8db | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 1138 | llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName, |
Chris Lattner | 2192fe5 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1139 | llvm::PointerType *PTy, |
Rafael Espindola | b73c973 | 2014-05-22 23:33:27 +0000 | [diff] [blame] | 1140 | const VarDecl *D); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1141 | |
Rafael Espindola | ee076a2 | 2014-05-13 18:45:53 +0000 | [diff] [blame] | 1142 | void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO); |
Rafael Espindola | 502f65a | 2014-05-05 20:21:03 +0000 | [diff] [blame] | 1143 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1144 | /// Set function attributes for a function declaration. |
David Majnemer | b9bd6fb | 2014-11-01 05:42:23 +0000 | [diff] [blame] | 1145 | void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, |
| 1146 | bool IsIncompleteFunction, bool IsThunk); |
Nuno Lopes | b6f7953 | 2008-06-08 15:45:52 +0000 | [diff] [blame] | 1147 | |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 1148 | void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr); |
Daniel Dunbar | f0acf7b | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 1149 | |
Rafael Espindola | cd7743b | 2013-12-09 16:01:03 +0000 | [diff] [blame] | 1150 | void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV); |
Daniel Dunbar | 9c42652 | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 1151 | void EmitGlobalVarDefinition(const VarDecl *D); |
John McCall | 7ec5043 | 2010-03-19 23:29:14 +0000 | [diff] [blame] | 1152 | void EmitAliasDefinition(GlobalDecl GD); |
Daniel Dunbar | 89654ee | 2008-08-26 08:29:31 +0000 | [diff] [blame] | 1153 | void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D); |
Fariborz Jahanian | 0dec1e0 | 2010-04-28 21:28:56 +0000 | [diff] [blame] | 1154 | void EmitObjCIvarInitializations(ObjCImplementationDecl *D); |
Fariborz Jahanian | 1518a5ec | 2010-10-27 16:21:54 +0000 | [diff] [blame] | 1155 | |
Anders Carlsson | f747524 | 2009-04-15 15:55:24 +0000 | [diff] [blame] | 1156 | // C++ related functions. |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1157 | |
Anders Carlsson | 237f349 | 2009-04-01 00:58:25 +0000 | [diff] [blame] | 1158 | void EmitNamespace(const NamespaceDecl *D); |
Anders Carlsson | cbaeb9e | 2009-04-02 05:55:18 +0000 | [diff] [blame] | 1159 | void EmitLinkageSpec(const LinkageSpecDecl *D); |
Adrian Prantl | ffcf4ba | 2013-05-09 23:16:27 +0000 | [diff] [blame] | 1160 | void CompleteDIClassType(const CXXMethodDecl* D); |
Anders Carlsson | f747524 | 2009-04-15 15:55:24 +0000 | [diff] [blame] | 1161 | |
Richard Smith | 2fd1d7a | 2013-04-19 16:42:07 +0000 | [diff] [blame] | 1162 | /// \brief Emit the function that initializes C++ thread_local variables. |
| 1163 | void EmitCXXThreadLocalInitFunc(); |
| 1164 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1165 | /// Emit the function that initializes C++ globals. |
Anders Carlsson | b8be93f | 2009-08-08 23:24:23 +0000 | [diff] [blame] | 1166 | void EmitCXXGlobalInitFunc(); |
Eli Friedman | 5866fe3 | 2010-01-08 00:50:11 +0000 | [diff] [blame] | 1167 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1168 | /// Emit the function that destroys C++ globals. |
Daniel Dunbar | fe06df4 | 2010-03-20 04:15:41 +0000 | [diff] [blame] | 1169 | void EmitCXXGlobalDtorFunc(); |
| 1170 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1171 | /// Emit the function that initializes the specified global (if PerformInit is |
| 1172 | /// true) and registers its destructor. |
John McCall | cdf7ef5 | 2010-11-06 09:44:32 +0000 | [diff] [blame] | 1173 | void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, |
Richard Smith | 6331c40 | 2012-02-13 22:16:19 +0000 | [diff] [blame] | 1174 | llvm::GlobalVariable *Addr, |
| 1175 | bool PerformInit); |
Eli Friedman | 5866fe3 | 2010-01-08 00:50:11 +0000 | [diff] [blame] | 1176 | |
Reid Kleckner | 1a711b1 | 2014-07-22 00:53:05 +0000 | [diff] [blame] | 1177 | void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr, |
| 1178 | llvm::Function *InitFunc, InitSegAttr *ISA); |
| 1179 | |
Daniel Dunbar | 74aa7e1 | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 1180 | // FIXME: Hardcoding priority here is gross. |
Reid Kleckner | 563f0e8 | 2014-05-23 21:13:45 +0000 | [diff] [blame] | 1181 | void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535, |
| 1182 | llvm::Constant *AssociatedData = 0); |
| 1183 | void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535); |
Daniel Dunbar | 9c42652 | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 1184 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1185 | /// Generates a global array of functions and priorities using the given list |
| 1186 | /// and name. This array will have appending linkage and is suitable for use |
| 1187 | /// as a LLVM constructor or destructor array. |
Daniel Dunbar | 74aa7e1 | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 1188 | void EmitCtorList(const CtorList &Fns, const char *GlobalName); |
| 1189 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1190 | /// Emit the RTTI descriptors for the given type. |
Rafael Espindola | adcc1d1 | 2010-03-27 02:52:14 +0000 | [diff] [blame] | 1191 | void EmitFundamentalRTTIDescriptor(QualType Type); |
| 1192 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1193 | /// Emit any needed decls for which code generation was deferred. |
Dmitri Gribenko | b2aa923 | 2012-11-15 14:28:07 +0000 | [diff] [blame] | 1194 | void EmitDeferred(); |
Daniel Dunbar | 08b26a0 | 2009-02-13 20:29:50 +0000 | [diff] [blame] | 1195 | |
Rafael Espindola | 2e2995b | 2013-11-05 21:37:29 +0000 | [diff] [blame] | 1196 | /// Call replaceAllUsesWith on all pairs in Replacements. |
| 1197 | void applyReplacements(); |
| 1198 | |
Rafael Espindola | 208b5c0 | 2013-10-22 19:26:13 +0000 | [diff] [blame] | 1199 | void checkAliases(); |
| 1200 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1201 | /// Emit any vtables which we deferred and still have a use for. |
John McCall | 6bd2a89 | 2013-01-25 22:31:03 +0000 | [diff] [blame] | 1202 | void EmitDeferredVTables(); |
| 1203 | |
Rafael Espindola | 060062a | 2014-03-06 22:15:10 +0000 | [diff] [blame] | 1204 | /// Emit the llvm.used and llvm.compiler.used metadata. |
| 1205 | void emitLLVMUsed(); |
Daniel Dunbar | 23fd462 | 2008-10-01 00:49:24 +0000 | [diff] [blame] | 1206 | |
Douglas Gregor | bc25ff4 | 2013-01-14 20:53:57 +0000 | [diff] [blame] | 1207 | /// \brief Emit the link options introduced by imported modules. |
| 1208 | void EmitModuleLinkOptions(); |
| 1209 | |
Richard Smith | df931ce | 2013-04-06 05:00:46 +0000 | [diff] [blame] | 1210 | /// \brief Emit aliases for internal-linkage declarations inside "C" language |
| 1211 | /// linkage specifications, giving them the "expected" name where possible. |
| 1212 | void EmitStaticExternCAliases(); |
| 1213 | |
John McCall | 09ae032 | 2010-07-06 23:57:41 +0000 | [diff] [blame] | 1214 | void EmitDeclMetadata(); |
| 1215 | |
Rafael Espindola | 3bfa468 | 2013-10-16 19:28:50 +0000 | [diff] [blame] | 1216 | /// \brief Emit the Clang version as llvm.ident metadata. |
| 1217 | void EmitVersionIdentMetadata(); |
| 1218 | |
Robert Lytton | 57765d5 | 2014-07-03 09:30:33 +0000 | [diff] [blame] | 1219 | /// Emits target specific Metadata for global declarations. |
| 1220 | void EmitTargetMetadata(); |
| 1221 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1222 | /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and |
| 1223 | /// .gcda files in a way that persists in .bc files. |
Nick Lewycky | 85c011d | 2011-05-05 00:08:20 +0000 | [diff] [blame] | 1224 | void EmitCoverageFile(); |
Nick Lewycky | 480cb99 | 2011-05-04 20:46:58 +0000 | [diff] [blame] | 1225 | |
Nico Weber | cf4ff586 | 2012-10-11 10:13:44 +0000 | [diff] [blame] | 1226 | /// Emits the initializer for a uuidof string. |
Nico Weber | 17d3a2c | 2014-09-08 16:26:36 +0000 | [diff] [blame] | 1227 | llvm::Constant *EmitUuidofInitializer(StringRef uuidstr); |
Nico Weber | cf4ff586 | 2012-10-11 10:13:44 +0000 | [diff] [blame] | 1228 | |
Hans Wennborg | 43a0f99 | 2015-01-10 01:19:48 +0000 | [diff] [blame] | 1229 | /// Determine whether the definition must be emitted; if this returns \c |
| 1230 | /// false, the definition can be emitted lazily if it's used. |
| 1231 | bool MustBeEmitted(const ValueDecl *D); |
| 1232 | |
| 1233 | /// Determine whether the definition can be emitted eagerly, or should be |
| 1234 | /// delayed until the end of the translation unit. This is relevant for |
| 1235 | /// definitions whose linkage can change, e.g. implicit function instantions |
| 1236 | /// which may later be explicitly instantiated. |
| 1237 | bool MayBeEmittedEagerly(const ValueDecl *D); |
John McCall | 0bdb1fd | 2010-09-16 06:16:50 +0000 | [diff] [blame] | 1238 | |
Rafael Espindola | e98ed2f | 2014-05-09 01:34:38 +0000 | [diff] [blame] | 1239 | /// Check whether we can use a "simpler", more core exceptions personality |
| 1240 | /// function. |
John McCall | 0bdb1fd | 2010-09-16 06:16:50 +0000 | [diff] [blame] | 1241 | void SimplifyPersonality(); |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 1242 | }; |
| 1243 | } // end namespace CodeGen |
| 1244 | } // end namespace clang |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 1245 | |
| 1246 | #endif |