Daniel Dunbar | beb3425 | 2012-02-29 00:20:33 +0000 | [diff] [blame] | 1 | //===-- llvm-stress.cpp - Generate random LL files to stress-test LLVM ----===// |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This program is a utility that generates random .ll files to stress-test |
| 11 | // different components in LLVM. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 14 | |
Chandler Carruth | 839a98e | 2013-01-07 15:26:48 +0000 | [diff] [blame] | 15 | #include "llvm/Analysis/CallGraphSCCPass.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 16 | #include "llvm/IR/Constants.h" |
Chandler Carruth | b8ddc70 | 2014-01-12 11:10:32 +0000 | [diff] [blame] | 17 | #include "llvm/IR/IRPrintingPasses.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 18 | #include "llvm/IR/Instruction.h" |
Chandler Carruth | b8ddc70 | 2014-01-12 11:10:32 +0000 | [diff] [blame] | 19 | #include "llvm/IR/LLVMContext.h" |
Chandler Carruth | 1b69ed8 | 2014-03-04 12:32:42 +0000 | [diff] [blame] | 20 | #include "llvm/IR/LegacyPassNameParser.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 21 | #include "llvm/IR/Module.h" |
Chandler Carruth | 5ad5f15 | 2014-01-13 09:26:24 +0000 | [diff] [blame] | 22 | #include "llvm/IR/Verifier.h" |
Chandler Carruth | 30d69c2 | 2015-02-13 10:01:29 +0000 | [diff] [blame] | 23 | #include "llvm/IR/LegacyPassManager.h" |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 24 | #include "llvm/Support/Debug.h" |
Benjamin Kramer | d59664f | 2014-04-29 23:26:49 +0000 | [diff] [blame] | 25 | #include "llvm/Support/FileSystem.h" |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 26 | #include "llvm/Support/ManagedStatic.h" |
| 27 | #include "llvm/Support/PluginLoader.h" |
| 28 | #include "llvm/Support/PrettyStackTrace.h" |
| 29 | #include "llvm/Support/ToolOutputFile.h" |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 30 | #include <algorithm> |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 31 | #include <set> |
| 32 | #include <sstream> |
| 33 | #include <vector> |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 34 | using namespace llvm; |
| 35 | |
| 36 | static cl::opt<unsigned> SeedCL("seed", |
| 37 | cl::desc("Seed used for randomness"), cl::init(0)); |
| 38 | static cl::opt<unsigned> SizeCL("size", |
| 39 | cl::desc("The estimated size of the generated function (# of instrs)"), |
| 40 | cl::init(100)); |
| 41 | static cl::opt<std::string> |
| 42 | OutputFilename("o", cl::desc("Override output filename"), |
| 43 | cl::value_desc("filename")); |
| 44 | |
Hal Finkel | c947412 | 2012-02-27 23:59:33 +0000 | [diff] [blame] | 45 | static cl::opt<bool> GenHalfFloat("generate-half-float", |
| 46 | cl::desc("Generate half-length floating-point values"), cl::init(false)); |
| 47 | static cl::opt<bool> GenX86FP80("generate-x86-fp80", |
| 48 | cl::desc("Generate 80-bit X86 floating-point values"), cl::init(false)); |
| 49 | static cl::opt<bool> GenFP128("generate-fp128", |
| 50 | cl::desc("Generate 128-bit floating-point values"), cl::init(false)); |
| 51 | static cl::opt<bool> GenPPCFP128("generate-ppc-fp128", |
| 52 | cl::desc("Generate 128-bit PPC floating-point values"), cl::init(false)); |
| 53 | static cl::opt<bool> GenX86MMX("generate-x86-mmx", |
| 54 | cl::desc("Generate X86 MMX floating-point values"), cl::init(false)); |
| 55 | |
Juergen Ributzka | 05c5a93 | 2013-11-19 03:08:35 +0000 | [diff] [blame] | 56 | namespace { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 57 | /// A utility class to provide a pseudo-random number generator which is |
| 58 | /// the same across all platforms. This is somewhat close to the libc |
| 59 | /// implementation. Note: This is not a cryptographically secure pseudorandom |
| 60 | /// number generator. |
| 61 | class Random { |
| 62 | public: |
| 63 | /// C'tor |
| 64 | Random(unsigned _seed):Seed(_seed) {} |
Dylan Noblesmith | 68f310d | 2012-04-10 22:44:51 +0000 | [diff] [blame] | 65 | |
| 66 | /// Return a random integer, up to a |
| 67 | /// maximum of 2**19 - 1. |
| 68 | uint32_t Rand() { |
| 69 | uint32_t Val = Seed + 0x000b07a1; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 70 | Seed = (Val * 0x3c7c0ac1); |
| 71 | // Only lowest 19 bits are random-ish. |
| 72 | return Seed & 0x7ffff; |
| 73 | } |
| 74 | |
Dylan Noblesmith | 68f310d | 2012-04-10 22:44:51 +0000 | [diff] [blame] | 75 | /// Return a random 32 bit integer. |
| 76 | uint32_t Rand32() { |
| 77 | uint32_t Val = Rand(); |
| 78 | Val &= 0xffff; |
| 79 | return Val | (Rand() << 16); |
| 80 | } |
| 81 | |
| 82 | /// Return a random 64 bit integer. |
| 83 | uint64_t Rand64() { |
| 84 | uint64_t Val = Rand32(); |
| 85 | return Val | (uint64_t(Rand32()) << 32); |
| 86 | } |
Nadav Rotem | 0fb7408 | 2012-06-21 08:58:15 +0000 | [diff] [blame] | 87 | |
| 88 | /// Rand operator for STL algorithms. |
| 89 | ptrdiff_t operator()(ptrdiff_t y) { |
| 90 | return Rand64() % y; |
| 91 | } |
| 92 | |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 93 | private: |
| 94 | unsigned Seed; |
| 95 | }; |
| 96 | |
| 97 | /// Generate an empty function with a default argument list. |
| 98 | Function *GenEmptyFunction(Module *M) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 99 | // Define a few arguments |
| 100 | LLVMContext &Context = M->getContext(); |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 101 | Type* ArgsTy[] = { |
| 102 | Type::getInt8PtrTy(Context), |
| 103 | Type::getInt32PtrTy(Context), |
| 104 | Type::getInt64PtrTy(Context), |
| 105 | Type::getInt32Ty(Context), |
| 106 | Type::getInt64Ty(Context), |
| 107 | Type::getInt8Ty(Context) |
| 108 | }; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 109 | |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 110 | auto *FuncTy = FunctionType::get(Type::getVoidTy(Context), ArgsTy, false); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 111 | // Pick a unique name to describe the input parameters |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 112 | Twine Name = "autogen_SD" + Twine{SeedCL}; |
| 113 | auto *Func = Function::Create(FuncTy, GlobalValue::ExternalLinkage, Name, M); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 114 | Func->setCallingConv(CallingConv::C); |
| 115 | return Func; |
| 116 | } |
| 117 | |
| 118 | /// A base class, implementing utilities needed for |
| 119 | /// modifying and adding new random instructions. |
| 120 | struct Modifier { |
| 121 | /// Used to store the randomly generated values. |
| 122 | typedef std::vector<Value*> PieceTable; |
| 123 | |
| 124 | public: |
| 125 | /// C'tor |
Nadav Rotem | dc497b6 | 2012-02-26 08:59:25 +0000 | [diff] [blame] | 126 | Modifier(BasicBlock *Block, PieceTable *PT, Random *R): |
Daniel Dunbar | beb3425 | 2012-02-29 00:20:33 +0000 | [diff] [blame] | 127 | BB(Block),PT(PT),Ran(R),Context(BB->getContext()) {} |
Andrew Trick | becbbbe | 2012-09-19 05:08:30 +0000 | [diff] [blame] | 128 | |
| 129 | /// virtual D'tor to silence warnings. |
Juergen Ributzka | 05c5a93 | 2013-11-19 03:08:35 +0000 | [diff] [blame] | 130 | virtual ~Modifier() {} |
Andrew Trick | becbbbe | 2012-09-19 05:08:30 +0000 | [diff] [blame] | 131 | |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 132 | /// Add a new instruction. |
| 133 | virtual void Act() = 0; |
| 134 | /// Add N new instructions, |
| 135 | virtual void ActN(unsigned n) { |
| 136 | for (unsigned i=0; i<n; ++i) |
| 137 | Act(); |
| 138 | } |
| 139 | |
| 140 | protected: |
| 141 | /// Return a random value from the list of known values. |
| 142 | Value *getRandomVal() { |
| 143 | assert(PT->size()); |
| 144 | return PT->at(Ran->Rand() % PT->size()); |
| 145 | } |
| 146 | |
Nadav Rotem | e4972dd | 2012-02-26 13:56:18 +0000 | [diff] [blame] | 147 | Constant *getRandomConstant(Type *Tp) { |
| 148 | if (Tp->isIntegerTy()) { |
| 149 | if (Ran->Rand() & 1) |
| 150 | return ConstantInt::getAllOnesValue(Tp); |
| 151 | return ConstantInt::getNullValue(Tp); |
| 152 | } else if (Tp->isFloatingPointTy()) { |
| 153 | if (Ran->Rand() & 1) |
| 154 | return ConstantFP::getAllOnesValue(Tp); |
| 155 | return ConstantFP::getNullValue(Tp); |
| 156 | } |
| 157 | return UndefValue::get(Tp); |
| 158 | } |
| 159 | |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 160 | /// Return a random value with a known type. |
| 161 | Value *getRandomValue(Type *Tp) { |
| 162 | unsigned index = Ran->Rand(); |
| 163 | for (unsigned i=0; i<PT->size(); ++i) { |
| 164 | Value *V = PT->at((index + i) % PT->size()); |
| 165 | if (V->getType() == Tp) |
| 166 | return V; |
| 167 | } |
| 168 | |
| 169 | // If the requested type was not found, generate a constant value. |
| 170 | if (Tp->isIntegerTy()) { |
| 171 | if (Ran->Rand() & 1) |
| 172 | return ConstantInt::getAllOnesValue(Tp); |
| 173 | return ConstantInt::getNullValue(Tp); |
| 174 | } else if (Tp->isFloatingPointTy()) { |
| 175 | if (Ran->Rand() & 1) |
| 176 | return ConstantFP::getAllOnesValue(Tp); |
| 177 | return ConstantFP::getNullValue(Tp); |
Nadav Rotem | e4972dd | 2012-02-26 13:56:18 +0000 | [diff] [blame] | 178 | } else if (Tp->isVectorTy()) { |
| 179 | VectorType *VTp = cast<VectorType>(Tp); |
| 180 | |
| 181 | std::vector<Constant*> TempValues; |
| 182 | TempValues.reserve(VTp->getNumElements()); |
| 183 | for (unsigned i = 0; i < VTp->getNumElements(); ++i) |
| 184 | TempValues.push_back(getRandomConstant(VTp->getScalarType())); |
| 185 | |
| 186 | ArrayRef<Constant*> VectorValue(TempValues); |
| 187 | return ConstantVector::get(VectorValue); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 190 | return UndefValue::get(Tp); |
| 191 | } |
| 192 | |
| 193 | /// Return a random value of any pointer type. |
| 194 | Value *getRandomPointerValue() { |
| 195 | unsigned index = Ran->Rand(); |
| 196 | for (unsigned i=0; i<PT->size(); ++i) { |
| 197 | Value *V = PT->at((index + i) % PT->size()); |
| 198 | if (V->getType()->isPointerTy()) |
| 199 | return V; |
| 200 | } |
| 201 | return UndefValue::get(pickPointerType()); |
| 202 | } |
| 203 | |
| 204 | /// Return a random value of any vector type. |
| 205 | Value *getRandomVectorValue() { |
| 206 | unsigned index = Ran->Rand(); |
| 207 | for (unsigned i=0; i<PT->size(); ++i) { |
| 208 | Value *V = PT->at((index + i) % PT->size()); |
| 209 | if (V->getType()->isVectorTy()) |
| 210 | return V; |
| 211 | } |
| 212 | return UndefValue::get(pickVectorType()); |
| 213 | } |
| 214 | |
| 215 | /// Pick a random type. |
| 216 | Type *pickType() { |
| 217 | return (Ran->Rand() & 1 ? pickVectorType() : pickScalarType()); |
| 218 | } |
| 219 | |
| 220 | /// Pick a random pointer type. |
| 221 | Type *pickPointerType() { |
| 222 | Type *Ty = pickType(); |
| 223 | return PointerType::get(Ty, 0); |
| 224 | } |
| 225 | |
| 226 | /// Pick a random vector type. |
| 227 | Type *pickVectorType(unsigned len = (unsigned)-1) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 228 | // Pick a random vector width in the range 2**0 to 2**4. |
| 229 | // by adding two randoms we are generating a normal-like distribution |
| 230 | // around 2**3. |
| 231 | unsigned width = 1<<((Ran->Rand() % 3) + (Ran->Rand() % 3)); |
Dylan Noblesmith | 2a592dc | 2012-04-10 22:44:49 +0000 | [diff] [blame] | 232 | Type *Ty; |
| 233 | |
| 234 | // Vectors of x86mmx are illegal; keep trying till we get something else. |
| 235 | do { |
| 236 | Ty = pickScalarType(); |
| 237 | } while (Ty->isX86_MMXTy()); |
| 238 | |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 239 | if (len != (unsigned)-1) |
| 240 | width = len; |
| 241 | return VectorType::get(Ty, width); |
| 242 | } |
| 243 | |
| 244 | /// Pick a random scalar type. |
| 245 | Type *pickScalarType() { |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 246 | Type *t = nullptr; |
Hal Finkel | c947412 | 2012-02-27 23:59:33 +0000 | [diff] [blame] | 247 | do { |
| 248 | switch (Ran->Rand() % 30) { |
| 249 | case 0: t = Type::getInt1Ty(Context); break; |
| 250 | case 1: t = Type::getInt8Ty(Context); break; |
| 251 | case 2: t = Type::getInt16Ty(Context); break; |
| 252 | case 3: case 4: |
| 253 | case 5: t = Type::getFloatTy(Context); break; |
| 254 | case 6: case 7: |
| 255 | case 8: t = Type::getDoubleTy(Context); break; |
| 256 | case 9: case 10: |
| 257 | case 11: t = Type::getInt32Ty(Context); break; |
| 258 | case 12: case 13: |
| 259 | case 14: t = Type::getInt64Ty(Context); break; |
| 260 | case 15: case 16: |
| 261 | case 17: if (GenHalfFloat) t = Type::getHalfTy(Context); break; |
| 262 | case 18: case 19: |
| 263 | case 20: if (GenX86FP80) t = Type::getX86_FP80Ty(Context); break; |
| 264 | case 21: case 22: |
| 265 | case 23: if (GenFP128) t = Type::getFP128Ty(Context); break; |
| 266 | case 24: case 25: |
| 267 | case 26: if (GenPPCFP128) t = Type::getPPC_FP128Ty(Context); break; |
| 268 | case 27: case 28: |
| 269 | case 29: if (GenX86MMX) t = Type::getX86_MMXTy(Context); break; |
| 270 | default: llvm_unreachable("Invalid scalar value"); |
| 271 | } |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 272 | } while (t == nullptr); |
Hal Finkel | c947412 | 2012-02-27 23:59:33 +0000 | [diff] [blame] | 273 | |
| 274 | return t; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | /// Basic block to populate |
| 278 | BasicBlock *BB; |
| 279 | /// Value table |
| 280 | PieceTable *PT; |
| 281 | /// Random number generator |
| 282 | Random *Ran; |
| 283 | /// Context |
| 284 | LLVMContext &Context; |
| 285 | }; |
| 286 | |
| 287 | struct LoadModifier: public Modifier { |
Daniel Dunbar | beb3425 | 2012-02-29 00:20:33 +0000 | [diff] [blame] | 288 | LoadModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {} |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 289 | void Act() override { |
Alp Toker | f907b89 | 2013-12-05 05:44:44 +0000 | [diff] [blame] | 290 | // Try to use predefined pointers. If non-exist, use undef pointer value; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 291 | Value *Ptr = getRandomPointerValue(); |
| 292 | Value *V = new LoadInst(Ptr, "L", BB->getTerminator()); |
| 293 | PT->push_back(V); |
| 294 | } |
| 295 | }; |
| 296 | |
| 297 | struct StoreModifier: public Modifier { |
| 298 | StoreModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {} |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 299 | void Act() override { |
Alp Toker | f907b89 | 2013-12-05 05:44:44 +0000 | [diff] [blame] | 300 | // Try to use predefined pointers. If non-exist, use undef pointer value; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 301 | Value *Ptr = getRandomPointerValue(); |
| 302 | Type *Tp = Ptr->getType(); |
| 303 | Value *Val = getRandomValue(Tp->getContainedType(0)); |
Nadav Rotem | 63ff91d | 2012-02-26 12:00:22 +0000 | [diff] [blame] | 304 | Type *ValTy = Val->getType(); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 305 | |
| 306 | // Do not store vectors of i1s because they are unsupported |
Nadav Rotem | 115ec82 | 2012-02-26 12:34:17 +0000 | [diff] [blame] | 307 | // by the codegen. |
| 308 | if (ValTy->isVectorTy() && ValTy->getScalarSizeInBits() == 1) |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 309 | return; |
| 310 | |
| 311 | new StoreInst(Val, Ptr, BB->getTerminator()); |
| 312 | } |
| 313 | }; |
| 314 | |
| 315 | struct BinModifier: public Modifier { |
| 316 | BinModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {} |
| 317 | |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 318 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 319 | Value *Val0 = getRandomVal(); |
| 320 | Value *Val1 = getRandomValue(Val0->getType()); |
| 321 | |
| 322 | // Don't handle pointer types. |
| 323 | if (Val0->getType()->isPointerTy() || |
| 324 | Val1->getType()->isPointerTy()) |
| 325 | return; |
| 326 | |
| 327 | // Don't handle i1 types. |
| 328 | if (Val0->getType()->getScalarSizeInBits() == 1) |
| 329 | return; |
| 330 | |
| 331 | |
| 332 | bool isFloat = Val0->getType()->getScalarType()->isFloatingPointTy(); |
| 333 | Instruction* Term = BB->getTerminator(); |
| 334 | unsigned R = Ran->Rand() % (isFloat ? 7 : 13); |
| 335 | Instruction::BinaryOps Op; |
| 336 | |
| 337 | switch (R) { |
| 338 | default: llvm_unreachable("Invalid BinOp"); |
| 339 | case 0:{Op = (isFloat?Instruction::FAdd : Instruction::Add); break; } |
| 340 | case 1:{Op = (isFloat?Instruction::FSub : Instruction::Sub); break; } |
| 341 | case 2:{Op = (isFloat?Instruction::FMul : Instruction::Mul); break; } |
| 342 | case 3:{Op = (isFloat?Instruction::FDiv : Instruction::SDiv); break; } |
| 343 | case 4:{Op = (isFloat?Instruction::FDiv : Instruction::UDiv); break; } |
| 344 | case 5:{Op = (isFloat?Instruction::FRem : Instruction::SRem); break; } |
| 345 | case 6:{Op = (isFloat?Instruction::FRem : Instruction::URem); break; } |
| 346 | case 7: {Op = Instruction::Shl; break; } |
| 347 | case 8: {Op = Instruction::LShr; break; } |
| 348 | case 9: {Op = Instruction::AShr; break; } |
| 349 | case 10:{Op = Instruction::And; break; } |
| 350 | case 11:{Op = Instruction::Or; break; } |
| 351 | case 12:{Op = Instruction::Xor; break; } |
| 352 | } |
| 353 | |
| 354 | PT->push_back(BinaryOperator::Create(Op, Val0, Val1, "B", Term)); |
| 355 | } |
| 356 | }; |
| 357 | |
| 358 | /// Generate constant values. |
| 359 | struct ConstModifier: public Modifier { |
| 360 | ConstModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {} |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 361 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 362 | Type *Ty = pickType(); |
| 363 | |
| 364 | if (Ty->isVectorTy()) { |
| 365 | switch (Ran->Rand() % 2) { |
| 366 | case 0: if (Ty->getScalarType()->isIntegerTy()) |
| 367 | return PT->push_back(ConstantVector::getAllOnesValue(Ty)); |
| 368 | case 1: if (Ty->getScalarType()->isIntegerTy()) |
| 369 | return PT->push_back(ConstantVector::getNullValue(Ty)); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | if (Ty->isFloatingPointTy()) { |
Dylan Noblesmith | 68f310d | 2012-04-10 22:44:51 +0000 | [diff] [blame] | 374 | // Generate 128 random bits, the size of the (currently) |
| 375 | // largest floating-point types. |
| 376 | uint64_t RandomBits[2]; |
| 377 | for (unsigned i = 0; i < 2; ++i) |
| 378 | RandomBits[i] = Ran->Rand64(); |
| 379 | |
| 380 | APInt RandomInt(Ty->getPrimitiveSizeInBits(), makeArrayRef(RandomBits)); |
Tim Northover | 98d9b7e | 2013-01-22 10:18:26 +0000 | [diff] [blame] | 381 | APFloat RandomFloat(Ty->getFltSemantics(), RandomInt); |
Dylan Noblesmith | 68f310d | 2012-04-10 22:44:51 +0000 | [diff] [blame] | 382 | |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 383 | if (Ran->Rand() & 1) |
| 384 | return PT->push_back(ConstantFP::getNullValue(Ty)); |
Dylan Noblesmith | 68f310d | 2012-04-10 22:44:51 +0000 | [diff] [blame] | 385 | return PT->push_back(ConstantFP::get(Ty->getContext(), RandomFloat)); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | if (Ty->isIntegerTy()) { |
| 389 | switch (Ran->Rand() % 7) { |
| 390 | case 0: if (Ty->isIntegerTy()) |
| 391 | return PT->push_back(ConstantInt::get(Ty, |
| 392 | APInt::getAllOnesValue(Ty->getPrimitiveSizeInBits()))); |
| 393 | case 1: if (Ty->isIntegerTy()) |
| 394 | return PT->push_back(ConstantInt::get(Ty, |
| 395 | APInt::getNullValue(Ty->getPrimitiveSizeInBits()))); |
| 396 | case 2: case 3: case 4: case 5: |
| 397 | case 6: if (Ty->isIntegerTy()) |
| 398 | PT->push_back(ConstantInt::get(Ty, Ran->Rand())); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | } |
| 403 | }; |
| 404 | |
| 405 | struct AllocaModifier: public Modifier { |
| 406 | AllocaModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R){} |
| 407 | |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 408 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 409 | Type *Tp = pickType(); |
| 410 | PT->push_back(new AllocaInst(Tp, "A", BB->getFirstNonPHI())); |
| 411 | } |
| 412 | }; |
| 413 | |
| 414 | struct ExtractElementModifier: public Modifier { |
| 415 | ExtractElementModifier(BasicBlock *BB, PieceTable *PT, Random *R): |
| 416 | Modifier(BB, PT, R) {} |
| 417 | |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 418 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 419 | Value *Val0 = getRandomVectorValue(); |
| 420 | Value *V = ExtractElementInst::Create(Val0, |
| 421 | ConstantInt::get(Type::getInt32Ty(BB->getContext()), |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 422 | Ran->Rand() % cast<VectorType>(Val0->getType())->getNumElements()), |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 423 | "E", BB->getTerminator()); |
| 424 | return PT->push_back(V); |
| 425 | } |
| 426 | }; |
| 427 | |
| 428 | struct ShuffModifier: public Modifier { |
| 429 | ShuffModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {} |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 430 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 431 | |
| 432 | Value *Val0 = getRandomVectorValue(); |
| 433 | Value *Val1 = getRandomValue(Val0->getType()); |
| 434 | |
| 435 | unsigned Width = cast<VectorType>(Val0->getType())->getNumElements(); |
| 436 | std::vector<Constant*> Idxs; |
| 437 | |
| 438 | Type *I32 = Type::getInt32Ty(BB->getContext()); |
| 439 | for (unsigned i=0; i<Width; ++i) { |
| 440 | Constant *CI = ConstantInt::get(I32, Ran->Rand() % (Width*2)); |
| 441 | // Pick some undef values. |
| 442 | if (!(Ran->Rand() % 5)) |
| 443 | CI = UndefValue::get(I32); |
| 444 | Idxs.push_back(CI); |
| 445 | } |
| 446 | |
| 447 | Constant *Mask = ConstantVector::get(Idxs); |
| 448 | |
| 449 | Value *V = new ShuffleVectorInst(Val0, Val1, Mask, "Shuff", |
| 450 | BB->getTerminator()); |
| 451 | PT->push_back(V); |
| 452 | } |
| 453 | }; |
| 454 | |
| 455 | struct InsertElementModifier: public Modifier { |
| 456 | InsertElementModifier(BasicBlock *BB, PieceTable *PT, Random *R): |
| 457 | Modifier(BB, PT, R) {} |
| 458 | |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 459 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 460 | Value *Val0 = getRandomVectorValue(); |
| 461 | Value *Val1 = getRandomValue(Val0->getType()->getScalarType()); |
| 462 | |
| 463 | Value *V = InsertElementInst::Create(Val0, Val1, |
| 464 | ConstantInt::get(Type::getInt32Ty(BB->getContext()), |
| 465 | Ran->Rand() % cast<VectorType>(Val0->getType())->getNumElements()), |
| 466 | "I", BB->getTerminator()); |
| 467 | return PT->push_back(V); |
| 468 | } |
| 469 | |
| 470 | }; |
| 471 | |
| 472 | struct CastModifier: public Modifier { |
| 473 | CastModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {} |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 474 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 475 | |
| 476 | Value *V = getRandomVal(); |
| 477 | Type *VTy = V->getType(); |
| 478 | Type *DestTy = pickScalarType(); |
| 479 | |
| 480 | // Handle vector casts vectors. |
| 481 | if (VTy->isVectorTy()) { |
| 482 | VectorType *VecTy = cast<VectorType>(VTy); |
| 483 | DestTy = pickVectorType(VecTy->getNumElements()); |
| 484 | } |
| 485 | |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 486 | // no need to cast. |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 487 | if (VTy == DestTy) return; |
| 488 | |
| 489 | // Pointers: |
| 490 | if (VTy->isPointerTy()) { |
| 491 | if (!DestTy->isPointerTy()) |
| 492 | DestTy = PointerType::get(DestTy, 0); |
| 493 | return PT->push_back( |
| 494 | new BitCastInst(V, DestTy, "PC", BB->getTerminator())); |
| 495 | } |
| 496 | |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 497 | unsigned VSize = VTy->getScalarType()->getPrimitiveSizeInBits(); |
| 498 | unsigned DestSize = DestTy->getScalarType()->getPrimitiveSizeInBits(); |
| 499 | |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 500 | // Generate lots of bitcasts. |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 501 | if ((Ran->Rand() & 1) && VSize == DestSize) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 502 | return PT->push_back( |
| 503 | new BitCastInst(V, DestTy, "BC", BB->getTerminator())); |
| 504 | } |
| 505 | |
| 506 | // Both types are integers: |
| 507 | if (VTy->getScalarType()->isIntegerTy() && |
| 508 | DestTy->getScalarType()->isIntegerTy()) { |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 509 | if (VSize > DestSize) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 510 | return PT->push_back( |
| 511 | new TruncInst(V, DestTy, "Tr", BB->getTerminator())); |
| 512 | } else { |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 513 | assert(VSize < DestSize && "Different int types with the same size?"); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 514 | if (Ran->Rand() & 1) |
| 515 | return PT->push_back( |
| 516 | new ZExtInst(V, DestTy, "ZE", BB->getTerminator())); |
| 517 | return PT->push_back(new SExtInst(V, DestTy, "Se", BB->getTerminator())); |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | // Fp to int. |
| 522 | if (VTy->getScalarType()->isFloatingPointTy() && |
| 523 | DestTy->getScalarType()->isIntegerTy()) { |
| 524 | if (Ran->Rand() & 1) |
| 525 | return PT->push_back( |
| 526 | new FPToSIInst(V, DestTy, "FC", BB->getTerminator())); |
| 527 | return PT->push_back(new FPToUIInst(V, DestTy, "FC", BB->getTerminator())); |
| 528 | } |
| 529 | |
| 530 | // Int to fp. |
| 531 | if (VTy->getScalarType()->isIntegerTy() && |
| 532 | DestTy->getScalarType()->isFloatingPointTy()) { |
| 533 | if (Ran->Rand() & 1) |
| 534 | return PT->push_back( |
| 535 | new SIToFPInst(V, DestTy, "FC", BB->getTerminator())); |
| 536 | return PT->push_back(new UIToFPInst(V, DestTy, "FC", BB->getTerminator())); |
| 537 | |
| 538 | } |
| 539 | |
| 540 | // Both floats. |
| 541 | if (VTy->getScalarType()->isFloatingPointTy() && |
| 542 | DestTy->getScalarType()->isFloatingPointTy()) { |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 543 | if (VSize > DestSize) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 544 | return PT->push_back( |
| 545 | new FPTruncInst(V, DestTy, "Tr", BB->getTerminator())); |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 546 | } else if (VSize < DestSize) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 547 | return PT->push_back( |
| 548 | new FPExtInst(V, DestTy, "ZE", BB->getTerminator())); |
| 549 | } |
Nadav Rotem | aeacc17 | 2012-04-15 20:17:14 +0000 | [diff] [blame] | 550 | // If VSize == DestSize, then the two types must be fp128 and ppc_fp128, |
| 551 | // for which there is no defined conversion. So do nothing. |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 552 | } |
| 553 | } |
| 554 | |
| 555 | }; |
| 556 | |
| 557 | struct SelectModifier: public Modifier { |
| 558 | SelectModifier(BasicBlock *BB, PieceTable *PT, Random *R): |
| 559 | Modifier(BB, PT, R) {} |
| 560 | |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 561 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 562 | // Try a bunch of different select configuration until a valid one is found. |
| 563 | Value *Val0 = getRandomVal(); |
| 564 | Value *Val1 = getRandomValue(Val0->getType()); |
| 565 | |
| 566 | Type *CondTy = Type::getInt1Ty(Context); |
| 567 | |
| 568 | // If the value type is a vector, and we allow vector select, then in 50% |
| 569 | // of the cases generate a vector select. |
| 570 | if (Val0->getType()->isVectorTy() && (Ran->Rand() % 1)) { |
| 571 | unsigned NumElem = cast<VectorType>(Val0->getType())->getNumElements(); |
| 572 | CondTy = VectorType::get(CondTy, NumElem); |
| 573 | } |
| 574 | |
| 575 | Value *Cond = getRandomValue(CondTy); |
| 576 | Value *V = SelectInst::Create(Cond, Val0, Val1, "Sl", BB->getTerminator()); |
| 577 | return PT->push_back(V); |
| 578 | } |
| 579 | }; |
| 580 | |
| 581 | |
| 582 | struct CmpModifier: public Modifier { |
| 583 | CmpModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {} |
Craig Topper | e56917c | 2014-03-08 08:27:28 +0000 | [diff] [blame] | 584 | void Act() override { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 585 | |
| 586 | Value *Val0 = getRandomVal(); |
| 587 | Value *Val1 = getRandomValue(Val0->getType()); |
| 588 | |
| 589 | if (Val0->getType()->isPointerTy()) return; |
| 590 | bool fp = Val0->getType()->getScalarType()->isFloatingPointTy(); |
| 591 | |
| 592 | int op; |
| 593 | if (fp) { |
| 594 | op = Ran->Rand() % |
| 595 | (CmpInst::LAST_FCMP_PREDICATE - CmpInst::FIRST_FCMP_PREDICATE) + |
| 596 | CmpInst::FIRST_FCMP_PREDICATE; |
| 597 | } else { |
| 598 | op = Ran->Rand() % |
| 599 | (CmpInst::LAST_ICMP_PREDICATE - CmpInst::FIRST_ICMP_PREDICATE) + |
| 600 | CmpInst::FIRST_ICMP_PREDICATE; |
| 601 | } |
| 602 | |
| 603 | Value *V = CmpInst::Create(fp ? Instruction::FCmp : Instruction::ICmp, |
| 604 | op, Val0, Val1, "Cmp", BB->getTerminator()); |
| 605 | return PT->push_back(V); |
| 606 | } |
| 607 | }; |
| 608 | |
Juergen Ributzka | 05c5a93 | 2013-11-19 03:08:35 +0000 | [diff] [blame] | 609 | } // end anonymous namespace |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 610 | |
Juergen Ributzka | 05c5a93 | 2013-11-19 03:08:35 +0000 | [diff] [blame] | 611 | static void FillFunction(Function *F, Random &R) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 612 | // Create a legal entry block. |
| 613 | BasicBlock *BB = BasicBlock::Create(F->getContext(), "BB", F); |
| 614 | ReturnInst::Create(F->getContext(), BB); |
| 615 | |
| 616 | // Create the value table. |
| 617 | Modifier::PieceTable PT; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 618 | |
| 619 | // Consider arguments as legal values. |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 620 | for (auto &arg : F->args()) |
| 621 | PT.push_back(&arg); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 622 | |
| 623 | // List of modifiers which add new random instructions. |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 624 | std::vector<std::unique_ptr<Modifier>> Modifiers; |
| 625 | Modifiers.emplace_back(new LoadModifier(BB, &PT, &R)); |
| 626 | Modifiers.emplace_back(new StoreModifier(BB, &PT, &R)); |
| 627 | auto SM = Modifiers.back().get(); |
| 628 | Modifiers.emplace_back(new ExtractElementModifier(BB, &PT, &R)); |
| 629 | Modifiers.emplace_back(new ShuffModifier(BB, &PT, &R)); |
| 630 | Modifiers.emplace_back(new InsertElementModifier(BB, &PT, &R)); |
| 631 | Modifiers.emplace_back(new BinModifier(BB, &PT, &R)); |
| 632 | Modifiers.emplace_back(new CastModifier(BB, &PT, &R)); |
| 633 | Modifiers.emplace_back(new SelectModifier(BB, &PT, &R)); |
| 634 | Modifiers.emplace_back(new CmpModifier(BB, &PT, &R)); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 635 | |
| 636 | // Generate the random instructions |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 637 | AllocaModifier{BB, &PT, &R}.ActN(5); // Throw in a few allocas |
| 638 | ConstModifier{BB, &PT, &R}.ActN(40); // Throw in a few constants |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 639 | |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 640 | for (unsigned i = 0; i < SizeCL / Modifiers.size(); ++i) |
| 641 | for (auto &Mod : Modifiers) |
| 642 | Mod->Act(); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 643 | |
| 644 | SM->ActN(5); // Throw in a few stores. |
| 645 | } |
| 646 | |
Juergen Ributzka | 05c5a93 | 2013-11-19 03:08:35 +0000 | [diff] [blame] | 647 | static void IntroduceControlFlow(Function *F, Random &R) { |
Nadav Rotem | 0fb7408 | 2012-06-21 08:58:15 +0000 | [diff] [blame] | 648 | std::vector<Instruction*> BoolInst; |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 649 | for (auto &Instr : F->front()) { |
| 650 | if (Instr.getType() == IntegerType::getInt1Ty(F->getContext())) |
| 651 | BoolInst.push_back(&Instr); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 652 | } |
| 653 | |
Nadav Rotem | 0fb7408 | 2012-06-21 08:58:15 +0000 | [diff] [blame] | 654 | std::random_shuffle(BoolInst.begin(), BoolInst.end(), R); |
| 655 | |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 656 | for (auto *Instr : BoolInst) { |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 657 | BasicBlock *Curr = Instr->getParent(); |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 658 | BasicBlock::iterator Loc = Instr; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 659 | BasicBlock *Next = Curr->splitBasicBlock(Loc, "CF"); |
| 660 | Instr->moveBefore(Curr->getTerminator()); |
| 661 | if (Curr != &F->getEntryBlock()) { |
| 662 | BranchInst::Create(Curr, Next, Instr, Curr->getTerminator()); |
| 663 | Curr->getTerminator()->eraseFromParent(); |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | int main(int argc, char **argv) { |
| 669 | // Init LLVM, call llvm_shutdown() on exit, parse args, etc. |
| 670 | llvm::PrettyStackTraceProgram X(argc, argv); |
| 671 | cl::ParseCommandLineOptions(argc, argv, "llvm codegen stress-tester\n"); |
| 672 | llvm_shutdown_obj Y; |
| 673 | |
Pawel Bylica | 2366347 | 2015-06-24 11:49:44 +0000 | [diff] [blame] | 674 | auto M = make_unique<Module>("/tmp/autogen.bc", getGlobalContext()); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 675 | Function *F = GenEmptyFunction(M.get()); |
Nadav Rotem | 0fb7408 | 2012-06-21 08:58:15 +0000 | [diff] [blame] | 676 | |
| 677 | // Pick an initial seed value |
| 678 | Random R(SeedCL); |
| 679 | // Generate lots of random instructions inside a single basic block. |
| 680 | FillFunction(F, R); |
| 681 | // Break the basic block into many loops. |
| 682 | IntroduceControlFlow(F, R); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 683 | |
| 684 | // Figure out what stream we are supposed to write to... |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 685 | std::unique_ptr<tool_output_file> Out; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 686 | // Default to standard output. |
| 687 | if (OutputFilename.empty()) |
| 688 | OutputFilename = "-"; |
| 689 | |
Rafael Espindola | 3fd1e99 | 2014-08-25 18:16:47 +0000 | [diff] [blame] | 690 | std::error_code EC; |
| 691 | Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None)); |
| 692 | if (EC) { |
| 693 | errs() << EC.message() << '\n'; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 694 | return 1; |
| 695 | } |
| 696 | |
Chandler Carruth | 30d69c2 | 2015-02-13 10:01:29 +0000 | [diff] [blame] | 697 | legacy::PassManager Passes; |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 698 | Passes.add(createVerifierPass()); |
Chandler Carruth | 3bdf043 | 2014-01-12 11:39:04 +0000 | [diff] [blame] | 699 | Passes.add(createPrintModulePass(Out->os())); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 700 | Passes.run(*M.get()); |
Nadav Rotem | 78bda89 | 2012-02-26 08:35:53 +0000 | [diff] [blame] | 701 | Out->keep(); |
| 702 | |
| 703 | return 0; |
| 704 | } |