blob: 800a522f4bf22f5e7d52a7a6453f0cd07b2500ee [file] [log] [blame]
Jim Laskey6da18642007-01-26 21:38:26 +00001//===-- llvm/CodeGen/MachineModuleInfo.cpp ----------------------*- C++ -*-===//
Jim Laskey6af56812006-01-04 13:36:38 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey6af56812006-01-04 13:36:38 +00007//
8//===----------------------------------------------------------------------===//
Jim Laskey6af56812006-01-04 13:36:38 +00009
Jim Laskey6da18642007-01-26 21:38:26 +000010#include "llvm/CodeGen/MachineModuleInfo.h"
Jim Laskey6af56812006-01-04 13:36:38 +000011
Jim Laskeyb3e789a2006-01-26 20:21:46 +000012#include "llvm/Constants.h"
Eric Christopher0d2b0ab2008-06-26 00:31:12 +000013#include "llvm/Analysis/ValueTracking.h"
Jim Laskey9d4209f2006-11-07 19:33:46 +000014#include "llvm/CodeGen/MachineFunctionPass.h"
15#include "llvm/CodeGen/MachineFunction.h"
Jim Laskey41886992006-04-07 16:34:46 +000016#include "llvm/CodeGen/MachineLocation.h"
Bill Wendling305635a2008-06-27 00:09:40 +000017#include "llvm/CodeGen/MachineDebugInfoDesc.h"
Jim Laskey9d4209f2006-11-07 19:33:46 +000018#include "llvm/Target/TargetInstrInfo.h"
19#include "llvm/Target/TargetMachine.h"
Jim Laskeyc1c47c32007-01-29 23:40:33 +000020#include "llvm/Target/TargetOptions.h"
Jim Laskeyb3e789a2006-01-26 20:21:46 +000021#include "llvm/DerivedTypes.h"
Jim Laskey86cbdba2006-02-06 15:33:21 +000022#include "llvm/GlobalVariable.h"
Jim Laskeyb3e789a2006-01-26 20:21:46 +000023#include "llvm/Intrinsics.h"
24#include "llvm/Instructions.h"
25#include "llvm/Module.h"
26#include "llvm/Support/Dwarf.h"
Bill Wendling832171c2006-12-07 20:04:42 +000027#include "llvm/Support/Streams.h"
Jim Laskey6af56812006-01-04 13:36:38 +000028using namespace llvm;
Jim Laskey9c4447a2006-03-01 20:39:36 +000029using namespace llvm::dwarf;
Jim Laskey6af56812006-01-04 13:36:38 +000030
31// Handle the Pass registration stuff necessary to use TargetData's.
Dan Gohman844731a2008-05-13 00:00:25 +000032static RegisterPass<MachineModuleInfo>
33X("machinemoduleinfo", "Module Information");
Devang Patel19974732007-05-03 01:11:54 +000034char MachineModuleInfo::ID = 0;
Jim Laskey063e7652006-01-17 17:31:53 +000035
Jim Laskeyb3e789a2006-01-26 20:21:46 +000036//===----------------------------------------------------------------------===//
37
Jim Laskey86cbdba2006-02-06 15:33:21 +000038/// getGlobalVariablesUsing - Return all of the GlobalVariables which have the
Jim Laskeyb3e789a2006-01-26 20:21:46 +000039/// specified value in their initializer somewhere.
40static void
41getGlobalVariablesUsing(Value *V, std::vector<GlobalVariable*> &Result) {
42 // Scan though value users.
43 for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) {
44 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(*I)) {
Jim Laskey86cbdba2006-02-06 15:33:21 +000045 // If the user is a GlobalVariable then add to result.
Jim Laskeyb3e789a2006-01-26 20:21:46 +000046 Result.push_back(GV);
47 } else if (Constant *C = dyn_cast<Constant>(*I)) {
48 // If the user is a constant variable then scan its users
49 getGlobalVariablesUsing(C, Result);
50 }
51 }
52}
53
Jim Laskey86cbdba2006-02-06 15:33:21 +000054/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
55/// named GlobalVariable.
Bill Wendling305635a2008-06-27 00:09:40 +000056static void
57getGlobalVariablesUsing(Module &M, const std::string &RootName,
58 std::vector<GlobalVariable*> &Result) {
Jim Laskeyce72b172006-02-11 01:01:30 +000059 std::vector<const Type*> FieldTypes;
Reid Spencer47857812006-12-31 05:55:36 +000060 FieldTypes.push_back(Type::Int32Ty);
61 FieldTypes.push_back(Type::Int32Ty);
Jim Laskeyb3e789a2006-01-26 20:21:46 +000062
Jim Laskey86cbdba2006-02-06 15:33:21 +000063 // Get the GlobalVariable root.
Jim Laskeyb3e789a2006-01-26 20:21:46 +000064 GlobalVariable *UseRoot = M.getGlobalVariable(RootName,
Jim Laskeyce72b172006-02-11 01:01:30 +000065 StructType::get(FieldTypes));
Jim Laskeyb3e789a2006-01-26 20:21:46 +000066
67 // If present and linkonce then scan for users.
Bill Wendling305635a2008-06-27 00:09:40 +000068 if (UseRoot && UseRoot->hasLinkOnceLinkage())
Jim Laskeyb3e789a2006-01-26 20:21:46 +000069 getGlobalVariablesUsing(UseRoot, Result);
Jim Laskeyb3e789a2006-01-26 20:21:46 +000070}
71
Jim Laskey86cbdba2006-02-06 15:33:21 +000072/// isStringValue - Return true if the given value can be coerced to a string.
73///
74static bool isStringValue(Value *V) {
75 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
76 if (GV->hasInitializer() && isa<ConstantArray>(GV->getInitializer())) {
77 ConstantArray *Init = cast<ConstantArray>(GV->getInitializer());
78 return Init->isString();
79 }
80 } else if (Constant *C = dyn_cast<Constant>(V)) {
81 if (GlobalValue *GV = dyn_cast<GlobalValue>(C))
82 return isStringValue(GV);
83 else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
84 if (CE->getOpcode() == Instruction::GetElementPtr) {
85 if (CE->getNumOperands() == 3 &&
86 cast<Constant>(CE->getOperand(1))->isNullValue() &&
87 isa<ConstantInt>(CE->getOperand(2))) {
88 return isStringValue(CE->getOperand(0));
89 }
90 }
91 }
92 }
93 return false;
94}
95
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +000096/// getGlobalVariable - Return either a direct or cast Global value.
Jim Laskeyd8f77ba2006-01-27 15:20:54 +000097///
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +000098static GlobalVariable *getGlobalVariable(Value *V) {
Jim Laskeyd8f77ba2006-01-27 15:20:54 +000099 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
100 return GV;
101 } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
Reid Spencer3da59db2006-11-27 01:05:10 +0000102 if (CE->getOpcode() == Instruction::BitCast) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000103 return dyn_cast<GlobalVariable>(CE->getOperand(0));
Dale Johannesen7757fff2008-01-30 19:00:21 +0000104 } else if (CE->getOpcode() == Instruction::GetElementPtr) {
105 for (unsigned int i=1; i<CE->getNumOperands(); i++) {
Dale Johannesen43b8f3b2008-01-30 19:44:39 +0000106 if (!CE->getOperand(i)->isNullValue())
Dale Johannesen7757fff2008-01-30 19:00:21 +0000107 return NULL;
108 }
109 return dyn_cast<GlobalVariable>(CE->getOperand(0));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000110 }
Jim Laskeyd8f77ba2006-01-27 15:20:54 +0000111 }
112 return NULL;
113}
114
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000115/// isGlobalVariable - Return true if the given value can be coerced to a
Jim Laskey86cbdba2006-02-06 15:33:21 +0000116/// GlobalVariable.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000117static bool isGlobalVariable(Value *V) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000118 if (isa<GlobalVariable>(V) || isa<ConstantPointerNull>(V)) {
119 return true;
120 } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
Reid Spencer3da59db2006-11-27 01:05:10 +0000121 if (CE->getOpcode() == Instruction::BitCast) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000122 return isa<GlobalVariable>(CE->getOperand(0));
Dale Johannesen7757fff2008-01-30 19:00:21 +0000123 } else if (CE->getOpcode() == Instruction::GetElementPtr) {
124 for (unsigned int i=1; i<CE->getNumOperands(); i++) {
Dale Johannesen43b8f3b2008-01-30 19:44:39 +0000125 if (!CE->getOperand(i)->isNullValue())
Dale Johannesen7757fff2008-01-30 19:00:21 +0000126 return false;
127 }
128 return isa<GlobalVariable>(CE->getOperand(0));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000129 }
130 }
131 return false;
132}
133
Jim Laskey86cbdba2006-02-06 15:33:21 +0000134//===----------------------------------------------------------------------===//
135
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000136/// ApplyToFields - Target the visitor to each field of the debug information
Jim Laskey86cbdba2006-02-06 15:33:21 +0000137/// descriptor.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000138void DIVisitor::ApplyToFields(DebugInfoDesc *DD) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000139 DD->ApplyToFields(this);
140}
141
Dan Gohman844731a2008-05-13 00:00:25 +0000142namespace {
143
Jim Laskey86cbdba2006-02-06 15:33:21 +0000144//===----------------------------------------------------------------------===//
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000145/// DICountVisitor - This DIVisitor counts all the fields in the supplied debug
146/// the supplied DebugInfoDesc.
147class DICountVisitor : public DIVisitor {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000148private:
149 unsigned Count; // Running count of fields.
150
151public:
Jim Laskeyce72b172006-02-11 01:01:30 +0000152 DICountVisitor() : DIVisitor(), Count(0) {}
Jim Laskey86cbdba2006-02-06 15:33:21 +0000153
154 // Accessors.
155 unsigned getCount() const { return Count; }
156
157 /// Apply - Count each of the fields.
158 ///
159 virtual void Apply(int &Field) { ++Count; }
160 virtual void Apply(unsigned &Field) { ++Count; }
Jim Laskeyf8913f12006-03-01 17:53:02 +0000161 virtual void Apply(int64_t &Field) { ++Count; }
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000162 virtual void Apply(uint64_t &Field) { ++Count; }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000163 virtual void Apply(bool &Field) { ++Count; }
164 virtual void Apply(std::string &Field) { ++Count; }
165 virtual void Apply(DebugInfoDesc *&Field) { ++Count; }
166 virtual void Apply(GlobalVariable *&Field) { ++Count; }
Jim Laskey45ccae52006-02-28 20:15:07 +0000167 virtual void Apply(std::vector<DebugInfoDesc *> &Field) {
168 ++Count;
169 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000170};
171
172//===----------------------------------------------------------------------===//
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000173/// DIDeserializeVisitor - This DIVisitor deserializes all the fields in the
174/// supplied DebugInfoDesc.
175class DIDeserializeVisitor : public DIVisitor {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000176private:
177 DIDeserializer &DR; // Active deserializer.
178 unsigned I; // Current operand index.
179 ConstantStruct *CI; // GlobalVariable constant initializer.
180
181public:
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000182 DIDeserializeVisitor(DIDeserializer &D, GlobalVariable *GV)
183 : DIVisitor()
Jim Laskey86cbdba2006-02-06 15:33:21 +0000184 , DR(D)
Jim Laskeyce72b172006-02-11 01:01:30 +0000185 , I(0)
Jim Laskey86cbdba2006-02-06 15:33:21 +0000186 , CI(cast<ConstantStruct>(GV->getInitializer()))
187 {}
188
189 /// Apply - Set the value of each of the fields.
190 ///
191 virtual void Apply(int &Field) {
192 Constant *C = CI->getOperand(I++);
Reid Spencerb83eb642006-10-20 07:07:24 +0000193 Field = cast<ConstantInt>(C)->getSExtValue();
Jim Laskey86cbdba2006-02-06 15:33:21 +0000194 }
195 virtual void Apply(unsigned &Field) {
196 Constant *C = CI->getOperand(I++);
Reid Spencerb83eb642006-10-20 07:07:24 +0000197 Field = cast<ConstantInt>(C)->getZExtValue();
Jim Laskey86cbdba2006-02-06 15:33:21 +0000198 }
Jim Laskeyf8913f12006-03-01 17:53:02 +0000199 virtual void Apply(int64_t &Field) {
200 Constant *C = CI->getOperand(I++);
Reid Spencerb83eb642006-10-20 07:07:24 +0000201 Field = cast<ConstantInt>(C)->getSExtValue();
Jim Laskeyf8913f12006-03-01 17:53:02 +0000202 }
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000203 virtual void Apply(uint64_t &Field) {
204 Constant *C = CI->getOperand(I++);
Reid Spencerb83eb642006-10-20 07:07:24 +0000205 Field = cast<ConstantInt>(C)->getZExtValue();
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000206 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000207 virtual void Apply(bool &Field) {
208 Constant *C = CI->getOperand(I++);
Reid Spencer579dca12007-01-12 04:24:46 +0000209 Field = cast<ConstantInt>(C)->getZExtValue();
Jim Laskey86cbdba2006-02-06 15:33:21 +0000210 }
211 virtual void Apply(std::string &Field) {
212 Constant *C = CI->getOperand(I++);
Owen Anderson8342cff2008-06-26 17:06:02 +0000213 // Fills in the string if it succeeds
214 if (!GetConstantStringInfo(C, Field))
215 Field.clear();
Jim Laskey86cbdba2006-02-06 15:33:21 +0000216 }
217 virtual void Apply(DebugInfoDesc *&Field) {
218 Constant *C = CI->getOperand(I++);
219 Field = DR.Deserialize(C);
220 }
221 virtual void Apply(GlobalVariable *&Field) {
222 Constant *C = CI->getOperand(I++);
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000223 Field = getGlobalVariable(C);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000224 }
Jim Laskey45ccae52006-02-28 20:15:07 +0000225 virtual void Apply(std::vector<DebugInfoDesc *> &Field) {
Jim Laskeyd04c1592006-07-13 15:27:42 +0000226 Field.resize(0);
Jim Laskey45ccae52006-02-28 20:15:07 +0000227 Constant *C = CI->getOperand(I++);
228 GlobalVariable *GV = getGlobalVariable(C);
Jim Laskeyd04c1592006-07-13 15:27:42 +0000229 if (GV->hasInitializer()) {
230 if (ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer())) {
231 for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) {
232 GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
233 DebugInfoDesc *DE = DR.Deserialize(GVE);
234 Field.push_back(DE);
235 }
236 } else if (GV->getInitializer()->isNullValue()) {
237 if (const ArrayType *T =
238 dyn_cast<ArrayType>(GV->getType()->getElementType())) {
239 Field.resize(T->getNumElements());
240 }
Jim Laskey2b0e3092006-03-08 02:07:02 +0000241 }
Jim Laskey45ccae52006-02-28 20:15:07 +0000242 }
243 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000244};
245
246//===----------------------------------------------------------------------===//
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000247/// DISerializeVisitor - This DIVisitor serializes all the fields in
Jim Laskey86cbdba2006-02-06 15:33:21 +0000248/// the supplied DebugInfoDesc.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000249class DISerializeVisitor : public DIVisitor {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000250private:
251 DISerializer &SR; // Active serializer.
252 std::vector<Constant*> &Elements; // Element accumulator.
253
254public:
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000255 DISerializeVisitor(DISerializer &S, std::vector<Constant*> &E)
256 : DIVisitor()
Jim Laskey86cbdba2006-02-06 15:33:21 +0000257 , SR(S)
258 , Elements(E)
259 {}
260
261 /// Apply - Set the value of each of the fields.
262 ///
263 virtual void Apply(int &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000264 Elements.push_back(ConstantInt::get(Type::Int32Ty, int32_t(Field)));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000265 }
266 virtual void Apply(unsigned &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000267 Elements.push_back(ConstantInt::get(Type::Int32Ty, uint32_t(Field)));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000268 }
Jim Laskeyf8913f12006-03-01 17:53:02 +0000269 virtual void Apply(int64_t &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000270 Elements.push_back(ConstantInt::get(Type::Int64Ty, int64_t(Field)));
Jim Laskeyf8913f12006-03-01 17:53:02 +0000271 }
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000272 virtual void Apply(uint64_t &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000273 Elements.push_back(ConstantInt::get(Type::Int64Ty, uint64_t(Field)));
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000274 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000275 virtual void Apply(bool &Field) {
Reid Spencer579dca12007-01-12 04:24:46 +0000276 Elements.push_back(ConstantInt::get(Type::Int1Ty, Field));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000277 }
278 virtual void Apply(std::string &Field) {
Jim Laskey21407982006-03-14 18:37:57 +0000279 Elements.push_back(SR.getString(Field));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000280 }
281 virtual void Apply(DebugInfoDesc *&Field) {
282 GlobalVariable *GV = NULL;
283
Jim Laskey9d0ff8e2006-03-15 19:09:58 +0000284 // If non-NULL then convert to global.
Jim Laskey86cbdba2006-02-06 15:33:21 +0000285 if (Field) GV = SR.Serialize(Field);
286
287 // FIXME - At some point should use specific type.
288 const PointerType *EmptyTy = SR.getEmptyStructPtrType();
289
290 if (GV) {
291 // Set to pointer to global.
Reid Spencer15f46d62006-12-12 01:17:41 +0000292 Elements.push_back(ConstantExpr::getBitCast(GV, EmptyTy));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000293 } else {
294 // Use NULL.
295 Elements.push_back(ConstantPointerNull::get(EmptyTy));
296 }
297 }
298 virtual void Apply(GlobalVariable *&Field) {
299 const PointerType *EmptyTy = SR.getEmptyStructPtrType();
Jim Laskeyce72b172006-02-11 01:01:30 +0000300 if (Field) {
Reid Spencer15f46d62006-12-12 01:17:41 +0000301 Elements.push_back(ConstantExpr::getBitCast(Field, EmptyTy));
Jim Laskeyce72b172006-02-11 01:01:30 +0000302 } else {
303 Elements.push_back(ConstantPointerNull::get(EmptyTy));
304 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000305 }
Jim Laskey45ccae52006-02-28 20:15:07 +0000306 virtual void Apply(std::vector<DebugInfoDesc *> &Field) {
307 const PointerType *EmptyTy = SR.getEmptyStructPtrType();
308 unsigned N = Field.size();
309 ArrayType *AT = ArrayType::get(EmptyTy, N);
310 std::vector<Constant *> ArrayElements;
311
312 for (unsigned i = 0, N = Field.size(); i < N; ++i) {
Jim Laskeyd04c1592006-07-13 15:27:42 +0000313 if (DebugInfoDesc *Element = Field[i]) {
314 GlobalVariable *GVE = SR.Serialize(Element);
Reid Spencer15f46d62006-12-12 01:17:41 +0000315 Constant *CE = ConstantExpr::getBitCast(GVE, EmptyTy);
Jim Laskeyd04c1592006-07-13 15:27:42 +0000316 ArrayElements.push_back(cast<Constant>(CE));
317 } else {
318 ArrayElements.push_back(ConstantPointerNull::get(EmptyTy));
319 }
Jim Laskey45ccae52006-02-28 20:15:07 +0000320 }
321
322 Constant *CA = ConstantArray::get(AT, ArrayElements);
Jim Laskeyf8913f12006-03-01 17:53:02 +0000323 GlobalVariable *CAGV = new GlobalVariable(AT, true,
324 GlobalValue::InternalLinkage,
325 CA, "llvm.dbg.array",
326 SR.getModule());
Jim Laskey78098112006-03-07 22:00:35 +0000327 CAGV->setSection("llvm.metadata");
Reid Spencer15f46d62006-12-12 01:17:41 +0000328 Constant *CAE = ConstantExpr::getBitCast(CAGV, EmptyTy);
Jim Laskey45ccae52006-02-28 20:15:07 +0000329 Elements.push_back(CAE);
330 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000331};
332
333//===----------------------------------------------------------------------===//
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000334/// DIGetTypesVisitor - This DIVisitor gathers all the field types in
Jim Laskey86cbdba2006-02-06 15:33:21 +0000335/// the supplied DebugInfoDesc.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000336class DIGetTypesVisitor : public DIVisitor {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000337private:
338 DISerializer &SR; // Active serializer.
339 std::vector<const Type*> &Fields; // Type accumulator.
340
341public:
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000342 DIGetTypesVisitor(DISerializer &S, std::vector<const Type*> &F)
343 : DIVisitor()
Jim Laskey86cbdba2006-02-06 15:33:21 +0000344 , SR(S)
345 , Fields(F)
346 {}
347
348 /// Apply - Set the value of each of the fields.
349 ///
350 virtual void Apply(int &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000351 Fields.push_back(Type::Int32Ty);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000352 }
353 virtual void Apply(unsigned &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000354 Fields.push_back(Type::Int32Ty);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000355 }
Jim Laskeyf8913f12006-03-01 17:53:02 +0000356 virtual void Apply(int64_t &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000357 Fields.push_back(Type::Int64Ty);
Jim Laskeyf8913f12006-03-01 17:53:02 +0000358 }
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000359 virtual void Apply(uint64_t &Field) {
Reid Spencer47857812006-12-31 05:55:36 +0000360 Fields.push_back(Type::Int64Ty);
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000361 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000362 virtual void Apply(bool &Field) {
Reid Spencer4fe16d62007-01-11 18:21:29 +0000363 Fields.push_back(Type::Int1Ty);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000364 }
365 virtual void Apply(std::string &Field) {
366 Fields.push_back(SR.getStrPtrType());
367 }
368 virtual void Apply(DebugInfoDesc *&Field) {
369 // FIXME - At some point should use specific type.
370 const PointerType *EmptyTy = SR.getEmptyStructPtrType();
371 Fields.push_back(EmptyTy);
372 }
373 virtual void Apply(GlobalVariable *&Field) {
374 const PointerType *EmptyTy = SR.getEmptyStructPtrType();
375 Fields.push_back(EmptyTy);
376 }
Jim Laskey45ccae52006-02-28 20:15:07 +0000377 virtual void Apply(std::vector<DebugInfoDesc *> &Field) {
378 const PointerType *EmptyTy = SR.getEmptyStructPtrType();
379 Fields.push_back(EmptyTy);
380 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000381};
382
383//===----------------------------------------------------------------------===//
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000384/// DIVerifyVisitor - This DIVisitor verifies all the field types against
Jim Laskey86cbdba2006-02-06 15:33:21 +0000385/// a constant initializer.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000386class DIVerifyVisitor : public DIVisitor {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000387private:
388 DIVerifier &VR; // Active verifier.
389 bool IsValid; // Validity status.
390 unsigned I; // Current operand index.
391 ConstantStruct *CI; // GlobalVariable constant initializer.
392
393public:
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000394 DIVerifyVisitor(DIVerifier &V, GlobalVariable *GV)
395 : DIVisitor()
Jim Laskey86cbdba2006-02-06 15:33:21 +0000396 , VR(V)
397 , IsValid(true)
Jim Laskeyce72b172006-02-11 01:01:30 +0000398 , I(0)
Jim Laskey86cbdba2006-02-06 15:33:21 +0000399 , CI(cast<ConstantStruct>(GV->getInitializer()))
400 {
401 }
402
403 // Accessors.
404 bool isValid() const { return IsValid; }
405
406 /// Apply - Set the value of each of the fields.
407 ///
408 virtual void Apply(int &Field) {
409 Constant *C = CI->getOperand(I++);
410 IsValid = IsValid && isa<ConstantInt>(C);
411 }
412 virtual void Apply(unsigned &Field) {
413 Constant *C = CI->getOperand(I++);
414 IsValid = IsValid && isa<ConstantInt>(C);
415 }
Jim Laskeyf8913f12006-03-01 17:53:02 +0000416 virtual void Apply(int64_t &Field) {
417 Constant *C = CI->getOperand(I++);
418 IsValid = IsValid && isa<ConstantInt>(C);
419 }
Jim Laskeyf4afdd92006-02-23 16:58:18 +0000420 virtual void Apply(uint64_t &Field) {
421 Constant *C = CI->getOperand(I++);
422 IsValid = IsValid && isa<ConstantInt>(C);
423 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000424 virtual void Apply(bool &Field) {
425 Constant *C = CI->getOperand(I++);
Reid Spencer4fe16d62007-01-11 18:21:29 +0000426 IsValid = IsValid && isa<ConstantInt>(C) && C->getType() == Type::Int1Ty;
Jim Laskey86cbdba2006-02-06 15:33:21 +0000427 }
428 virtual void Apply(std::string &Field) {
429 Constant *C = CI->getOperand(I++);
Jim Laskey26a36872007-01-03 13:46:20 +0000430 IsValid = IsValid &&
431 (!C || isStringValue(C) || C->isNullValue());
Jim Laskey86cbdba2006-02-06 15:33:21 +0000432 }
433 virtual void Apply(DebugInfoDesc *&Field) {
434 // FIXME - Prepare the correct descriptor.
435 Constant *C = CI->getOperand(I++);
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000436 IsValid = IsValid && isGlobalVariable(C);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000437 }
438 virtual void Apply(GlobalVariable *&Field) {
439 Constant *C = CI->getOperand(I++);
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000440 IsValid = IsValid && isGlobalVariable(C);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000441 }
Jim Laskey45ccae52006-02-28 20:15:07 +0000442 virtual void Apply(std::vector<DebugInfoDesc *> &Field) {
443 Constant *C = CI->getOperand(I++);
444 IsValid = IsValid && isGlobalVariable(C);
445 if (!IsValid) return;
446
447 GlobalVariable *GV = getGlobalVariable(C);
448 IsValid = IsValid && GV && GV->hasInitializer();
449 if (!IsValid) return;
450
451 ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer());
452 IsValid = IsValid && CA;
453 if (!IsValid) return;
454
455 for (unsigned i = 0, N = CA->getNumOperands(); IsValid && i < N; ++i) {
456 IsValid = IsValid && isGlobalVariable(CA->getOperand(i));
457 if (!IsValid) return;
458
459 GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
460 VR.Verify(GVE);
461 }
462 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000463};
464
Dan Gohman844731a2008-05-13 00:00:25 +0000465}
Jim Laskeyce72b172006-02-11 01:01:30 +0000466
Jim Laskey86cbdba2006-02-06 15:33:21 +0000467//===----------------------------------------------------------------------===//
468
Jim Laskey86cbdba2006-02-06 15:33:21 +0000469DebugInfoDesc *DIDeserializer::Deserialize(Value *V) {
Jim Laskeyce72b172006-02-11 01:01:30 +0000470 return Deserialize(getGlobalVariable(V));
Jim Laskey86cbdba2006-02-06 15:33:21 +0000471}
472DebugInfoDesc *DIDeserializer::Deserialize(GlobalVariable *GV) {
Jim Laskeyce72b172006-02-11 01:01:30 +0000473 // Handle NULL.
474 if (!GV) return NULL;
475
Jim Laskey86cbdba2006-02-06 15:33:21 +0000476 // Check to see if it has been already deserialized.
477 DebugInfoDesc *&Slot = GlobalDescs[GV];
478 if (Slot) return Slot;
479
480 // Get the Tag from the global.
481 unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
482
Jim Laskey86cbdba2006-02-06 15:33:21 +0000483 // Create an empty instance of the correct sort.
484 Slot = DebugInfoDesc::DescFactory(Tag);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000485
Jim Laskey21407982006-03-14 18:37:57 +0000486 // If not a user defined descriptor.
487 if (Slot) {
488 // Deserialize the fields.
489 DIDeserializeVisitor DRAM(*this, GV);
490 DRAM.ApplyToFields(Slot);
491 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000492
493 return Slot;
494}
495
496//===----------------------------------------------------------------------===//
497
498/// getStrPtrType - Return a "sbyte *" type.
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000499///
Jim Laskey86cbdba2006-02-06 15:33:21 +0000500const PointerType *DISerializer::getStrPtrType() {
501 // If not already defined.
502 if (!StrPtrTy) {
503 // Construct the pointer to signed bytes.
Christopher Lamb43ad6b32007-12-17 01:12:55 +0000504 StrPtrTy = PointerType::getUnqual(Type::Int8Ty);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000505 }
506
507 return StrPtrTy;
508}
509
510/// getEmptyStructPtrType - Return a "{ }*" type.
511///
512const PointerType *DISerializer::getEmptyStructPtrType() {
513 // If not already defined.
514 if (!EmptyStructPtrTy) {
515 // Construct the empty structure type.
516 const StructType *EmptyStructTy =
517 StructType::get(std::vector<const Type*>());
518 // Construct the pointer to empty structure type.
Christopher Lamb43ad6b32007-12-17 01:12:55 +0000519 EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000520 }
521
522 return EmptyStructPtrTy;
523}
524
525/// getTagType - Return the type describing the specified descriptor (via tag.)
526///
527const StructType *DISerializer::getTagType(DebugInfoDesc *DD) {
528 // Attempt to get the previously defined type.
529 StructType *&Ty = TagTypes[DD->getTag()];
530
531 // If not already defined.
532 if (!Ty) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000533 // Set up fields vector.
534 std::vector<const Type*> Fields;
Jim Laskeyce72b172006-02-11 01:01:30 +0000535 // Get types of fields.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000536 DIGetTypesVisitor GTAM(*this, Fields);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000537 GTAM.ApplyToFields(DD);
538
539 // Construct structured type.
540 Ty = StructType::get(Fields);
541
Jim Laskey86cbdba2006-02-06 15:33:21 +0000542 // Register type name with module.
Jim Laskeyce72b172006-02-11 01:01:30 +0000543 M->addTypeName(DD->getTypeString(), Ty);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000544 }
545
546 return Ty;
547}
548
549/// getString - Construct the string as constant string global.
550///
Jim Laskeyce72b172006-02-11 01:01:30 +0000551Constant *DISerializer::getString(const std::string &String) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000552 // Check string cache for previous edition.
Jim Laskeyce72b172006-02-11 01:01:30 +0000553 Constant *&Slot = StringCache[String];
Jim Laskey9d0ff8e2006-03-15 19:09:58 +0000554 // Return Constant if previously defined.
Jim Laskey86cbdba2006-02-06 15:33:21 +0000555 if (Slot) return Slot;
Jim Laskey9d0ff8e2006-03-15 19:09:58 +0000556 // If empty string then use a sbyte* null instead.
557 if (String.empty()) {
558 Slot = ConstantPointerNull::get(getStrPtrType());
559 } else {
560 // Construct string as an llvm constant.
561 Constant *ConstStr = ConstantArray::get(String);
562 // Otherwise create and return a new string global.
563 GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
564 GlobalVariable::InternalLinkage,
Devang Patel1e4c23a2007-05-11 23:14:43 +0000565 ConstStr, ".str", M);
Jim Laskey9d0ff8e2006-03-15 19:09:58 +0000566 StrGV->setSection("llvm.metadata");
567 // Convert to generic string pointer.
Reid Spencer15f46d62006-12-12 01:17:41 +0000568 Slot = ConstantExpr::getBitCast(StrGV, getStrPtrType());
Jim Laskey9d0ff8e2006-03-15 19:09:58 +0000569 }
Jim Laskeyce72b172006-02-11 01:01:30 +0000570 return Slot;
571
Jim Laskey86cbdba2006-02-06 15:33:21 +0000572}
573
574/// Serialize - Recursively cast the specified descriptor into a GlobalVariable
575/// so that it can be serialized to a .bc or .ll file.
576GlobalVariable *DISerializer::Serialize(DebugInfoDesc *DD) {
577 // Check if the DebugInfoDesc is already in the map.
578 GlobalVariable *&Slot = DescGlobals[DD];
579
580 // See if DebugInfoDesc exists, if so return prior GlobalVariable.
581 if (Slot) return Slot;
582
Jim Laskey86cbdba2006-02-06 15:33:21 +0000583 // Get the type associated with the Tag.
584 const StructType *Ty = getTagType(DD);
585
586 // Create the GlobalVariable early to prevent infinite recursion.
Jim Laskeyce72b172006-02-11 01:01:30 +0000587 GlobalVariable *GV = new GlobalVariable(Ty, true, DD->getLinkage(),
588 NULL, DD->getDescString(), M);
Jim Laskey78098112006-03-07 22:00:35 +0000589 GV->setSection("llvm.metadata");
Jim Laskey86cbdba2006-02-06 15:33:21 +0000590
591 // Insert new GlobalVariable in DescGlobals map.
592 Slot = GV;
593
594 // Set up elements vector
595 std::vector<Constant*> Elements;
Jim Laskeyce72b172006-02-11 01:01:30 +0000596 // Add fields.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000597 DISerializeVisitor SRAM(*this, Elements);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000598 SRAM.ApplyToFields(DD);
599
600 // Set the globals initializer.
601 GV->setInitializer(ConstantStruct::get(Ty, Elements));
602
603 return GV;
604}
605
Devang Patel962e0752007-11-30 00:51:33 +0000606/// addDescriptor - Directly connect DD with existing GV.
607void DISerializer::addDescriptor(DebugInfoDesc *DD,
608 GlobalVariable *GV) {
609 DescGlobals[DD] = GV;
610}
611
Jim Laskey86cbdba2006-02-06 15:33:21 +0000612//===----------------------------------------------------------------------===//
613
Jim Laskey86cbdba2006-02-06 15:33:21 +0000614/// Verify - Return true if the GlobalVariable appears to be a valid
615/// serialization of a DebugInfoDesc.
Jim Laskeyce72b172006-02-11 01:01:30 +0000616bool DIVerifier::Verify(Value *V) {
Jim Laskeyaaa80eb2006-03-28 01:30:18 +0000617 return !V || Verify(getGlobalVariable(V));
Jim Laskeyce72b172006-02-11 01:01:30 +0000618}
Jim Laskey86cbdba2006-02-06 15:33:21 +0000619bool DIVerifier::Verify(GlobalVariable *GV) {
Jim Laskey98e04102006-03-26 22:45:20 +0000620 // NULLs are valid.
621 if (!GV) return true;
Jim Laskey86cbdba2006-02-06 15:33:21 +0000622
Jim Laskey98e04102006-03-26 22:45:20 +0000623 // Check prior validity.
624 unsigned &ValiditySlot = Validity[GV];
625
626 // If visited before then use old state.
627 if (ValiditySlot) return ValiditySlot == Valid;
628
629 // Assume validity for the time being (recursion.)
630 ValiditySlot = Valid;
Jim Laskeya8299de2006-03-27 01:51:47 +0000631
632 // Make sure the global is internal or link once (anchor.)
633 if (GV->getLinkage() != GlobalValue::InternalLinkage &&
634 GV->getLinkage() != GlobalValue::LinkOnceLinkage) {
635 ValiditySlot = Invalid;
636 return false;
637 }
Jim Laskey98e04102006-03-26 22:45:20 +0000638
Jim Laskey2bbff6d2006-11-30 18:29:23 +0000639 // Get the Tag.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000640 unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
Jim Laskeyb8509c52006-03-23 18:07:55 +0000641
642 // Check for user defined descriptors.
Jim Laskey2bbff6d2006-11-30 18:29:23 +0000643 if (Tag == DW_TAG_invalid) {
644 ValiditySlot = Valid;
645 return true;
646 }
647
648 // Get the Version.
649 unsigned Version = DebugInfoDesc::VersionFromGlobal(GV);
650
651 // Check for version mismatch.
652 if (Version != LLVMDebugVersion) {
653 ValiditySlot = Invalid;
654 return false;
655 }
Jim Laskey86cbdba2006-02-06 15:33:21 +0000656
Jim Laskey86cbdba2006-02-06 15:33:21 +0000657 // Construct an empty DebugInfoDesc.
658 DebugInfoDesc *DD = DebugInfoDesc::DescFactory(Tag);
Jim Laskey21407982006-03-14 18:37:57 +0000659
660 // Allow for user defined descriptors.
661 if (!DD) return true;
Jim Laskey86cbdba2006-02-06 15:33:21 +0000662
663 // Get the initializer constant.
664 ConstantStruct *CI = cast<ConstantStruct>(GV->getInitializer());
665
666 // Get the operand count.
667 unsigned N = CI->getNumOperands();
668
669 // Get the field count.
Jim Laskey98e04102006-03-26 22:45:20 +0000670 unsigned &CountSlot = Counts[Tag];
671 if (!CountSlot) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000672 // Check the operand count to the field count
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000673 DICountVisitor CTAM;
Jim Laskey86cbdba2006-02-06 15:33:21 +0000674 CTAM.ApplyToFields(DD);
Jim Laskey98e04102006-03-26 22:45:20 +0000675 CountSlot = CTAM.getCount();
Jim Laskey86cbdba2006-02-06 15:33:21 +0000676 }
677
Jim Laskey21407982006-03-14 18:37:57 +0000678 // Field count must be at most equal operand count.
Jim Laskey98e04102006-03-26 22:45:20 +0000679 if (CountSlot > N) {
Jim Laskey86cbdba2006-02-06 15:33:21 +0000680 delete DD;
Jim Laskey98e04102006-03-26 22:45:20 +0000681 ValiditySlot = Invalid;
Jim Laskey86cbdba2006-02-06 15:33:21 +0000682 return false;
683 }
684
685 // Check each field for valid type.
Jim Laskeyc2f0c8d2006-02-06 19:12:02 +0000686 DIVerifyVisitor VRAM(*this, GV);
Jim Laskey86cbdba2006-02-06 15:33:21 +0000687 VRAM.ApplyToFields(DD);
688
689 // Release empty DebugInfoDesc.
690 delete DD;
691
Jim Laskey98e04102006-03-26 22:45:20 +0000692 // If fields are not valid.
693 if (!VRAM.isValid()) {
694 ValiditySlot = Invalid;
695 return false;
696 }
697
698 return true;
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000699}
700
Evan Chenga844bde2008-02-02 04:07:54 +0000701/// isVerified - Return true if the specified GV has already been
702/// verified as a debug information descriptor.
703bool DIVerifier::isVerified(GlobalVariable *GV) {
704 unsigned &ValiditySlot = Validity[GV];
705 if (ValiditySlot) return ValiditySlot == Valid;
706 return false;
707}
708
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000709//===----------------------------------------------------------------------===//
710
Jim Laskeyb8509c52006-03-23 18:07:55 +0000711DebugScope::~DebugScope() {
712 for (unsigned i = 0, N = Scopes.size(); i < N; ++i) delete Scopes[i];
713 for (unsigned j = 0, M = Variables.size(); j < M; ++j) delete Variables[j];
714}
715
716//===----------------------------------------------------------------------===//
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000717
Jim Laskey6da18642007-01-26 21:38:26 +0000718MachineModuleInfo::MachineModuleInfo()
Devang Patel794fd752007-05-01 21:15:47 +0000719: ImmutablePass((intptr_t)&ID)
720, DR()
Jim Laskeyb8509c52006-03-23 18:07:55 +0000721, VR()
Jim Laskey86cbdba2006-02-06 15:33:21 +0000722, CompileUnits()
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000723, Directories()
724, SourceFiles()
725, Lines()
Jim Laskey9d4209f2006-11-07 19:33:46 +0000726, LabelIDList()
Jim Laskeyb8509c52006-03-23 18:07:55 +0000727, ScopeMap()
728, RootScope(NULL)
Jim Laskey41886992006-04-07 16:34:46 +0000729, FrameMoves()
Jim Laskey59667fe2007-02-21 22:38:31 +0000730, LandingPads()
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +0000731, Personalities()
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000732, CallsEHReturn(0)
733, CallsUnwindInit(0)
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +0000734{
735 // Always emit "no personality" info
736 Personalities.push_back(NULL);
737}
Jim Laskey6da18642007-01-26 21:38:26 +0000738MachineModuleInfo::~MachineModuleInfo() {
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000739
740}
741
Jim Laskey6da18642007-01-26 21:38:26 +0000742/// doInitialization - Initialize the state for a new module.
Jim Laskeyb2efb852006-01-04 22:28:25 +0000743///
Jim Laskey6da18642007-01-26 21:38:26 +0000744bool MachineModuleInfo::doInitialization() {
Jim Laskeyb2efb852006-01-04 22:28:25 +0000745 return false;
Jim Laskey6af56812006-01-04 13:36:38 +0000746}
747
Jim Laskey6da18642007-01-26 21:38:26 +0000748/// doFinalization - Tear down the state after completion of a module.
Jim Laskeyb2efb852006-01-04 22:28:25 +0000749///
Jim Laskey6da18642007-01-26 21:38:26 +0000750bool MachineModuleInfo::doFinalization() {
Jim Laskeyb2efb852006-01-04 22:28:25 +0000751 return false;
752}
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000753
Jim Laskey6da18642007-01-26 21:38:26 +0000754/// BeginFunction - Begin gathering function meta information.
Jim Laskey41886992006-04-07 16:34:46 +0000755///
Jim Laskey6da18642007-01-26 21:38:26 +0000756void MachineModuleInfo::BeginFunction(MachineFunction *MF) {
Jim Laskey41886992006-04-07 16:34:46 +0000757 // Coming soon.
758}
759
Jim Laskey6da18642007-01-26 21:38:26 +0000760/// EndFunction - Discard function meta information.
Jim Laskey41886992006-04-07 16:34:46 +0000761///
Jim Laskey6da18642007-01-26 21:38:26 +0000762void MachineModuleInfo::EndFunction() {
Jim Laskey41886992006-04-07 16:34:46 +0000763 // Clean up scope information.
764 if (RootScope) {
765 delete RootScope;
766 ScopeMap.clear();
767 RootScope = NULL;
768 }
769
Jim Laskeyb82313f2007-02-01 16:31:34 +0000770 // Clean up line info.
771 Lines.clear();
772
Jim Laskey41886992006-04-07 16:34:46 +0000773 // Clean up frame info.
Jim Laskey41886992006-04-07 16:34:46 +0000774 FrameMoves.clear();
Jim Laskey59667fe2007-02-21 22:38:31 +0000775
776 // Clean up exception info.
777 LandingPads.clear();
778 TypeInfos.clear();
Duncan Sands73ef58a2007-06-02 16:53:42 +0000779 FilterIds.clear();
Duncan Sands14da32a2007-07-05 15:15:01 +0000780 FilterEnds.clear();
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000781 CallsEHReturn = 0;
782 CallsUnwindInit = 0;
Jim Laskey41886992006-04-07 16:34:46 +0000783}
784
Jim Laskeyd96185a2006-02-13 12:50:39 +0000785/// getDescFor - Convert a Value to a debug information descriptor.
Jim Laskeyce72b172006-02-11 01:01:30 +0000786///
Jim Laskeyd96185a2006-02-13 12:50:39 +0000787// FIXME - use new Value type when available.
Jim Laskey6da18642007-01-26 21:38:26 +0000788DebugInfoDesc *MachineModuleInfo::getDescFor(Value *V) {
Jim Laskeyce72b172006-02-11 01:01:30 +0000789 return DR.Deserialize(V);
790}
791
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000792/// AnalyzeModule - Scan the module for global debug information.
793///
Jim Laskey6da18642007-01-26 21:38:26 +0000794void MachineModuleInfo::AnalyzeModule(Module &M) {
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000795 SetupCompileUnits(M);
Dale Johannesen48ae02f2008-01-16 19:59:28 +0000796
797 // Insert functions in the llvm.used array into UsedFunctions.
798 GlobalVariable *GV = M.getGlobalVariable("llvm.used");
799 if (!GV || !GV->hasInitializer()) return;
800
801 // Should be an array of 'i8*'.
802 ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
803 if (InitList == 0) return;
804
805 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
806 if (ConstantExpr *CE = dyn_cast<ConstantExpr>(InitList->getOperand(i)))
807 if (CE->getOpcode() == Instruction::BitCast)
808 if (Function *F = dyn_cast<Function>(CE->getOperand(0)))
809 UsedFunctions.insert(F);
810 }
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000811}
812
813/// SetupCompileUnits - Set up the unique vector of compile units.
814///
Jim Laskey6da18642007-01-26 21:38:26 +0000815void MachineModuleInfo::SetupCompileUnits(Module &M) {
Bill Wendling305635a2008-06-27 00:09:40 +0000816 std::vector<void*> CUList;
817 CompileUnitDesc CUD;
818 getAnchoredDescriptors(M, &CUD, CUList);
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000819
Bill Wendling305635a2008-06-27 00:09:40 +0000820 for (unsigned i = 0, N = CUList.size(); i < N; i++)
821 CompileUnits.insert((CompileUnitDesc*)CUList[i]);
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000822}
823
Jim Laskey6e87c0e2006-01-26 21:22:49 +0000824/// getCompileUnits - Return a vector of debug compile units.
825///
Jim Laskey6da18642007-01-26 21:38:26 +0000826const UniqueVector<CompileUnitDesc *> MachineModuleInfo::getCompileUnits()const{
Jim Laskey6e87c0e2006-01-26 21:22:49 +0000827 return CompileUnits;
828}
829
Bill Wendling305635a2008-06-27 00:09:40 +0000830/// getAnchoredDescriptors - Return a vector of anchored debug descriptors.
831///
832void
833MachineModuleInfo::getAnchoredDescriptors(Module &M, const AnchoredDesc *Desc,
834 std::vector<void*> &AnchoredDescs) {
835 std::vector<GlobalVariable*> Globals;
836 getGlobalVariablesUsing(M, Desc->getAnchorString(), Globals);
837
838 for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
839 GlobalVariable *GV = Globals[i];
840
841 // FIXME - In the short term, changes are too drastic to continue.
842 if (DebugInfoDesc::TagFromGlobal(GV) == Desc->getTag() &&
843 DebugInfoDesc::VersionFromGlobal(GV) == LLVMDebugVersion)
844 AnchoredDescs.push_back(DR.Deserialize(GV));
845 }
846}
847
Jim Laskey0420f2a2006-02-22 19:02:11 +0000848/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
849/// named GlobalVariable.
Bill Wendling305635a2008-06-27 00:09:40 +0000850void
Jim Laskey6da18642007-01-26 21:38:26 +0000851MachineModuleInfo::getGlobalVariablesUsing(Module &M,
Bill Wendling305635a2008-06-27 00:09:40 +0000852 const std::string &RootName,
853 std::vector<GlobalVariable*> &Globals) {
854 return ::getGlobalVariablesUsing(M, RootName, Globals);
Jim Laskeyb3e789a2006-01-26 20:21:46 +0000855}
Jim Laskeyb8509c52006-03-23 18:07:55 +0000856
Evan Chenga647c922008-02-01 02:05:57 +0000857/// RecordSourceLine - Records location information and associates it with a
Jim Laskeyb8509c52006-03-23 18:07:55 +0000858/// debug label. Returns a unique label ID used to generate a label and
859/// provide correspondence to the source line list.
Evan Chenga647c922008-02-01 02:05:57 +0000860unsigned MachineModuleInfo::RecordSourceLine(unsigned Line, unsigned Column,
861 unsigned Source) {
Jim Laskeyb8509c52006-03-23 18:07:55 +0000862 unsigned ID = NextLabelID();
Chris Lattner8466b212006-10-17 22:06:46 +0000863 Lines.push_back(SourceLineInfo(Line, Column, Source, ID));
Jim Laskeyb8509c52006-03-23 18:07:55 +0000864 return ID;
865}
866
867/// RecordSource - Register a source file with debug info. Returns an source
868/// ID.
Jim Laskey6da18642007-01-26 21:38:26 +0000869unsigned MachineModuleInfo::RecordSource(const std::string &Directory,
870 const std::string &Source) {
Jim Laskeyb8509c52006-03-23 18:07:55 +0000871 unsigned DirectoryID = Directories.insert(Directory);
872 return SourceFiles.insert(SourceFileInfo(DirectoryID, Source));
873}
Jim Laskey6da18642007-01-26 21:38:26 +0000874unsigned MachineModuleInfo::RecordSource(const CompileUnitDesc *CompileUnit) {
Jim Laskeyb8509c52006-03-23 18:07:55 +0000875 return RecordSource(CompileUnit->getDirectory(),
876 CompileUnit->getFileName());
877}
878
879/// RecordRegionStart - Indicate the start of a region.
880///
Jim Laskey6da18642007-01-26 21:38:26 +0000881unsigned MachineModuleInfo::RecordRegionStart(Value *V) {
Jim Laskeyb8509c52006-03-23 18:07:55 +0000882 // FIXME - need to be able to handle split scopes because of bb cloning.
883 DebugInfoDesc *ScopeDesc = DR.Deserialize(V);
884 DebugScope *Scope = getOrCreateScope(ScopeDesc);
885 unsigned ID = NextLabelID();
886 if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);
887 return ID;
888}
889
890/// RecordRegionEnd - Indicate the end of a region.
891///
Jim Laskey6da18642007-01-26 21:38:26 +0000892unsigned MachineModuleInfo::RecordRegionEnd(Value *V) {
Jim Laskeyb8509c52006-03-23 18:07:55 +0000893 // FIXME - need to be able to handle split scopes because of bb cloning.
894 DebugInfoDesc *ScopeDesc = DR.Deserialize(V);
895 DebugScope *Scope = getOrCreateScope(ScopeDesc);
896 unsigned ID = NextLabelID();
897 Scope->setEndLabelID(ID);
898 return ID;
899}
900
901/// RecordVariable - Indicate the declaration of a local variable.
902///
Evan Chenga844bde2008-02-02 04:07:54 +0000903void MachineModuleInfo::RecordVariable(GlobalValue *GV, unsigned FrameIndex) {
904 VariableDesc *VD = cast<VariableDesc>(DR.Deserialize(GV));
Jim Laskeyb8509c52006-03-23 18:07:55 +0000905 DebugScope *Scope = getOrCreateScope(VD->getContext());
906 DebugVariable *DV = new DebugVariable(VD, FrameIndex);
907 Scope->AddVariable(DV);
908}
909
910/// getOrCreateScope - Returns the scope associated with the given descriptor.
911///
Jim Laskey6da18642007-01-26 21:38:26 +0000912DebugScope *MachineModuleInfo::getOrCreateScope(DebugInfoDesc *ScopeDesc) {
Jim Laskeyb8509c52006-03-23 18:07:55 +0000913 DebugScope *&Slot = ScopeMap[ScopeDesc];
914 if (!Slot) {
915 // FIXME - breaks down when the context is an inlined function.
916 DebugInfoDesc *ParentDesc = NULL;
917 if (BlockDesc *Block = dyn_cast<BlockDesc>(ScopeDesc)) {
918 ParentDesc = Block->getContext();
919 }
920 DebugScope *Parent = ParentDesc ? getOrCreateScope(ParentDesc) : NULL;
921 Slot = new DebugScope(Parent, ScopeDesc);
922 if (Parent) {
923 Parent->AddScope(Slot);
924 } else if (RootScope) {
925 // FIXME - Add inlined function scopes to the root so we can delete
926 // them later. Long term, handle inlined functions properly.
927 RootScope->AddScope(Slot);
928 } else {
929 // First function is top level function.
930 RootScope = Slot;
931 }
932 }
933 return Slot;
934}
935
Jim Laskey59667fe2007-02-21 22:38:31 +0000936//===-EH-------------------------------------------------------------------===//
937
938/// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the
939/// specified MachineBasicBlock.
940LandingPadInfo &MachineModuleInfo::getOrCreateLandingPadInfo
941 (MachineBasicBlock *LandingPad) {
942 unsigned N = LandingPads.size();
943 for (unsigned i = 0; i < N; ++i) {
Jim Laskey59e84342007-03-01 20:25:32 +0000944 LandingPadInfo &LP = LandingPads[i];
945 if (LP.LandingPadBlock == LandingPad)
946 return LP;
Jim Laskey59667fe2007-02-21 22:38:31 +0000947 }
948
949 LandingPads.push_back(LandingPadInfo(LandingPad));
950 return LandingPads[N];
951}
952
953/// addInvoke - Provide the begin and end labels of an invoke style call and
954/// associate it with a try landing pad block.
955void MachineModuleInfo::addInvoke(MachineBasicBlock *LandingPad,
956 unsigned BeginLabel, unsigned EndLabel) {
Jim Laskey59e84342007-03-01 20:25:32 +0000957 LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
Anton Korobeynikoveeb37e02007-05-10 22:34:59 +0000958 LP.BeginLabels.push_back(BeginLabel);
959 LP.EndLabels.push_back(EndLabel);
Jim Laskey59667fe2007-02-21 22:38:31 +0000960}
961
962/// addLandingPad - Provide the label of a try LandingPad block.
963///
964unsigned MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) {
965 unsigned LandingPadLabel = NextLabelID();
Jim Laskey59e84342007-03-01 20:25:32 +0000966 LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
967 LP.LandingPadLabel = LandingPadLabel;
Jim Laskey59667fe2007-02-21 22:38:31 +0000968 return LandingPadLabel;
969}
970
971/// addPersonality - Provide the personality function for the exception
972/// information.
973void MachineModuleInfo::addPersonality(MachineBasicBlock *LandingPad,
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +0000974 Function *Personality) {
Jim Laskey59e84342007-03-01 20:25:32 +0000975 LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +0000976 LP.Personality = Personality;
Anton Korobeynikov0ff3ca42007-05-12 22:36:25 +0000977
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +0000978 for (unsigned i = 0; i < Personalities.size(); ++i)
979 if (Personalities[i] == Personality)
980 return;
981
982 Personalities.push_back(Personality);
Jim Laskey59667fe2007-02-21 22:38:31 +0000983}
984
985/// addCatchTypeInfo - Provide the catch typeinfo for a landing pad.
986///
987void MachineModuleInfo::addCatchTypeInfo(MachineBasicBlock *LandingPad,
988 std::vector<GlobalVariable *> &TyInfo) {
Jim Laskey59e84342007-03-01 20:25:32 +0000989 LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
Jim Laskey59667fe2007-02-21 22:38:31 +0000990 for (unsigned N = TyInfo.size(); N; --N)
Jim Laskey59e84342007-03-01 20:25:32 +0000991 LP.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1]));
Jim Laskey59667fe2007-02-21 22:38:31 +0000992}
Duncan Sands73ef58a2007-06-02 16:53:42 +0000993
994/// addFilterTypeInfo - Provide the filter typeinfo for a landing pad.
Jim Laskey59e84342007-03-01 20:25:32 +0000995///
Duncan Sands73ef58a2007-06-02 16:53:42 +0000996void MachineModuleInfo::addFilterTypeInfo(MachineBasicBlock *LandingPad,
997 std::vector<GlobalVariable *> &TyInfo) {
Jim Laskey59e84342007-03-01 20:25:32 +0000998 LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
Duncan Sands73ef58a2007-06-02 16:53:42 +0000999 std::vector<unsigned> IdsInFilter (TyInfo.size());
1000 for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
1001 IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
1002 LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
Jim Laskey59e84342007-03-01 20:25:32 +00001003}
1004
Duncan Sands6590b042007-08-27 15:47:50 +00001005/// addCleanup - Add a cleanup action for a landing pad.
1006///
1007void MachineModuleInfo::addCleanup(MachineBasicBlock *LandingPad) {
1008 LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
1009 LP.TypeIds.push_back(0);
1010}
1011
Jim Laskey59667fe2007-02-21 22:38:31 +00001012/// TidyLandingPads - Remap landing pad labels and remove any deleted landing
1013/// pads.
1014void MachineModuleInfo::TidyLandingPads() {
1015 for (unsigned i = 0; i != LandingPads.size(); ) {
1016 LandingPadInfo &LandingPad = LandingPads[i];
Jim Laskey59667fe2007-02-21 22:38:31 +00001017 LandingPad.LandingPadLabel = MappedLabel(LandingPad.LandingPadLabel);
Anton Korobeynikoveeb37e02007-05-10 22:34:59 +00001018
Anton Korobeynikov070280e2007-05-23 11:08:31 +00001019 // Special case: we *should* emit LPs with null LP MBB. This indicates
Duncan Sands481dc722007-12-19 07:36:31 +00001020 // "nounwind" case.
Anton Korobeynikov070280e2007-05-23 11:08:31 +00001021 if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) {
Jim Laskey59667fe2007-02-21 22:38:31 +00001022 LandingPads.erase(LandingPads.begin() + i);
1023 continue;
1024 }
Duncan Sands57810cd2007-09-05 11:27:52 +00001025
Anton Korobeynikoveeb37e02007-05-10 22:34:59 +00001026 for (unsigned j=0; j != LandingPads[i].BeginLabels.size(); ) {
1027 unsigned BeginLabel = MappedLabel(LandingPad.BeginLabels[j]);
1028 unsigned EndLabel = MappedLabel(LandingPad.EndLabels[j]);
Duncan Sands57810cd2007-09-05 11:27:52 +00001029
Anton Korobeynikoveeb37e02007-05-10 22:34:59 +00001030 if (!BeginLabel || !EndLabel) {
Anton Korobeynikoveeb37e02007-05-10 22:34:59 +00001031 LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j);
1032 LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j);
1033 continue;
1034 }
1035
1036 LandingPad.BeginLabels[j] = BeginLabel;
1037 LandingPad.EndLabels[j] = EndLabel;
1038 ++j;
1039 }
Duncan Sands57810cd2007-09-05 11:27:52 +00001040
1041 // Remove landing pads with no try-ranges.
Dan Gohman30359592008-01-29 13:02:09 +00001042 if (LandingPads[i].BeginLabels.empty()) {
Duncan Sands57810cd2007-09-05 11:27:52 +00001043 LandingPads.erase(LandingPads.begin() + i);
1044 continue;
1045 }
1046
1047 // If there is no landing pad, ensure that the list of typeids is empty.
1048 // If the only typeid is a cleanup, this is the same as having no typeids.
1049 if (!LandingPad.LandingPadBlock ||
1050 (LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0]))
1051 LandingPad.TypeIds.clear();
1052
Jim Laskey59667fe2007-02-21 22:38:31 +00001053 ++i;
1054 }
1055}
1056
1057/// getTypeIDFor - Return the type id for the specified typeinfo. This is
1058/// function wide.
1059unsigned MachineModuleInfo::getTypeIDFor(GlobalVariable *TI) {
1060 for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
1061 if (TypeInfos[i] == TI) return i + 1;
1062
1063 TypeInfos.push_back(TI);
1064 return TypeInfos.size();
1065}
1066
Duncan Sands73ef58a2007-06-02 16:53:42 +00001067/// getFilterIDFor - Return the filter id for the specified typeinfos. This is
1068/// function wide.
1069int MachineModuleInfo::getFilterIDFor(std::vector<unsigned> &TyIds) {
Duncan Sands14da32a2007-07-05 15:15:01 +00001070 // If the new filter coincides with the tail of an existing filter, then
1071 // re-use the existing filter. Folding filters more than this requires
1072 // re-ordering filters and/or their elements - probably not worth it.
1073 for (std::vector<unsigned>::iterator I = FilterEnds.begin(),
1074 E = FilterEnds.end(); I != E; ++I) {
1075 unsigned i = *I, j = TyIds.size();
1076
1077 while (i && j)
1078 if (FilterIds[--i] != TyIds[--j])
1079 goto try_next;
1080
1081 if (!j)
1082 // The new filter coincides with range [i, end) of the existing filter.
1083 return -(1 + i);
1084
1085try_next:;
1086 }
1087
1088 // Add the new filter.
Duncan Sands73ef58a2007-06-02 16:53:42 +00001089 int FilterID = -(1 + FilterIds.size());
1090 FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
1091 for (unsigned I = 0, N = TyIds.size(); I != N; ++I)
1092 FilterIds.push_back(TyIds[I]);
Duncan Sands14da32a2007-07-05 15:15:01 +00001093 FilterEnds.push_back(FilterIds.size());
Duncan Sands73ef58a2007-06-02 16:53:42 +00001094 FilterIds.push_back(0); // terminator
1095 return FilterID;
1096}
1097
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +00001098/// getPersonality - Return the personality function for the current function.
Jim Laskey59667fe2007-02-21 22:38:31 +00001099Function *MachineModuleInfo::getPersonality() const {
Anton Korobeynikov0ff3ca42007-05-12 22:36:25 +00001100 // FIXME: Until PR1414 will be fixed, we're using 1 personality function per
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +00001101 // function
1102 return !LandingPads.empty() ? LandingPads[0].Personality : NULL;
Jim Laskey59667fe2007-02-21 22:38:31 +00001103}
1104
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +00001105/// getPersonalityIndex - Return unique index for current personality
1106/// function. NULL personality function should always get zero index.
1107unsigned MachineModuleInfo::getPersonalityIndex() const {
Anton Korobeynikov070280e2007-05-23 11:08:31 +00001108 const Function* Personality = NULL;
1109
1110 // Scan landing pads. If there is at least one non-NULL personality - use it.
1111 for (unsigned i = 0; i != LandingPads.size(); ++i)
1112 if (LandingPads[i].Personality) {
1113 Personality = LandingPads[i].Personality;
1114 break;
1115 }
1116
Anton Korobeynikov8c7c1732007-05-13 15:42:26 +00001117 for (unsigned i = 0; i < Personalities.size(); ++i) {
1118 if (Personalities[i] == Personality)
1119 return i;
1120 }
1121
1122 // This should never happen
1123 assert(0 && "Personality function should be set!");
1124 return 0;
1125}
Jim Laskey59667fe2007-02-21 22:38:31 +00001126
Jim Laskey9d4209f2006-11-07 19:33:46 +00001127//===----------------------------------------------------------------------===//
Jim Laskey6da18642007-01-26 21:38:26 +00001128/// DebugLabelFolding pass - This pass prunes out redundant labels. This allows
1129/// a info consumer to determine if the range of two labels is empty, by seeing
1130/// if the labels map to the same reduced label.
Jim Laskey9d4209f2006-11-07 19:33:46 +00001131
1132namespace llvm {
1133
1134struct DebugLabelFolder : public MachineFunctionPass {
Devang Patel19974732007-05-03 01:11:54 +00001135 static char ID;
Devang Patel794fd752007-05-01 21:15:47 +00001136 DebugLabelFolder() : MachineFunctionPass((intptr_t)&ID) {}
1137
Jim Laskey9d4209f2006-11-07 19:33:46 +00001138 virtual bool runOnMachineFunction(MachineFunction &MF);
Jim Laskey6da18642007-01-26 21:38:26 +00001139 virtual const char *getPassName() const { return "Label Folder"; }
Jim Laskey9d4209f2006-11-07 19:33:46 +00001140};
1141
Devang Patel19974732007-05-03 01:11:54 +00001142char DebugLabelFolder::ID = 0;
Devang Patel794fd752007-05-01 21:15:47 +00001143
Jim Laskey9d4209f2006-11-07 19:33:46 +00001144bool DebugLabelFolder::runOnMachineFunction(MachineFunction &MF) {
Jim Laskey6da18642007-01-26 21:38:26 +00001145 // Get machine module info.
1146 MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>();
1147 if (!MMI) return false;
Jim Laskey9d4209f2006-11-07 19:33:46 +00001148
1149 // Track if change is made.
1150 bool MadeChange = false;
1151 // No prior label to begin.
1152 unsigned PriorLabel = 0;
1153
1154 // Iterate through basic blocks.
1155 for (MachineFunction::iterator BB = MF.begin(), E = MF.end();
1156 BB != E; ++BB) {
1157 // Iterate through instructions.
1158 for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
Jim Laskey6da18642007-01-26 21:38:26 +00001159 // Is it a label.
Evan Chengbb81d972008-01-31 09:59:15 +00001160 if (I->isDebugLabel()) {
Jim Laskey9d4209f2006-11-07 19:33:46 +00001161 // The label ID # is always operand #0, an immediate.
1162 unsigned NextLabel = I->getOperand(0).getImm();
1163
1164 // If there was an immediate prior label.
1165 if (PriorLabel) {
1166 // Remap the current label to prior label.
Jim Laskey6da18642007-01-26 21:38:26 +00001167 MMI->RemapLabel(NextLabel, PriorLabel);
Jim Laskey9d4209f2006-11-07 19:33:46 +00001168 // Delete the current label.
1169 I = BB->erase(I);
1170 // Indicate a change has been made.
1171 MadeChange = true;
1172 continue;
1173 } else {
1174 // Start a new round.
1175 PriorLabel = NextLabel;
1176 }
1177 } else {
1178 // No consecutive labels.
1179 PriorLabel = 0;
1180 }
1181
1182 ++I;
1183 }
1184 }
1185
1186 return MadeChange;
1187}
1188
1189FunctionPass *createDebugLabelFoldingPass() { return new DebugLabelFolder(); }
1190
1191}