source: icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp @ 5170

Last change on this file since 5170 was 5170, checked in by cameron, 3 years ago

Fix for Pablo bounded while statements

File size: 21.0 KB
Line 
1/*
2 *  Copyright (c) 2014-16 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include <pablo/pablo_compiler.h>
8#include <pablo/pablo_toolchain.h>
9#include <pablo/codegenstate.h>
10#include <pablo/carry_manager.h>
11#include <pablo/printer_pablos.h>
12#include <pablo/function.h>
13#include <re/re_name.h>
14#include <stdexcept>
15#include <sstream>
16#include <IDISA/idisa_builder.h>
17#include <llvm/IR/Module.h>
18#include <llvm/IR/IRBuilder.h>
19#include <iostream>
20#include <hrtime.h>
21#include <llvm/Support/Debug.h>
22
23namespace pablo {
24
25PabloCompiler::PabloCompiler(IDISA::IDISA_Builder * b, PabloKernel * k, PabloFunction * const function)
26: mMod(b->getModule())
27, iBuilder(b)
28, mBitBlockType(b->getBitBlockType())
29, mCarryManager(nullptr)
30, mPabloFunction(function)
31, mPabloBlock(nullptr)
32, mKernelBuilder(k)
33, mWhileDepth(0)
34, mIfDepth(0)
35, mFunction(nullptr)
36, mMaxWhileDepth(0) {
37   
38}
39
40
41Type * PabloCompiler::initializeKernelData() {
42    Examine(mPabloFunction);
43   
44    mCarryManager = make_unique<CarryManager>(iBuilder);
45    Type * carryDataType = mCarryManager->initializeCarryData(mPabloFunction);
46    return carryDataType;
47}
48   
49void PabloCompiler::compile(Function * doBlockFunction) {
50
51    // Make sure that we generate code into the right module.
52    mMod = iBuilder->getModule();
53    mFunction = doBlockFunction;
54    #ifdef PRINT_TIMING_INFORMATION
55    const timestamp_t pablo_compilation_start = read_cycle_counter();
56    #endif
57
58    //Generate Kernel//
59    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
60    mSelf = mKernelBuilder->getParameter(doBlockFunction, "self");
61    mCarryManager->initializeCodeGen(mKernelBuilder, mSelf);
62     
63    Value * blockNo = mKernelBuilder->getScalarField(mSelf, blockNoScalar);
64    std::string inputName = mKernelBuilder->mStreamSetInputs[0].ssName;
65    Value * inputSet_ptr  = mKernelBuilder->getStreamSetBlockPtr(mSelf, inputName, blockNo);
66
67    Value * outputSet_ptr = nullptr;
68    if (mPabloFunction->getNumOfResults() > 0) {
69        std::string outputName = mKernelBuilder->mStreamSetOutputs[0].ssName;
70        outputSet_ptr = mKernelBuilder->getStreamSetBlockPtr(mSelf, outputName, blockNo);
71    }
72
73    PabloBlock * const entryBlock = mPabloFunction->getEntryBlock();
74    mMarkerMap.emplace(entryBlock->createZeroes(), iBuilder->allZeroes());
75    mMarkerMap.emplace(entryBlock->createOnes(), iBuilder->allOnes());
76    for (unsigned j = 0; j < mPabloFunction->getNumOfParameters(); ++j) {
77        Value * inputVal = iBuilder->CreateGEP(inputSet_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(j)}); 
78        const Var * const var = mPabloFunction->getParameter(j);
79        if (DebugOptionIsSet(DumpTrace)) {
80            iBuilder->CallPrintRegister(var->getName()->to_string(), iBuilder->CreateBlockAlignedLoad(inputVal));
81        }
82        mMarkerMap.emplace(var, inputVal);
83    }
84   
85    compileBlock(entryBlock);
86   
87    for (unsigned j = 0; j < mPabloFunction->getNumOfResults(); ++j) {
88        const auto f = mMarkerMap.find(mPabloFunction->getResult(j));
89        if (LLVM_UNLIKELY(f == mMarkerMap.end())) {
90            throw std::runtime_error("PabloCompiler: result " + std::to_string(j) + " was not assigned a value!");
91        }
92        iBuilder->CreateBlockAlignedStore(f->second, outputSet_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(j)});
93    }
94    iBuilder->CreateRetVoid();
95   
96    #ifdef PRINT_TIMING_INFORMATION
97    const timestamp_t pablo_compilation_end = read_cycle_counter();
98    std::cerr << "PABLO COMPILATION TIME: " << (pablo_compilation_end - pablo_compilation_start) << std::endl;
99    #endif
100}
101
102inline void PabloCompiler::Examine(const PabloFunction * const function) {
103    mWhileDepth = 0;
104    mIfDepth = 0;
105    mMaxWhileDepth = 0;
106    Examine(function->getEntryBlock());
107}
108
109void PabloCompiler::Examine(const PabloBlock * const block) {
110    unsigned maxOffset = 0;
111    for (const Statement * stmt : *block) {
112         boost::container::flat_set<unsigned> offsets;
113        if (LLVM_UNLIKELY(isa<Lookahead>(stmt))) {
114            const Lookahead * const la = cast<Lookahead>(stmt);
115            assert (isa<Var>(la->getExpr()));
116            if (la->getAmount() > maxOffset) maxOffset = la->getAmount();
117        } else {
118            if (LLVM_UNLIKELY(isa<If>(stmt))) {
119                Examine(cast<If>(stmt)->getBody());
120            } else if (LLVM_UNLIKELY(isa<While>(stmt))) {
121                mMaxWhileDepth = std::max(mMaxWhileDepth, ++mWhileDepth);
122                Examine(cast<While>(stmt)->getBody());
123                --mWhileDepth;
124            }
125        }
126        mKernelBuilder->setLookAhead(maxOffset);
127    }
128}
129
130void PabloCompiler::compileBlock(const PabloBlock * const block) {
131    mPabloBlock = block;
132    for (const Statement * statement : *block) {
133        compileStatement(statement);
134    }
135    mPabloBlock = block->getPredecessor ();
136}
137
138void PabloCompiler::compileIf(const If * ifStatement) {       
139    //
140    //  The If-ElseZero stmt:
141    //  if <predicate:expr> then <body:stmt>* elsezero <defined:var>* endif
142    //  If the value of the predicate is nonzero, then determine the values of variables
143    //  <var>* by executing the given statements.  Otherwise, the value of the
144    //  variables are all zero.  Requirements: (a) no variable that is defined within
145    //  the body of the if may be accessed outside unless it is explicitly
146    //  listed in the variable list, (b) every variable in the defined list receives
147    //  a value within the body, and (c) the logical consequence of executing
148    //  the statements in the event that the predicate is zero is that the
149    //  values of all defined variables indeed work out to be 0.
150    //
151    //  Simple Implementation with Phi nodes:  a phi node in the if exit block
152    //  is inserted for each variable in the defined variable list.  It receives
153    //  a zero value from the ifentry block and the defined value from the if
154    //  body.
155    //
156
157    BasicBlock * const ifEntryBlock = iBuilder->GetInsertBlock();
158    BasicBlock * const ifBodyBlock = BasicBlock::Create(mMod->getContext(), "if.body", mFunction, 0);
159    BasicBlock * const ifEndBlock = BasicBlock::Create(mMod->getContext(), "if.end", mFunction, 0);
160   
161    PabloBlock * ifBody = ifStatement->getBody();
162   
163    Value * const condition = compileExpression(ifStatement->getCondition());
164   
165    mCarryManager->enterScope(ifBody);
166    iBuilder->CreateCondBr(mCarryManager->generateSummaryTest(condition), ifBodyBlock, ifEndBlock);
167   
168    // Entry processing is complete, now handle the body of the if.
169    iBuilder->SetInsertPoint(ifBodyBlock);
170   
171    compileBlock(ifBody);
172    BasicBlock * ifExitBlock = iBuilder->GetInsertBlock();
173
174    if (mCarryManager->hasCarries()) {
175        mCarryManager->storeCarryOutSummary();
176    }
177    mCarryManager->addOuterSummaryToNestedSummary();
178
179    iBuilder->CreateBr(ifEndBlock);
180    //End Block
181    iBuilder->SetInsertPoint(ifEndBlock);
182    for (const PabloAST * node : ifStatement->getDefined()) {
183        const Assign * assign = cast<Assign>(node);
184        PHINode * phi = iBuilder->CreatePHI(mBitBlockType, 2, assign->getName()->value());
185        auto f = mMarkerMap.find(assign);
186        assert (f != mMarkerMap.end());
187        phi->addIncoming(iBuilder->allZeroes(), ifEntryBlock);
188        phi->addIncoming(f->second, ifExitBlock);
189        f->second = phi;
190        assert (mMarkerMap[assign] == phi);
191    }
192    // Create the phi Node for the summary variable, if needed.
193    mCarryManager->buildCarryDataPhisAfterIfBody(ifEntryBlock, ifExitBlock);
194    mCarryManager->leaveScope();
195}
196
197void PabloCompiler::compileWhile(const While * whileStatement) {
198
199    PabloBlock * const whileBody = whileStatement->getBody();
200   
201    BasicBlock * whileEntryBlock = iBuilder->GetInsertBlock();
202    BasicBlock * whileBodyBlock = BasicBlock::Create(mMod->getContext(), "while.body", mFunction, 0);
203    BasicBlock * whileEndBlock = BasicBlock::Create(mMod->getContext(), "while.end", mFunction, 0);
204
205    mCarryManager->enterScope(whileBody);
206    mCarryManager->ensureCarriesLoadedRecursive();
207
208    const auto & nextNodes = whileStatement->getVariants();
209    std::vector<PHINode *> nextPhis;
210    nextPhis.reserve(nextNodes.size());
211#ifdef ENABLE_BOUNDED_WHILE
212    PHINode * bound_phi = nullptr;  // Needed for bounded while loops.
213#endif
214    // On entry to the while structure, proceed to execute the first iteration
215    // of the loop body unconditionally.   The while condition is tested at the end of
216    // the loop.
217
218    iBuilder->CreateBr(whileBodyBlock);
219    iBuilder->SetInsertPoint(whileBodyBlock);
220
221    //
222    // There are 3 sets of Phi nodes for the while loop.
223    // (1) Carry-ins: (a) incoming carry data first iterations, (b) zero thereafter
224    // (2) Carry-out accumulators: (a) zero first iteration, (b) |= carry-out of each iteration
225    // (3) Next nodes: (a) values set up before loop, (b) modified values calculated in loop.
226#ifdef ENABLE_BOUNDED_WHILE
227    // (4) The loop bound, if any.
228#endif
229
230    mCarryManager->initializeWhileEntryCarryDataPhis(whileEntryBlock);
231
232    // for any Next nodes in the loop body, initialize to (a) pre-loop value.
233    for (const Next * n : nextNodes) {
234        PHINode * phi = iBuilder->CreatePHI(mBitBlockType, 2, n->getName()->value());
235        auto f = mMarkerMap.find(n->getInitial());       
236        assert (f != mMarkerMap.end());
237        phi->addIncoming(f->second, whileEntryBlock);
238        f->second = phi;
239        assert(mMarkerMap[n->getInitial()] == phi);
240        nextPhis.push_back(phi);
241    }
242#ifdef ENABLE_BOUNDED_WHILE
243    if (whileStatement->getBound()) {
244        bound_phi = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2, "while_bound");
245        bound_phi->addIncoming(ConstantInt::get(iBuilder->getSizeTy(), whileStatement->getBound()), whileEntryBlock);
246    }
247#endif
248    //
249    // Now compile the loop body proper.  Carry-out accumulated values
250    // and iterated values of Next nodes will be computed.
251    ++mWhileDepth;
252    compileBlock(whileBody);
253
254    // After the whileBody has been compiled, we may be in a different basic block.
255    BasicBlock * whileExitBlock = iBuilder->GetInsertBlock();
256
257    if (mCarryManager->hasCarries()) {
258        mCarryManager->storeCarryOutSummary();
259    }
260    mCarryManager->finalizeWhileBlockCarryDataPhis(whileExitBlock);
261
262    // Terminate the while loop body with a conditional branch back.
263    Value * cond_expr = iBuilder->bitblock_any(compileExpression(whileStatement->getCondition()));
264#ifdef ENABLE_BOUNDED_WHILE
265    if (whileStatement->getBound()) {
266        Value * new_bound = iBuilder->CreateSub(bound_phi, ConstantInt::get(iBuilder->getSizeTy(), 1));
267        bound_phi->addIncoming(new_bound, whileExitBlock);
268        cond_expr = iBuilder->CreateAnd(cond_expr, iBuilder->CreateICmpUGT(new_bound, ConstantInt::getNullValue(iBuilder->getSizeTy())));
269    }
270#endif   
271    iBuilder->CreateCondBr(cond_expr, whileBodyBlock, whileEndBlock);
272
273    // and for any Next nodes in the loop body
274    for (unsigned i = 0; i < nextNodes.size(); i++) {
275        const Next * n = nextNodes[i];
276        const auto f = mMarkerMap.find(n->getExpr());
277        if (LLVM_UNLIKELY(f == mMarkerMap.end())) {
278            throw std::runtime_error("Next node expression was not compiled!");
279        }
280        nextPhis[i]->addIncoming(f->second, whileExitBlock);
281    }
282
283    iBuilder->SetInsertPoint(whileEndBlock);
284    --mWhileDepth;
285
286    mCarryManager->ensureCarriesStoredRecursive();
287    mCarryManager->leaveScope();
288}
289
290
291void PabloCompiler::compileStatement(const Statement * stmt) {
292    Value * expr = nullptr;
293    if (const Assign * assign = dyn_cast<const Assign>(stmt)) {
294        expr = compileExpression(assign->getExpression());
295    } else if (const Next * next = dyn_cast<const Next>(stmt)) {
296        expr = compileExpression(next->getExpr());
297    } else if (const If * ifStatement = dyn_cast<const If>(stmt)) {
298        compileIf(ifStatement);
299        return;
300    } else if (const While * whileStatement = dyn_cast<const While>(stmt)) {
301        compileWhile(whileStatement);
302        return;
303//    } else if (const Call* call = dyn_cast<Call>(stmt)) {
304//        // Call the callee once and store the result in the marker map.
305//        if (LLVM_UNLIKELY(mMarkerMap.count(call) == 0)) {
306//            return;
307//        }
308
309//        const Prototype * proto = call->getPrototype();
310//        const String * callee = proto->getName();
311
312//        Type * inputType = StructType::get(mMod->getContext(), std::vector<Type *>{proto->getNumOfParameters(), mBitBlockType});
313//        Type * outputType = StructType::get(mMod->getContext(), std::vector<Type *>{proto->getNumOfResults(), mBitBlockType});
314//        FunctionType * functionType = FunctionType::get(Type::getVoidTy(mMod->getContext()), std::vector<Type *>{PointerType::get(inputType, 0), PointerType::get(outputType, 0)}, false);
315
316//        //Starts on process_block
317//        SmallVector<AttributeSet, 3> Attrs;
318//        Attrs.push_back(AttributeSet::get(mMod->getContext(), 1U, std::vector<Attribute::AttrKind>({ Attribute::ReadOnly, Attribute::NoCapture })));
319//        Attrs.push_back(AttributeSet::get(mMod->getContext(), 2U, std::vector<Attribute::AttrKind>({ Attribute::ReadNone, Attribute::NoCapture })));
320//        AttributeSet AttrSet = AttributeSet::get(mMod->getContext(), Attrs);
321
322//        Function * externalFunction = cast<Function>(mMod->getOrInsertFunction(callee->value(), functionType, AttrSet));
323//        if (LLVM_UNLIKELY(externalFunction == nullptr)) {
324//            throw std::runtime_error("Could not create static method call for external function \"" + callee->to_string() + "\"");
325//        }
326//        externalFunction->setCallingConv(llvm::CallingConv::C);
327
328//        AllocaInst * outputStruct = iBuilder->CreateAlloca(outputType);
329//        iBuilder->CreateCall2(externalFunction, mInputAddressPtr, outputStruct);
330//        Value * outputPtr = iBuilder->CreateGEP(outputStruct, std::vector<Value *>({ iBuilder->getInt32(0), iBuilder->getInt32(0) }));
331
332//        expr = iBuilder->CreateBlockAlignedLoad(outputPtr);
333    } else if (const And * pablo_and = dyn_cast<And>(stmt)) {
334        expr = iBuilder->simd_and(compileExpression(pablo_and->getOperand(0)), compileExpression(pablo_and->getOperand(1)));
335    } else if (const Or * pablo_or = dyn_cast<Or>(stmt)) {
336        expr = iBuilder->simd_or(compileExpression(pablo_or->getOperand(0)), compileExpression(pablo_or->getOperand(1)));
337    } else if (const Xor * pablo_xor = dyn_cast<Xor>(stmt)) {
338        expr = iBuilder->simd_xor(compileExpression(pablo_xor->getOperand(0)), compileExpression(pablo_xor->getOperand(1)));
339    } else if (const Sel * sel = dyn_cast<Sel>(stmt)) {
340        Value* ifMask = compileExpression(sel->getCondition());
341        Value* ifTrue = iBuilder->simd_and(ifMask, compileExpression(sel->getTrueExpr()));
342        Value* ifFalse = iBuilder->simd_and(iBuilder->simd_not(ifMask), compileExpression(sel->getFalseExpr()));
343        expr = iBuilder->simd_or(ifTrue, ifFalse);
344    } else if (const Not * pablo_not = dyn_cast<Not>(stmt)) {
345        expr = iBuilder->simd_not(compileExpression(pablo_not->getExpr()));
346    } else if (const Advance * adv = dyn_cast<Advance>(stmt)) {
347        Value * const strm_value = compileExpression(adv->getExpr());
348        expr = mCarryManager->advanceCarryInCarryOut(adv->getLocalIndex(), adv->getAmount(), strm_value);
349    } else if (const MatchStar * mstar = dyn_cast<MatchStar>(stmt)) {
350        Value * const marker = compileExpression(mstar->getMarker());
351        Value * const cc = compileExpression(mstar->getCharClass());
352        Value * const marker_and_cc = iBuilder->simd_and(marker, cc);
353        Value * const sum = mCarryManager->addCarryInCarryOut(mstar->getLocalCarryIndex(), marker_and_cc, cc);
354        expr = iBuilder->simd_or(iBuilder->simd_xor(sum, cc), marker);
355    } else if (const ScanThru * sthru = dyn_cast<ScanThru>(stmt)) {
356        Value * const  marker_expr = compileExpression(sthru->getScanFrom());
357        Value * const  cc_expr = compileExpression(sthru->getScanThru());
358        Value * const  sum = mCarryManager->addCarryInCarryOut(sthru->getLocalCarryIndex(), marker_expr, cc_expr);
359        expr = iBuilder->simd_and(sum, iBuilder->simd_not(cc_expr));
360    } else if (const InFile * e = dyn_cast<InFile>(stmt)) {
361        Value * EOFmask = mKernelBuilder->getScalarField(mSelf, "EOFmask");
362        expr = iBuilder->simd_xor(compileExpression(e->getExpr()), EOFmask);
363    } else if (const AtEOF * e = dyn_cast<AtEOF>(stmt)) {
364        Value * EOFbit = mKernelBuilder->getScalarField(mSelf, "EOFbit");
365                expr = iBuilder->simd_and(compileExpression(e->getExpr()), EOFbit);
366    } else if (const Count * c = dyn_cast<Count>(stmt)) {
367        Value * const to_count = compileExpression(c->getExpr());
368        std::string counter = c->getName()->to_string();
369        Value * countSoFar = mKernelBuilder->getScalarField(mSelf, counter);
370        unsigned counterSize = countSoFar->getType()->getIntegerBitWidth();
371        Value * fieldCounts = iBuilder->simd_popcount(counterSize, to_count);
372        for (unsigned i = 0; i < iBuilder->getBitBlockWidth()/counterSize; ++i) {
373            countSoFar = iBuilder->CreateAdd(countSoFar, iBuilder->mvmd_extract(counterSize, fieldCounts, i));
374        }
375        mKernelBuilder->setScalarField(mSelf, counter, countSoFar);
376        expr = iBuilder->bitCast(iBuilder->CreateZExt(countSoFar, iBuilder->getIntNTy(iBuilder->getBitBlockWidth())));
377    } else if (const Lookahead * l = dyn_cast<Lookahead>(stmt)) {
378        PabloAST * const var = l->getExpr();
379        if (LLVM_UNLIKELY(!isa<Var>(var))) {
380            throw std::runtime_error("Lookahead operations may only be applied to input streams");
381        }
382        unsigned index = 0;
383        for (; index < mPabloFunction->getNumOfParameters(); ++index) {
384            if (mPabloFunction->getParameter(index) == var) {
385                break;
386            }
387        }
388        if (LLVM_UNLIKELY(index >= mPabloFunction->getNumOfParameters())) {
389            throw std::runtime_error("Lookahead has an illegal Var operand");
390        }
391        const unsigned bit_shift = (l->getAmount() % iBuilder->getBitBlockWidth());
392        const unsigned block_shift = (l->getAmount() / iBuilder->getBitBlockWidth());
393        std::string inputName = mKernelBuilder->mStreamSetInputs[0].ssName;
394        Value * blockNo = mKernelBuilder->getScalarField(mSelf, blockNoScalar);
395        Value * lookAhead_blockPtr  = mKernelBuilder->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, ConstantInt::get(iBuilder->getSizeTy(), block_shift)));
396        Value * lookAhead_inputPtr = iBuilder->CreateGEP(lookAhead_blockPtr, {iBuilder->getInt32(0), iBuilder->getInt32(index)});
397        Value * lookAhead = iBuilder->CreateBlockAlignedLoad(lookAhead_inputPtr);
398        if (bit_shift == 0) {  // Simple case with no intra-block shifting.
399            expr = lookAhead; 
400        }
401        else { // Need to form shift result from two adjacent blocks.
402            Value * lookAhead_blockPtr1  = mKernelBuilder->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, ConstantInt::get(iBuilder->getSizeTy(), block_shift + 1)));
403            Value * lookAhead_inputPtr1 = iBuilder->CreateGEP(lookAhead_blockPtr1, {iBuilder->getInt32(0), iBuilder->getInt32(index)});
404            Value * lookAhead1 = iBuilder->CreateBlockAlignedLoad(lookAhead_inputPtr1);
405            if (LLVM_UNLIKELY((bit_shift % 8) == 0)) { // Use a single whole-byte shift, if possible.
406                expr = iBuilder->mvmd_dslli(8, lookAhead1, lookAhead, (bit_shift / 8));
407            }
408            else {
409                Type  * const streamType = iBuilder->getIntNTy(iBuilder->getBitBlockWidth());
410                Value * b1 = iBuilder->CreateBitCast(lookAhead1, streamType);
411                Value * b0 = iBuilder->CreateBitCast(lookAhead, streamType);
412                Value * result = iBuilder->CreateOr(iBuilder->CreateShl(b1, iBuilder->getBitBlockWidth() - bit_shift), iBuilder->CreateLShr(b0, bit_shift));
413                expr = iBuilder->CreateBitCast(result, mBitBlockType);
414            }
415        }
416    } else {
417        std::string tmp;
418        llvm::raw_string_ostream msg(tmp);
419        msg << "Internal error: ";
420        PabloPrinter::print(stmt, msg);
421        msg << " is not a recognized statement in the Pablo compiler.";
422        throw std::runtime_error(msg.str());
423    }
424    mMarkerMap.emplace(stmt, expr);
425    if (DebugOptionIsSet(DumpTrace)) {
426        iBuilder->CallPrintRegister(stmt->getName()->to_string(), expr);
427    }
428   
429}
430
431Value * PabloCompiler::compileExpression(const PabloAST * expr) {
432    if (LLVM_UNLIKELY(isa<Ones>(expr))) {
433        return iBuilder->allOnes();
434    } else if (LLVM_UNLIKELY(isa<Zeroes>(expr))) {
435        return iBuilder->allZeroes();
436    }
437    auto f = mMarkerMap.find(expr);
438    if (LLVM_UNLIKELY(f == mMarkerMap.end())) {
439        std::string tmp;
440        llvm::raw_string_ostream out(tmp);
441        out << "\"";
442        PabloPrinter::print(expr, out);
443        out << "\" was used before definition!";
444        throw std::runtime_error(out.str());
445    }
446    Value * result = f->second;
447    if (LLVM_UNLIKELY(isa<Var>(expr))) {
448        assert (isa<GetElementPtrInst>(result));
449        result = iBuilder->CreateBlockAlignedLoad(result);
450    }
451    return result;
452}
453
454}
Note: See TracBrowser for help on using the repository browser.