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

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

Preparing 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        PHINode * bound_phi = iBuilder->CreatePHI(iBuilder->getSizeTy());
245        bound_phi->addIncoming(ConstantInt::get(iBuilder->getSizeTy(), whileStatement->getBound()));
246    }
247#endif
248
249    //
250    // Now compile the loop body proper.  Carry-out accumulated values
251    // and iterated values of Next nodes will be computed.
252    ++mWhileDepth;
253    compileBlock(whileBody);
254
255    // After the whileBody has been compiled, we may be in a different basic block.
256    BasicBlock * whileExitBlock = iBuilder->GetInsertBlock();
257
258    if (mCarryManager->hasCarries()) {
259        mCarryManager->storeCarryOutSummary();
260    }
261    mCarryManager->finalizeWhileBlockCarryDataPhis(whileExitBlock);
262
263    // Terminate the while loop body with a conditional branch back.
264    Value * cond_expr = iBuilder->bitblock_any(compileExpression(whileStatement->getCondition()));
265#ifdef ENABLE_BOUNDED_WHILE
266    if (whileStatement->getBound()) {
267        Value * new_bound = iBuilder->CreateSub(bound_phi, ConstantInt::get(iBuilder->getSizeTy(), 1));
268        bound_phi->addIncoming(new_bound, whileExitBlock)));
269        cond_expr = iBuilder->CreateAnd(cond_expr, iBuilder->CreateCmpGE(new_bound, ConstantInt::GetNullValue(iBuilder->getSizeTy()));
270    }
271#endif   
272    iBuilder->CreateCondBr(cond_expr, whileBodyBlock, whileEndBlock);
273
274    // and for any Next nodes in the loop body
275    for (unsigned i = 0; i < nextNodes.size(); i++) {
276        const Next * n = nextNodes[i];
277        const auto f = mMarkerMap.find(n->getExpr());
278        if (LLVM_UNLIKELY(f == mMarkerMap.end())) {
279            throw std::runtime_error("Next node expression was not compiled!");
280        }
281        nextPhis[i]->addIncoming(f->second, whileExitBlock);
282    }
283
284    iBuilder->SetInsertPoint(whileEndBlock);
285    --mWhileDepth;
286
287    mCarryManager->ensureCarriesStoredRecursive();
288    mCarryManager->leaveScope();
289}
290
291
292void PabloCompiler::compileStatement(const Statement * stmt) {
293    Value * expr = nullptr;
294    if (const Assign * assign = dyn_cast<const Assign>(stmt)) {
295        expr = compileExpression(assign->getExpression());
296    } else if (const Next * next = dyn_cast<const Next>(stmt)) {
297        expr = compileExpression(next->getExpr());
298    } else if (const If * ifStatement = dyn_cast<const If>(stmt)) {
299        compileIf(ifStatement);
300        return;
301    } else if (const While * whileStatement = dyn_cast<const While>(stmt)) {
302        compileWhile(whileStatement);
303        return;
304//    } else if (const Call* call = dyn_cast<Call>(stmt)) {
305//        // Call the callee once and store the result in the marker map.
306//        if (LLVM_UNLIKELY(mMarkerMap.count(call) == 0)) {
307//            return;
308//        }
309
310//        const Prototype * proto = call->getPrototype();
311//        const String * callee = proto->getName();
312
313//        Type * inputType = StructType::get(mMod->getContext(), std::vector<Type *>{proto->getNumOfParameters(), mBitBlockType});
314//        Type * outputType = StructType::get(mMod->getContext(), std::vector<Type *>{proto->getNumOfResults(), mBitBlockType});
315//        FunctionType * functionType = FunctionType::get(Type::getVoidTy(mMod->getContext()), std::vector<Type *>{PointerType::get(inputType, 0), PointerType::get(outputType, 0)}, false);
316
317//        //Starts on process_block
318//        SmallVector<AttributeSet, 3> Attrs;
319//        Attrs.push_back(AttributeSet::get(mMod->getContext(), 1U, std::vector<Attribute::AttrKind>({ Attribute::ReadOnly, Attribute::NoCapture })));
320//        Attrs.push_back(AttributeSet::get(mMod->getContext(), 2U, std::vector<Attribute::AttrKind>({ Attribute::ReadNone, Attribute::NoCapture })));
321//        AttributeSet AttrSet = AttributeSet::get(mMod->getContext(), Attrs);
322
323//        Function * externalFunction = cast<Function>(mMod->getOrInsertFunction(callee->value(), functionType, AttrSet));
324//        if (LLVM_UNLIKELY(externalFunction == nullptr)) {
325//            throw std::runtime_error("Could not create static method call for external function \"" + callee->to_string() + "\"");
326//        }
327//        externalFunction->setCallingConv(llvm::CallingConv::C);
328
329//        AllocaInst * outputStruct = iBuilder->CreateAlloca(outputType);
330//        iBuilder->CreateCall2(externalFunction, mInputAddressPtr, outputStruct);
331//        Value * outputPtr = iBuilder->CreateGEP(outputStruct, std::vector<Value *>({ iBuilder->getInt32(0), iBuilder->getInt32(0) }));
332
333//        expr = iBuilder->CreateBlockAlignedLoad(outputPtr);
334    } else if (const And * pablo_and = dyn_cast<And>(stmt)) {
335        expr = iBuilder->simd_and(compileExpression(pablo_and->getOperand(0)), compileExpression(pablo_and->getOperand(1)));
336    } else if (const Or * pablo_or = dyn_cast<Or>(stmt)) {
337        expr = iBuilder->simd_or(compileExpression(pablo_or->getOperand(0)), compileExpression(pablo_or->getOperand(1)));
338    } else if (const Xor * pablo_xor = dyn_cast<Xor>(stmt)) {
339        expr = iBuilder->simd_xor(compileExpression(pablo_xor->getOperand(0)), compileExpression(pablo_xor->getOperand(1)));
340    } else if (const Sel * sel = dyn_cast<Sel>(stmt)) {
341        Value* ifMask = compileExpression(sel->getCondition());
342        Value* ifTrue = iBuilder->simd_and(ifMask, compileExpression(sel->getTrueExpr()));
343        Value* ifFalse = iBuilder->simd_and(iBuilder->simd_not(ifMask), compileExpression(sel->getFalseExpr()));
344        expr = iBuilder->simd_or(ifTrue, ifFalse);
345    } else if (const Not * pablo_not = dyn_cast<Not>(stmt)) {
346        expr = iBuilder->simd_not(compileExpression(pablo_not->getExpr()));
347    } else if (const Advance * adv = dyn_cast<Advance>(stmt)) {
348        Value * const strm_value = compileExpression(adv->getExpr());
349        expr = mCarryManager->advanceCarryInCarryOut(adv->getLocalIndex(), adv->getAmount(), strm_value);
350    } else if (const MatchStar * mstar = dyn_cast<MatchStar>(stmt)) {
351        Value * const marker = compileExpression(mstar->getMarker());
352        Value * const cc = compileExpression(mstar->getCharClass());
353        Value * const marker_and_cc = iBuilder->simd_and(marker, cc);
354        Value * const sum = mCarryManager->addCarryInCarryOut(mstar->getLocalCarryIndex(), marker_and_cc, cc);
355        expr = iBuilder->simd_or(iBuilder->simd_xor(sum, cc), marker);
356    } else if (const ScanThru * sthru = dyn_cast<ScanThru>(stmt)) {
357        Value * const  marker_expr = compileExpression(sthru->getScanFrom());
358        Value * const  cc_expr = compileExpression(sthru->getScanThru());
359        Value * const  sum = mCarryManager->addCarryInCarryOut(sthru->getLocalCarryIndex(), marker_expr, cc_expr);
360        expr = iBuilder->simd_and(sum, iBuilder->simd_not(cc_expr));
361    } else if (const InFile * e = dyn_cast<InFile>(stmt)) {
362        Value * EOFmask = mKernelBuilder->getScalarField(mSelf, "EOFmask");
363        expr = iBuilder->simd_xor(compileExpression(e->getExpr()), EOFmask);
364    } else if (const AtEOF * e = dyn_cast<AtEOF>(stmt)) {
365        Value * EOFbit = mKernelBuilder->getScalarField(mSelf, "EOFbit");
366                expr = iBuilder->simd_and(compileExpression(e->getExpr()), EOFbit);
367    } else if (const Count * c = dyn_cast<Count>(stmt)) {
368        Value * const to_count = compileExpression(c->getExpr());
369        std::string counter = c->getName()->to_string();
370        Value * countSoFar = mKernelBuilder->getScalarField(mSelf, counter);
371        unsigned counterSize = countSoFar->getType()->getIntegerBitWidth();
372        Value * fieldCounts = iBuilder->simd_popcount(counterSize, to_count);
373        for (unsigned i = 0; i < iBuilder->getBitBlockWidth()/counterSize; ++i) {
374            countSoFar = iBuilder->CreateAdd(countSoFar, iBuilder->mvmd_extract(counterSize, fieldCounts, i));
375        }
376        mKernelBuilder->setScalarField(mSelf, counter, countSoFar);
377        expr = iBuilder->bitCast(iBuilder->CreateZExt(countSoFar, iBuilder->getIntNTy(iBuilder->getBitBlockWidth())));
378    } else if (const Lookahead * l = dyn_cast<Lookahead>(stmt)) {
379        PabloAST * const var = l->getExpr();
380        if (LLVM_UNLIKELY(!isa<Var>(var))) {
381            throw std::runtime_error("Lookahead operations may only be applied to input streams");
382        }
383        unsigned index = 0;
384        for (; index < mPabloFunction->getNumOfParameters(); ++index) {
385            if (mPabloFunction->getParameter(index) == var) {
386                break;
387            }
388        }
389        if (LLVM_UNLIKELY(index >= mPabloFunction->getNumOfParameters())) {
390            throw std::runtime_error("Lookahead has an illegal Var operand");
391        }
392        const unsigned bit_shift = (l->getAmount() % iBuilder->getBitBlockWidth());
393        const unsigned block_shift = (l->getAmount() / iBuilder->getBitBlockWidth());
394        std::string inputName = mKernelBuilder->mStreamSetInputs[0].ssName;
395        Value * blockNo = mKernelBuilder->getScalarField(mSelf, blockNoScalar);
396        Value * lookAhead_blockPtr  = mKernelBuilder->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, ConstantInt::get(iBuilder->getSizeTy(), block_shift)));
397        Value * lookAhead_inputPtr = iBuilder->CreateGEP(lookAhead_blockPtr, {iBuilder->getInt32(0), iBuilder->getInt32(index)});
398        Value * lookAhead = iBuilder->CreateBlockAlignedLoad(lookAhead_inputPtr);
399        if (bit_shift == 0) {  // Simple case with no intra-block shifting.
400            expr = lookAhead; 
401        }
402        else { // Need to form shift result from two adjacent blocks.
403            Value * lookAhead_blockPtr1  = mKernelBuilder->getStreamSetBlockPtr(mSelf, inputName, iBuilder->CreateAdd(blockNo, ConstantInt::get(iBuilder->getSizeTy(), block_shift + 1)));
404            Value * lookAhead_inputPtr1 = iBuilder->CreateGEP(lookAhead_blockPtr1, {iBuilder->getInt32(0), iBuilder->getInt32(index)});
405            Value * lookAhead1 = iBuilder->CreateBlockAlignedLoad(lookAhead_inputPtr1);
406            if (LLVM_UNLIKELY((bit_shift % 8) == 0)) { // Use a single whole-byte shift, if possible.
407                expr = iBuilder->mvmd_dslli(8, lookAhead1, lookAhead, (bit_shift / 8));
408            }
409            else {
410                Type  * const streamType = iBuilder->getIntNTy(iBuilder->getBitBlockWidth());
411                Value * b1 = iBuilder->CreateBitCast(lookAhead1, streamType);
412                Value * b0 = iBuilder->CreateBitCast(lookAhead, streamType);
413                Value * result = iBuilder->CreateOr(iBuilder->CreateShl(b1, iBuilder->getBitBlockWidth() - bit_shift), iBuilder->CreateLShr(b0, bit_shift));
414                expr = iBuilder->CreateBitCast(result, mBitBlockType);
415            }
416        }
417    } else {
418        std::string tmp;
419        llvm::raw_string_ostream msg(tmp);
420        msg << "Internal error: ";
421        PabloPrinter::print(stmt, msg);
422        msg << " is not a recognized statement in the Pablo compiler.";
423        throw std::runtime_error(msg.str());
424    }
425    mMarkerMap.emplace(stmt, expr);
426    if (DebugOptionIsSet(DumpTrace)) {
427        iBuilder->CallPrintRegister(stmt->getName()->to_string(), expr);
428    }
429   
430}
431
432Value * PabloCompiler::compileExpression(const PabloAST * expr) {
433    if (LLVM_UNLIKELY(isa<Ones>(expr))) {
434        return iBuilder->allOnes();
435    } else if (LLVM_UNLIKELY(isa<Zeroes>(expr))) {
436        return iBuilder->allZeroes();
437    }
438    auto f = mMarkerMap.find(expr);
439    if (LLVM_UNLIKELY(f == mMarkerMap.end())) {
440        std::string tmp;
441        llvm::raw_string_ostream out(tmp);
442        out << "\"";
443        PabloPrinter::print(expr, out);
444        out << "\" was used before definition!";
445        throw std::runtime_error(out.str());
446    }
447    Value * result = f->second;
448    if (LLVM_UNLIKELY(isa<Var>(expr))) {
449        assert (isa<GetElementPtrInst>(result));
450        result = iBuilder->CreateBlockAlignedLoad(result);
451    }
452    return result;
453}
454
455}
Note: See TracBrowser for help on using the repository browser.