blob: 51f758c542298cbae820a3eefd7959e8e903db2a [file] [log] [blame]
Chris Lattner4b009652007-07-25 00:24:17 +00001//===--- CodeGenModule.cpp - Emit LLVM Code from ASTs for a Module --------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This coordinates the per-module state used while generating code.
11//
12//===----------------------------------------------------------------------===//
13
14#include "CodeGenModule.h"
15#include "CodeGenFunction.h"
16#include "clang/AST/ASTContext.h"
17#include "clang/AST/Decl.h"
Chris Lattnerdb6be562007-11-28 05:34:05 +000018#include "clang/Basic/LangOptions.h"
Chris Lattner4b009652007-07-25 00:24:17 +000019#include "clang/Basic/TargetInfo.h"
20#include "llvm/Constants.h"
21#include "llvm/DerivedTypes.h"
Chris Lattnerab862cc2007-08-31 04:31:45 +000022#include "llvm/Module.h"
Chris Lattner4b009652007-07-25 00:24:17 +000023#include "llvm/Intrinsics.h"
24using namespace clang;
25using namespace CodeGen;
26
27
Chris Lattnerdb6be562007-11-28 05:34:05 +000028CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
Chris Lattner22595b82007-12-02 01:40:18 +000029 llvm::Module &M, const llvm::TargetData &TD,
30 Diagnostic &diags)
31 : Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags),
Devang Patela8fccb82007-10-31 20:01:01 +000032 Types(C, M, TD), MemCpyFn(0), CFConstantStringClassRef(0) {}
Chris Lattner4b009652007-07-25 00:24:17 +000033
Chris Lattner0e4755d2007-12-02 06:27:33 +000034
35/// ReplaceMapValuesWith - This is a really slow and bad function that
36/// searches for any entries in GlobalDeclMap that point to OldVal, changing
37/// them to point to NewVal. This is badbadbad, FIXME!
38void CodeGenModule::ReplaceMapValuesWith(llvm::Constant *OldVal,
39 llvm::Constant *NewVal) {
40 for (llvm::DenseMap<const Decl*, llvm::Constant*>::iterator
41 I = GlobalDeclMap.begin(), E = GlobalDeclMap.end(); I != E; ++I)
42 if (I->second == OldVal) I->second = NewVal;
43}
44
45
Steve Naroffcb597472007-09-13 21:41:19 +000046llvm::Constant *CodeGenModule::GetAddrOfGlobalDecl(const ValueDecl *D) {
Chris Lattner4b009652007-07-25 00:24:17 +000047 // See if it is already in the map.
48 llvm::Constant *&Entry = GlobalDeclMap[D];
49 if (Entry) return Entry;
50
51 QualType ASTTy = cast<ValueDecl>(D)->getType();
52 const llvm::Type *Ty = getTypes().ConvertType(ASTTy);
53 if (isa<FunctionDecl>(D)) {
54 const llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty);
Chris Lattner2568ae42007-12-02 05:56:05 +000055
56 // Check to see if the function already exists.
57 if (llvm::Function *F = getModule().getFunction(D->getName())) {
58 // If so, make sure it is the correct type.
59 return llvm::ConstantExpr::getBitCast(F, llvm::PointerType::get(FTy));
60 }
61
Chris Lattner4b009652007-07-25 00:24:17 +000062 // FIXME: param attributes for sext/zext etc.
63 return Entry = new llvm::Function(FTy, llvm::Function::ExternalLinkage,
64 D->getName(), &getModule());
65 }
66
67 assert(isa<FileVarDecl>(D) && "Unknown global decl!");
68
69 return Entry = new llvm::GlobalVariable(Ty, false,
70 llvm::GlobalValue::ExternalLinkage,
71 0, D->getName(), &getModule());
72}
73
74void CodeGenModule::EmitFunction(const FunctionDecl *FD) {
75 // If this is not a prototype, emit the body.
76 if (FD->getBody())
77 CodeGenFunction(*this).GenerateCode(FD);
78}
79
Chris Lattnercef01ec2007-11-23 22:07:55 +000080static llvm::Constant *GenerateConstantExpr(const Expr *Expression,
81 CodeGenModule& CGModule);
Devang Patel08a10cc2007-10-30 21:27:20 +000082
Chris Lattnercef01ec2007-11-23 22:07:55 +000083/// GenerateConversionToBool - Generate comparison to zero for conversion to
84/// bool
85static llvm::Constant *GenerateConversionToBool(llvm::Constant *Expression,
86 QualType Source) {
87 if (Source->isRealFloatingType()) {
88 // Compare against 0.0 for fp scalars.
89 llvm::Constant *Zero = llvm::Constant::getNullValue(Expression->getType());
90 return llvm::ConstantExpr::getFCmp(llvm::FCmpInst::FCMP_UNE, Expression,
91 Zero);
92 }
93
94 assert((Source->isIntegerType() || Source->isPointerType()) &&
95 "Unknown scalar type to convert");
96
97 // Compare against an integer or pointer null.
98 llvm::Constant *Zero = llvm::Constant::getNullValue(Expression->getType());
99 return llvm::ConstantExpr::getICmp(llvm::ICmpInst::ICMP_NE, Expression, Zero);
100}
101
102/// GenerateConstantCast - Generates a constant cast to convert the Expression
103/// into the Target type.
104static llvm::Constant *GenerateConstantCast(const Expr *Expression,
105 QualType Target,
106 CodeGenModule& CGModule) {
107 CodeGenTypes& Types = CGModule.getTypes();
108 QualType Source = Expression->getType().getCanonicalType();
109 Target = Target.getCanonicalType();
110
111 assert (!Target->isVoidType());
112
113 llvm::Constant *SubExpr = GenerateConstantExpr(Expression, CGModule);
114
115 if (Source == Target)
116 return SubExpr;
117
118 // Handle conversions to bool first, they are special: comparisons against 0.
119 if (Target->isBooleanType())
120 return GenerateConversionToBool(SubExpr, Source);
121
122 const llvm::Type *SourceType = Types.ConvertType(Source);
123 const llvm::Type *TargetType = Types.ConvertType(Target);
124
125 // Ignore conversions like int -> uint.
126 if (SubExpr->getType() == TargetType)
127 return SubExpr;
128
129 // Handle pointer conversions next: pointers can only be converted to/from
130 // other pointers and integers.
131 if (isa<llvm::PointerType>(TargetType)) {
132 // The source value may be an integer, or a pointer.
133 if (isa<llvm::PointerType>(SubExpr->getType()))
134 return llvm::ConstantExpr::getBitCast(SubExpr, TargetType);
135 assert(Source->isIntegerType() && "Not ptr->ptr or int->ptr conversion?");
136 return llvm::ConstantExpr::getIntToPtr(SubExpr, TargetType);
137 }
138
139 if (isa<llvm::PointerType>(SourceType)) {
140 // Must be an ptr to int cast.
141 assert(isa<llvm::IntegerType>(TargetType) && "not ptr->int?");
142 return llvm::ConstantExpr::getPtrToInt(SubExpr, TargetType);
143 }
144
145 if (Source->isRealFloatingType() && Target->isRealFloatingType()) {
146 return llvm::ConstantExpr::getFPCast(SubExpr, TargetType);
147 }
148
149 // Finally, we have the arithmetic types: real int/float.
150 if (isa<llvm::IntegerType>(SourceType)) {
151 bool InputSigned = Source->isSignedIntegerType();
152 if (isa<llvm::IntegerType>(TargetType))
153 return llvm::ConstantExpr::getIntegerCast(SubExpr, TargetType,
154 InputSigned);
155 else if (InputSigned)
156 return llvm::ConstantExpr::getSIToFP(SubExpr, TargetType);
157 else
158 return llvm::ConstantExpr::getUIToFP(SubExpr, TargetType);
159 }
160
161 assert(SubExpr->getType()->isFloatingPoint() && "Unknown real conversion");
162 if (isa<llvm::IntegerType>(TargetType)) {
163 if (Target->isSignedIntegerType())
164 return llvm::ConstantExpr::getFPToSI(SubExpr, TargetType);
165 else
166 return llvm::ConstantExpr::getFPToUI(SubExpr, TargetType);
167 }
168
169 assert(TargetType->isFloatingPoint() && "Unknown real conversion");
170 if (TargetType->getTypeID() < SubExpr->getType()->getTypeID())
171 return llvm::ConstantExpr::getFPTrunc(SubExpr, TargetType);
172 else
173 return llvm::ConstantExpr::getFPExtend(SubExpr, TargetType);
174
175 assert (!"Unsupported cast type in global intialiser.");
176 return 0;
177}
178
Chris Lattnercef01ec2007-11-23 22:07:55 +0000179/// GenerateAggregateInit - Generate a Constant initaliser for global array or
180/// struct typed variables.
181static llvm::Constant *GenerateAggregateInit(const InitListExpr *ILE,
182 CodeGenModule& CGModule) {
183 assert (ILE->getType()->isArrayType() || ILE->getType()->isStructureType());
184 CodeGenTypes& Types = CGModule.getTypes();
Devang Patel08a10cc2007-10-30 21:27:20 +0000185
186 unsigned NumInitElements = ILE->getNumInits();
187
Chris Lattnercef01ec2007-11-23 22:07:55 +0000188 const llvm::CompositeType *CType =
189 cast<llvm::CompositeType>(Types.ConvertType(ILE->getType()));
190 assert(CType);
191 std::vector<llvm::Constant*> Elts;
192
Devang Patel08a10cc2007-10-30 21:27:20 +0000193 // Copy initializer elements.
194 unsigned i = 0;
195 for (i = 0; i < NumInitElements; ++i) {
Chris Lattnercef01ec2007-11-23 22:07:55 +0000196 llvm::Constant *C = GenerateConstantExpr(ILE->getInit(i), CGModule);
197 assert (C && "Failed to create initialiser expression");
198 Elts.push_back(C);
Devang Patel08a10cc2007-10-30 21:27:20 +0000199 }
200
Chris Lattnercef01ec2007-11-23 22:07:55 +0000201 if (ILE->getType()->isStructureType())
202 return llvm::ConstantStruct::get(cast<llvm::StructType>(CType), Elts);
203
204 // Initialising an array requires us to automatically initialise any
205 // elements that have not been initialised explicitly
206 const llvm::ArrayType *AType = cast<llvm::ArrayType>(CType);
207 assert(AType);
Devang Patel08a10cc2007-10-30 21:27:20 +0000208 const llvm::Type *AElemTy = AType->getElementType();
Chris Lattnercef01ec2007-11-23 22:07:55 +0000209 unsigned NumArrayElements = AType->getNumElements();
210 // Initialize remaining array elements.
Devang Patel08a10cc2007-10-30 21:27:20 +0000211 for (; i < NumArrayElements; ++i)
Chris Lattnercef01ec2007-11-23 22:07:55 +0000212 Elts.push_back(llvm::Constant::getNullValue(AElemTy));
Devang Patel08a10cc2007-10-30 21:27:20 +0000213
Chris Lattnercef01ec2007-11-23 22:07:55 +0000214 return llvm::ConstantArray::get(AType, Elts);
215}
216
217/// GenerateConstantExpr - Recursively builds a constant initialiser for the
218/// given expression.
219static llvm::Constant *GenerateConstantExpr(const Expr* Expression,
220 CodeGenModule& CGModule) {
221 CodeGenTypes& Types = CGModule.getTypes();
222 ASTContext& Context = CGModule.getContext();
223 assert ((Expression->isConstantExpr(Context, 0) ||
224 Expression->getStmtClass() == Stmt::InitListExprClass) &&
225 "Only constant global initialisers are supported.");
226
227 QualType type = Expression->getType().getCanonicalType();
228
229 if (type->isIntegerType()) {
230 llvm::APSInt
231 Value(static_cast<uint32_t>(Context.getTypeSize(type, SourceLocation())));
232 if (Expression->isIntegerConstantExpr(Value, Context)) {
233 return llvm::ConstantInt::get(Value);
234 }
235 }
236
237 switch (Expression->getStmtClass()) {
238 // Generate constant for floating point literal values.
239 case Stmt::FloatingLiteralClass: {
240 const FloatingLiteral *FLiteral = cast<FloatingLiteral>(Expression);
241 return llvm::ConstantFP::get(Types.ConvertType(type), FLiteral->getValue());
242 }
243
244 // Generate constant for string literal values.
245 case Stmt::StringLiteralClass: {
246 const StringLiteral *SLiteral = cast<StringLiteral>(Expression);
Chris Lattnerdb6be562007-11-28 05:34:05 +0000247 const char *StrData = SLiteral->getStrData();
248 unsigned Len = SLiteral->getByteLength();
249 return CGModule.GetAddrOfConstantString(std::string(StrData,
250 StrData + Len));
Chris Lattnercef01ec2007-11-23 22:07:55 +0000251 }
252
253 // Elide parenthesis.
254 case Stmt::ParenExprClass:
255 return GenerateConstantExpr(cast<ParenExpr>(Expression)->getSubExpr(),
256 CGModule);
257
258 // Generate constant for sizeof operator.
259 // FIXME: Need to support AlignOf
260 case Stmt::SizeOfAlignOfTypeExprClass: {
261 const SizeOfAlignOfTypeExpr *SOExpr =
262 cast<SizeOfAlignOfTypeExpr>(Expression);
263 assert (SOExpr->isSizeOf());
264 return llvm::ConstantExpr::getSizeOf(Types.ConvertType(type));
265 }
266
267 // Generate constant cast expressions.
268 case Stmt::CastExprClass:
269 return GenerateConstantCast(cast<CastExpr>(Expression)->getSubExpr(), type,
270 CGModule);
271
272 case Stmt::ImplicitCastExprClass: {
273 const ImplicitCastExpr *ICExpr = cast<ImplicitCastExpr>(Expression);
274 return GenerateConstantCast(ICExpr->getSubExpr(), type, CGModule);
275 }
276
277 // Generate a constant array access expression
278 // FIXME: Clang's semantic analysis incorrectly prevents array access in
279 // global initialisers, preventing us from testing this.
280 case Stmt::ArraySubscriptExprClass: {
281 const ArraySubscriptExpr* ASExpr = cast<ArraySubscriptExpr>(Expression);
282 llvm::Constant *Base = GenerateConstantExpr(ASExpr->getBase(), CGModule);
283 llvm::Constant *Index = GenerateConstantExpr(ASExpr->getIdx(), CGModule);
284 return llvm::ConstantExpr::getExtractElement(Base, Index);
285 }
286
287 // Generate a constant expression to initialise an aggregate type, such as
288 // an array or struct.
289 case Stmt::InitListExprClass:
290 return GenerateAggregateInit(cast<InitListExpr>(Expression), CGModule);
291
292 default:
293 assert (!"Unsupported expression in global initialiser.");
294 }
295 return 0;
296}
297
Oliver Hunt253e0a72007-12-02 00:11:25 +0000298llvm::Constant *CodeGenModule::EmitGlobalInit(const Expr *Expression) {
299 return GenerateConstantExpr(Expression, *this);
Devang Patel08a10cc2007-10-30 21:27:20 +0000300}
301
Chris Lattner4b009652007-07-25 00:24:17 +0000302void CodeGenModule::EmitGlobalVar(const FileVarDecl *D) {
303 llvm::GlobalVariable *GV = cast<llvm::GlobalVariable>(GetAddrOfGlobalDecl(D));
304
305 // If the storage class is external and there is no initializer, just leave it
306 // as a declaration.
307 if (D->getStorageClass() == VarDecl::Extern && D->getInit() == 0)
308 return;
309
310 // Otherwise, convert the initializer, or use zero if appropriate.
311 llvm::Constant *Init = 0;
312 if (D->getInit() == 0) {
313 Init = llvm::Constant::getNullValue(GV->getType()->getElementType());
314 } else if (D->getType()->isIntegerType()) {
Hartmut Kaiserff08d2c2007-10-17 15:00:17 +0000315 llvm::APSInt Value(static_cast<uint32_t>(
Chris Lattnera96e0d82007-09-04 02:34:27 +0000316 getContext().getTypeSize(D->getInit()->getType(), SourceLocation())));
Chris Lattner4b009652007-07-25 00:24:17 +0000317 if (D->getInit()->isIntegerConstantExpr(Value, Context))
318 Init = llvm::ConstantInt::get(Value);
319 }
Devang Patel8b5f5302007-10-26 16:31:40 +0000320
Devang Patel08a10cc2007-10-30 21:27:20 +0000321 if (!Init)
Oliver Hunt253e0a72007-12-02 00:11:25 +0000322 Init = EmitGlobalInit(D->getInit());
Devang Patel8b5f5302007-10-26 16:31:40 +0000323
Devang Patel08a10cc2007-10-30 21:27:20 +0000324 assert(Init && "FIXME: Global variable initializers unimp!");
Chris Lattner4b009652007-07-25 00:24:17 +0000325
326 GV->setInitializer(Init);
327
328 // Set the llvm linkage type as appropriate.
329 // FIXME: This isn't right. This should handle common linkage and other
330 // stuff.
331 switch (D->getStorageClass()) {
332 case VarDecl::Auto:
333 case VarDecl::Register:
334 assert(0 && "Can't have auto or register globals");
335 case VarDecl::None:
336 case VarDecl::Extern:
337 // todo: common
338 break;
339 case VarDecl::Static:
340 GV->setLinkage(llvm::GlobalVariable::InternalLinkage);
341 break;
342 }
343}
344
345/// EmitGlobalVarDeclarator - Emit all the global vars attached to the specified
346/// declarator chain.
347void CodeGenModule::EmitGlobalVarDeclarator(const FileVarDecl *D) {
348 for (; D; D = cast_or_null<FileVarDecl>(D->getNextDeclarator()))
349 EmitGlobalVar(D);
350}
351
Chris Lattnerab862cc2007-08-31 04:31:45 +0000352/// getBuiltinLibFunction
353llvm::Function *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) {
354 if (BuiltinFunctions.size() <= BuiltinID)
355 BuiltinFunctions.resize(BuiltinID);
356
357 // Already available?
358 llvm::Function *&FunctionSlot = BuiltinFunctions[BuiltinID];
359 if (FunctionSlot)
360 return FunctionSlot;
361
362 assert(Context.BuiltinInfo.isLibFunction(BuiltinID) && "isn't a lib fn");
363
364 // Get the name, skip over the __builtin_ prefix.
365 const char *Name = Context.BuiltinInfo.GetName(BuiltinID)+10;
366
367 // Get the type for the builtin.
368 QualType Type = Context.BuiltinInfo.GetBuiltinType(BuiltinID, Context);
369 const llvm::FunctionType *Ty =
370 cast<llvm::FunctionType>(getTypes().ConvertType(Type));
371
372 // FIXME: This has a serious problem with code like this:
373 // void abs() {}
374 // ... __builtin_abs(x);
375 // The two versions of abs will collide. The fix is for the builtin to win,
376 // and for the existing one to be turned into a constantexpr cast of the
377 // builtin. In the case where the existing one is a static function, it
378 // should just be renamed.
Chris Lattner02c60f52007-08-31 04:44:06 +0000379 if (llvm::Function *Existing = getModule().getFunction(Name)) {
380 if (Existing->getFunctionType() == Ty && Existing->hasExternalLinkage())
381 return FunctionSlot = Existing;
382 assert(Existing == 0 && "FIXME: Name collision");
383 }
Chris Lattnerab862cc2007-08-31 04:31:45 +0000384
385 // FIXME: param attributes for sext/zext etc.
386 return FunctionSlot = new llvm::Function(Ty, llvm::Function::ExternalLinkage,
387 Name, &getModule());
388}
389
390
Chris Lattner4b009652007-07-25 00:24:17 +0000391llvm::Function *CodeGenModule::getMemCpyFn() {
392 if (MemCpyFn) return MemCpyFn;
393 llvm::Intrinsic::ID IID;
394 uint64_t Size; unsigned Align;
395 Context.Target.getPointerInfo(Size, Align, SourceLocation());
396 switch (Size) {
397 default: assert(0 && "Unknown ptr width");
398 case 32: IID = llvm::Intrinsic::memcpy_i32; break;
399 case 64: IID = llvm::Intrinsic::memcpy_i64; break;
400 }
401 return MemCpyFn = llvm::Intrinsic::getDeclaration(&TheModule, IID);
402}
Anders Carlsson36a04872007-08-21 00:21:21 +0000403
Chris Lattnerab862cc2007-08-31 04:31:45 +0000404llvm::Constant *CodeGenModule::
405GetAddrOfConstantCFString(const std::string &str) {
Anders Carlsson36a04872007-08-21 00:21:21 +0000406 llvm::StringMapEntry<llvm::Constant *> &Entry =
407 CFConstantStringMap.GetOrCreateValue(&str[0], &str[str.length()]);
408
409 if (Entry.getValue())
410 return Entry.getValue();
411
412 std::vector<llvm::Constant*> Fields;
413
414 if (!CFConstantStringClassRef) {
415 const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
416 Ty = llvm::ArrayType::get(Ty, 0);
417
418 CFConstantStringClassRef =
419 new llvm::GlobalVariable(Ty, false,
420 llvm::GlobalVariable::ExternalLinkage, 0,
421 "__CFConstantStringClassReference",
422 &getModule());
423 }
424
425 // Class pointer.
426 llvm::Constant *Zero = llvm::Constant::getNullValue(llvm::Type::Int32Ty);
427 llvm::Constant *Zeros[] = { Zero, Zero };
428 llvm::Constant *C =
429 llvm::ConstantExpr::getGetElementPtr(CFConstantStringClassRef, Zeros, 2);
430 Fields.push_back(C);
431
432 // Flags.
433 const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
434 Fields.push_back(llvm::ConstantInt::get(Ty, 1992));
435
436 // String pointer.
437 C = llvm::ConstantArray::get(str);
438 C = new llvm::GlobalVariable(C->getType(), true,
439 llvm::GlobalValue::InternalLinkage,
440 C, ".str", &getModule());
441
442 C = llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2);
443 Fields.push_back(C);
444
445 // String length.
446 Ty = getTypes().ConvertType(getContext().LongTy);
447 Fields.push_back(llvm::ConstantInt::get(Ty, str.length()));
448
449 // The struct.
450 Ty = getTypes().ConvertType(getContext().getCFConstantStringType());
451 C = llvm::ConstantStruct::get(cast<llvm::StructType>(Ty), Fields);
Anders Carlsson9be009e2007-11-01 00:41:52 +0000452 llvm::GlobalVariable *GV =
453 new llvm::GlobalVariable(C->getType(), true,
454 llvm::GlobalVariable::InternalLinkage,
455 C, "", &getModule());
456 GV->setSection("__DATA,__cfstring");
457 Entry.setValue(GV);
458 return GV;
Anders Carlsson36a04872007-08-21 00:21:21 +0000459}
Chris Lattnerdb6be562007-11-28 05:34:05 +0000460
461/// GenerateWritableString -- Creates storage for a string literal
462static llvm::Constant *GenerateStringLiteral(const std::string &str,
463 bool constant,
464 CodeGenModule& CGModule) {
465 // Create Constant for this string literal
466 llvm::Constant *C=llvm::ConstantArray::get(str);
467
468 // Create a global variable for this string
469 C = new llvm::GlobalVariable(C->getType(), constant,
470 llvm::GlobalValue::InternalLinkage,
471 C, ".str", &CGModule.getModule());
472 llvm::Constant *Zero = llvm::Constant::getNullValue(llvm::Type::Int32Ty);
473 llvm::Constant *Zeros[] = { Zero, Zero };
474 C = llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2);
475 return C;
476}
477
478/// CodeGenModule::GetAddrOfConstantString -- returns a pointer to the first
479/// element of a character array containing the literal.
480llvm::Constant *CodeGenModule::GetAddrOfConstantString(const std::string &str) {
481 // Don't share any string literals if writable-strings is turned on.
482 if (Features.WritableStrings)
483 return GenerateStringLiteral(str, false, *this);
484
485 llvm::StringMapEntry<llvm::Constant *> &Entry =
486 ConstantStringMap.GetOrCreateValue(&str[0], &str[str.length()]);
487
488 if (Entry.getValue())
489 return Entry.getValue();
490
491 // Create a global variable for this.
492 llvm::Constant *C = GenerateStringLiteral(str, true, *this);
493 Entry.setValue(C);
494 return C;
495}