1 //===--- DIBuilder.cpp - Debug Information Builder ------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the DIBuilder.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/DIBuilder.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/DebugInfo.h"
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/IntrinsicInst.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/Support/Dwarf.h"
24 using namespace llvm::dwarf;
26 static Constant *GetTagConstant(LLVMContext &VMContext, unsigned Tag) {
27 assert((Tag & LLVMDebugVersionMask) == 0 &&
28 "Tag too large for debug encoding!");
29 return ConstantInt::get(Type::getInt32Ty(VMContext), Tag | LLVMDebugVersion);
32 DIBuilder::DIBuilder(Module &m)
33 : M(m), VMContext(M.getContext()), TempEnumTypes(0),
34 TempRetainTypes(0), TempSubprograms(0), TempGVs(0), DeclareFn(0),
38 /// finalize - Construct any deferred debug info descriptors.
39 void DIBuilder::finalize() {
40 DIArray Enums = getOrCreateArray(AllEnumTypes);
41 DIType(TempEnumTypes).replaceAllUsesWith(Enums);
43 DIArray RetainTypes = getOrCreateArray(AllRetainTypes);
44 DIType(TempRetainTypes).replaceAllUsesWith(RetainTypes);
46 DIArray SPs = getOrCreateArray(AllSubprograms);
47 DIType(TempSubprograms).replaceAllUsesWith(SPs);
48 for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
49 DISubprogram SP(SPs.getElement(i));
50 SmallVector<Value *, 4> Variables;
51 if (NamedMDNode *NMD = getFnSpecificMDNode(M, SP)) {
52 for (unsigned ii = 0, ee = NMD->getNumOperands(); ii != ee; ++ii)
53 Variables.push_back(NMD->getOperand(ii));
54 NMD->eraseFromParent();
56 if (MDNode *Temp = SP.getVariablesNodes()) {
57 DIArray AV = getOrCreateArray(Variables);
58 DIType(Temp).replaceAllUsesWith(AV);
62 DIArray GVs = getOrCreateArray(AllGVs);
63 DIType(TempGVs).replaceAllUsesWith(GVs);
65 DIArray IMs = getOrCreateArray(AllImportedModules);
66 DIType(TempImportedModules).replaceAllUsesWith(IMs);
69 /// getNonCompileUnitScope - If N is compile unit return NULL otherwise return
71 static MDNode *getNonCompileUnitScope(MDNode *N) {
72 if (DIDescriptor(N).isCompileUnit())
77 static MDNode *createFilePathPair(LLVMContext &VMContext, StringRef Filename,
78 StringRef Directory) {
79 assert(!Filename.empty() && "Unable to create file without name");
81 MDString::get(VMContext, Filename),
82 MDString::get(VMContext, Directory),
84 return MDNode::get(VMContext, Pair);
87 /// createCompileUnit - A CompileUnit provides an anchor for all debugging
88 /// information generated during this instance of compilation.
89 DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
91 StringRef Producer, bool isOptimized,
92 StringRef Flags, unsigned RunTimeVer,
93 StringRef SplitName) {
94 assert(((Lang <= dwarf::DW_LANG_Python && Lang >= dwarf::DW_LANG_C89) ||
95 (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
96 "Invalid Language tag");
97 assert(!Filename.empty() &&
98 "Unable to create compile unit without filename");
99 Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
100 TempEnumTypes = MDNode::getTemporary(VMContext, TElts);
102 TempRetainTypes = MDNode::getTemporary(VMContext, TElts);
104 TempSubprograms = MDNode::getTemporary(VMContext, TElts);
106 TempGVs = MDNode::getTemporary(VMContext, TElts);
108 TempImportedModules = MDNode::getTemporary(VMContext, TElts);
111 GetTagConstant(VMContext, dwarf::DW_TAG_compile_unit),
112 createFilePathPair(VMContext, Filename, Directory),
113 ConstantInt::get(Type::getInt32Ty(VMContext), Lang),
114 MDString::get(VMContext, Producer),
115 ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
116 MDString::get(VMContext, Flags),
117 ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer),
123 MDString::get(VMContext, SplitName)
126 MDNode *CUNode = MDNode::get(VMContext, Elts);
128 // Create a named metadata so that it is easier to find cu in a module.
129 NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
130 NMD->addOperand(CUNode);
132 return DICompileUnit(CUNode);
135 static DIImportedEntity
136 createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS,
137 unsigned Line, StringRef Name,
138 SmallVectorImpl<Value *> &AllImportedModules) {
142 GetTagConstant(C, dwarf::DW_TAG_imported_module),
145 ConstantInt::get(Type::getInt32Ty(C), Line),
147 R = MDNode::get(C, Elts);
150 GetTagConstant(C, dwarf::DW_TAG_imported_module),
153 ConstantInt::get(Type::getInt32Ty(C), Line),
154 MDString::get(C, Name)
156 R = MDNode::get(C, Elts);
158 DIImportedEntity M(R);
159 assert(M.Verify() && "Imported module should be valid");
160 AllImportedModules.push_back(M);
164 DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
165 DINameSpace NS, unsigned Line,
167 return ::createImportedModule(VMContext, Context, NS, Line, Name,
171 DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
175 return ::createImportedModule(VMContext, Context, NS, Line, Name,
179 DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
183 GetTagConstant(VMContext, dwarf::DW_TAG_imported_declaration),
186 ConstantInt::get(Type::getInt32Ty(VMContext), Line),
188 DIImportedEntity M(MDNode::get(VMContext, Elts));
189 assert(M.Verify() && "Imported module should be valid");
190 AllImportedModules.push_back(M);
194 /// createFile - Create a file descriptor to hold debugging information
196 DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
198 GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
199 createFilePathPair(VMContext, Filename, Directory)
201 return DIFile(MDNode::get(VMContext, Elts));
204 /// createEnumerator - Create a single enumerator value.
205 DIEnumerator DIBuilder::createEnumerator(StringRef Name, int64_t Val) {
206 assert(!Name.empty() && "Unable to create enumerator without name");
208 GetTagConstant(VMContext, dwarf::DW_TAG_enumerator),
209 MDString::get(VMContext, Name),
210 ConstantInt::get(Type::getInt64Ty(VMContext), Val)
212 return DIEnumerator(MDNode::get(VMContext, Elts));
215 /// \brief Create a DWARF unspecified type.
216 DIBasicType DIBuilder::createUnspecifiedType(StringRef Name) {
217 assert(!Name.empty() && "Unable to create type without name");
218 // Unspecified types are encoded in DIBasicType format. Line number, filename,
219 // size, alignment, offset and flags are always empty here.
221 GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_type),
224 MDString::get(VMContext, Name),
225 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
226 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
227 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
228 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
229 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags;
230 ConstantInt::get(Type::getInt32Ty(VMContext), 0) // Encoding
232 return DIBasicType(MDNode::get(VMContext, Elts));
235 /// \brief Create C++11 nullptr type.
236 DIBasicType DIBuilder::createNullPtrType() {
237 return createUnspecifiedType("decltype(nullptr)");
240 /// createBasicType - Create debugging information entry for a basic
241 /// type, e.g 'char'.
243 DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
244 uint64_t AlignInBits, unsigned Encoding) {
245 assert(!Name.empty() && "Unable to create type without name");
246 // Basic types are encoded in DIBasicType format. Line number, filename,
247 // offset and flags are always empty here.
249 GetTagConstant(VMContext, dwarf::DW_TAG_base_type),
250 NULL, // File/directory name
252 MDString::get(VMContext, Name),
253 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
254 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
255 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
256 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
257 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags;
258 ConstantInt::get(Type::getInt32Ty(VMContext), Encoding)
260 return DIBasicType(MDNode::get(VMContext, Elts));
263 /// createQualifiedType - Create debugging information entry for a qualified
264 /// type, e.g. 'const int'.
265 DIDerivedType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) {
266 // Qualified types are encoded in DIDerivedType format.
268 GetTagConstant(VMContext, Tag),
271 MDString::get(VMContext, StringRef()), // Empty name.
272 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
273 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
274 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
275 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
276 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
279 return DIDerivedType(MDNode::get(VMContext, Elts));
282 /// createPointerType - Create debugging information entry for a pointer.
284 DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
285 uint64_t AlignInBits, StringRef Name) {
286 // Pointer types are encoded in DIDerivedType format.
288 GetTagConstant(VMContext, dwarf::DW_TAG_pointer_type),
291 MDString::get(VMContext, Name),
292 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
293 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
294 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
295 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
296 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
299 return DIDerivedType(MDNode::get(VMContext, Elts));
302 DIDerivedType DIBuilder::createMemberPointerType(DIType PointeeTy,
304 // Pointer types are encoded in DIDerivedType format.
306 GetTagConstant(VMContext, dwarf::DW_TAG_ptr_to_member_type),
310 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
311 ConstantInt::get(Type::getInt64Ty(VMContext), 0),
312 ConstantInt::get(Type::getInt64Ty(VMContext), 0),
313 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
314 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
318 return DIDerivedType(MDNode::get(VMContext, Elts));
321 /// createReferenceType - Create debugging information entry for a reference
323 DIDerivedType DIBuilder::createReferenceType(unsigned Tag, DIType RTy) {
324 assert(RTy.isType() && "Unable to create reference type");
325 // References are encoded in DIDerivedType format.
327 GetTagConstant(VMContext, Tag),
331 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
332 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
333 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
334 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
335 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
338 return DIDerivedType(MDNode::get(VMContext, Elts));
341 /// createTypedef - Create debugging information entry for a typedef.
342 DIDerivedType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
343 unsigned LineNo, DIDescriptor Context) {
344 // typedefs are encoded in DIDerivedType format.
345 assert(Ty.isType() && "Invalid typedef type!");
347 GetTagConstant(VMContext, dwarf::DW_TAG_typedef),
349 getNonCompileUnitScope(Context),
350 MDString::get(VMContext, Name),
351 ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
352 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
353 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
354 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
355 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
358 return DIDerivedType(MDNode::get(VMContext, Elts));
361 /// createFriend - Create debugging information entry for a 'friend'.
362 DIDerivedType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
363 // typedefs are encoded in DIDerivedType format.
364 assert(Ty.isType() && "Invalid type!");
365 assert(FriendTy.isType() && "Invalid friend type!");
367 GetTagConstant(VMContext, dwarf::DW_TAG_friend),
371 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
372 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
373 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
374 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
375 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
378 return DIDerivedType(MDNode::get(VMContext, Elts));
381 /// createInheritance - Create debugging information entry to establish
382 /// inheritance relationship between two types.
383 DIDerivedType DIBuilder::createInheritance(
384 DIType Ty, DIType BaseTy, uint64_t BaseOffset, unsigned Flags) {
385 assert(Ty.isType() && "Unable to create inheritance");
386 // TAG_inheritance is encoded in DIDerivedType format.
388 GetTagConstant(VMContext, dwarf::DW_TAG_inheritance),
392 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
393 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
394 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
395 ConstantInt::get(Type::getInt64Ty(VMContext), BaseOffset),
396 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
399 return DIDerivedType(MDNode::get(VMContext, Elts));
402 /// createMemberType - Create debugging information entry for a member.
403 DIDerivedType DIBuilder::createMemberType(
404 DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
405 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
406 unsigned Flags, DIType Ty) {
407 // TAG_member is encoded in DIDerivedType format.
409 GetTagConstant(VMContext, dwarf::DW_TAG_member),
411 getNonCompileUnitScope(Scope),
412 MDString::get(VMContext, Name),
413 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
414 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
415 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
416 ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
417 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
420 return DIDerivedType(MDNode::get(VMContext, Elts));
423 /// createStaticMemberType - Create debugging information entry for a
424 /// C++ static data member.
426 DIBuilder::createStaticMemberType(DIDescriptor Scope, StringRef Name,
427 DIFile File, unsigned LineNumber,
428 DIType Ty, unsigned Flags,
430 // TAG_member is encoded in DIDerivedType format.
431 Flags |= DIDescriptor::FlagStaticMember;
433 GetTagConstant(VMContext, dwarf::DW_TAG_member),
435 getNonCompileUnitScope(Scope),
436 MDString::get(VMContext, Name),
437 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
438 ConstantInt::get(Type::getInt64Ty(VMContext), 0/*SizeInBits*/),
439 ConstantInt::get(Type::getInt64Ty(VMContext), 0/*AlignInBits*/),
440 ConstantInt::get(Type::getInt64Ty(VMContext), 0/*OffsetInBits*/),
441 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
445 return DIDerivedType(MDNode::get(VMContext, Elts));
448 /// createObjCIVar - Create debugging information entry for Objective-C
449 /// instance variable.
451 DIBuilder::createObjCIVar(StringRef Name,
452 DIFile File, unsigned LineNumber,
453 uint64_t SizeInBits, uint64_t AlignInBits,
454 uint64_t OffsetInBits, unsigned Flags,
455 DIType Ty, StringRef PropertyName,
456 StringRef GetterName, StringRef SetterName,
457 unsigned PropertyAttributes) {
458 // TAG_member is encoded in DIDerivedType format.
460 GetTagConstant(VMContext, dwarf::DW_TAG_member),
462 getNonCompileUnitScope(File),
463 MDString::get(VMContext, Name),
464 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
465 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
466 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
467 ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
468 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
470 MDString::get(VMContext, PropertyName),
471 MDString::get(VMContext, GetterName),
472 MDString::get(VMContext, SetterName),
473 ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes)
475 return DIDerivedType(MDNode::get(VMContext, Elts));
478 /// createObjCIVar - Create debugging information entry for Objective-C
479 /// instance variable.
481 DIBuilder::createObjCIVar(StringRef Name,
482 DIFile File, unsigned LineNumber,
483 uint64_t SizeInBits, uint64_t AlignInBits,
484 uint64_t OffsetInBits, unsigned Flags,
485 DIType Ty, MDNode *PropertyNode) {
486 // TAG_member is encoded in DIDerivedType format.
488 GetTagConstant(VMContext, dwarf::DW_TAG_member),
490 getNonCompileUnitScope(File),
491 MDString::get(VMContext, Name),
492 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
493 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
494 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
495 ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
496 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
500 return DIDerivedType(MDNode::get(VMContext, Elts));
503 /// createObjCProperty - Create debugging information entry for Objective-C
505 DIObjCProperty DIBuilder::createObjCProperty(StringRef Name,
506 DIFile File, unsigned LineNumber,
507 StringRef GetterName,
508 StringRef SetterName,
509 unsigned PropertyAttributes,
512 GetTagConstant(VMContext, dwarf::DW_TAG_APPLE_property),
513 MDString::get(VMContext, Name),
515 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
516 MDString::get(VMContext, GetterName),
517 MDString::get(VMContext, SetterName),
518 ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes),
521 return DIObjCProperty(MDNode::get(VMContext, Elts));
524 /// createTemplateTypeParameter - Create debugging information for template
526 DITemplateTypeParameter
527 DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
528 DIType Ty, MDNode *File, unsigned LineNo,
531 GetTagConstant(VMContext, dwarf::DW_TAG_template_type_parameter),
532 getNonCompileUnitScope(Context),
533 MDString::get(VMContext, Name),
536 ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
537 ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
539 return DITemplateTypeParameter(MDNode::get(VMContext, Elts));
542 DITemplateValueParameter
543 DIBuilder::createTemplateValueParameter(unsigned Tag, DIDescriptor Context,
544 StringRef Name, DIType Ty,
545 Value *Val, MDNode *File,
549 GetTagConstant(VMContext, Tag),
550 getNonCompileUnitScope(Context),
551 MDString::get(VMContext, Name),
555 ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
556 ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
558 return DITemplateValueParameter(MDNode::get(VMContext, Elts));
561 /// createTemplateValueParameter - Create debugging information for template
563 DITemplateValueParameter
564 DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
565 DIType Ty, Value *Val,
566 MDNode *File, unsigned LineNo,
568 return createTemplateValueParameter(dwarf::DW_TAG_template_value_parameter,
569 Context, Name, Ty, Val, File, LineNo,
573 DITemplateValueParameter
574 DIBuilder::createTemplateTemplateParameter(DIDescriptor Context, StringRef Name,
575 DIType Ty, StringRef Val,
576 MDNode *File, unsigned LineNo,
578 return createTemplateValueParameter(
579 dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
580 MDString::get(VMContext, Val), File, LineNo, ColumnNo);
583 DITemplateValueParameter
584 DIBuilder::createTemplateParameterPack(DIDescriptor Context, StringRef Name,
585 DIType Ty, DIArray Val,
586 MDNode *File, unsigned LineNo,
588 return createTemplateValueParameter(dwarf::DW_TAG_GNU_template_parameter_pack,
589 Context, Name, Ty, Val, File, LineNo,
593 /// createClassType - Create debugging information entry for a class.
594 DICompositeType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
595 DIFile File, unsigned LineNumber,
597 uint64_t AlignInBits,
598 uint64_t OffsetInBits,
599 unsigned Flags, DIType DerivedFrom,
601 MDNode *VTableHolder,
602 MDNode *TemplateParams) {
603 assert((!Context || Context.isScope() || Context.isType()) &&
604 "createClassType should be called with a valid Context");
605 // TAG_class_type is encoded in DICompositeType format.
607 GetTagConstant(VMContext, dwarf::DW_TAG_class_type),
609 getNonCompileUnitScope(Context),
610 MDString::get(VMContext, Name),
611 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
612 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
613 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
614 ConstantInt::get(Type::getInt32Ty(VMContext), OffsetInBits),
615 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
618 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
621 NULL // Type Identifer
623 DICompositeType R(MDNode::get(VMContext, Elts));
624 assert(R.isCompositeType() &&
625 "createClassType should return a DICompositeType");
629 /// createStructType - Create debugging information entry for a struct.
630 DICompositeType DIBuilder::createStructType(DIDescriptor Context,
631 StringRef Name, DIFile File,
634 uint64_t AlignInBits,
635 unsigned Flags, DIType DerivedFrom,
637 unsigned RunTimeLang,
638 MDNode *VTableHolder) {
639 // TAG_structure_type is encoded in DICompositeType format.
641 GetTagConstant(VMContext, dwarf::DW_TAG_structure_type),
643 getNonCompileUnitScope(Context),
644 MDString::get(VMContext, Name),
645 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
646 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
647 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
648 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
649 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
652 ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
655 NULL // Type Identifer
657 DICompositeType R(MDNode::get(VMContext, Elts));
658 assert(R.isCompositeType() &&
659 "createStructType should return a DICompositeType");
663 /// createUnionType - Create debugging information entry for an union.
664 DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
665 DIFile File, unsigned LineNumber,
667 uint64_t AlignInBits, unsigned Flags,
669 unsigned RunTimeLang) {
670 // TAG_union_type is encoded in DICompositeType format.
672 GetTagConstant(VMContext, dwarf::DW_TAG_union_type),
674 getNonCompileUnitScope(Scope),
675 MDString::get(VMContext, Name),
676 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
677 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
678 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
679 ConstantInt::get(Type::getInt64Ty(VMContext), 0),
680 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
683 ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
686 NULL // Type Identifer
688 return DICompositeType(MDNode::get(VMContext, Elts));
691 /// createSubroutineType - Create subroutine type.
693 DIBuilder::createSubroutineType(DIFile File, DIArray ParameterTypes) {
694 // TAG_subroutine_type is encoded in DICompositeType format.
696 GetTagConstant(VMContext, dwarf::DW_TAG_subroutine_type),
697 Constant::getNullValue(Type::getInt32Ty(VMContext)),
698 Constant::getNullValue(Type::getInt32Ty(VMContext)),
699 MDString::get(VMContext, ""),
700 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
701 ConstantInt::get(Type::getInt64Ty(VMContext), 0),
702 ConstantInt::get(Type::getInt64Ty(VMContext), 0),
703 ConstantInt::get(Type::getInt64Ty(VMContext), 0),
704 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
707 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
710 NULL // Type Identifer
712 return DICompositeType(MDNode::get(VMContext, Elts));
715 /// createEnumerationType - Create debugging information entry for an
717 DICompositeType DIBuilder::createEnumerationType(
718 DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
719 uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements,
720 DIType UnderlyingType) {
721 // TAG_enumeration_type is encoded in DICompositeType format.
723 GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type),
725 getNonCompileUnitScope(Scope),
726 MDString::get(VMContext, Name),
727 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
728 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
729 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
730 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
731 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
734 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
737 NULL // Type Identifer
739 MDNode *Node = MDNode::get(VMContext, Elts);
740 AllEnumTypes.push_back(Node);
741 return DICompositeType(Node);
744 /// createArrayType - Create debugging information entry for an array.
745 DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
746 DIType Ty, DIArray Subscripts) {
747 // TAG_array_type is encoded in DICompositeType format.
749 GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
750 NULL, // Filename/Directory,
752 MDString::get(VMContext, ""),
753 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
754 ConstantInt::get(Type::getInt64Ty(VMContext), Size),
755 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
756 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
757 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
760 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
763 NULL // Type Identifer
765 return DICompositeType(MDNode::get(VMContext, Elts));
768 /// createVectorType - Create debugging information entry for a vector.
769 DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
770 DIType Ty, DIArray Subscripts) {
771 // A vector is an array type with the FlagVector flag applied.
773 GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
774 NULL, // Filename/Directory,
776 MDString::get(VMContext, ""),
777 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
778 ConstantInt::get(Type::getInt64Ty(VMContext), Size),
779 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
780 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
781 ConstantInt::get(Type::getInt32Ty(VMContext), DIType::FlagVector),
784 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
787 NULL // Type Identifer
789 return DICompositeType(MDNode::get(VMContext, Elts));
792 /// createArtificialType - Create a new DIType with "artificial" flag set.
793 DIType DIBuilder::createArtificialType(DIType Ty) {
794 if (Ty.isArtificial())
797 SmallVector<Value *, 9> Elts;
799 assert (N && "Unexpected input DIType!");
800 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
801 if (Value *V = N->getOperand(i))
804 Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
807 unsigned CurFlags = Ty.getFlags();
808 CurFlags = CurFlags | DIType::FlagArtificial;
810 // Flags are stored at this slot.
811 Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
813 return DIType(MDNode::get(VMContext, Elts));
816 /// createObjectPointerType - Create a new type with both the object pointer
817 /// and artificial flags set.
818 DIType DIBuilder::createObjectPointerType(DIType Ty) {
819 if (Ty.isObjectPointer())
822 SmallVector<Value *, 9> Elts;
824 assert (N && "Unexpected input DIType!");
825 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
826 if (Value *V = N->getOperand(i))
829 Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
832 unsigned CurFlags = Ty.getFlags();
833 CurFlags = CurFlags | (DIType::FlagObjectPointer | DIType::FlagArtificial);
835 // Flags are stored at this slot.
836 Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
838 return DIType(MDNode::get(VMContext, Elts));
841 /// retainType - Retain DIType in a module even if it is not referenced
842 /// through debug info anchors.
843 void DIBuilder::retainType(DIType T) {
844 AllRetainTypes.push_back(T);
847 /// createUnspecifiedParameter - Create unspeicified type descriptor
848 /// for the subroutine type.
849 DIDescriptor DIBuilder::createUnspecifiedParameter() {
851 GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_parameters)
853 return DIDescriptor(MDNode::get(VMContext, Elts));
856 /// createForwardDecl - Create a temporary forward-declared type that
857 /// can be RAUW'd if the full type is seen.
858 DICompositeType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name,
859 DIDescriptor Scope, DIFile F,
860 unsigned Line, unsigned RuntimeLang,
862 uint64_t AlignInBits) {
863 // Create a temporary MDNode.
865 GetTagConstant(VMContext, Tag),
867 getNonCompileUnitScope(Scope),
868 MDString::get(VMContext, Name),
869 ConstantInt::get(Type::getInt32Ty(VMContext), Line),
870 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
871 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
872 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
873 ConstantInt::get(Type::getInt32Ty(VMContext),
874 DIDescriptor::FlagFwdDecl),
877 ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang),
879 NULL, //TemplateParams
880 NULL // Type Identifer
882 MDNode *Node = MDNode::getTemporary(VMContext, Elts);
883 DICompositeType RetTy(Node);
884 assert(RetTy.isCompositeType() &&
885 "createForwardDecl result should be a DIType");
889 /// getOrCreateArray - Get a DIArray, create one if required.
890 DIArray DIBuilder::getOrCreateArray(ArrayRef<Value *> Elements) {
891 if (Elements.empty()) {
892 Value *Null = Constant::getNullValue(Type::getInt32Ty(VMContext));
893 return DIArray(MDNode::get(VMContext, Null));
895 return DIArray(MDNode::get(VMContext, Elements));
898 /// getOrCreateSubrange - Create a descriptor for a value range. This
899 /// implicitly uniques the values returned.
900 DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
902 GetTagConstant(VMContext, dwarf::DW_TAG_subrange_type),
903 ConstantInt::get(Type::getInt64Ty(VMContext), Lo),
904 ConstantInt::get(Type::getInt64Ty(VMContext), Count)
907 return DISubrange(MDNode::get(VMContext, Elts));
910 /// \brief Create a new descriptor for the specified global.
911 DIGlobalVariable DIBuilder::
912 createGlobalVariable(StringRef Name, StringRef LinkageName, DIFile F,
913 unsigned LineNumber, DIType Ty, bool isLocalToUnit,
916 GetTagConstant(VMContext, dwarf::DW_TAG_variable),
917 Constant::getNullValue(Type::getInt32Ty(VMContext)),
919 MDString::get(VMContext, Name),
920 MDString::get(VMContext, Name),
921 MDString::get(VMContext, LinkageName),
923 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
925 ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit),
926 ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/
930 MDNode *Node = MDNode::get(VMContext, Elts);
931 AllGVs.push_back(Node);
932 return DIGlobalVariable(Node);
935 /// \brief Create a new descriptor for the specified global.
936 DIGlobalVariable DIBuilder::
937 createGlobalVariable(StringRef Name, DIFile F, unsigned LineNumber,
938 DIType Ty, bool isLocalToUnit, Value *Val) {
939 return createGlobalVariable(Name, Name, F, LineNumber, Ty, isLocalToUnit,
943 /// createStaticVariable - Create a new descriptor for the specified static
945 DIGlobalVariable DIBuilder::
946 createStaticVariable(DIDescriptor Context, StringRef Name,
947 StringRef LinkageName, DIFile F, unsigned LineNumber,
948 DIType Ty, bool isLocalToUnit, Value *Val, MDNode *Decl) {
950 GetTagConstant(VMContext, dwarf::DW_TAG_variable),
951 Constant::getNullValue(Type::getInt32Ty(VMContext)),
952 getNonCompileUnitScope(Context),
953 MDString::get(VMContext, Name),
954 MDString::get(VMContext, Name),
955 MDString::get(VMContext, LinkageName),
957 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
959 ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit),
960 ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/
964 MDNode *Node = MDNode::get(VMContext, Elts);
965 AllGVs.push_back(Node);
966 return DIGlobalVariable(Node);
969 /// createVariable - Create a new descriptor for the specified variable.
970 DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
971 StringRef Name, DIFile File,
972 unsigned LineNo, DIType Ty,
973 bool AlwaysPreserve, unsigned Flags,
975 DIDescriptor Context(getNonCompileUnitScope(Scope));
976 assert((!Context || Context.isScope()) &&
977 "createLocalVariable should be called with a valid Context");
978 assert(Ty.isType() &&
979 "createLocalVariable should be called with a valid type");
981 GetTagConstant(VMContext, Tag),
982 getNonCompileUnitScope(Scope),
983 MDString::get(VMContext, Name),
985 ConstantInt::get(Type::getInt32Ty(VMContext), (LineNo | (ArgNo << 24))),
987 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
988 Constant::getNullValue(Type::getInt32Ty(VMContext))
990 MDNode *Node = MDNode::get(VMContext, Elts);
991 if (AlwaysPreserve) {
992 // The optimizer may remove local variable. If there is an interest
993 // to preserve variable info in such situation then stash it in a
995 DISubprogram Fn(getDISubprogram(Scope));
996 NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, Fn);
997 FnLocals->addOperand(Node);
999 DIVariable RetVar(Node);
1000 assert(RetVar.isVariable() &&
1001 "createLocalVariable should return a valid DIVariable");
1005 /// createComplexVariable - Create a new descriptor for the specified variable
1006 /// which has a complex address expression for its address.
1007 DIVariable DIBuilder::createComplexVariable(unsigned Tag, DIDescriptor Scope,
1008 StringRef Name, DIFile F,
1010 DIType Ty, ArrayRef<Value *> Addr,
1012 SmallVector<Value *, 15> Elts;
1013 Elts.push_back(GetTagConstant(VMContext, Tag));
1014 Elts.push_back(getNonCompileUnitScope(Scope)),
1015 Elts.push_back(MDString::get(VMContext, Name));
1017 Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext),
1018 (LineNo | (ArgNo << 24))));
1020 Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
1021 Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
1022 Elts.append(Addr.begin(), Addr.end());
1024 return DIVariable(MDNode::get(VMContext, Elts));
1027 /// createFunction - Create a new descriptor for the specified function.
1028 DISubprogram DIBuilder::createFunction(DIDescriptor Context,
1030 StringRef LinkageName,
1031 DIFile File, unsigned LineNo,
1033 bool isLocalToUnit, bool isDefinition,
1035 unsigned Flags, bool isOptimized,
1039 assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
1040 "function types should be subroutines");
1041 Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
1043 GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
1045 getNonCompileUnitScope(Context),
1046 MDString::get(VMContext, Name),
1047 MDString::get(VMContext, Name),
1048 MDString::get(VMContext, LinkageName),
1049 ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
1051 ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
1052 ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
1053 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
1054 ConstantInt::get(Type::getInt32Ty(VMContext), 0),
1056 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
1057 ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
1061 MDNode::getTemporary(VMContext, TElts),
1062 ConstantInt::get(Type::getInt32Ty(VMContext), ScopeLine)
1064 MDNode *Node = MDNode::get(VMContext, Elts);
1066 // Create a named metadata so that we do not lose this mdnode.
1068 AllSubprograms.push_back(Node);
1069 DISubprogram S(Node);
1070 assert(S.isSubprogram() && "createFunction should return a valid DISubprogram");
1074 /// createMethod - Create a new descriptor for the specified C++ method.
1075 DISubprogram DIBuilder::createMethod(DIDescriptor Context,
1077 StringRef LinkageName,
1079 unsigned LineNo, DICompositeType Ty,
1082 unsigned VK, unsigned VIndex,
1083 MDNode *VTableHolder,
1088 assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
1089 "function types should be subroutines");
1090 Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
1092 GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
1094 getNonCompileUnitScope(Context),
1095 MDString::get(VMContext, Name),
1096 MDString::get(VMContext, Name),
1097 MDString::get(VMContext, LinkageName),
1098 ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
1100 ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
1101 ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
1102 ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK),
1103 ConstantInt::get(Type::getInt32Ty(VMContext), VIndex),
1105 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
1106 ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
1109 Constant::getNullValue(Type::getInt32Ty(VMContext)),
1110 MDNode::getTemporary(VMContext, TElts),
1111 // FIXME: Do we want to use different scope/lines?
1112 ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
1114 MDNode *Node = MDNode::get(VMContext, Elts);
1116 AllSubprograms.push_back(Node);
1117 DISubprogram S(Node);
1118 assert(S.isSubprogram() && "createMethod should return a valid DISubprogram");
1122 /// createNameSpace - This creates new descriptor for a namespace
1123 /// with the specified parent scope.
1124 DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
1125 DIFile File, unsigned LineNo) {
1127 GetTagConstant(VMContext, dwarf::DW_TAG_namespace),
1129 getNonCompileUnitScope(Scope),
1130 MDString::get(VMContext, Name),
1131 ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
1133 DINameSpace R(MDNode::get(VMContext, Elts));
1134 assert(R.Verify() &&
1135 "createNameSpace should return a verifiable DINameSpace");
1139 /// createLexicalBlockFile - This creates a new MDNode that encapsulates
1140 /// an existing scope with a new filename.
1141 DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
1144 GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
1148 DILexicalBlockFile R(MDNode::get(VMContext, Elts));
1151 "createLexicalBlockFile should return a verifiable DILexicalBlockFile");
1155 DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
1156 unsigned Line, unsigned Col) {
1157 // Defeat MDNode uniquing for lexical blocks by using unique id.
1158 static unsigned int unique_id = 0;
1160 GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
1162 getNonCompileUnitScope(Scope),
1163 ConstantInt::get(Type::getInt32Ty(VMContext), Line),
1164 ConstantInt::get(Type::getInt32Ty(VMContext), Col),
1165 ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
1167 DILexicalBlock R(MDNode::get(VMContext, Elts));
1168 assert(R.Verify() &&
1169 "createLexicalBlock should return a verifiable DILexicalBlock");
1173 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
1174 Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
1175 Instruction *InsertBefore) {
1176 assert(Storage && "no storage passed to dbg.declare");
1177 assert(VarInfo.isVariable() &&
1178 "empty or invalid DIVariable passed to dbg.declare");
1180 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
1182 Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
1183 return CallInst::Create(DeclareFn, Args, "", InsertBefore);
1186 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
1187 Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
1188 BasicBlock *InsertAtEnd) {
1189 assert(Storage && "no storage passed to dbg.declare");
1190 assert(VarInfo.isVariable() &&
1191 "empty or invalid DIVariable passed to dbg.declare");
1193 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
1195 Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
1197 // If this block already has a terminator then insert this intrinsic
1198 // before the terminator.
1199 if (TerminatorInst *T = InsertAtEnd->getTerminator())
1200 return CallInst::Create(DeclareFn, Args, "", T);
1202 return CallInst::Create(DeclareFn, Args, "", InsertAtEnd);
1205 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
1206 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
1208 Instruction *InsertBefore) {
1209 assert(V && "no value passed to dbg.value");
1210 assert(VarInfo.isVariable() &&
1211 "empty or invalid DIVariable passed to dbg.value");
1213 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
1215 Value *Args[] = { MDNode::get(V->getContext(), V),
1216 ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
1218 return CallInst::Create(ValueFn, Args, "", InsertBefore);
1221 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
1222 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
1224 BasicBlock *InsertAtEnd) {
1225 assert(V && "no value passed to dbg.value");
1226 assert(VarInfo.isVariable() &&
1227 "empty or invalid DIVariable passed to dbg.value");
1229 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
1231 Value *Args[] = { MDNode::get(V->getContext(), V),
1232 ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
1234 return CallInst::Create(ValueFn, Args, "", InsertAtEnd);