Chris Lattner | 44d2c35 | 2003-10-13 03:32:08 +0000 | [diff] [blame] | 1 | //===-- Module.cpp - Implement the Module class ---------------------------===// |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 482202a | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 482202a | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file implements the Module class for the VMCore library. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 14 | #include "llvm/Module.h" |
Chris Lattner | 31cf984 | 2001-06-30 04:35:40 +0000 | [diff] [blame] | 15 | #include "llvm/InstrTypes.h" |
Chris Lattner | ca14237 | 2002-04-28 19:55:58 +0000 | [diff] [blame] | 16 | #include "llvm/Constants.h" |
Chris Lattner | a483b06 | 2002-03-29 03:44:18 +0000 | [diff] [blame] | 17 | #include "llvm/DerivedTypes.h" |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 18 | #include "llvm/GVMaterializer.h" |
Owen Anderson | 6773d38 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 19 | #include "llvm/LLVMContext.h" |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/DenseSet.h" |
Devang Patel | a6d20f4 | 2010-06-16 00:53:55 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallString.h" |
Reid Spencer | 7c16caa | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/STLExtras.h" |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/StringExtras.h" |
Reid Spencer | 7c16caa | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 24 | #include "llvm/Support/LeakDetector.h" |
Chris Lattner | 113f4f4 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 25 | #include "SymbolTableListTraitsImpl.h" |
| 26 | #include <algorithm> |
Chris Lattner | bd717d8 | 2003-08-31 00:19:28 +0000 | [diff] [blame] | 27 | #include <cstdarg> |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 28 | #include <cstdlib> |
Chris Lattner | 189d19f | 2003-11-21 20:23:48 +0000 | [diff] [blame] | 29 | using namespace llvm; |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 30 | |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 31 | //===----------------------------------------------------------------------===// |
Misha Brukman | 3bcead7 | 2004-04-21 18:27:56 +0000 | [diff] [blame] | 32 | // Methods to implement the globals and functions lists. |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 33 | // |
| 34 | |
Chris Lattner | 113f4f4 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 35 | // Explicit instantiations of SymbolTableListTraits since some of the methods |
Chris Lattner | eef2fe7 | 2006-01-24 04:13:11 +0000 | [diff] [blame] | 36 | // are not in the public header file. |
John McCall | 086bb4e | 2009-12-19 00:55:12 +0000 | [diff] [blame] | 37 | template class llvm::SymbolTableListTraits<Function, Module>; |
Nick Lewycky | 2be81ac | 2011-08-13 01:04:44 +0000 | [diff] [blame] | 38 | template class llvm::SymbolTableListTraits<GlobalVariable, Module>; |
John McCall | 086bb4e | 2009-12-19 00:55:12 +0000 | [diff] [blame] | 39 | template class llvm::SymbolTableListTraits<GlobalAlias, Module>; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 40 | |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 41 | //===----------------------------------------------------------------------===// |
| 42 | // Primitive Module methods. |
| 43 | // |
Chris Lattner | 446ad50 | 2001-10-13 06:58:40 +0000 | [diff] [blame] | 44 | |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 45 | Module::Module(StringRef MID, LLVMContext& C) |
Dan Gohman | 5cae103 | 2010-08-04 01:39:08 +0000 | [diff] [blame] | 46 | : Context(C), Materializer(NULL), ModuleID(MID) { |
Reid Spencer | 3aaaa0b | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 47 | ValSymTab = new ValueSymbolTable(); |
Dan Gohman | 2637cc1 | 2010-07-21 23:38:33 +0000 | [diff] [blame] | 48 | NamedMDSymTab = new StringMap<NamedMDNode *>(); |
Owen Anderson | 8e89e41 | 2010-09-08 18:03:32 +0000 | [diff] [blame] | 49 | Context.addModule(this); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | Module::~Module() { |
Owen Anderson | 8e89e41 | 2010-09-08 18:03:32 +0000 | [diff] [blame] | 53 | Context.removeModule(this); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 54 | dropAllReferences(); |
Chris Lattner | 113f4f4 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 55 | GlobalList.clear(); |
Chris Lattner | 113f4f4 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 56 | FunctionList.clear(); |
Anton Korobeynikov | a97b694 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 57 | AliasList.clear(); |
Reid Spencer | a0b05b3 | 2004-07-25 18:08:57 +0000 | [diff] [blame] | 58 | LibraryList.clear(); |
Devang Patel | 18dfdc9 | 2009-07-29 17:16:17 +0000 | [diff] [blame] | 59 | NamedMDList.clear(); |
Reid Spencer | 32af9e8 | 2007-01-06 07:24:44 +0000 | [diff] [blame] | 60 | delete ValSymTab; |
Dan Gohman | 2637cc1 | 2010-07-21 23:38:33 +0000 | [diff] [blame] | 61 | delete static_cast<StringMap<NamedMDNode *> *>(NamedMDSymTab); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 64 | /// Target endian information. |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 65 | Module::Endianness Module::getEndianness() const { |
Benjamin Kramer | c6fe3c3 | 2010-01-11 18:03:24 +0000 | [diff] [blame] | 66 | StringRef temp = DataLayout; |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 67 | Module::Endianness ret = AnyEndianness; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 68 | |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 69 | while (!temp.empty()) { |
Chris Lattner | 5cf753c | 2011-07-21 06:21:31 +0000 | [diff] [blame] | 70 | std::pair<StringRef, StringRef> P = getToken(temp, "-"); |
| 71 | |
| 72 | StringRef token = P.first; |
| 73 | temp = P.second; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 74 | |
| 75 | if (token[0] == 'e') { |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 76 | ret = LittleEndian; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 77 | } else if (token[0] == 'E') { |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 78 | ret = BigEndian; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 79 | } |
| 80 | } |
| 81 | |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 82 | return ret; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 83 | } |
| 84 | |
Chris Lattner | 5cf753c | 2011-07-21 06:21:31 +0000 | [diff] [blame] | 85 | /// Target Pointer Size information. |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 86 | Module::PointerSize Module::getPointerSize() const { |
Benjamin Kramer | c6fe3c3 | 2010-01-11 18:03:24 +0000 | [diff] [blame] | 87 | StringRef temp = DataLayout; |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 88 | Module::PointerSize ret = AnyPointerSize; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 89 | |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 90 | while (!temp.empty()) { |
Chris Lattner | 5cf753c | 2011-07-21 06:21:31 +0000 | [diff] [blame] | 91 | std::pair<StringRef, StringRef> TmpP = getToken(temp, "-"); |
| 92 | temp = TmpP.second; |
| 93 | TmpP = getToken(TmpP.first, ":"); |
| 94 | StringRef token = TmpP.second, signalToken = TmpP.first; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 95 | |
Benjamin Kramer | c6fe3c3 | 2010-01-11 18:03:24 +0000 | [diff] [blame] | 96 | if (signalToken[0] == 'p') { |
| 97 | int size = 0; |
| 98 | getToken(token, ":").first.getAsInteger(10, size); |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 99 | if (size == 32) |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 100 | ret = Pointer32; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 101 | else if (size == 64) |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 102 | ret = Pointer64; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | |
Owen Anderson | 08aecf5 | 2006-05-18 05:46:08 +0000 | [diff] [blame] | 106 | return ret; |
Owen Anderson | 9eb1a26 | 2006-05-18 02:10:31 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 109 | /// getNamedValue - Return the first global value in the module with |
| 110 | /// the specified name, of arbitrary type. This method returns null |
| 111 | /// if a global with the specified name is not found. |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 112 | GlobalValue *Module::getNamedValue(StringRef Name) const { |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 113 | return cast_or_null<GlobalValue>(getValueSymbolTable().lookup(Name)); |
| 114 | } |
| 115 | |
Chris Lattner | a056697 | 2009-12-29 09:01:33 +0000 | [diff] [blame] | 116 | /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. |
| 117 | /// This ID is uniqued across modules in the current LLVMContext. |
| 118 | unsigned Module::getMDKindID(StringRef Name) const { |
| 119 | return Context.getMDKindID(Name); |
| 120 | } |
| 121 | |
| 122 | /// getMDKindNames - Populate client supplied SmallVector with the name for |
| 123 | /// custom metadata IDs registered in this LLVMContext. ID #0 is not used, |
| 124 | /// so it is filled in as an empty string. |
| 125 | void Module::getMDKindNames(SmallVectorImpl<StringRef> &Result) const { |
| 126 | return Context.getMDKindNames(Result); |
| 127 | } |
| 128 | |
| 129 | |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 130 | //===----------------------------------------------------------------------===// |
| 131 | // Methods for easy access to the functions in the module. |
| 132 | // |
| 133 | |
Reid Spencer | 3aaaa0b | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 134 | // getOrInsertFunction - Look up the specified function in the module symbol |
| 135 | // table. If it does not exist, add a prototype for the function and return |
| 136 | // it. This is nice because it allows most passes to get away with not handling |
| 137 | // the symbol table directly for this common task. |
| 138 | // |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 139 | Constant *Module::getOrInsertFunction(StringRef Name, |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 140 | FunctionType *Ty, |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 141 | AttrListPtr AttributeList) { |
Reid Spencer | 3aaaa0b | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 142 | // See if we have a definition for the specified function already. |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 143 | GlobalValue *F = getNamedValue(Name); |
Chris Lattner | 505c06b | 2007-01-07 08:09:25 +0000 | [diff] [blame] | 144 | if (F == 0) { |
Reid Spencer | 3aaaa0b | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 145 | // Nope, add it |
Gabor Greif | e9ecc68 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 146 | Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage, Name); |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 147 | if (!New->isIntrinsic()) // Intrinsics get attrs set on construction |
| 148 | New->setAttributes(AttributeList); |
Chris Lattner | a483b06 | 2002-03-29 03:44:18 +0000 | [diff] [blame] | 149 | FunctionList.push_back(New); |
Chris Lattner | 505c06b | 2007-01-07 08:09:25 +0000 | [diff] [blame] | 150 | return New; // Return the new prototype. |
Chris Lattner | a483b06 | 2002-03-29 03:44:18 +0000 | [diff] [blame] | 151 | } |
Chris Lattner | 505c06b | 2007-01-07 08:09:25 +0000 | [diff] [blame] | 152 | |
| 153 | // Okay, the function exists. Does it have externally visible linkage? |
Rafael Espindola | 6de96a1 | 2009-01-15 20:18:42 +0000 | [diff] [blame] | 154 | if (F->hasLocalLinkage()) { |
Chris Lattner | 42e983e | 2008-06-27 21:25:24 +0000 | [diff] [blame] | 155 | // Clear the function's name. |
| 156 | F->setName(""); |
Chris Lattner | 505c06b | 2007-01-07 08:09:25 +0000 | [diff] [blame] | 157 | // Retry, now there won't be a conflict. |
Chris Lattner | 42e983e | 2008-06-27 21:25:24 +0000 | [diff] [blame] | 158 | Constant *NewF = getOrInsertFunction(Name, Ty); |
Daniel Dunbar | d43b86d | 2009-07-25 06:02:13 +0000 | [diff] [blame] | 159 | F->setName(Name); |
Chris Lattner | 42e983e | 2008-06-27 21:25:24 +0000 | [diff] [blame] | 160 | return NewF; |
Chris Lattner | 505c06b | 2007-01-07 08:09:25 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // If the function exists but has the wrong type, return a bitcast to the |
| 164 | // right type. |
Owen Anderson | 4056ca9 | 2009-07-29 22:17:13 +0000 | [diff] [blame] | 165 | if (F->getType() != PointerType::getUnqual(Ty)) |
| 166 | return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty)); |
Chris Lattner | 505c06b | 2007-01-07 08:09:25 +0000 | [diff] [blame] | 167 | |
| 168 | // Otherwise, we just found the existing function or a prototype. |
| 169 | return F; |
Chris Lattner | a483b06 | 2002-03-29 03:44:18 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 172 | Constant *Module::getOrInsertTargetIntrinsic(StringRef Name, |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 173 | FunctionType *Ty, |
Dale Johannesen | b842d52 | 2009-02-05 01:49:45 +0000 | [diff] [blame] | 174 | AttrListPtr AttributeList) { |
Dale Johannesen | b842d52 | 2009-02-05 01:49:45 +0000 | [diff] [blame] | 175 | // See if we have a definition for the specified function already. |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 176 | GlobalValue *F = getNamedValue(Name); |
Dale Johannesen | b842d52 | 2009-02-05 01:49:45 +0000 | [diff] [blame] | 177 | if (F == 0) { |
| 178 | // Nope, add it |
| 179 | Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage, Name); |
| 180 | New->setAttributes(AttributeList); |
| 181 | FunctionList.push_back(New); |
| 182 | return New; // Return the new prototype. |
| 183 | } |
| 184 | |
| 185 | // Otherwise, we just found the existing function or a prototype. |
| 186 | return F; |
| 187 | } |
| 188 | |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 189 | Constant *Module::getOrInsertFunction(StringRef Name, |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 190 | FunctionType *Ty) { |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 191 | AttrListPtr AttributeList = AttrListPtr::get((AttributeWithIndex *)0, 0); |
| 192 | return getOrInsertFunction(Name, Ty, AttributeList); |
| 193 | } |
| 194 | |
Chris Lattner | bd717d8 | 2003-08-31 00:19:28 +0000 | [diff] [blame] | 195 | // getOrInsertFunction - Look up the specified function in the module symbol |
| 196 | // table. If it does not exist, add a prototype for the function and return it. |
| 197 | // This version of the method takes a null terminated list of function |
| 198 | // arguments, which makes it easier for clients to use. |
| 199 | // |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 200 | Constant *Module::getOrInsertFunction(StringRef Name, |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 201 | AttrListPtr AttributeList, |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 202 | Type *RetTy, ...) { |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 203 | va_list Args; |
| 204 | va_start(Args, RetTy); |
| 205 | |
| 206 | // Build the list of argument types... |
Jay Foad | b804a2b | 2011-07-12 14:06:48 +0000 | [diff] [blame] | 207 | std::vector<Type*> ArgTys; |
| 208 | while (Type *ArgTy = va_arg(Args, Type*)) |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 209 | ArgTys.push_back(ArgTy); |
| 210 | |
| 211 | va_end(Args); |
| 212 | |
| 213 | // Build the function type and chain to the other getOrInsertFunction... |
Owen Anderson | 785c56c | 2009-07-08 23:50:31 +0000 | [diff] [blame] | 214 | return getOrInsertFunction(Name, |
Owen Anderson | 4056ca9 | 2009-07-29 22:17:13 +0000 | [diff] [blame] | 215 | FunctionType::get(RetTy, ArgTys, false), |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 216 | AttributeList); |
| 217 | } |
| 218 | |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 219 | Constant *Module::getOrInsertFunction(StringRef Name, |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 220 | Type *RetTy, ...) { |
Chris Lattner | bd717d8 | 2003-08-31 00:19:28 +0000 | [diff] [blame] | 221 | va_list Args; |
| 222 | va_start(Args, RetTy); |
| 223 | |
| 224 | // Build the list of argument types... |
Jay Foad | b804a2b | 2011-07-12 14:06:48 +0000 | [diff] [blame] | 225 | std::vector<Type*> ArgTys; |
| 226 | while (Type *ArgTy = va_arg(Args, Type*)) |
Chris Lattner | bd717d8 | 2003-08-31 00:19:28 +0000 | [diff] [blame] | 227 | ArgTys.push_back(ArgTy); |
| 228 | |
| 229 | va_end(Args); |
| 230 | |
| 231 | // Build the function type and chain to the other getOrInsertFunction... |
Owen Anderson | 785c56c | 2009-07-08 23:50:31 +0000 | [diff] [blame] | 232 | return getOrInsertFunction(Name, |
Owen Anderson | 4056ca9 | 2009-07-29 22:17:13 +0000 | [diff] [blame] | 233 | FunctionType::get(RetTy, ArgTys, false), |
Nick Lewycky | 3a0c106 | 2009-01-04 22:54:40 +0000 | [diff] [blame] | 234 | AttrListPtr::get((AttributeWithIndex *)0, 0)); |
Chris Lattner | bd717d8 | 2003-08-31 00:19:28 +0000 | [diff] [blame] | 235 | } |
| 236 | |
Chris Lattner | a483b06 | 2002-03-29 03:44:18 +0000 | [diff] [blame] | 237 | // getFunction - Look up the specified function in the module symbol table. |
| 238 | // If it does not exist, return null. |
| 239 | // |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 240 | Function *Module::getFunction(StringRef Name) const { |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 241 | return dyn_cast_or_null<Function>(getNamedValue(Name)); |
Chris Lattner | e43649f | 2008-06-27 21:09:10 +0000 | [diff] [blame] | 242 | } |
| 243 | |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 244 | //===----------------------------------------------------------------------===// |
| 245 | // Methods for easy access to the global variables in the module. |
| 246 | // |
| 247 | |
| 248 | /// getGlobalVariable - Look up the specified global variable in the module |
Chris Lattner | 7d4d93c | 2005-12-05 05:30:21 +0000 | [diff] [blame] | 249 | /// symbol table. If it does not exist, return null. The type argument |
| 250 | /// should be the underlying type of the global, i.e., it should not have |
| 251 | /// the top-level PointerType, which represents the address of the global. |
Rafael Espindola | 6de96a1 | 2009-01-15 20:18:42 +0000 | [diff] [blame] | 252 | /// If AllowLocal is set to true, this function will return types that |
| 253 | /// have an local. By default, these types are not returned. |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 254 | /// |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 255 | GlobalVariable *Module::getGlobalVariable(StringRef Name, |
Rafael Espindola | 6de96a1 | 2009-01-15 20:18:42 +0000 | [diff] [blame] | 256 | bool AllowLocal) const { |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 257 | if (GlobalVariable *Result = |
| 258 | dyn_cast_or_null<GlobalVariable>(getNamedValue(Name))) |
| 259 | if (AllowLocal || !Result->hasLocalLinkage()) |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 260 | return Result; |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 261 | return 0; |
| 262 | } |
| 263 | |
Bill Wendling | f5f6f74 | 2008-11-05 23:42:27 +0000 | [diff] [blame] | 264 | /// getOrInsertGlobal - Look up the specified global in the module symbol table. |
| 265 | /// 1. If it does not exist, add a declaration of the global and return it. |
| 266 | /// 2. Else, the global exists but has the wrong type: return the function |
| 267 | /// with a constantexpr cast to the right type. |
| 268 | /// 3. Finally, if the existing global is the correct delclaration, return the |
| 269 | /// existing global. |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 270 | Constant *Module::getOrInsertGlobal(StringRef Name, Type *Ty) { |
Bill Wendling | 2f40956 | 2008-11-04 22:51:24 +0000 | [diff] [blame] | 271 | // See if we have a definition for the specified global already. |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 272 | GlobalVariable *GV = dyn_cast_or_null<GlobalVariable>(getNamedValue(Name)); |
Bill Wendling | 2f40956 | 2008-11-04 22:51:24 +0000 | [diff] [blame] | 273 | if (GV == 0) { |
| 274 | // Nope, add it |
| 275 | GlobalVariable *New = |
Owen Anderson | b17f329 | 2009-07-08 19:03:57 +0000 | [diff] [blame] | 276 | new GlobalVariable(*this, Ty, false, GlobalVariable::ExternalLinkage, |
| 277 | 0, Name); |
| 278 | return New; // Return the new declaration. |
Bill Wendling | 2f40956 | 2008-11-04 22:51:24 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | // If the variable exists but has the wrong type, return a bitcast to the |
| 282 | // right type. |
Owen Anderson | 4056ca9 | 2009-07-29 22:17:13 +0000 | [diff] [blame] | 283 | if (GV->getType() != PointerType::getUnqual(Ty)) |
| 284 | return ConstantExpr::getBitCast(GV, PointerType::getUnqual(Ty)); |
Bill Wendling | 2f40956 | 2008-11-04 22:51:24 +0000 | [diff] [blame] | 285 | |
| 286 | // Otherwise, we just found the existing function or a prototype. |
| 287 | return GV; |
| 288 | } |
| 289 | |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 290 | //===----------------------------------------------------------------------===// |
Anton Korobeynikov | a97b694 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 291 | // Methods for easy access to the global variables in the module. |
| 292 | // |
| 293 | |
| 294 | // getNamedAlias - Look up the specified global in the module symbol table. |
| 295 | // If it does not exist, return null. |
| 296 | // |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 297 | GlobalAlias *Module::getNamedAlias(StringRef Name) const { |
Daniel Dunbar | dcf8d3c | 2009-03-06 22:04:43 +0000 | [diff] [blame] | 298 | return dyn_cast_or_null<GlobalAlias>(getNamedValue(Name)); |
Anton Korobeynikov | a97b694 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 299 | } |
| 300 | |
Devang Patel | 9825079 | 2009-07-30 23:59:04 +0000 | [diff] [blame] | 301 | /// getNamedMetadata - Return the first NamedMDNode in the module with the |
| 302 | /// specified name. This method returns null if a NamedMDNode with the |
Bob Wilson | 4581434 | 2010-06-19 05:33:57 +0000 | [diff] [blame] | 303 | /// specified name is not found. |
Devang Patel | b6e058d | 2010-06-22 01:19:38 +0000 | [diff] [blame] | 304 | NamedMDNode *Module::getNamedMetadata(const Twine &Name) const { |
Devang Patel | a6d20f4 | 2010-06-16 00:53:55 +0000 | [diff] [blame] | 305 | SmallString<256> NameData; |
| 306 | StringRef NameRef = Name.toStringRef(NameData); |
Dan Gohman | 2637cc1 | 2010-07-21 23:38:33 +0000 | [diff] [blame] | 307 | return static_cast<StringMap<NamedMDNode*> *>(NamedMDSymTab)->lookup(NameRef); |
Devang Patel | a6d20f4 | 2010-06-16 00:53:55 +0000 | [diff] [blame] | 308 | } |
| 309 | |
Devang Patel | 9825079 | 2009-07-30 23:59:04 +0000 | [diff] [blame] | 310 | /// getOrInsertNamedMetadata - Return the first named MDNode in the module |
| 311 | /// with the specified name. This method returns a new NamedMDNode if a |
| 312 | /// NamedMDNode with the specified name is not found. |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 313 | NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) { |
Dan Gohman | 2637cc1 | 2010-07-21 23:38:33 +0000 | [diff] [blame] | 314 | NamedMDNode *&NMD = |
| 315 | (*static_cast<StringMap<NamedMDNode *> *>(NamedMDSymTab))[Name]; |
| 316 | if (!NMD) { |
| 317 | NMD = new NamedMDNode(Name); |
| 318 | NMD->setParent(this); |
| 319 | NamedMDList.push_back(NMD); |
| 320 | } |
Devang Patel | 9825079 | 2009-07-30 23:59:04 +0000 | [diff] [blame] | 321 | return NMD; |
| 322 | } |
| 323 | |
Bill Wendling | 66f0241 | 2012-02-11 11:38:06 +0000 | [diff] [blame] | 324 | /// eraseNamedMetadata - Remove the given NamedMDNode from this module and |
| 325 | /// delete it. |
Dan Gohman | 2637cc1 | 2010-07-21 23:38:33 +0000 | [diff] [blame] | 326 | void Module::eraseNamedMetadata(NamedMDNode *NMD) { |
| 327 | static_cast<StringMap<NamedMDNode *> *>(NamedMDSymTab)->erase(NMD->getName()); |
| 328 | NamedMDList.erase(NMD); |
| 329 | } |
| 330 | |
Bill Wendling | 0294932 | 2012-02-15 22:34:20 +0000 | [diff] [blame] | 331 | /// getModuleFlagsMetadata - Returns the module flags in the provided vector. |
| 332 | void Module:: |
| 333 | getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const { |
| 334 | const NamedMDNode *ModFlags = getModuleFlagsMetadata(); |
| 335 | if (!ModFlags) return; |
| 336 | |
| 337 | for (unsigned i = 0, e = ModFlags->getNumOperands(); i != e; ++i) { |
| 338 | MDNode *Flag = ModFlags->getOperand(i); |
| 339 | ConstantInt *Behavior = cast<ConstantInt>(Flag->getOperand(0)); |
| 340 | MDString *Key = cast<MDString>(Flag->getOperand(1)); |
| 341 | Value *Val = Flag->getOperand(2); |
Bill Wendling | 399eae6 | 2012-02-15 23:27:50 +0000 | [diff] [blame^] | 342 | Flags.push_back(ModuleFlagEntry(ModAttrBehavior(Behavior->getZExtValue()), |
| 343 | Key, Val)); |
Bill Wendling | 0294932 | 2012-02-15 22:34:20 +0000 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | |
Bill Wendling | 66f0241 | 2012-02-11 11:38:06 +0000 | [diff] [blame] | 347 | /// getModuleFlagsMetadata - Returns the NamedMDNode in the module that |
| 348 | /// represents module-level flags. This method returns null if there are no |
| 349 | /// module-level flags. |
| 350 | NamedMDNode *Module::getModuleFlagsMetadata() const { |
| 351 | return getNamedMetadata("llvm.module.flags"); |
| 352 | } |
| 353 | |
| 354 | /// getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module that |
| 355 | /// represents module-level flags. If module-level flags aren't found, it |
| 356 | /// creates the named metadata that contains them. |
| 357 | NamedMDNode *Module::getOrInsertModuleFlagsMetadata() { |
| 358 | return getOrInsertNamedMetadata("llvm.module.flags"); |
| 359 | } |
| 360 | |
| 361 | /// addModuleFlag - Add a module-level flag to the module-level flags |
| 362 | /// metadata. It will create the module-level flags named metadata if it doesn't |
| 363 | /// already exist. |
| 364 | void Module::addModuleFlag(ModAttrBehavior Behavior, StringRef Key, |
| 365 | Value *Val) { |
| 366 | Type *Int32Ty = Type::getInt32Ty(Context); |
| 367 | Value *Ops[3] = { |
| 368 | ConstantInt::get(Int32Ty, Behavior), MDString::get(Context, Key), Val |
| 369 | }; |
| 370 | getOrInsertModuleFlagsMetadata()->addOperand(MDNode::get(Context, Ops)); |
| 371 | } |
| 372 | void Module::addModuleFlag(ModAttrBehavior Behavior, StringRef Key, |
| 373 | uint32_t Val) { |
| 374 | Type *Int32Ty = Type::getInt32Ty(Context); |
| 375 | addModuleFlag(Behavior, Key, ConstantInt::get(Int32Ty, Val)); |
| 376 | } |
| 377 | void Module::addModuleFlag(MDNode *Node) { |
| 378 | assert(Node->getNumOperands() == 3 && |
| 379 | "Invalid number of operands for module flag!"); |
| 380 | assert(isa<ConstantInt>(Node->getOperand(0)) && |
| 381 | isa<MDString>(Node->getOperand(1)) && |
| 382 | "Invalid operand types for module flag!"); |
| 383 | getOrInsertModuleFlagsMetadata()->addOperand(Node); |
| 384 | } |
Chris Lattner | 10b7cb5 | 2002-04-13 18:58:33 +0000 | [diff] [blame] | 385 | |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 386 | //===----------------------------------------------------------------------===// |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 387 | // Methods to control the materialization of GlobalValues in the Module. |
| 388 | // |
| 389 | void Module::setMaterializer(GVMaterializer *GVM) { |
| 390 | assert(!Materializer && |
| 391 | "Module already has a GVMaterializer. Call MaterializeAllPermanently" |
| 392 | " to clear it out before setting another one."); |
| 393 | Materializer.reset(GVM); |
| 394 | } |
| 395 | |
| 396 | bool Module::isMaterializable(const GlobalValue *GV) const { |
| 397 | if (Materializer) |
| 398 | return Materializer->isMaterializable(GV); |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | bool Module::isDematerializable(const GlobalValue *GV) const { |
| 403 | if (Materializer) |
| 404 | return Materializer->isDematerializable(GV); |
| 405 | return false; |
| 406 | } |
| 407 | |
| 408 | bool Module::Materialize(GlobalValue *GV, std::string *ErrInfo) { |
| 409 | if (Materializer) |
| 410 | return Materializer->Materialize(GV, ErrInfo); |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | void Module::Dematerialize(GlobalValue *GV) { |
| 415 | if (Materializer) |
| 416 | return Materializer->Dematerialize(GV); |
| 417 | } |
| 418 | |
| 419 | bool Module::MaterializeAll(std::string *ErrInfo) { |
| 420 | if (!Materializer) |
| 421 | return false; |
| 422 | return Materializer->MaterializeModule(this, ErrInfo); |
| 423 | } |
| 424 | |
| 425 | bool Module::MaterializeAllPermanently(std::string *ErrInfo) { |
| 426 | if (MaterializeAll(ErrInfo)) |
| 427 | return true; |
| 428 | Materializer.reset(); |
| 429 | return false; |
| 430 | } |
| 431 | |
| 432 | //===----------------------------------------------------------------------===// |
Chris Lattner | 09bd1a0 | 2003-12-31 08:43:01 +0000 | [diff] [blame] | 433 | // Other module related stuff. |
| 434 | // |
| 435 | |
| 436 | |
Chris Lattner | e0f6af9b | 2002-08-17 23:32:47 +0000 | [diff] [blame] | 437 | // dropAllReferences() - This function causes all the subelementss to "let go" |
| 438 | // of all references that they are maintaining. This allows one to 'delete' a |
| 439 | // whole module at a time, even though there may be circular references... first |
| 440 | // all references are dropped, and all use counts go to zero. Then everything |
Misha Brukman | fa10053 | 2003-10-10 17:54:14 +0000 | [diff] [blame] | 441 | // is deleted for real. Note that no operations are valid on an object that |
Chris Lattner | e0f6af9b | 2002-08-17 23:32:47 +0000 | [diff] [blame] | 442 | // has "dropped all references", except operator delete. |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 443 | // |
| 444 | void Module::dropAllReferences() { |
Chris Lattner | 113f4f4 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 445 | for(Module::iterator I = begin(), E = end(); I != E; ++I) |
| 446 | I->dropAllReferences(); |
Chris Lattner | 446ad50 | 2001-10-13 06:58:40 +0000 | [diff] [blame] | 447 | |
Chris Lattner | 531f9e9 | 2005-03-15 04:54:21 +0000 | [diff] [blame] | 448 | for(Module::global_iterator I = global_begin(), E = global_end(); I != E; ++I) |
Chris Lattner | 113f4f4 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 449 | I->dropAllReferences(); |
Anton Korobeynikov | b18f8f8 | 2007-04-28 13:45:00 +0000 | [diff] [blame] | 450 | |
| 451 | for(Module::alias_iterator I = alias_begin(), E = alias_end(); I != E; ++I) |
| 452 | I->dropAllReferences(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 453 | } |
Chris Lattner | 31cf984 | 2001-06-30 04:35:40 +0000 | [diff] [blame] | 454 | |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 455 | void Module::addLibrary(StringRef Lib) { |
Reid Spencer | 3f4e6e8 | 2007-02-04 00:40:42 +0000 | [diff] [blame] | 456 | for (Module::lib_iterator I = lib_begin(), E = lib_end(); I != E; ++I) |
| 457 | if (*I == Lib) |
| 458 | return; |
| 459 | LibraryList.push_back(Lib); |
| 460 | } |
| 461 | |
Daniel Dunbar | ad36e8a | 2009-11-06 10:58:06 +0000 | [diff] [blame] | 462 | void Module::removeLibrary(StringRef Lib) { |
Reid Spencer | 3f4e6e8 | 2007-02-04 00:40:42 +0000 | [diff] [blame] | 463 | LibraryListType::iterator I = LibraryList.begin(); |
| 464 | LibraryListType::iterator E = LibraryList.end(); |
| 465 | for (;I != E; ++I) |
| 466 | if (*I == Lib) { |
| 467 | LibraryList.erase(I); |
| 468 | return; |
| 469 | } |
| 470 | } |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 471 | |
| 472 | //===----------------------------------------------------------------------===// |
| 473 | // Type finding functionality. |
| 474 | //===----------------------------------------------------------------------===// |
| 475 | |
| 476 | namespace { |
| 477 | /// TypeFinder - Walk over a module, identifying all of the types that are |
| 478 | /// used by the module. |
| 479 | class TypeFinder { |
| 480 | // To avoid walking constant expressions multiple times and other IR |
| 481 | // objects, we keep several helper maps. |
| 482 | DenseSet<const Value*> VisitedConstants; |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 483 | DenseSet<Type*> VisitedTypes; |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 484 | |
| 485 | std::vector<StructType*> &StructTypes; |
| 486 | public: |
| 487 | TypeFinder(std::vector<StructType*> &structTypes) |
| 488 | : StructTypes(structTypes) {} |
| 489 | |
| 490 | void run(const Module &M) { |
| 491 | // Get types from global variables. |
| 492 | for (Module::const_global_iterator I = M.global_begin(), |
| 493 | E = M.global_end(); I != E; ++I) { |
| 494 | incorporateType(I->getType()); |
| 495 | if (I->hasInitializer()) |
| 496 | incorporateValue(I->getInitializer()); |
| 497 | } |
| 498 | |
| 499 | // Get types from aliases. |
| 500 | for (Module::const_alias_iterator I = M.alias_begin(), |
| 501 | E = M.alias_end(); I != E; ++I) { |
| 502 | incorporateType(I->getType()); |
| 503 | if (const Value *Aliasee = I->getAliasee()) |
| 504 | incorporateValue(Aliasee); |
| 505 | } |
| 506 | |
| 507 | SmallVector<std::pair<unsigned, MDNode*>, 4> MDForInst; |
| 508 | |
| 509 | // Get types from functions. |
| 510 | for (Module::const_iterator FI = M.begin(), E = M.end(); FI != E; ++FI) { |
| 511 | incorporateType(FI->getType()); |
| 512 | |
| 513 | for (Function::const_iterator BB = FI->begin(), E = FI->end(); |
| 514 | BB != E;++BB) |
| 515 | for (BasicBlock::const_iterator II = BB->begin(), |
| 516 | E = BB->end(); II != E; ++II) { |
| 517 | const Instruction &I = *II; |
| 518 | // Incorporate the type of the instruction and all its operands. |
| 519 | incorporateType(I.getType()); |
| 520 | for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end(); |
| 521 | OI != OE; ++OI) |
| 522 | incorporateValue(*OI); |
| 523 | |
| 524 | // Incorporate types hiding in metadata. |
Chris Lattner | 4cc3bcd | 2011-07-14 18:58:40 +0000 | [diff] [blame] | 525 | I.getAllMetadataOtherThanDebugLoc(MDForInst); |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 526 | for (unsigned i = 0, e = MDForInst.size(); i != e; ++i) |
| 527 | incorporateMDNode(MDForInst[i].second); |
| 528 | MDForInst.clear(); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | for (Module::const_named_metadata_iterator I = M.named_metadata_begin(), |
| 533 | E = M.named_metadata_end(); I != E; ++I) { |
| 534 | const NamedMDNode *NMD = I; |
| 535 | for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) |
| 536 | incorporateMDNode(NMD->getOperand(i)); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | private: |
| 541 | void incorporateType(Type *Ty) { |
| 542 | // Check to see if we're already visited this type. |
| 543 | if (!VisitedTypes.insert(Ty).second) |
| 544 | return; |
| 545 | |
| 546 | // If this is a structure or opaque type, add a name for the type. |
| 547 | if (StructType *STy = dyn_cast<StructType>(Ty)) |
| 548 | StructTypes.push_back(STy); |
| 549 | |
| 550 | // Recursively walk all contained types. |
| 551 | for (Type::subtype_iterator I = Ty->subtype_begin(), |
| 552 | E = Ty->subtype_end(); I != E; ++I) |
| 553 | incorporateType(*I); |
| 554 | } |
| 555 | |
| 556 | /// incorporateValue - This method is used to walk operand lists finding |
| 557 | /// types hiding in constant expressions and other operands that won't be |
| 558 | /// walked in other ways. GlobalValues, basic blocks, instructions, and |
| 559 | /// inst operands are all explicitly enumerated. |
| 560 | void incorporateValue(const Value *V) { |
| 561 | if (const MDNode *M = dyn_cast<MDNode>(V)) |
| 562 | return incorporateMDNode(M); |
| 563 | if (!isa<Constant>(V) || isa<GlobalValue>(V)) return; |
| 564 | |
| 565 | // Already visited? |
| 566 | if (!VisitedConstants.insert(V).second) |
| 567 | return; |
| 568 | |
| 569 | // Check this type. |
| 570 | incorporateType(V->getType()); |
| 571 | |
| 572 | // Look in operands for types. |
| 573 | const User *U = cast<User>(V); |
| 574 | for (Constant::const_op_iterator I = U->op_begin(), |
| 575 | E = U->op_end(); I != E;++I) |
| 576 | incorporateValue(*I); |
| 577 | } |
| 578 | |
| 579 | void incorporateMDNode(const MDNode *V) { |
| 580 | |
| 581 | // Already visited? |
| 582 | if (!VisitedConstants.insert(V).second) |
| 583 | return; |
| 584 | |
| 585 | // Look in operands for types. |
| 586 | for (unsigned i = 0, e = V->getNumOperands(); i != e; ++i) |
| 587 | if (Value *Op = V->getOperand(i)) |
| 588 | incorporateValue(Op); |
| 589 | } |
| 590 | }; |
| 591 | } // end anonymous namespace |
| 592 | |
| 593 | void Module::findUsedStructTypes(std::vector<StructType*> &StructTypes) const { |
| 594 | TypeFinder(StructTypes).run(*this); |
| 595 | } |