src/irgenerator/GenExpressions.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2026 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #include "IRGenerator.h" | ||
| 4 | |||
| 5 | #include <SourceFile.h> | ||
| 6 | #include <ast/ASTNodes.h> | ||
| 7 | #include <driver/Driver.h> | ||
| 8 | |||
| 9 | #include <llvm/IR/Module.h> | ||
| 10 | |||
| 11 | namespace spice::compiler { | ||
| 12 | |||
| 13 | 53198 | std::any IRGenerator::visitAssignExpr(const AssignExprNode *node) { | |
| 14 | // Visit ternary expression | ||
| 15 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 53198 times.
|
53198 | if (node->ternaryExpr) |
| 16 | ✗ | return visit(node->ternaryExpr); | |
| 17 | |||
| 18 | 53198 | diGenerator.setSourceLocation(node); | |
| 19 | |||
| 20 | // Assign or compound assign operation | ||
| 21 |
1/2✓ Branch 5 → 6 taken 53198 times.
✗ Branch 5 → 60 not taken.
|
53198 | if (node->op != AssignExprNode::AssignOp::OP_NONE) { |
| 22 | 53198 | const ExprNode *lhsNode = node->lhs; | |
| 23 | 53198 | const ExprNode *rhsNode = node->rhs; | |
| 24 | |||
| 25 | // Normal assignment | ||
| 26 |
2/2✓ Branch 6 → 7 taken 47555 times.
✓ Branch 6 → 11 taken 5643 times.
|
53198 | if (node->op == AssignExprNode::AssignOp::OP_ASSIGN) |
| 27 |
2/4✓ Branch 7 → 8 taken 47555 times.
✗ Branch 7 → 69 not taken.
✓ Branch 8 → 9 taken 47555 times.
✗ Branch 8 → 69 not taken.
|
95110 | return doAssignment(lhsNode, rhsNode, node); |
| 28 | |||
| 29 | // Compound assignment | ||
| 30 | // Get symbol types of left and right side | ||
| 31 |
1/2✓ Branch 11 → 12 taken 5643 times.
✗ Branch 11 → 85 not taken.
|
5643 | const QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 32 |
1/2✓ Branch 12 → 13 taken 5643 times.
✗ Branch 12 → 85 not taken.
|
5643 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 33 | |||
| 34 | // Retrieve rhs | ||
| 35 |
2/4✓ Branch 13 → 14 taken 5643 times.
✗ Branch 13 → 72 not taken.
✓ Branch 14 → 15 taken 5643 times.
✗ Branch 14 → 70 not taken.
|
5643 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 36 | // Retrieve lhs | ||
| 37 |
2/4✓ Branch 16 → 17 taken 5643 times.
✗ Branch 16 → 75 not taken.
✓ Branch 17 → 18 taken 5643 times.
✗ Branch 17 → 73 not taken.
|
5643 | auto lhs = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 38 | |||
| 39 | 5643 | LLVMExprResult result; | |
| 40 |
10/11✓ Branch 19 → 20 taken 3799 times.
✓ Branch 19 → 22 taken 177 times.
✓ Branch 19 → 24 taken 506 times.
✓ Branch 19 → 26 taken 214 times.
✓ Branch 19 → 28 taken 96 times.
✓ Branch 19 → 30 taken 22 times.
✓ Branch 19 → 32 taken 34 times.
✓ Branch 19 → 34 taken 56 times.
✓ Branch 19 → 36 taken 56 times.
✓ Branch 19 → 38 taken 683 times.
✗ Branch 19 → 40 not taken.
|
5643 | switch (node->op) { |
| 41 | 3799 | case AssignExprNode::AssignOp::OP_PLUS_EQUAL: | |
| 42 |
1/2✓ Branch 20 → 21 taken 3799 times.
✗ Branch 20 → 85 not taken.
|
3799 | result = conversionManager.getPlusEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 43 | 3799 | break; | |
| 44 | 177 | case AssignExprNode::AssignOp::OP_MINUS_EQUAL: | |
| 45 |
1/2✓ Branch 22 → 23 taken 177 times.
✗ Branch 22 → 85 not taken.
|
177 | result = conversionManager.getMinusEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 46 | 177 | break; | |
| 47 | 506 | case AssignExprNode::AssignOp::OP_MUL_EQUAL: | |
| 48 |
1/2✓ Branch 24 → 25 taken 506 times.
✗ Branch 24 → 85 not taken.
|
506 | result = conversionManager.getMulEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 49 | 506 | break; | |
| 50 | 214 | case AssignExprNode::AssignOp::OP_DIV_EQUAL: | |
| 51 |
1/2✓ Branch 26 → 27 taken 214 times.
✗ Branch 26 → 85 not taken.
|
214 | result = conversionManager.getDivEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 52 | 214 | break; | |
| 53 | 96 | case AssignExprNode::AssignOp::OP_REM_EQUAL: | |
| 54 |
1/2✓ Branch 28 → 29 taken 96 times.
✗ Branch 28 → 85 not taken.
|
96 | result = conversionManager.getRemEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 55 | 96 | break; | |
| 56 | 22 | case AssignExprNode::AssignOp::OP_SHL_EQUAL: | |
| 57 |
1/2✓ Branch 30 → 31 taken 22 times.
✗ Branch 30 → 85 not taken.
|
22 | result = conversionManager.getSHLEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 58 | 22 | break; | |
| 59 | 34 | case AssignExprNode::AssignOp::OP_SHR_EQUAL: | |
| 60 |
1/2✓ Branch 32 → 33 taken 34 times.
✗ Branch 32 → 85 not taken.
|
34 | result = conversionManager.getSHREqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 61 | 34 | break; | |
| 62 | 56 | case AssignExprNode::AssignOp::OP_AND_EQUAL: | |
| 63 |
1/2✓ Branch 34 → 35 taken 56 times.
✗ Branch 34 → 85 not taken.
|
56 | result = conversionManager.getAndEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 64 | 56 | break; | |
| 65 | 56 | case AssignExprNode::AssignOp::OP_OR_EQUAL: | |
| 66 |
1/2✓ Branch 36 → 37 taken 56 times.
✗ Branch 36 → 85 not taken.
|
56 | result = conversionManager.getOrEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 67 | 56 | break; | |
| 68 | 683 | case AssignExprNode::AssignOp::OP_XOR_EQUAL: | |
| 69 |
1/2✓ Branch 38 → 39 taken 683 times.
✗ Branch 38 → 85 not taken.
|
683 | result = conversionManager.getXorEqualInst(node, lhs, lhsSTy, rhs, rhsSTy); |
| 70 | 683 | break; | |
| 71 | − | default: // GCOV_EXCL_LINE | |
| 72 | − | throw CompilerError(UNHANDLED_BRANCH, "Assign op fall-through"); // GCOV_EXCL_LINE | |
| 73 | } | ||
| 74 | |||
| 75 |
1/2✗ Branch 48 → 49 not taken.
✓ Branch 48 → 51 taken 5643 times.
|
5643 | if (result.ptr) { // The operation allocated more memory |
| 76 | ✗ | if (lhs.entry) | |
| 77 | ✗ | updateAddress(lhs.entry, result.ptr); | |
| 78 |
2/2✓ Branch 51 → 52 taken 4205 times.
✓ Branch 51 → 57 taken 1438 times.
|
5643 | } else if (result.value) { // The operation only updated the value |
| 79 | // Store the result | ||
| 80 | 4205 | lhs.value = result.value; | |
| 81 |
5/6✓ Branch 52 → 53 taken 4103 times.
✓ Branch 52 → 55 taken 102 times.
✓ Branch 53 → 54 taken 2 times.
✓ Branch 53 → 55 taken 4101 times.
✓ Branch 56 → 57 taken 4205 times.
✗ Branch 56 → 85 not taken.
|
4205 | insertStore(lhs.value, lhs.ptr, lhs.entry && lhs.entry->isVolatile); |
| 82 | } | ||
| 83 |
1/2✓ Branch 57 → 58 taken 5643 times.
✗ Branch 57 → 85 not taken.
|
5643 | return lhs; |
| 84 | } | ||
| 85 | |||
| 86 | // This is a fallthrough case -> throw an error | ||
| 87 | − | throw CompilerError(UNHANDLED_BRANCH, "AssignStmt fall-through"); // GCOV_EXCL_LINE | |
| 88 | } | ||
| 89 | |||
| 90 | 3656 | std::any IRGenerator::visitTernaryExpr(const TernaryExprNode *node) { | |
| 91 | // Check if only one operand is present -> loop through | ||
| 92 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 3656 times.
|
3656 | if (!node->falseExpr) |
| 93 | ✗ | return visit(node->condition); | |
| 94 | |||
| 95 | 3656 | diGenerator.setSourceLocation(node); | |
| 96 | |||
| 97 | // It is a ternary | ||
| 98 | // Retrieve the condition value | ||
| 99 | 3656 | llvm::Value *condValue = resolveValue(node->condition); | |
| 100 |
2/2✓ Branch 6 → 7 taken 2 times.
✓ Branch 6 → 8 taken 3654 times.
|
3656 | const ExprNode *trueNode = node->isShortened ? node->condition : node->trueExpr; |
| 101 | 3656 | const ExprNode *falseNode = node->falseExpr; | |
| 102 | |||
| 103 | 3656 | llvm::Value *resultValue = nullptr; | |
| 104 | 3656 | llvm::Value *resultPtr = nullptr; | |
| 105 | 3656 | const SymbolTableEntry *anonymousSymbol = nullptr; | |
| 106 |
6/6✓ Branch 10 → 11 taken 954 times.
✓ Branch 10 → 14 taken 2702 times.
✓ Branch 12 → 13 taken 898 times.
✓ Branch 12 → 14 taken 56 times.
✓ Branch 15 → 16 taken 898 times.
✓ Branch 15 → 21 taken 2758 times.
|
3656 | if (trueNode->hasCompileTimeValue(manIdx) && falseNode->hasCompileTimeValue(manIdx)) { |
| 107 | // If both are constants, we can simply emit a selection instruction | ||
| 108 | 898 | llvm::Value *trueValue = resolveValue(trueNode); | |
| 109 | 898 | llvm::Value *falseValue = resolveValue(falseNode); | |
| 110 |
2/4✓ Branch 18 → 19 taken 898 times.
✗ Branch 18 → 145 not taken.
✓ Branch 19 → 20 taken 898 times.
✗ Branch 19 → 145 not taken.
|
898 | resultValue = builder.CreateSelect(condValue, trueValue, falseValue); |
| 111 | } else { | ||
| 112 | // We have at least one non-constant value, use branching to not perform both sides | ||
| 113 |
1/2✓ Branch 21 → 22 taken 2758 times.
✗ Branch 21 → 204 not taken.
|
2758 | const std::string codeLoc = node->codeLoc.toPrettyLineAndColumn(); |
| 114 |
2/4✓ Branch 22 → 23 taken 2758 times.
✗ Branch 22 → 148 not taken.
✓ Branch 23 → 24 taken 2758 times.
✗ Branch 23 → 146 not taken.
|
2758 | llvm::BasicBlock *condTrue = createBlock("cond.true." + codeLoc); |
| 115 |
2/4✓ Branch 25 → 26 taken 2758 times.
✗ Branch 25 → 151 not taken.
✓ Branch 26 → 27 taken 2758 times.
✗ Branch 26 → 149 not taken.
|
2758 | llvm::BasicBlock *condFalse = createBlock("cond.false." + codeLoc); |
| 116 |
2/4✓ Branch 28 → 29 taken 2758 times.
✗ Branch 28 → 154 not taken.
✓ Branch 29 → 30 taken 2758 times.
✗ Branch 29 → 152 not taken.
|
2758 | llvm::BasicBlock *condExit = createBlock("cond.exit." + codeLoc); |
| 117 | |||
| 118 | // Jump from original block to true or false block, depending on condition | ||
| 119 |
1/2✓ Branch 31 → 32 taken 2758 times.
✗ Branch 31 → 202 not taken.
|
2758 | insertCondJump(condValue, condTrue, condFalse); |
| 120 | |||
| 121 | // Fill true block | ||
| 122 |
1/2✓ Branch 32 → 33 taken 2758 times.
✗ Branch 32 → 202 not taken.
|
2758 | switchToBlock(condTrue); |
| 123 |
1/2✓ Branch 33 → 34 taken 2758 times.
✗ Branch 33 → 202 not taken.
|
2758 | const QualType &resultType = node->getEvaluatedSymbolType(manIdx); |
| 124 | 2758 | llvm::Value *trueValue = nullptr; | |
| 125 | 2758 | llvm::Value *truePtr = nullptr; | |
| 126 |
7/8✓ Branch 34 → 35 taken 2704 times.
✓ Branch 34 → 37 taken 54 times.
✓ Branch 35 → 36 taken 2704 times.
✗ Branch 35 → 202 not taken.
✓ Branch 36 → 37 taken 28 times.
✓ Branch 36 → 38 taken 2676 times.
✓ Branch 39 → 40 taken 82 times.
✓ Branch 39 → 42 taken 2676 times.
|
2758 | if (node->falseSideCallsCopyCtor || resultType.isRef()) { // both sides or only the false side needs copy ctor call |
| 127 |
1/2✓ Branch 40 → 41 taken 82 times.
✗ Branch 40 → 202 not taken.
|
82 | truePtr = resolveAddress(trueNode); |
| 128 |
2/2✓ Branch 42 → 43 taken 8 times.
✓ Branch 42 → 57 taken 2668 times.
|
2676 | } else if (node->trueSideCallsCopyCtor) { // only true side needs copy ctor call |
| 129 |
1/2✓ Branch 43 → 44 taken 8 times.
✗ Branch 43 → 202 not taken.
|
8 | llvm::Value *originalPtr = resolveAddress(trueNode); |
| 130 | // Allocate storage for the copy using the ternary's own result type, not trueNode's own evaluated type: | ||
| 131 | // trueNode may be a reference (e.g. a 'const T&' parameter), whose LLVM type is just a pointer and would | ||
| 132 | // undersize this alloca for the struct value the copy ctor is about to write into it. | ||
| 133 |
1/2✓ Branch 47 → 48 taken 8 times.
✗ Branch 47 → 155 not taken.
|
8 | truePtr = insertAlloca(resultType); |
| 134 |
2/4✓ Branch 52 → 53 taken 8 times.
✗ Branch 52 → 163 not taken.
✓ Branch 53 → 54 taken 8 times.
✗ Branch 53 → 161 not taken.
|
16 | generateCtorOrDtorCall(truePtr, node->calledCopyCtor, {originalPtr}); |
| 135 | } else { // neither true nor false side need copy ctor call | ||
| 136 |
1/2✓ Branch 57 → 58 taken 2668 times.
✗ Branch 57 → 202 not taken.
|
2668 | trueValue = resolveValue(trueNode); |
| 137 | } | ||
| 138 | // Set the true block to the current insert point, since it could have changed in the meantime | ||
| 139 | 2758 | condTrue = builder.GetInsertBlock(); | |
| 140 |
1/2✓ Branch 60 → 61 taken 2758 times.
✗ Branch 60 → 202 not taken.
|
2758 | insertJump(condExit); |
| 141 | |||
| 142 | // Fill false block | ||
| 143 |
1/2✓ Branch 61 → 62 taken 2758 times.
✗ Branch 61 → 202 not taken.
|
2758 | switchToBlock(condFalse); |
| 144 | 2758 | llvm::Value *falseValue = nullptr; | |
| 145 | 2758 | llvm::Value *falsePtr = nullptr; | |
| 146 |
7/8✓ Branch 62 → 63 taken 2738 times.
✓ Branch 62 → 65 taken 20 times.
✓ Branch 63 → 64 taken 2738 times.
✗ Branch 63 → 202 not taken.
✓ Branch 64 → 65 taken 28 times.
✓ Branch 64 → 66 taken 2710 times.
✓ Branch 67 → 68 taken 48 times.
✓ Branch 67 → 70 taken 2710 times.
|
2758 | if (node->trueSideCallsCopyCtor || resultType.isRef()) { // both sides or only the true side needs copy ctor call |
| 147 |
1/2✓ Branch 68 → 69 taken 48 times.
✗ Branch 68 → 202 not taken.
|
48 | falsePtr = resolveAddress(falseNode); |
| 148 |
2/2✓ Branch 70 → 71 taken 42 times.
✓ Branch 70 → 85 taken 2668 times.
|
2710 | } else if (node->falseSideCallsCopyCtor) { // only false side needs copy ctor call |
| 149 |
1/2✓ Branch 71 → 72 taken 42 times.
✗ Branch 71 → 202 not taken.
|
42 | llvm::Value *originalPtr = resolveAddress(falseNode); |
| 150 | // See the analogous truePtr allocation above: use the ternary's result type, not falseNode's own | ||
| 151 | // (possibly reference-qualified) evaluated type. | ||
| 152 |
1/2✓ Branch 75 → 76 taken 42 times.
✗ Branch 75 → 168 not taken.
|
42 | falsePtr = insertAlloca(resultType); |
| 153 |
2/4✓ Branch 80 → 81 taken 42 times.
✗ Branch 80 → 176 not taken.
✓ Branch 81 → 82 taken 42 times.
✗ Branch 81 → 174 not taken.
|
126 | generateCtorOrDtorCall(falsePtr, node->calledCopyCtor, {originalPtr}); |
| 154 | } else { // neither true nor false side need copy ctor call | ||
| 155 |
1/2✓ Branch 85 → 86 taken 2668 times.
✗ Branch 85 → 202 not taken.
|
2668 | falseValue = resolveValue(falseNode); |
| 156 | } | ||
| 157 | // Set the true block to the current insert point, since it could have changed in the meantime | ||
| 158 | 2758 | condFalse = builder.GetInsertBlock(); | |
| 159 |
1/2✓ Branch 88 → 89 taken 2758 times.
✗ Branch 88 → 202 not taken.
|
2758 | insertJump(condExit); |
| 160 | |||
| 161 | // Fill the exit block | ||
| 162 |
1/2✓ Branch 89 → 90 taken 2758 times.
✗ Branch 89 → 202 not taken.
|
2758 | switchToBlock(condExit); |
| 163 |
9/10✓ Branch 90 → 91 taken 2738 times.
✓ Branch 90 → 94 taken 20 times.
✓ Branch 91 → 92 taken 2696 times.
✓ Branch 91 → 94 taken 42 times.
✓ Branch 92 → 93 taken 2696 times.
✗ Branch 92 → 202 not taken.
✓ Branch 93 → 94 taken 28 times.
✓ Branch 93 → 95 taken 2668 times.
✓ Branch 96 → 97 taken 90 times.
✓ Branch 96 → 119 taken 2668 times.
|
2758 | if (node->trueSideCallsCopyCtor || node->falseSideCallsCopyCtor || resultType.isRef()) { // one side calls copy ctor |
| 164 |
3/6✓ Branch 97 → 98 taken 90 times.
✗ Branch 97 → 181 not taken.
✓ Branch 98 → 99 taken 90 times.
✗ Branch 98 → 181 not taken.
✓ Branch 99 → 100 taken 90 times.
✗ Branch 99 → 181 not taken.
|
90 | llvm::PHINode *phiInst = builder.CreatePHI(builder.getPtrTy(), 2, "cond.result"); |
| 165 |
1/2✓ Branch 100 → 101 taken 90 times.
✗ Branch 100 → 202 not taken.
|
90 | phiInst->addIncoming(truePtr, condTrue); |
| 166 |
1/2✓ Branch 101 → 102 taken 90 times.
✗ Branch 101 → 202 not taken.
|
90 | phiInst->addIncoming(falsePtr, condFalse); |
| 167 |
4/4✓ Branch 102 → 103 taken 20 times.
✓ Branch 102 → 117 taken 70 times.
✓ Branch 103 → 104 taken 12 times.
✓ Branch 103 → 117 taken 8 times.
|
90 | if (node->trueSideCallsCopyCtor && node->falseSideCallsCopyCtor) { // both sides need copy ctor call |
| 168 |
1/2✓ Branch 107 → 108 taken 12 times.
✗ Branch 107 → 182 not taken.
|
12 | resultPtr = insertAlloca(resultType); |
| 169 |
2/4✓ Branch 112 → 113 taken 12 times.
✗ Branch 112 → 190 not taken.
✓ Branch 113 → 114 taken 12 times.
✗ Branch 113 → 188 not taken.
|
36 | generateCtorOrDtorCall(resultPtr, node->calledCopyCtor, {phiInst}); |
| 170 | } else { | ||
| 171 | 78 | resultPtr = phiInst; | |
| 172 | } | ||
| 173 | } else { // neither true nor false side calls copy ctor | ||
| 174 |
1/2✗ Branch 119 → 120 not taken.
✓ Branch 119 → 121 taken 2668 times.
|
2668 | assert(trueValue != nullptr); |
| 175 |
3/6✓ Branch 121 → 122 taken 2668 times.
✗ Branch 121 → 195 not taken.
✓ Branch 122 → 123 taken 2668 times.
✗ Branch 122 → 195 not taken.
✓ Branch 123 → 124 taken 2668 times.
✗ Branch 123 → 195 not taken.
|
2668 | llvm::PHINode *phiInst = builder.CreatePHI(resultType.toLLVMType(sourceFile), 2, "cond.result"); |
| 176 |
1/2✓ Branch 124 → 125 taken 2668 times.
✗ Branch 124 → 202 not taken.
|
2668 | phiInst->addIncoming(trueValue, condTrue); |
| 177 |
1/2✓ Branch 125 → 126 taken 2668 times.
✗ Branch 125 → 202 not taken.
|
2668 | phiInst->addIncoming(falseValue, condFalse); |
| 178 | 2668 | resultValue = phiInst; | |
| 179 | } | ||
| 180 | |||
| 181 | // If we have an anonymous symbol for this ternary expr, make sure that it has an address to reference. | ||
| 182 |
1/2✓ Branch 127 → 128 taken 2758 times.
✗ Branch 127 → 202 not taken.
|
2758 | anonymousSymbol = currentScope->symbolTable.lookupAnonymous(node); |
| 183 |
2/2✓ Branch 128 → 129 taken 20 times.
✓ Branch 128 → 139 taken 2738 times.
|
2758 | if (anonymousSymbol != nullptr) { |
| 184 |
1/2✗ Branch 129 → 130 not taken.
✓ Branch 129 → 138 taken 20 times.
|
20 | if (!resultPtr) { |
| 185 | ✗ | resultPtr = insertAlloca(anonymousSymbol->getQualType()); | |
| 186 | ✗ | insertStore(resultValue, resultPtr); | |
| 187 | } | ||
| 188 |
1/2✓ Branch 138 → 139 taken 20 times.
✗ Branch 138 → 202 not taken.
|
20 | updateAddress(anonymousSymbol, resultPtr); |
| 189 | } | ||
| 190 | 2758 | } | |
| 191 | |||
| 192 |
1/2✓ Branch 141 → 142 taken 3656 times.
✗ Branch 141 → 205 not taken.
|
7312 | return LLVMExprResult{.value = resultValue, .ptr = resultPtr, .entry = anonymousSymbol}; |
| 193 | } | ||
| 194 | |||
| 195 | 4914 | std::any IRGenerator::visitLogicalOrExpr(const LogicalOrExprNode *node) { | |
| 196 | // Check if only one operand is present -> loop through | ||
| 197 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 4914 times.
|
4914 | if (node->operands.size() == 1) |
| 198 | ✗ | return visit(node->operands.front()); | |
| 199 | |||
| 200 |
1/2✓ Branch 7 → 8 taken 4914 times.
✗ Branch 7 → 104 not taken.
|
4914 | diGenerator.setSourceLocation(node); |
| 201 | |||
| 202 | // It is a logical or expression | ||
| 203 | // Create exit block for short-circuiting | ||
| 204 |
1/2✓ Branch 8 → 9 taken 4914 times.
✗ Branch 8 → 104 not taken.
|
4914 | const std::string codeLoc = node->codeLoc.toPrettyLineAndColumn(); |
| 205 |
2/4✓ Branch 9 → 10 taken 4914 times.
✗ Branch 9 → 81 not taken.
✓ Branch 10 → 11 taken 4914 times.
✗ Branch 10 → 79 not taken.
|
4914 | llvm::BasicBlock *bExit = createBlock("lor.exit." + codeLoc); |
| 206 | |||
| 207 | // Visit the first operand | ||
| 208 |
1/2✓ Branch 13 → 14 taken 4914 times.
✗ Branch 13 → 102 not taken.
|
4914 | llvm::Value *firstOperandValue = resolveValue(node->operands.front()); |
| 209 | |||
| 210 | // Prepare an array for value-to-block-mapping | ||
| 211 | 4914 | std::vector<std::pair<llvm::BasicBlock *, llvm::Value *>> shortCircuitBlocks; | |
| 212 |
1/2✓ Branch 15 → 16 taken 4914 times.
✗ Branch 15 → 100 not taken.
|
4914 | shortCircuitBlocks.reserve(node->operands.size()); |
| 213 | // The first element is the first operand value with the original block | ||
| 214 |
1/2✓ Branch 17 → 18 taken 4914 times.
✗ Branch 17 → 82 not taken.
|
4914 | shortCircuitBlocks.emplace_back(builder.GetInsertBlock(), firstOperandValue); |
| 215 | // Create a block for each additional operand and save it to the mapping | ||
| 216 |
2/2✓ Branch 31 → 19 taken 6586 times.
✓ Branch 31 → 32 taken 4914 times.
|
11500 | for (size_t i = 1; i < node->operands.size(); i++) |
| 217 |
6/12✓ Branch 19 → 20 taken 6586 times.
✗ Branch 19 → 91 not taken.
✓ Branch 20 → 21 taken 6586 times.
✗ Branch 20 → 89 not taken.
✓ Branch 21 → 22 taken 6586 times.
✗ Branch 21 → 87 not taken.
✓ Branch 22 → 23 taken 6586 times.
✗ Branch 22 → 85 not taken.
✓ Branch 23 → 24 taken 6586 times.
✗ Branch 23 → 83 not taken.
✓ Branch 24 → 25 taken 6586 times.
✗ Branch 24 → 83 not taken.
|
6586 | shortCircuitBlocks.emplace_back(createBlock("lor." + std::to_string(i) + "." + codeLoc), nullptr); |
| 218 | // Create conditional jump to the exit block if the first operand was true, otherwise to the next block | ||
| 219 |
2/4✓ Branch 32 → 33 taken 4914 times.
✗ Branch 32 → 100 not taken.
✓ Branch 33 → 34 taken 4914 times.
✗ Branch 33 → 100 not taken.
|
4914 | insertCondJump(firstOperandValue, bExit, shortCircuitBlocks.at(1).first); |
| 220 | |||
| 221 | // Create block for each operand | ||
| 222 |
2/2✓ Branch 50 → 35 taken 6586 times.
✓ Branch 50 → 51 taken 4914 times.
|
11500 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 223 | // Switch to the next block | ||
| 224 |
2/4✓ Branch 35 → 36 taken 6586 times.
✗ Branch 35 → 100 not taken.
✓ Branch 36 → 37 taken 6586 times.
✗ Branch 36 → 100 not taken.
|
6586 | switchToBlock(shortCircuitBlocks.at(i).first); |
| 225 | // Evaluate operand and save the result in the mapping | ||
| 226 |
2/4✓ Branch 38 → 39 taken 6586 times.
✗ Branch 38 → 100 not taken.
✓ Branch 39 → 40 taken 6586 times.
✗ Branch 39 → 100 not taken.
|
6586 | shortCircuitBlocks.at(i).second = resolveValue(node->operands[i]); |
| 227 | // Replace the array entry with the current insert block, since the insert block could have changed in the meantime | ||
| 228 |
1/2✓ Branch 41 → 42 taken 6586 times.
✗ Branch 41 → 100 not taken.
|
6586 | shortCircuitBlocks.at(i).first = builder.GetInsertBlock(); |
| 229 | // Check if there are more blocks to process | ||
| 230 |
2/2✓ Branch 43 → 44 taken 4914 times.
✓ Branch 43 → 45 taken 1672 times.
|
6586 | if (i == node->operands.size() - 1) { |
| 231 | // Insert a simple jump to the exit block for the last block | ||
| 232 |
1/2✓ Branch 44 → 48 taken 4914 times.
✗ Branch 44 → 100 not taken.
|
4914 | insertJump(bExit); |
| 233 | } else { | ||
| 234 | // Create conditional jump to the exit block if the first operand was true, otherwise to the next block | ||
| 235 |
3/6✓ Branch 45 → 46 taken 1672 times.
✗ Branch 45 → 100 not taken.
✓ Branch 46 → 47 taken 1672 times.
✗ Branch 46 → 100 not taken.
✓ Branch 47 → 48 taken 1672 times.
✗ Branch 47 → 100 not taken.
|
1672 | insertCondJump(shortCircuitBlocks.at(i).second, bExit, shortCircuitBlocks.at(i + 1).first); |
| 236 | } | ||
| 237 | } | ||
| 238 | |||
| 239 | // Get the result with the phi node | ||
| 240 |
1/2✓ Branch 51 → 52 taken 4914 times.
✗ Branch 51 → 100 not taken.
|
4914 | switchToBlock(bExit); |
| 241 |
2/4✓ Branch 52 → 53 taken 4914 times.
✗ Branch 52 → 97 not taken.
✓ Branch 55 → 56 taken 4914 times.
✗ Branch 55 → 97 not taken.
|
4914 | llvm::PHINode *result = builder.CreatePHI(firstOperandValue->getType(), node->operands.size(), "lor_phi"); |
| 242 |
2/2✓ Branch 72 → 58 taken 11500 times.
✓ Branch 72 → 73 taken 4914 times.
|
32828 | for (const auto &[incomingBlock, value] : shortCircuitBlocks) |
| 243 |
1/2✓ Branch 62 → 63 taken 11500 times.
✗ Branch 62 → 98 not taken.
|
11500 | result->addIncoming(value, incomingBlock); |
| 244 | |||
| 245 | // Return the result | ||
| 246 |
1/2✓ Branch 73 → 74 taken 4914 times.
✗ Branch 73 → 99 not taken.
|
4914 | return LLVMExprResult{.value = result}; |
| 247 | 4914 | } | |
| 248 | |||
| 249 | 3458 | std::any IRGenerator::visitLogicalAndExpr(const LogicalAndExprNode *node) { | |
| 250 | // Check if only one operand is present -> loop through | ||
| 251 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 3458 times.
|
3458 | if (node->operands.size() == 1) |
| 252 | ✗ | return visit(node->operands.front()); | |
| 253 | |||
| 254 |
1/2✓ Branch 7 → 8 taken 3458 times.
✗ Branch 7 → 104 not taken.
|
3458 | diGenerator.setSourceLocation(node); |
| 255 | |||
| 256 | // It is a logical and expression | ||
| 257 | // Create exit block for short-circuiting | ||
| 258 |
1/2✓ Branch 8 → 9 taken 3458 times.
✗ Branch 8 → 104 not taken.
|
3458 | const std::string codeLoc = node->codeLoc.toPrettyLineAndColumn(); |
| 259 |
2/4✓ Branch 9 → 10 taken 3458 times.
✗ Branch 9 → 81 not taken.
✓ Branch 10 → 11 taken 3458 times.
✗ Branch 10 → 79 not taken.
|
3458 | llvm::BasicBlock *bExit = createBlock("land.exit." + codeLoc); |
| 260 | |||
| 261 | // Visit the first operand | ||
| 262 |
1/2✓ Branch 13 → 14 taken 3458 times.
✗ Branch 13 → 102 not taken.
|
3458 | llvm::Value *firstOperandValue = resolveValue(node->operands.front()); |
| 263 | |||
| 264 | // Prepare an array for value-to-block-mapping | ||
| 265 | 3458 | std::vector<std::pair<llvm::BasicBlock *, llvm::Value *>> shortCircuitBlocks; | |
| 266 |
1/2✓ Branch 15 → 16 taken 3458 times.
✗ Branch 15 → 100 not taken.
|
3458 | shortCircuitBlocks.reserve(node->operands.size()); |
| 267 | // The first element is the first operand value with the original block | ||
| 268 |
1/2✓ Branch 17 → 18 taken 3458 times.
✗ Branch 17 → 82 not taken.
|
3458 | shortCircuitBlocks.emplace_back(builder.GetInsertBlock(), firstOperandValue); |
| 269 | // Create a block for each additional operand and save it to the mapping | ||
| 270 |
2/2✓ Branch 31 → 19 taken 4460 times.
✓ Branch 31 → 32 taken 3458 times.
|
7918 | for (size_t i = 1; i < node->operands.size(); i++) |
| 271 |
6/12✓ Branch 19 → 20 taken 4460 times.
✗ Branch 19 → 91 not taken.
✓ Branch 20 → 21 taken 4460 times.
✗ Branch 20 → 89 not taken.
✓ Branch 21 → 22 taken 4460 times.
✗ Branch 21 → 87 not taken.
✓ Branch 22 → 23 taken 4460 times.
✗ Branch 22 → 85 not taken.
✓ Branch 23 → 24 taken 4460 times.
✗ Branch 23 → 83 not taken.
✓ Branch 24 → 25 taken 4460 times.
✗ Branch 24 → 83 not taken.
|
4460 | shortCircuitBlocks.emplace_back(createBlock("land." + std::to_string(i) + "." + codeLoc), nullptr); |
| 272 | // Create conditional jump to the exit block if the first operand was true, otherwise to the next block | ||
| 273 |
2/4✓ Branch 32 → 33 taken 3458 times.
✗ Branch 32 → 100 not taken.
✓ Branch 33 → 34 taken 3458 times.
✗ Branch 33 → 100 not taken.
|
3458 | insertCondJump(firstOperandValue, shortCircuitBlocks.at(1).first, bExit); |
| 274 | |||
| 275 | // Create block for each operand | ||
| 276 |
2/2✓ Branch 50 → 35 taken 4460 times.
✓ Branch 50 → 51 taken 3458 times.
|
7918 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 277 | // Switch to the next block | ||
| 278 |
2/4✓ Branch 35 → 36 taken 4460 times.
✗ Branch 35 → 100 not taken.
✓ Branch 36 → 37 taken 4460 times.
✗ Branch 36 → 100 not taken.
|
4460 | switchToBlock(shortCircuitBlocks.at(i).first); |
| 279 | // Evaluate operand and save the result in the mapping | ||
| 280 |
2/4✓ Branch 38 → 39 taken 4460 times.
✗ Branch 38 → 100 not taken.
✓ Branch 39 → 40 taken 4460 times.
✗ Branch 39 → 100 not taken.
|
4460 | shortCircuitBlocks.at(i).second = resolveValue(node->operands[i]); |
| 281 | // Replace the array entry with the current insert block, since the insert block could have changed in the meantime | ||
| 282 |
1/2✓ Branch 41 → 42 taken 4460 times.
✗ Branch 41 → 100 not taken.
|
4460 | shortCircuitBlocks.at(i).first = builder.GetInsertBlock(); |
| 283 | // Check if there are more blocks to process | ||
| 284 |
2/2✓ Branch 43 → 44 taken 3458 times.
✓ Branch 43 → 45 taken 1002 times.
|
4460 | if (i == node->operands.size() - 1) { |
| 285 | // Insert a simple jump to the exit block for the last block | ||
| 286 |
1/2✓ Branch 44 → 48 taken 3458 times.
✗ Branch 44 → 100 not taken.
|
3458 | insertJump(bExit); |
| 287 | } else { | ||
| 288 | // Create conditional jump to the exit block if the operand was true, otherwise to the next block | ||
| 289 |
3/6✓ Branch 45 → 46 taken 1002 times.
✗ Branch 45 → 100 not taken.
✓ Branch 46 → 47 taken 1002 times.
✗ Branch 46 → 100 not taken.
✓ Branch 47 → 48 taken 1002 times.
✗ Branch 47 → 100 not taken.
|
1002 | insertCondJump(shortCircuitBlocks.at(i).second, shortCircuitBlocks.at(i + 1).first, bExit); |
| 290 | } | ||
| 291 | } | ||
| 292 | |||
| 293 | // Get the result with the phi node | ||
| 294 |
1/2✓ Branch 51 → 52 taken 3458 times.
✗ Branch 51 → 100 not taken.
|
3458 | switchToBlock(bExit); |
| 295 |
2/4✓ Branch 52 → 53 taken 3458 times.
✗ Branch 52 → 97 not taken.
✓ Branch 55 → 56 taken 3458 times.
✗ Branch 55 → 97 not taken.
|
3458 | llvm::PHINode *result = builder.CreatePHI(firstOperandValue->getType(), node->operands.size(), "land_phi"); |
| 296 |
2/2✓ Branch 72 → 58 taken 7918 times.
✓ Branch 72 → 73 taken 3458 times.
|
22752 | for (const auto &[incomingBlock, value] : shortCircuitBlocks) |
| 297 |
1/2✓ Branch 62 → 63 taken 7918 times.
✗ Branch 62 → 98 not taken.
|
7918 | result->addIncoming(value, incomingBlock); |
| 298 | |||
| 299 | // Return the result | ||
| 300 |
1/2✓ Branch 73 → 74 taken 3458 times.
✗ Branch 73 → 99 not taken.
|
3458 | return LLVMExprResult{.value = result}; |
| 301 | 3458 | } | |
| 302 | |||
| 303 | 762 | std::any IRGenerator::visitBitwiseOrExpr(const BitwiseOrExprNode *node) { | |
| 304 | // Check if only one operand is present -> loop through | ||
| 305 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 762 times.
|
762 | if (node->operands.size() == 1) |
| 306 | ✗ | return visit(node->operands.front()); | |
| 307 | |||
| 308 |
1/2✓ Branch 7 → 8 taken 762 times.
✗ Branch 7 → 34 not taken.
|
762 | diGenerator.setSourceLocation(node); |
| 309 | |||
| 310 | // It is a bitwise or expression | ||
| 311 | // Evaluate first operand | ||
| 312 | 762 | const ExprNode *lhsNode = node->operands.front(); | |
| 313 |
1/2✓ Branch 9 → 10 taken 762 times.
✗ Branch 9 → 34 not taken.
|
762 | const QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 314 |
2/4✓ Branch 10 → 11 taken 762 times.
✗ Branch 10 → 29 not taken.
✓ Branch 11 → 12 taken 762 times.
✗ Branch 11 → 27 not taken.
|
762 | auto result = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 315 | |||
| 316 | // Evaluate all additional operands | ||
| 317 |
2/2✓ Branch 22 → 14 taken 764 times.
✓ Branch 22 → 23 taken 762 times.
|
1526 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 318 | // Evaluate the operand | ||
| 319 | 764 | const ExprNode *rhsNode = node->operands[i]; | |
| 320 |
1/2✓ Branch 15 → 16 taken 764 times.
✗ Branch 15 → 33 not taken.
|
764 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 321 |
2/4✓ Branch 16 → 17 taken 764 times.
✗ Branch 16 → 32 not taken.
✓ Branch 17 → 18 taken 764 times.
✗ Branch 17 → 30 not taken.
|
764 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 322 |
1/2✓ Branch 19 → 20 taken 764 times.
✗ Branch 19 → 33 not taken.
|
764 | result = conversionManager.getBitwiseOrInst(node, result, lhsSTy, rhs, rhsSTy, i - 1); |
| 323 | } | ||
| 324 | |||
| 325 | // Return result | ||
| 326 |
1/2✓ Branch 23 → 24 taken 762 times.
✗ Branch 23 → 34 not taken.
|
762 | return result; |
| 327 | } | ||
| 328 | |||
| 329 | 145 | std::any IRGenerator::visitBitwiseXorExpr(const BitwiseXorExprNode *node) { | |
| 330 | // Check if only one operand is present -> loop through | ||
| 331 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 145 times.
|
145 | if (node->operands.size() == 1) |
| 332 | ✗ | return visit(node->operands.front()); | |
| 333 | |||
| 334 |
1/2✓ Branch 7 → 8 taken 145 times.
✗ Branch 7 → 34 not taken.
|
145 | diGenerator.setSourceLocation(node); |
| 335 | |||
| 336 | // It is a bitwise xor expression | ||
| 337 | // Evaluate first operand | ||
| 338 | 145 | const ExprNode *lhsNode = node->operands.front(); | |
| 339 |
1/2✓ Branch 9 → 10 taken 145 times.
✗ Branch 9 → 34 not taken.
|
145 | const QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 340 |
2/4✓ Branch 10 → 11 taken 145 times.
✗ Branch 10 → 29 not taken.
✓ Branch 11 → 12 taken 145 times.
✗ Branch 11 → 27 not taken.
|
145 | auto result = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 341 | |||
| 342 | // Evaluate all additional operands | ||
| 343 |
2/2✓ Branch 22 → 14 taken 147 times.
✓ Branch 22 → 23 taken 145 times.
|
292 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 344 | // Evaluate the operand | ||
| 345 | 147 | const ExprNode *rhsNode = node->operands[i]; | |
| 346 |
1/2✓ Branch 15 → 16 taken 147 times.
✗ Branch 15 → 33 not taken.
|
147 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 347 |
2/4✓ Branch 16 → 17 taken 147 times.
✗ Branch 16 → 32 not taken.
✓ Branch 17 → 18 taken 147 times.
✗ Branch 17 → 30 not taken.
|
147 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 348 |
1/2✓ Branch 19 → 20 taken 147 times.
✗ Branch 19 → 33 not taken.
|
147 | result = conversionManager.getBitwiseXorInst(node, result, lhsSTy, rhs, rhsSTy, i - 1); |
| 349 | } | ||
| 350 | |||
| 351 | // Return result | ||
| 352 |
1/2✓ Branch 23 → 24 taken 145 times.
✗ Branch 23 → 34 not taken.
|
145 | return result; |
| 353 | } | ||
| 354 | |||
| 355 | 666 | std::any IRGenerator::visitBitwiseAndExpr(const BitwiseAndExprNode *node) { | |
| 356 | // Check if only one operand is present -> loop through | ||
| 357 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 666 times.
|
666 | if (node->operands.size() == 1) |
| 358 | ✗ | return visit(node->operands.front()); | |
| 359 | |||
| 360 |
1/2✓ Branch 7 → 8 taken 666 times.
✗ Branch 7 → 34 not taken.
|
666 | diGenerator.setSourceLocation(node); |
| 361 | |||
| 362 | // It is a bitwise and expression | ||
| 363 | // Evaluate first operand | ||
| 364 | 666 | const ExprNode *lhsNode = node->operands.front(); | |
| 365 |
1/2✓ Branch 9 → 10 taken 666 times.
✗ Branch 9 → 34 not taken.
|
666 | const QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 366 |
2/4✓ Branch 10 → 11 taken 666 times.
✗ Branch 10 → 29 not taken.
✓ Branch 11 → 12 taken 666 times.
✗ Branch 11 → 27 not taken.
|
666 | auto result = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 367 | |||
| 368 | // Evaluate all additional operands | ||
| 369 |
2/2✓ Branch 22 → 14 taken 668 times.
✓ Branch 22 → 23 taken 666 times.
|
1334 | for (size_t i = 1; i < node->operands.size(); i++) { |
| 370 | // Evaluate the operand | ||
| 371 | 668 | const ExprNode *rhsNode = node->operands[i]; | |
| 372 |
1/2✓ Branch 15 → 16 taken 668 times.
✗ Branch 15 → 33 not taken.
|
668 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 373 |
2/4✓ Branch 16 → 17 taken 668 times.
✗ Branch 16 → 32 not taken.
✓ Branch 17 → 18 taken 668 times.
✗ Branch 17 → 30 not taken.
|
668 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 374 |
1/2✓ Branch 19 → 20 taken 668 times.
✗ Branch 19 → 33 not taken.
|
668 | result = conversionManager.getBitwiseAndInst(node, result, lhsSTy, rhs, rhsSTy, i - 1); |
| 375 | } | ||
| 376 | |||
| 377 | // Return result | ||
| 378 |
1/2✓ Branch 23 → 24 taken 666 times.
✗ Branch 23 → 34 not taken.
|
666 | return result; |
| 379 | } | ||
| 380 | |||
| 381 | 44996 | std::any IRGenerator::visitEqualityExpr(const EqualityExprNode *node) { | |
| 382 | // Check if only one operand is present -> loop through | ||
| 383 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 44996 times.
|
44996 | if (node->operands.size() == 1) |
| 384 | ✗ | return visit(node->operands.front()); | |
| 385 | |||
| 386 |
1/2✓ Branch 7 → 8 taken 44996 times.
✗ Branch 7 → 50 not taken.
|
44996 | diGenerator.setSourceLocation(node); |
| 387 | |||
| 388 | // It is an equality expression | ||
| 389 | // Evaluate lhs | ||
| 390 | 44996 | const ExprNode *lhsNode = node->operands[0]; | |
| 391 |
1/2✓ Branch 9 → 10 taken 44996 times.
✗ Branch 9 → 50 not taken.
|
44996 | const QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 392 |
2/4✓ Branch 10 → 11 taken 44996 times.
✗ Branch 10 → 37 not taken.
✓ Branch 11 → 12 taken 44996 times.
✗ Branch 11 → 35 not taken.
|
44996 | auto result = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 393 | |||
| 394 | // Evaluate rhs | ||
| 395 | 44996 | const ExprNode *rhsNode = node->operands[1]; | |
| 396 |
1/2✓ Branch 14 → 15 taken 44996 times.
✗ Branch 14 → 50 not taken.
|
44996 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 397 |
2/4✓ Branch 15 → 16 taken 44996 times.
✗ Branch 15 → 40 not taken.
✓ Branch 16 → 17 taken 44996 times.
✗ Branch 16 → 38 not taken.
|
44996 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 398 | |||
| 399 | // Retrieve the result value, based on the exact operator | ||
| 400 |
2/3✓ Branch 18 → 19 taken 37633 times.
✓ Branch 18 → 21 taken 7363 times.
✗ Branch 18 → 23 not taken.
|
44996 | switch (node->op) { |
| 401 | 37633 | case EqualityExprNode::EqualityOp::OP_EQUAL: | |
| 402 |
1/2✓ Branch 19 → 20 taken 37633 times.
✗ Branch 19 → 50 not taken.
|
37633 | result = conversionManager.getEqualInst(node, result, lhsSTy, rhs, rhsSTy); |
| 403 | 37633 | break; | |
| 404 | 7363 | case EqualityExprNode::EqualityOp::OP_NOT_EQUAL: | |
| 405 |
1/2✓ Branch 21 → 22 taken 7363 times.
✗ Branch 21 → 50 not taken.
|
7363 | result = conversionManager.getNotEqualInst(node, result, lhsSTy, rhs, rhsSTy); |
| 406 | 7363 | break; | |
| 407 | − | default: // GCOV_EXCL_LINE | |
| 408 | − | throw CompilerError(UNHANDLED_BRANCH, "EqualityExpr fall-through"); // GCOV_EXCL_LINE | |
| 409 | } | ||
| 410 | |||
| 411 | // Return the result | ||
| 412 |
1/2✓ Branch 31 → 32 taken 44996 times.
✗ Branch 31 → 50 not taken.
|
44996 | return result; |
| 413 | } | ||
| 414 | |||
| 415 | 27176 | std::any IRGenerator::visitRelationalExpr(const RelationalExprNode *node) { | |
| 416 | // Check if only one operand is present -> loop through | ||
| 417 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 27176 times.
|
27176 | if (node->operands.size() == 1) |
| 418 | ✗ | return visit(node->operands.front()); | |
| 419 | |||
| 420 |
1/2✓ Branch 7 → 8 taken 27176 times.
✗ Branch 7 → 54 not taken.
|
27176 | diGenerator.setSourceLocation(node); |
| 421 | |||
| 422 | // It is a relational expression | ||
| 423 | // Evaluate lhs | ||
| 424 | 27176 | const ExprNode *lhsNode = node->operands[0]; | |
| 425 |
1/2✓ Branch 9 → 10 taken 27176 times.
✗ Branch 9 → 54 not taken.
|
27176 | const QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 426 |
2/4✓ Branch 10 → 11 taken 27176 times.
✗ Branch 10 → 41 not taken.
✓ Branch 11 → 12 taken 27176 times.
✗ Branch 11 → 39 not taken.
|
27176 | auto result = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 427 | |||
| 428 | // Evaluate rhs | ||
| 429 | 27176 | const ExprNode *rhsNode = node->operands[1]; | |
| 430 |
1/2✓ Branch 14 → 15 taken 27176 times.
✗ Branch 14 → 54 not taken.
|
27176 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 431 |
2/4✓ Branch 15 → 16 taken 27176 times.
✗ Branch 15 → 44 not taken.
✓ Branch 16 → 17 taken 27176 times.
✗ Branch 16 → 42 not taken.
|
27176 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 432 | |||
| 433 | // Retrieve the result value, based on the exact operator | ||
| 434 |
4/5✓ Branch 18 → 19 taken 11107 times.
✓ Branch 18 → 21 taken 6218 times.
✓ Branch 18 → 23 taken 3518 times.
✓ Branch 18 → 25 taken 6333 times.
✗ Branch 18 → 27 not taken.
|
27176 | switch (node->op) { |
| 435 | 11107 | case RelationalExprNode::RelationalOp::OP_LESS: | |
| 436 |
1/2✓ Branch 19 → 20 taken 11107 times.
✗ Branch 19 → 54 not taken.
|
11107 | result = conversionManager.getLessInst(node, result, lhsSTy, rhs, rhsSTy); |
| 437 | 11107 | break; | |
| 438 | 6218 | case RelationalExprNode::RelationalOp::OP_GREATER: | |
| 439 |
1/2✓ Branch 21 → 22 taken 6218 times.
✗ Branch 21 → 54 not taken.
|
6218 | result = conversionManager.getGreaterInst(node, result, lhsSTy, rhs, rhsSTy); |
| 440 | 6218 | break; | |
| 441 | 3518 | case RelationalExprNode::RelationalOp::OP_LESS_EQUAL: | |
| 442 |
1/2✓ Branch 23 → 24 taken 3518 times.
✗ Branch 23 → 54 not taken.
|
3518 | result = conversionManager.getLessEqualInst(node, result, lhsSTy, rhs, rhsSTy); |
| 443 | 3518 | break; | |
| 444 | 6333 | case RelationalExprNode::RelationalOp::OP_GREATER_EQUAL: | |
| 445 |
1/2✓ Branch 25 → 26 taken 6333 times.
✗ Branch 25 → 54 not taken.
|
6333 | result = conversionManager.getGreaterEqualInst(node, result, lhsSTy, rhs, rhsSTy); |
| 446 | 6333 | break; | |
| 447 | − | default: // GCOV_EXCL_LINE | |
| 448 | − | throw CompilerError(UNHANDLED_BRANCH, "EqualityExpr fall-through"); // GCOV_EXCL_LINE | |
| 449 | } | ||
| 450 | |||
| 451 | // Return the result | ||
| 452 |
1/2✓ Branch 35 → 36 taken 27176 times.
✗ Branch 35 → 54 not taken.
|
27176 | return result; |
| 453 | } | ||
| 454 | |||
| 455 | 3640 | std::any IRGenerator::visitShiftExpr(const ShiftExprNode *node) { | |
| 456 | // Check if only one operand is present -> loop through | ||
| 457 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 3640 times.
|
3640 | if (node->operands.size() == 1) |
| 458 | ✗ | return visit(node->operands.front()); | |
| 459 | |||
| 460 |
1/2✓ Branch 7 → 8 taken 3640 times.
✗ Branch 7 → 64 not taken.
|
3640 | diGenerator.setSourceLocation(node); |
| 461 | |||
| 462 | // It is a shift expression | ||
| 463 | // Evaluate first operand | ||
| 464 | 3640 | const ExprNode *lhsNode = node->operands.front(); | |
| 465 |
1/2✓ Branch 9 → 10 taken 3640 times.
✗ Branch 9 → 64 not taken.
|
3640 | QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 466 |
2/4✓ Branch 10 → 11 taken 3640 times.
✗ Branch 10 → 48 not taken.
✓ Branch 11 → 12 taken 3640 times.
✗ Branch 11 → 46 not taken.
|
3640 | auto lhs = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 467 | |||
| 468 |
1/2✓ Branch 13 → 14 taken 3640 times.
✗ Branch 13 → 64 not taken.
|
3640 | auto opQueue = node->opQueue; |
| 469 | 3640 | size_t operandIndex = 1; | |
| 470 |
2/2✓ Branch 40 → 15 taken 5316 times.
✓ Branch 40 → 41 taken 3640 times.
|
8956 | while (!opQueue.empty()) { |
| 471 | 5316 | const size_t operatorIndex = operandIndex - 1; | |
| 472 | // Evaluate next operand | ||
| 473 | 5316 | const ExprNode *rhsNode = node->operands[operandIndex++]; | |
| 474 |
1/2✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 5316 times.
|
5316 | assert(rhsNode != nullptr); |
| 475 |
1/2✓ Branch 18 → 19 taken 5316 times.
✗ Branch 18 → 61 not taken.
|
5316 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 476 |
2/4✓ Branch 19 → 20 taken 5316 times.
✗ Branch 19 → 51 not taken.
✓ Branch 20 → 21 taken 5316 times.
✗ Branch 20 → 49 not taken.
|
5316 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 477 | |||
| 478 | // Retrieve the result, based on the exact operator | ||
| 479 |
2/3✓ Branch 23 → 24 taken 4565 times.
✓ Branch 23 → 26 taken 751 times.
✗ Branch 23 → 28 not taken.
|
5316 | switch (opQueue.front().first) { |
| 480 | 4565 | case ShiftExprNode::ShiftOp::OP_SHIFT_LEFT: | |
| 481 |
1/2✓ Branch 24 → 25 taken 4565 times.
✗ Branch 24 → 61 not taken.
|
4565 | lhs = conversionManager.getShiftLeftInst(node, lhs, lhsSTy, rhs, rhsSTy, operatorIndex); |
| 482 | 4565 | break; | |
| 483 | 751 | case ShiftExprNode::ShiftOp::OP_SHIFT_RIGHT: | |
| 484 |
1/2✓ Branch 26 → 27 taken 751 times.
✗ Branch 26 → 61 not taken.
|
751 | lhs = conversionManager.getShiftRightInst(node, lhs, lhsSTy, rhs, rhsSTy, operatorIndex); |
| 485 | 751 | break; | |
| 486 | − | default: // GCOV_EXCL_LINE | |
| 487 | − | throw CompilerError(UNHANDLED_BRANCH, "AdditiveExpr fall-through"); // GCOV_EXCL_LINE | |
| 488 | } | ||
| 489 | |||
| 490 | // Retrieve the new lhs symbol type | ||
| 491 | 5316 | lhsSTy = opQueue.front().second; | |
| 492 | |||
| 493 | 5316 | opQueue.pop(); | |
| 494 | } | ||
| 495 | |||
| 496 | // Return the result | ||
| 497 |
1/2✓ Branch 41 → 42 taken 3640 times.
✗ Branch 41 → 62 not taken.
|
3640 | return lhs; |
| 498 | 3640 | } | |
| 499 | |||
| 500 | 23455 | std::any IRGenerator::visitAdditiveExpr(const AdditiveExprNode *node) { | |
| 501 | // Check if only one operand is present -> loop through | ||
| 502 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 23455 times.
|
23455 | if (node->operands.size() == 1) |
| 503 | ✗ | return visit(node->operands.front()); | |
| 504 | |||
| 505 |
1/2✓ Branch 7 → 8 taken 23455 times.
✗ Branch 7 → 64 not taken.
|
23455 | diGenerator.setSourceLocation(node); |
| 506 | |||
| 507 | // It is an additive expression | ||
| 508 | // Evaluate first operand | ||
| 509 | 23455 | const ExprNode *lhsNode = node->operands[0]; | |
| 510 |
1/2✓ Branch 9 → 10 taken 23455 times.
✗ Branch 9 → 64 not taken.
|
23455 | QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 511 |
2/4✓ Branch 10 → 11 taken 23455 times.
✗ Branch 10 → 48 not taken.
✓ Branch 11 → 12 taken 23455 times.
✗ Branch 11 → 46 not taken.
|
23455 | auto lhs = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 512 | |||
| 513 |
1/2✓ Branch 13 → 14 taken 23455 times.
✗ Branch 13 → 64 not taken.
|
23455 | auto opQueue = node->opQueue; |
| 514 | 23455 | size_t operandIndex = 1; | |
| 515 |
2/2✓ Branch 40 → 15 taken 26500 times.
✓ Branch 40 → 41 taken 23455 times.
|
49955 | while (!opQueue.empty()) { |
| 516 | 26500 | const size_t operatorIndex = operandIndex - 1; | |
| 517 | // Evaluate next operand | ||
| 518 | 26500 | const ExprNode *rhsNode = node->operands[operandIndex++]; | |
| 519 |
1/2✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 26500 times.
|
26500 | assert(rhsNode != nullptr); |
| 520 |
1/2✓ Branch 18 → 19 taken 26500 times.
✗ Branch 18 → 61 not taken.
|
26500 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 521 |
2/4✓ Branch 19 → 20 taken 26500 times.
✗ Branch 19 → 51 not taken.
✓ Branch 20 → 21 taken 26500 times.
✗ Branch 20 → 49 not taken.
|
26500 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 522 | |||
| 523 | // Retrieve the result, based on the exact operator | ||
| 524 |
2/3✓ Branch 23 → 24 taken 16862 times.
✓ Branch 23 → 26 taken 9638 times.
✗ Branch 23 → 28 not taken.
|
26500 | switch (opQueue.front().first) { |
| 525 | 16862 | case AdditiveExprNode::AdditiveOp::OP_PLUS: | |
| 526 |
1/2✓ Branch 24 → 25 taken 16862 times.
✗ Branch 24 → 61 not taken.
|
16862 | lhs = conversionManager.getPlusInst(node, lhs, lhsSTy, rhs, rhsSTy, operatorIndex); |
| 527 | 16862 | break; | |
| 528 | 9638 | case AdditiveExprNode::AdditiveOp::OP_MINUS: | |
| 529 |
1/2✓ Branch 26 → 27 taken 9638 times.
✗ Branch 26 → 61 not taken.
|
9638 | lhs = conversionManager.getMinusInst(node, lhs, lhsSTy, rhs, rhsSTy, operatorIndex); |
| 530 | 9638 | break; | |
| 531 | − | default: // GCOV_EXCL_LINE | |
| 532 | − | throw CompilerError(UNHANDLED_BRANCH, "AdditiveExpr fall-through"); // GCOV_EXCL_LINE | |
| 533 | } | ||
| 534 | |||
| 535 | // Retrieve the new lhs symbol type | ||
| 536 | 26500 | lhsSTy = opQueue.front().second; | |
| 537 | |||
| 538 | 26500 | opQueue.pop(); | |
| 539 | } | ||
| 540 | |||
| 541 | // Return the result | ||
| 542 |
1/2✓ Branch 41 → 42 taken 23455 times.
✗ Branch 41 → 62 not taken.
|
23455 | return lhs; |
| 543 | 23455 | } | |
| 544 | |||
| 545 | 5629 | std::any IRGenerator::visitMultiplicativeExpr(const MultiplicativeExprNode *node) { | |
| 546 | // Check if only one operand is present -> loop through | ||
| 547 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 7 taken 5629 times.
|
5629 | if (node->operands.size() == 1) |
| 548 | ✗ | return visit(node->operands.front()); | |
| 549 | |||
| 550 |
1/2✓ Branch 7 → 8 taken 5629 times.
✗ Branch 7 → 66 not taken.
|
5629 | diGenerator.setSourceLocation(node); |
| 551 | |||
| 552 | // It is an additive expression | ||
| 553 | // Evaluate first operand | ||
| 554 | 5629 | const ExprNode *lhsNode = node->operands[0]; | |
| 555 |
1/2✓ Branch 9 → 10 taken 5629 times.
✗ Branch 9 → 66 not taken.
|
5629 | QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 556 |
2/4✓ Branch 10 → 11 taken 5629 times.
✗ Branch 10 → 50 not taken.
✓ Branch 11 → 12 taken 5629 times.
✗ Branch 11 → 48 not taken.
|
5629 | auto result = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 557 | |||
| 558 |
1/2✓ Branch 13 → 14 taken 5629 times.
✗ Branch 13 → 66 not taken.
|
5629 | auto opQueue = node->opQueue; |
| 559 | 5629 | size_t operandIndex = 1; | |
| 560 |
2/2✓ Branch 42 → 15 taken 5899 times.
✓ Branch 42 → 43 taken 5629 times.
|
11528 | while (!opQueue.empty()) { |
| 561 | 5899 | const size_t operatorIndex = operandIndex - 1; | |
| 562 | // Evaluate next operand | ||
| 563 | 5899 | const ExprNode *rhsNode = node->operands[operandIndex++]; | |
| 564 |
1/2✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 5899 times.
|
5899 | assert(rhsNode != nullptr); |
| 565 |
1/2✓ Branch 18 → 19 taken 5899 times.
✗ Branch 18 → 63 not taken.
|
5899 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 566 |
2/4✓ Branch 19 → 20 taken 5899 times.
✗ Branch 19 → 53 not taken.
✓ Branch 20 → 21 taken 5899 times.
✗ Branch 20 → 51 not taken.
|
5899 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 567 | |||
| 568 | // Retrieve the result, based on the exact operator | ||
| 569 |
3/4✓ Branch 23 → 24 taken 4693 times.
✓ Branch 23 → 26 taken 980 times.
✓ Branch 23 → 28 taken 226 times.
✗ Branch 23 → 30 not taken.
|
5899 | switch (opQueue.front().first) { |
| 570 | 4693 | case MultiplicativeExprNode::MultiplicativeOp::OP_MUL: | |
| 571 |
1/2✓ Branch 24 → 25 taken 4693 times.
✗ Branch 24 → 63 not taken.
|
4693 | result = conversionManager.getMulInst(node, result, lhsSTy, rhs, rhsSTy, operatorIndex); |
| 572 | 4693 | break; | |
| 573 | 980 | case MultiplicativeExprNode::MultiplicativeOp::OP_DIV: | |
| 574 |
1/2✓ Branch 26 → 27 taken 980 times.
✗ Branch 26 → 63 not taken.
|
980 | result = conversionManager.getDivInst(node, result, lhsSTy, rhs, rhsSTy, operatorIndex); |
| 575 | 980 | break; | |
| 576 | 226 | case MultiplicativeExprNode::MultiplicativeOp::OP_REM: | |
| 577 |
1/2✓ Branch 28 → 29 taken 226 times.
✗ Branch 28 → 63 not taken.
|
226 | result = conversionManager.getRemInst(node, result, lhsSTy, rhs, rhsSTy); |
| 578 | 226 | break; | |
| 579 | − | default: // GCOV_EXCL_LINE | |
| 580 | − | throw CompilerError(UNHANDLED_BRANCH, "MultiplicativeExpr fall-through"); // GCOV_EXCL_LINE | |
| 581 | } | ||
| 582 | |||
| 583 | // Retrieve the new lhs symbol type | ||
| 584 | 5899 | lhsSTy = opQueue.front().second; | |
| 585 | 5899 | opQueue.pop(); | |
| 586 | } | ||
| 587 | |||
| 588 | // Return the result | ||
| 589 |
1/2✓ Branch 43 → 44 taken 5629 times.
✗ Branch 43 → 64 not taken.
|
5629 | return result; |
| 590 | 5629 | } | |
| 591 | |||
| 592 | 21171 | std::any IRGenerator::visitCastExpr(const CastExprNode *node) { | |
| 593 | // Check if only one operand is present -> loop through | ||
| 594 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 21171 times.
|
21171 | if (!node->isCast) |
| 595 | ✗ | return visit(node->prefixUnaryExpr); | |
| 596 | |||
| 597 |
1/2✓ Branch 5 → 6 taken 21171 times.
✗ Branch 5 → 19 not taken.
|
21171 | diGenerator.setSourceLocation(node); |
| 598 | |||
| 599 | // It is a cast expression | ||
| 600 | // Retrieve target symbol type | ||
| 601 |
1/2✓ Branch 6 → 7 taken 21171 times.
✗ Branch 6 → 19 not taken.
|
21171 | const QualType targetSTy = node->getEvaluatedSymbolType(manIdx); |
| 602 | |||
| 603 | // Evaluate rhs | ||
| 604 | 21171 | const ExprNode *rhsNode = node->assignExpr; | |
| 605 |
1/2✓ Branch 7 → 8 taken 21171 times.
✗ Branch 7 → 19 not taken.
|
21171 | const QualType rhsSTy = rhsNode->getEvaluatedSymbolType(manIdx); |
| 606 |
2/4✓ Branch 8 → 9 taken 21171 times.
✗ Branch 8 → 18 not taken.
✓ Branch 9 → 10 taken 21171 times.
✗ Branch 9 → 16 not taken.
|
21171 | auto rhs = std::any_cast<LLVMExprResult>(visit(rhsNode)); |
| 607 | |||
| 608 | // Retrieve the result value | ||
| 609 |
1/2✓ Branch 11 → 12 taken 21171 times.
✗ Branch 11 → 19 not taken.
|
21171 | const LLVMExprResult result = conversionManager.getCastInst(node, targetSTy, rhs, rhsSTy); |
| 610 | |||
| 611 | // Return the result | ||
| 612 |
1/2✓ Branch 12 → 13 taken 21171 times.
✗ Branch 12 → 19 not taken.
|
21171 | return result; |
| 613 | } | ||
| 614 | |||
| 615 | 14993 | std::any IRGenerator::visitPrefixUnaryExpr(const PrefixUnaryExprNode *node) { | |
| 616 | // If no operator is applied, simply visit the atomic expression | ||
| 617 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 14993 times.
|
14993 | if (node->op == PrefixUnaryExprNode::PrefixUnaryOp::OP_NONE) |
| 618 | ✗ | return visit(node->postfixUnaryExpr); | |
| 619 | |||
| 620 |
1/2✓ Branch 5 → 6 taken 14993 times.
✗ Branch 5 → 117 not taken.
|
14993 | diGenerator.setSourceLocation(node); |
| 621 | |||
| 622 | // Evaluate lhs | ||
| 623 | 14993 | const ExprNode *lhsNode = node->prefixUnaryExpr; | |
| 624 |
1/2✓ Branch 6 → 7 taken 14993 times.
✗ Branch 6 → 117 not taken.
|
14993 | const QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 625 |
2/4✓ Branch 7 → 8 taken 14993 times.
✗ Branch 7 → 87 not taken.
✓ Branch 8 → 9 taken 14993 times.
✗ Branch 8 → 85 not taken.
|
14993 | auto lhs = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 626 | |||
| 627 |
7/8✓ Branch 10 → 11 taken 2049 times.
✓ Branch 10 → 21 taken 22 times.
✓ Branch 10 → 36 taken 30 times.
✓ Branch 10 → 51 taken 8483 times.
✓ Branch 10 → 53 taken 60 times.
✓ Branch 10 → 55 taken 2006 times.
✓ Branch 10 → 64 taken 2343 times.
✗ Branch 10 → 73 not taken.
|
14993 | switch (node->op) { |
| 628 | 2049 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS: { | |
| 629 | // Execute operation | ||
| 630 |
1/2✓ Branch 11 → 12 taken 2049 times.
✗ Branch 11 → 117 not taken.
|
2049 | lhs = conversionManager.getPrefixMinusInst(node, lhs, lhsSTy); |
| 631 | |||
| 632 | // This operator can not work in-place, so we need additional memory | ||
| 633 |
1/2✓ Branch 16 → 17 taken 2049 times.
✗ Branch 16 → 88 not taken.
|
2049 | lhs.ptr = insertAlloca(lhs.value->getType()); |
| 634 | |||
| 635 | // Store the new value | ||
| 636 |
1/2✓ Branch 19 → 20 taken 2049 times.
✗ Branch 19 → 117 not taken.
|
2049 | insertStore(lhs.value, lhs.ptr); |
| 637 | |||
| 638 | 2049 | break; | |
| 639 | } | ||
| 640 | 22 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_PLUS_PLUS: { | |
| 641 | // Execute operation | ||
| 642 |
1/2✓ Branch 21 → 22 taken 22 times.
✗ Branch 21 → 94 not taken.
|
22 | lhs.value = conversionManager.getPrefixPlusPlusInst(node, lhs, lhsSTy).value; |
| 643 | |||
| 644 | // If this operation happens on a volatile variable, store the value directly | ||
| 645 |
3/4✓ Branch 22 → 23 taken 20 times.
✓ Branch 22 → 25 taken 2 times.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 20 times.
|
22 | if (lhs.entry && lhs.entry->isVolatile) |
| 646 | ✗ | insertStore(lhs.value, lhs.ptr, true); | |
| 647 | |||
| 648 | // Save to the existing address if possible, otherwise (e.g. for literals) allocate new space | ||
| 649 |
2/2✓ Branch 25 → 26 taken 2 times.
✓ Branch 25 → 34 taken 20 times.
|
22 | if (!lhs.ptr) |
| 650 |
1/2✓ Branch 30 → 31 taken 2 times.
✗ Branch 30 → 95 not taken.
|
2 | lhs.ptr = insertAlloca(lhs.value->getType()); |
| 651 | |||
| 652 | // Store the new value | ||
| 653 |
1/2✓ Branch 34 → 35 taken 22 times.
✗ Branch 34 → 117 not taken.
|
22 | insertStore(lhs.value, lhs.ptr); |
| 654 | |||
| 655 | 22 | break; | |
| 656 | } | ||
| 657 | 30 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_MINUS_MINUS: { | |
| 658 | // Execute operation | ||
| 659 |
1/2✓ Branch 36 → 37 taken 30 times.
✗ Branch 36 → 101 not taken.
|
30 | lhs.value = conversionManager.getPrefixMinusMinusInst(node, lhs, lhsSTy).value; |
| 660 | |||
| 661 | // If this operation happens on a volatile variable, store the value directly | ||
| 662 |
3/4✓ Branch 37 → 38 taken 28 times.
✓ Branch 37 → 40 taken 2 times.
✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 28 times.
|
30 | if (lhs.entry && lhs.entry->isVolatile) |
| 663 | ✗ | insertStore(lhs.value, lhs.ptr, true); | |
| 664 | |||
| 665 | // Save to the existing address if possible, otherwise (e.g. for literals) allocate new space | ||
| 666 |
2/2✓ Branch 40 → 41 taken 2 times.
✓ Branch 40 → 49 taken 28 times.
|
30 | if (!lhs.ptr) |
| 667 |
1/2✓ Branch 45 → 46 taken 2 times.
✗ Branch 45 → 102 not taken.
|
2 | lhs.ptr = insertAlloca(lhs.value->getType()); |
| 668 | |||
| 669 | // Store the new value | ||
| 670 |
1/2✓ Branch 49 → 50 taken 30 times.
✗ Branch 49 → 117 not taken.
|
30 | insertStore(lhs.value, lhs.ptr); |
| 671 | |||
| 672 | 30 | break; | |
| 673 | } | ||
| 674 | 8483 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_NOT: { | |
| 675 | // Execute operation | ||
| 676 |
1/2✓ Branch 51 → 52 taken 8483 times.
✗ Branch 51 → 117 not taken.
|
8483 | lhs = conversionManager.getPrefixNotInst(node, lhs, lhsSTy); |
| 677 | 8483 | break; | |
| 678 | } | ||
| 679 | 60 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_BITWISE_NOT: { | |
| 680 | // Execute operation | ||
| 681 |
1/2✓ Branch 53 → 54 taken 60 times.
✗ Branch 53 → 117 not taken.
|
60 | lhs = conversionManager.getPrefixBitwiseNotInst(node, lhs, lhsSTy); |
| 682 | 60 | break; | |
| 683 | } | ||
| 684 | 2006 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_DEREFERENCE: { | |
| 685 | // If only .refPtr is filled, we can't simply rewire the fields, but need to actually perform a load. | ||
| 686 | // For that we can use resolveValue(). | ||
| 687 |
4/4✓ Branch 55 → 56 taken 1953 times.
✓ Branch 55 → 58 taken 53 times.
✓ Branch 56 → 57 taken 72 times.
✓ Branch 56 → 58 taken 1881 times.
|
2006 | const bool onlyRefPtrIsFilled = lhs.value == nullptr && lhs.ptr == nullptr; |
| 688 | // Rewire the fields | ||
| 689 |
3/4✓ Branch 59 → 60 taken 72 times.
✓ Branch 59 → 62 taken 1934 times.
✓ Branch 60 → 61 taken 72 times.
✗ Branch 60 → 117 not taken.
|
2006 | llvm::Value *newRefPtr = onlyRefPtrIsFilled ? resolveValue(lhsNode, lhs) : lhs.ptr; |
| 690 | 2006 | llvm::Value *newPtr = lhs.value; | |
| 691 | 2006 | lhs = {.ptr = newPtr, .refPtr = newRefPtr}; | |
| 692 | 2006 | break; | |
| 693 | } | ||
| 694 | 2343 | case PrefixUnaryExprNode::PrefixUnaryOp::OP_ADDRESS_OF: { | |
| 695 | // If only .value is filled, we can't simply rewire the fields, but need to actually perform alloca + store. | ||
| 696 | // For that we can use resolveAddress(). | ||
| 697 |
4/4✓ Branch 64 → 65 taken 172 times.
✓ Branch 64 → 67 taken 2171 times.
✓ Branch 65 → 66 taken 4 times.
✓ Branch 65 → 67 taken 168 times.
|
2343 | const bool onlyValueIsFilled = lhs.ptr == nullptr && lhs.refPtr == nullptr; |
| 698 | // Rewire the fields | ||
| 699 |
3/4✓ Branch 68 → 69 taken 4 times.
✓ Branch 68 → 71 taken 2339 times.
✓ Branch 69 → 70 taken 4 times.
✗ Branch 69 → 117 not taken.
|
2343 | llvm::Value *newValue = onlyValueIsFilled ? resolveAddress(lhs) : lhs.ptr; |
| 700 | 2343 | llvm::Value *newPtr = lhs.refPtr; | |
| 701 | 2343 | lhs = {.value = newValue, .ptr = newPtr}; | |
| 702 | 2343 | break; | |
| 703 | } | ||
| 704 | − | default: // GCOV_EXCL_LINE | |
| 705 | − | throw CompilerError(UNHANDLED_BRANCH, "PrefixUnaryExpr fall-through"); // GCOV_EXCL_LINE | |
| 706 | } | ||
| 707 | |||
| 708 |
1/2✓ Branch 81 → 82 taken 14993 times.
✗ Branch 81 → 117 not taken.
|
14993 | return lhs; |
| 709 | } | ||
| 710 | |||
| 711 | 175098 | std::any IRGenerator::visitPostfixUnaryExpr(const PostfixUnaryExprNode *node) { | |
| 712 | // If no operator is applied, simply visit the atomic expression | ||
| 713 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 175098 times.
|
175098 | if (node->op == PostfixUnaryExprNode::PostfixUnaryOp::OP_NONE) |
| 714 | ✗ | return visit(node->atomicExpr); | |
| 715 | |||
| 716 |
1/2✓ Branch 5 → 6 taken 175098 times.
✗ Branch 5 → 510 not taken.
|
175098 | diGenerator.setSourceLocation(node); |
| 717 | |||
| 718 | // Evaluate lhs | ||
| 719 | 175098 | const ExprNode *lhsNode = node->postfixUnaryExpr; | |
| 720 |
1/2✓ Branch 6 → 7 taken 175098 times.
✗ Branch 6 → 510 not taken.
|
175098 | QualType lhsSTy = lhsNode->getEvaluatedSymbolType(manIdx); |
| 721 |
2/4✓ Branch 7 → 8 taken 175098 times.
✗ Branch 7 → 332 not taken.
✓ Branch 8 → 9 taken 175098 times.
✗ Branch 8 → 330 not taken.
|
175098 | auto lhs = std::any_cast<LLVMExprResult>(visit(lhsNode)); |
| 722 | |||
| 723 |
5/6✓ Branch 10 → 11 taken 18168 times.
✓ Branch 10 → 62 taken 142763 times.
✓ Branch 10 → 200 taken 12950 times.
✓ Branch 10 → 224 taken 1097 times.
✓ Branch 10 → 248 taken 120 times.
✗ Branch 10 → 318 not taken.
|
175098 | switch (node->op) { |
| 724 | 18168 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_SUBSCRIPT: { | |
| 725 | 18168 | const ExprNode *indexExpr = node->subscriptIndexExpr; | |
| 726 | |||
| 727 | // Check if we need to generate a call to an overloaded operator function | ||
| 728 |
3/4✓ Branch 11 → 12 taken 18168 times.
✗ Branch 11 → 368 not taken.
✓ Branch 12 → 13 taken 1080 times.
✓ Branch 12 → 29 taken 17088 times.
|
18168 | if (conversionManager.callsOverloadedOpFct(node, 0)) { |
| 729 |
1/2✓ Branch 13 → 14 taken 1080 times.
✗ Branch 13 → 333 not taken.
|
1080 | ResolverFct lhsV = [&] { return resolveValue(lhsSTy, lhs); }; |
| 730 | 2160 | ResolverFct lhsP = [&] { return resolveAddress(lhs); }; | |
| 731 | 2114 | ResolverFct idxV = [&] { return resolveValue(indexExpr); }; | |
| 732 | 1126 | ResolverFct idxP = [&] { return resolveAddress(indexExpr); }; | |
| 733 | 1080 | lhs = conversionManager.callOperatorOverloadFct<2>(node, {lhsV, lhsP, idxV, idxP}, 0); | |
| 734 | 1080 | break; | |
| 735 | 1080 | } | |
| 736 | |||
| 737 |
1/2✓ Branch 29 → 30 taken 17088 times.
✗ Branch 29 → 351 not taken.
|
17088 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
| 738 | |||
| 739 | // Get the index value | ||
| 740 |
1/2✓ Branch 30 → 31 taken 17088 times.
✗ Branch 30 → 368 not taken.
|
17088 | llvm::Value *indexValue = resolveValue(indexExpr); |
| 741 | // Come up with the address | ||
| 742 |
8/10✓ Branch 31 → 32 taken 17088 times.
✗ Branch 31 → 368 not taken.
✓ Branch 32 → 33 taken 2271 times.
✓ Branch 32 → 36 taken 14817 times.
✓ Branch 33 → 34 taken 2271 times.
✗ Branch 33 → 368 not taken.
✓ Branch 34 → 35 taken 2079 times.
✓ Branch 34 → 36 taken 192 times.
✓ Branch 37 → 38 taken 2079 times.
✓ Branch 37 → 49 taken 15009 times.
|
17088 | if (lhsSTy.isArray() && lhsSTy.getArraySize() != ARRAY_SIZE_UNKNOWN) { // Array |
| 743 | // Make sure the address is present | ||
| 744 |
1/2✓ Branch 38 → 39 taken 2079 times.
✗ Branch 38 → 359 not taken.
|
2079 | resolveAddress(lhs); |
| 745 | |||
| 746 | // Calculate address of array item | ||
| 747 |
1/2✓ Branch 39 → 40 taken 2079 times.
✗ Branch 39 → 359 not taken.
|
2079 | llvm::Type *lhsTy = lhsSTy.toLLVMType(sourceFile); |
| 748 |
1/2✓ Branch 40 → 41 taken 2079 times.
✗ Branch 40 → 359 not taken.
|
2079 | llvm::Value *indices[2] = {builder.getInt64(0), indexValue}; |
| 749 |
1/2✓ Branch 45 → 46 taken 2079 times.
✗ Branch 45 → 352 not taken.
|
2079 | lhs.ptr = insertInBoundsGEP(lhsTy, lhs.ptr, indices); |
| 750 | } else { // Pointer | ||
| 751 | // Now the pointer is the value | ||
| 752 |
1/2✓ Branch 49 → 50 taken 15009 times.
✗ Branch 49 → 368 not taken.
|
15009 | lhs.ptr = resolveValue(lhsNode, lhs); |
| 753 | |||
| 754 |
2/4✓ Branch 50 → 51 taken 15009 times.
✗ Branch 50 → 360 not taken.
✓ Branch 51 → 52 taken 15009 times.
✗ Branch 51 → 360 not taken.
|
15009 | llvm::Type *lhsTy = lhsSTy.getContained().toLLVMType(sourceFile); |
| 755 | // Calculate address of pointer item | ||
| 756 |
1/2✓ Branch 56 → 57 taken 15009 times.
✗ Branch 56 → 361 not taken.
|
15009 | lhs.ptr = insertInBoundsGEP(lhsTy, lhs.ptr, indexValue); |
| 757 | } | ||
| 758 | |||
| 759 | // Reset value and entry | ||
| 760 | 17088 | lhs.value = nullptr; | |
| 761 | 17088 | lhs.entry = nullptr; | |
| 762 | 17088 | break; | |
| 763 | } | ||
| 764 | 142763 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_MEMBER_ACCESS: { | |
| 765 | // Get the address of the struct/union instance | ||
| 766 |
1/2✓ Branch 62 → 63 taken 142763 times.
✗ Branch 62 → 443 not taken.
|
142763 | resolveAddress(lhs); |
| 767 |
1/2✓ Branch 63 → 64 taken 142763 times.
✗ Branch 63 → 369 not taken.
|
142763 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
| 768 | |||
| 769 | // Auto de-reference pointer | ||
| 770 |
1/2✓ Branch 64 → 65 taken 142763 times.
✗ Branch 64 → 443 not taken.
|
142763 | autoDeReferencePtr(lhs.ptr, lhsSTy); |
| 771 | |||
| 772 | 142763 | const std::string &fieldName = node->identifier; | |
| 773 | |||
| 774 | // Union field access is handled separately, since it is backed by a tagged { i32 tag, ..., payload } layout | ||
| 775 | // instead of one LLVM struct member per Spice field (see Type::toLLVMType's TY_UNION branch), and needs a | ||
| 776 | // runtime tag read-guard/write-update around the payload access. | ||
| 777 |
3/4✓ Branch 65 → 66 taken 142763 times.
✗ Branch 65 → 443 not taken.
✓ Branch 66 → 67 taken 50 times.
✓ Branch 66 → 158 taken 142713 times.
|
142763 | if (lhsSTy.is(TY_UNION)) { |
| 778 |
1/2✓ Branch 67 → 68 taken 50 times.
✗ Branch 67 → 429 not taken.
|
50 | Scope *unionScope = lhsSTy.getBodyScope(); |
| 779 |
1/2✓ Branch 68 → 69 taken 50 times.
✗ Branch 68 → 429 not taken.
|
50 | SymbolTableEntry *fieldEntry = unionScope->symbolTable.lookupStrict(fieldName); |
| 780 |
1/2✗ Branch 69 → 70 not taken.
✓ Branch 69 → 71 taken 50 times.
|
50 | assert(fieldEntry != nullptr); |
| 781 |
1/2✓ Branch 71 → 72 taken 50 times.
✗ Branch 71 → 429 not taken.
|
50 | const QualType fieldSymbolType = fieldEntry->getQualType(); |
| 782 | // Tag 0 is reserved for the "unset" state, so a field's tag is its order index shifted up by one. This makes | ||
| 783 | // an all-zero union (e.g. from .bss, a generic memset, or a nested aggregate's zero default) correctly unset | ||
| 784 | // rather than aliasing field 0, so the tag-mismatch guard below also catches accidental zero-initialization. | ||
| 785 | 50 | const auto fieldTagIndex = static_cast<uint32_t>(fieldEntry->orderIndex) + 1; | |
| 786 | |||
| 787 |
1/2✓ Branch 72 → 73 taken 50 times.
✗ Branch 72 → 429 not taken.
|
50 | llvm::Type *unionLLVMTy = lhsSTy.toLLVMType(sourceFile); |
| 788 | 50 | llvm::Value *unionBasePtr = lhs.ptr; | |
| 789 |
2/4✓ Branch 75 → 76 taken 50 times.
✗ Branch 75 → 372 not taken.
✓ Branch 76 → 77 taken 50 times.
✗ Branch 76 → 370 not taken.
|
50 | llvm::Value *tagAddr = insertStructGEP(unionLLVMTy, unionBasePtr, 0, "tag.addr"); |
| 790 | |||
| 791 | // A plain `u.field = value` assignment is the only access that should update the tag instead of checking it: | ||
| 792 | // it is the sole case where this exact node is the direct, unwrapped left-hand side of a plain '=' assignment. | ||
| 793 | // Every other use (reads, compound-assign's read-then-store-back, address-of, pass-by-ref, or descending | ||
| 794 | // further into a by-value struct/union field) must first prove the field is currently active. | ||
| 795 |
1/2✓ Branch 79 → 80 taken 50 times.
✗ Branch 79 → 81 not taken.
|
50 | const auto *assignParent = dynamic_cast<const AssignExprNode *>(node->parent); |
| 796 | 50 | const bool isDirectAssignTarget = | |
| 797 |
5/6✓ Branch 82 → 83 taken 22 times.
✓ Branch 82 → 86 taken 28 times.
✓ Branch 83 → 84 taken 22 times.
✗ Branch 83 → 86 not taken.
✓ Branch 84 → 85 taken 20 times.
✓ Branch 84 → 86 taken 2 times.
|
50 | assignParent != nullptr && assignParent->lhs == node && assignParent->op == AssignExprNode::AssignOp::OP_ASSIGN; |
| 798 | |||
| 799 |
2/2✓ Branch 87 → 88 taken 20 times.
✓ Branch 87 → 90 taken 30 times.
|
50 | if (isDirectAssignTarget) { |
| 800 |
2/4✓ Branch 88 → 89 taken 20 times.
✗ Branch 88 → 429 not taken.
✓ Branch 89 → 149 taken 20 times.
✗ Branch 89 → 429 not taken.
|
20 | insertStore(builder.getInt32(fieldTagIndex), tagAddr); |
| 801 | } else { | ||
| 802 | // Guard the read with a runtime tag check. This is an always-on safety check (unlike e.g. the assert | ||
| 803 | // statement, which is skipped in release builds), since it protects a core invariant of the union type | ||
| 804 | // itself, not an optional user-level debug assertion. | ||
| 805 |
2/4✓ Branch 93 → 94 taken 30 times.
✗ Branch 93 → 376 not taken.
✓ Branch 94 → 95 taken 30 times.
✗ Branch 94 → 376 not taken.
|
30 | llvm::Value *tagValue = insertLoad(builder.getInt32Ty(), tagAddr); |
| 806 |
4/8✓ Branch 97 → 98 taken 30 times.
✗ Branch 97 → 382 not taken.
✓ Branch 98 → 99 taken 30 times.
✗ Branch 98 → 382 not taken.
✓ Branch 99 → 100 taken 30 times.
✗ Branch 99 → 382 not taken.
✓ Branch 100 → 101 taken 30 times.
✗ Branch 100 → 425 not taken.
|
30 | llvm::Value *tagMatches = builder.CreateICmpEQ(tagValue, builder.getInt32(fieldTagIndex)); |
| 807 | |||
| 808 |
1/2✓ Branch 100 → 101 taken 30 times.
✗ Branch 100 → 425 not taken.
|
30 | const std::string &codeLine = node->codeLoc.toPrettyLine(); |
| 809 |
2/4✓ Branch 101 → 102 taken 30 times.
✗ Branch 101 → 385 not taken.
✓ Branch 102 → 103 taken 30 times.
✗ Branch 102 → 383 not taken.
|
30 | llvm::BasicBlock *bOk = createBlock("union.tag.ok." + codeLine); |
| 810 |
2/4✓ Branch 104 → 105 taken 30 times.
✗ Branch 104 → 388 not taken.
✓ Branch 105 → 106 taken 30 times.
✗ Branch 105 → 386 not taken.
|
30 | llvm::BasicBlock *bPanic = createBlock("union.tag.panic." + codeLine); |
| 811 |
1/2✓ Branch 107 → 108 taken 30 times.
✗ Branch 107 → 423 not taken.
|
30 | insertCondJump(tagMatches, bOk, bPanic, Likelihood::LIKELY); |
| 812 | |||
| 813 |
1/2✓ Branch 108 → 109 taken 30 times.
✗ Branch 108 → 423 not taken.
|
30 | switchToBlock(bPanic); |
| 814 |
1/2✓ Branch 109 → 110 taken 30 times.
✗ Branch 109 → 423 not taken.
|
30 | llvm::Value *stdErrValue = getStdErrValue(); |
| 815 |
2/4✓ Branch 110 → 111 taken 30 times.
✗ Branch 110 → 397 not taken.
✓ Branch 111 → 112 taken 30 times.
✗ Branch 111 → 395 not taken.
|
60 | const std::string errorMsg = "Program panicked at " + node->codeLoc.toPrettyString() + |
| 816 |
3/6✓ Branch 112 → 113 taken 30 times.
✗ Branch 112 → 393 not taken.
✓ Branch 113 → 114 taken 30 times.
✗ Branch 113 → 391 not taken.
✓ Branch 114 → 115 taken 30 times.
✗ Branch 114 → 389 not taken.
|
30 | ": active field mismatch on union field access '" + fieldName + "'\n"; |
| 817 |
4/8✓ Branch 121 → 122 taken 30 times.
✗ Branch 121 → 406 not taken.
✓ Branch 122 → 123 taken 30 times.
✗ Branch 122 → 404 not taken.
✓ Branch 123 → 124 taken 30 times.
✗ Branch 123 → 402 not taken.
✓ Branch 125 → 126 taken 30 times.
✗ Branch 125 → 401 not taken.
|
60 | llvm::GlobalVariable *globalString = builder.CreateGlobalString(errorMsg, getUnusedGlobalName(ANON_GLOBAL_STRING_NAME)); |
| 818 |
1/2✓ Branch 129 → 130 taken 30 times.
✗ Branch 129 → 133 not taken.
|
30 | if (cliOptions.comparableOutput) |
| 819 |
2/4✓ Branch 130 → 131 taken 30 times.
✗ Branch 130 → 412 not taken.
✓ Branch 131 → 132 taken 30 times.
✗ Branch 131 → 412 not taken.
|
30 | globalString->setAlignment(llvm::Align(4)); |
| 820 |
5/10✓ Branch 133 → 134 taken 30 times.
✗ Branch 133 → 416 not taken.
✓ Branch 135 → 136 taken 30 times.
✗ Branch 135 → 413 not taken.
✓ Branch 136 → 137 taken 30 times.
✗ Branch 136 → 413 not taken.
✓ Branch 137 → 138 taken 30 times.
✗ Branch 137 → 413 not taken.
✓ Branch 138 → 139 taken 30 times.
✗ Branch 138 → 420 not taken.
|
30 | builder.CreateCall(stdFunctionManager.getFPrintfFct(), {stdErrValue, globalString}); |
| 821 |
6/12✓ Branch 138 → 139 taken 30 times.
✗ Branch 138 → 420 not taken.
✓ Branch 139 → 140 taken 30 times.
✗ Branch 139 → 418 not taken.
✓ Branch 141 → 142 taken 30 times.
✗ Branch 141 → 417 not taken.
✓ Branch 142 → 143 taken 30 times.
✗ Branch 142 → 417 not taken.
✓ Branch 143 → 144 taken 30 times.
✗ Branch 143 → 417 not taken.
✓ Branch 144 → 145 taken 30 times.
✗ Branch 144 → 421 not taken.
|
30 | builder.CreateCall(stdFunctionManager.getExitFct(), builder.getInt32(EXIT_FAILURE)); |
| 822 |
1/2✓ Branch 144 → 145 taken 30 times.
✗ Branch 144 → 421 not taken.
|
30 | builder.CreateUnreachable(); |
| 823 | |||
| 824 |
1/2✓ Branch 145 → 146 taken 30 times.
✗ Branch 145 → 421 not taken.
|
30 | switchToBlock(bOk); |
| 825 | 30 | } | |
| 826 | |||
| 827 | // Get address of the payload (index 2: { tag, alignPad, payload }) | ||
| 828 |
2/4✓ Branch 149 → 150 taken 50 times.
✗ Branch 149 → 428 not taken.
✓ Branch 150 → 151 taken 50 times.
✗ Branch 150 → 426 not taken.
|
50 | llvm::Value *memberAddr = insertStructGEP(unionLLVMTy, unionBasePtr, 2, fieldName + ".addr"); |
| 829 | |||
| 830 | // Set as ptr or refPtr, depending on the type | ||
| 831 |
2/4✓ Branch 152 → 153 taken 50 times.
✗ Branch 152 → 429 not taken.
✗ Branch 153 → 154 not taken.
✓ Branch 153 → 155 taken 50 times.
|
50 | if (fieldSymbolType.isRef()) { |
| 832 | ✗ | lhs.ptr = nullptr; | |
| 833 | ✗ | lhs.refPtr = memberAddr; | |
| 834 | } else { | ||
| 835 | 50 | lhs.ptr = memberAddr; | |
| 836 | 50 | lhs.refPtr = nullptr; | |
| 837 | } | ||
| 838 | |||
| 839 | 50 | lhs.entry = fieldEntry; | |
| 840 | 50 | lhs.value = nullptr; | |
| 841 | 50 | break; | |
| 842 | } | ||
| 843 | |||
| 844 |
2/4✓ Branch 158 → 159 taken 142713 times.
✗ Branch 158 → 443 not taken.
✗ Branch 159 → 160 not taken.
✓ Branch 159 → 161 taken 142713 times.
|
142713 | assert(lhsSTy.is(TY_STRUCT)); |
| 845 | |||
| 846 | // Retrieve struct scope | ||
| 847 |
1/2✓ Branch 161 → 162 taken 142713 times.
✗ Branch 161 → 443 not taken.
|
142713 | Scope *structScope = lhsSTy.getBodyScope(); |
| 848 | |||
| 849 | // Retrieve field entry | ||
| 850 | 142713 | std::vector<size_t> indexPath; | |
| 851 |
1/2✓ Branch 162 → 163 taken 142713 times.
✗ Branch 162 → 441 not taken.
|
142713 | lhs.entry = structScope->symbolTable.lookupInComposedFields(fieldName, indexPath); |
| 852 |
1/2✗ Branch 163 → 164 not taken.
✓ Branch 163 → 165 taken 142713 times.
|
142713 | assert(lhs.entry != nullptr); |
| 853 |
1/2✓ Branch 165 → 166 taken 142713 times.
✗ Branch 165 → 441 not taken.
|
142713 | const QualType fieldSymbolType = lhs.entry->getQualType(); |
| 854 | |||
| 855 | // Get address of the field in the struct instance | ||
| 856 |
2/4✓ Branch 166 → 167 taken 142713 times.
✗ Branch 166 → 433 not taken.
✓ Branch 169 → 170 taken 142713 times.
✗ Branch 169 → 430 not taken.
|
285426 | std::vector<llvm::Value *> indices = {builder.getInt64(0)}; |
| 857 |
2/2✓ Branch 186 → 173 taken 142805 times.
✓ Branch 186 → 187 taken 142713 times.
|
428231 | for (const size_t index : indexPath) |
| 858 |
2/4✓ Branch 175 → 176 taken 142805 times.
✗ Branch 175 → 434 not taken.
✓ Branch 176 → 177 taken 142805 times.
✗ Branch 176 → 434 not taken.
|
142805 | indices.push_back(builder.getInt32(index)); |
| 859 |
1/2✓ Branch 187 → 188 taken 142713 times.
✗ Branch 187 → 439 not taken.
|
142713 | const std::string name = fieldName + ".addr"; |
| 860 |
2/4✓ Branch 189 → 190 taken 142713 times.
✗ Branch 189 → 436 not taken.
✓ Branch 190 → 191 taken 142713 times.
✗ Branch 190 → 436 not taken.
|
142713 | llvm::Value *memberAddr = insertInBoundsGEP(lhsSTy.toLLVMType(sourceFile), lhs.ptr, indices, name); |
| 861 | |||
| 862 | // Set as ptr or refPtr, depending on the type | ||
| 863 |
3/4✓ Branch 191 → 192 taken 142713 times.
✗ Branch 191 → 437 not taken.
✓ Branch 192 → 193 taken 2515 times.
✓ Branch 192 → 194 taken 140198 times.
|
142713 | if (fieldSymbolType.isRef()) { |
| 864 | 2515 | lhs.ptr = nullptr; | |
| 865 | 2515 | lhs.refPtr = memberAddr; | |
| 866 | } else { | ||
| 867 | 140198 | lhs.ptr = memberAddr; | |
| 868 | 140198 | lhs.refPtr = nullptr; | |
| 869 | } | ||
| 870 | |||
| 871 | // Reset the value | ||
| 872 | 142713 | lhs.value = nullptr; | |
| 873 | 142713 | break; | |
| 874 | 142713 | } | |
| 875 | 12950 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_PLUS_PLUS: { | |
| 876 | // Make sure a value is present | ||
| 877 |
1/2✓ Branch 200 → 201 taken 12950 times.
✗ Branch 200 → 450 not taken.
|
12950 | resolveValue(lhsNode, lhs); |
| 878 | |||
| 879 | // Allocate new local variable if required | ||
| 880 |
2/2✓ Branch 201 → 202 taken 4 times.
✓ Branch 201 → 212 taken 12946 times.
|
12950 | if (!lhs.ptr) { |
| 881 |
1/2✗ Branch 202 → 203 not taken.
✓ Branch 202 → 204 taken 4 times.
|
4 | assert(lhs.value != nullptr); |
| 882 |
1/2✓ Branch 208 → 209 taken 4 times.
✗ Branch 208 → 444 not taken.
|
4 | lhs.ptr = insertAlloca(lhs.value->getType()); |
| 883 | } | ||
| 884 | |||
| 885 | // Execute operation | ||
| 886 |
1/2✓ Branch 212 → 213 taken 12950 times.
✗ Branch 212 → 450 not taken.
|
12950 | const LLVMExprResult result = conversionManager.getPostfixPlusPlusInst(node, lhs, lhsSTy); |
| 887 | |||
| 888 | // Save the new value to the old address | ||
| 889 |
3/4✓ Branch 213 → 214 taken 12950 times.
✗ Branch 213 → 450 not taken.
✓ Branch 214 → 215 taken 18 times.
✓ Branch 214 → 216 taken 12932 times.
|
12950 | if (conversionManager.callsOverloadedOpFct(node, 0)) { |
| 890 | 18 | lhs.value = result.value; | |
| 891 | 18 | lhs.ptr = result.ptr; | |
| 892 | } else { | ||
| 893 |
5/6✓ Branch 216 → 217 taken 12926 times.
✓ Branch 216 → 219 taken 6 times.
✓ Branch 217 → 218 taken 6 times.
✓ Branch 217 → 219 taken 12920 times.
✓ Branch 220 → 221 taken 12932 times.
✗ Branch 220 → 450 not taken.
|
12932 | insertStore(result.value, lhs.ptr, lhs.entry && lhs.entry->isVolatile); |
| 894 | 12932 | lhs.ptr = nullptr; | |
| 895 | } | ||
| 896 | 12950 | break; | |
| 897 | } | ||
| 898 | 1097 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_MINUS_MINUS: { | |
| 899 | // Make sure a value is present | ||
| 900 |
1/2✓ Branch 224 → 225 taken 1097 times.
✗ Branch 224 → 457 not taken.
|
1097 | resolveValue(lhsNode, lhs); |
| 901 | |||
| 902 | // Allocate new local variable if required | ||
| 903 |
2/2✓ Branch 225 → 226 taken 4 times.
✓ Branch 225 → 236 taken 1093 times.
|
1097 | if (!lhs.ptr) { |
| 904 |
1/2✗ Branch 226 → 227 not taken.
✓ Branch 226 → 228 taken 4 times.
|
4 | assert(lhs.value != nullptr); |
| 905 |
1/2✓ Branch 232 → 233 taken 4 times.
✗ Branch 232 → 451 not taken.
|
4 | lhs.ptr = insertAlloca(lhs.value->getType()); |
| 906 | } | ||
| 907 | |||
| 908 | // Execute operation | ||
| 909 |
1/2✓ Branch 236 → 237 taken 1097 times.
✗ Branch 236 → 457 not taken.
|
1097 | const LLVMExprResult result = conversionManager.getPostfixMinusMinusInst(node, lhs, lhsSTy); |
| 910 | |||
| 911 | // Save the new value to the old address | ||
| 912 |
3/4✓ Branch 237 → 238 taken 1097 times.
✗ Branch 237 → 457 not taken.
✓ Branch 238 → 239 taken 14 times.
✓ Branch 238 → 240 taken 1083 times.
|
1097 | if (conversionManager.callsOverloadedOpFct(node, 0)) { |
| 913 | 14 | lhs.value = result.value; | |
| 914 | 14 | lhs.ptr = result.ptr; | |
| 915 | } else { | ||
| 916 |
4/6✓ Branch 240 → 241 taken 1079 times.
✓ Branch 240 → 243 taken 4 times.
✗ Branch 241 → 242 not taken.
✓ Branch 241 → 243 taken 1079 times.
✓ Branch 244 → 245 taken 1083 times.
✗ Branch 244 → 457 not taken.
|
1083 | insertStore(result.value, lhs.ptr, lhs.entry && lhs.entry->isVolatile); |
| 917 | 1083 | lhs.ptr = nullptr; | |
| 918 | } | ||
| 919 | 1097 | break; | |
| 920 | } | ||
| 921 | 120 | case PostfixUnaryExprNode::PostfixUnaryOp::OP_ERR_PROPAGATION: { | |
| 922 | // Get the address of the Result<T> operand | ||
| 923 |
1/2✓ Branch 248 → 249 taken 120 times.
✗ Branch 248 → 500 not taken.
|
120 | llvm::Value *operandPtr = resolveAddress(lhs); |
| 924 | |||
| 925 | // Call isErr() on the operand | ||
| 926 |
1/2✗ Branch 249 → 250 not taken.
✓ Branch 249 → 251 taken 120 times.
|
120 | assert(node->errPropIsErrFct != nullptr); |
| 927 |
1/2✓ Branch 251 → 252 taken 120 times.
✗ Branch 251 → 500 not taken.
|
120 | llvm::Function *isErrFct = stdFunctionManager.getResultIsErrFct(node->errPropIsErrFct); |
| 928 |
4/8✓ Branch 252 → 253 taken 120 times.
✗ Branch 252 → 460 not taken.
✓ Branch 254 → 255 taken 120 times.
✗ Branch 254 → 458 not taken.
✓ Branch 255 → 256 taken 120 times.
✗ Branch 255 → 458 not taken.
✓ Branch 256 → 257 taken 120 times.
✗ Branch 256 → 500 not taken.
|
120 | llvm::Value *isErr = builder.CreateCall(isErrFct, operandPtr); |
| 929 | |||
| 930 | // Create blocks | ||
| 931 |
1/2✓ Branch 256 → 257 taken 120 times.
✗ Branch 256 → 500 not taken.
|
120 | const std::string codeLine = node->codeLoc.toPrettyLine(); |
| 932 |
2/4✓ Branch 257 → 258 taken 120 times.
✗ Branch 257 → 463 not taken.
✓ Branch 258 → 259 taken 120 times.
✗ Branch 258 → 461 not taken.
|
120 | llvm::BasicBlock *bThen = createBlock("err.prop.then." + codeLine); |
| 933 |
2/4✓ Branch 260 → 261 taken 120 times.
✗ Branch 260 → 466 not taken.
✓ Branch 261 → 262 taken 120 times.
✗ Branch 261 → 464 not taken.
|
120 | llvm::BasicBlock *bExit = createBlock("err.prop.exit." + codeLine); |
| 934 |
1/2✓ Branch 263 → 264 taken 120 times.
✗ Branch 263 → 498 not taken.
|
120 | insertCondJump(isErr, bThen, bExit, Likelihood::UNLIKELY); |
| 935 | |||
| 936 | // Switch to then block: propagate the error as the enclosing function's Result<U> | ||
| 937 |
1/2✓ Branch 264 → 265 taken 120 times.
✗ Branch 264 → 498 not taken.
|
120 | switchToBlock(bThen); |
| 938 |
2/4✓ Branch 265 → 266 taken 120 times.
✗ Branch 265 → 268 not taken.
✓ Branch 266 → 267 taken 120 times.
✗ Branch 266 → 268 not taken.
|
120 | assert(node->errPropGetErrFct != nullptr && node->errPropCtorFct != nullptr); |
| 939 |
1/2✓ Branch 269 → 270 taken 120 times.
✗ Branch 269 → 498 not taken.
|
120 | llvm::Function *getErrFct = stdFunctionManager.getResultGetErrFct(node->errPropGetErrFct); |
| 940 |
4/8✓ Branch 270 → 271 taken 120 times.
✗ Branch 270 → 469 not taken.
✓ Branch 272 → 273 taken 120 times.
✗ Branch 272 → 467 not taken.
✓ Branch 273 → 274 taken 120 times.
✗ Branch 273 → 467 not taken.
✓ Branch 274 → 275 taken 120 times.
✗ Branch 274 → 498 not taken.
|
120 | llvm::Value *errorPtr = builder.CreateCall(getErrFct, operandPtr); |
| 941 |
1/2✓ Branch 274 → 275 taken 120 times.
✗ Branch 274 → 498 not taken.
|
120 | llvm::Function *errCtorFct = stdFunctionManager.getResultErrCtorFct(node->errPropCtorFct); |
| 942 |
5/8✓ Branch 275 → 276 taken 120 times.
✗ Branch 275 → 472 not taken.
✓ Branch 277 → 278 taken 120 times.
✗ Branch 277 → 470 not taken.
✓ Branch 278 → 279 taken 120 times.
✗ Branch 278 → 470 not taken.
✓ Branch 279 → 280 taken 6 times.
✓ Branch 279 → 304 taken 114 times.
|
120 | llvm::Value *propagatedResult = builder.CreateCall(errCtorFct, errorPtr); |
| 943 | |||
| 944 | // Record this propagation hop in the error return trace, if tracing is enabled for this file | ||
| 945 |
2/2✓ Branch 279 → 280 taken 6 times.
✓ Branch 279 → 304 taken 114 times.
|
120 | if (sourceFile->errorReturnTracing) { |
| 946 |
1/2✓ Branch 280 → 281 taken 6 times.
✗ Branch 280 → 498 not taken.
|
6 | llvm::Function *pushFct = stdFunctionManager.getErrTracePushFct(); |
| 947 | llvm::Constant *signature = | ||
| 948 |
3/6✓ Branch 281 → 282 taken 6 times.
✗ Branch 281 → 481 not taken.
✓ Branch 284 → 285 taken 6 times.
✗ Branch 284 → 475 not taken.
✓ Branch 285 → 286 taken 6 times.
✗ Branch 285 → 473 not taken.
|
18 | createGlobalStringConst("errtrace.hop.sig.", node->getEnclosingFunctionSignature(manIdx), node->codeLoc); |
| 949 |
3/6✓ Branch 289 → 290 taken 6 times.
✗ Branch 289 → 490 not taken.
✓ Branch 292 → 293 taken 6 times.
✗ Branch 292 → 484 not taken.
✓ Branch 293 → 294 taken 6 times.
✗ Branch 293 → 482 not taken.
|
18 | llvm::Constant *fileName = createGlobalStringConst("errtrace.hop.file.", node->codeLoc.toPrettyFilePath(), node->codeLoc); |
| 950 |
1/2✓ Branch 297 → 298 taken 6 times.
✗ Branch 297 → 498 not taken.
|
6 | llvm::Value *line = builder.getInt32(node->codeLoc.line); |
| 951 |
1/2✓ Branch 298 → 299 taken 6 times.
✗ Branch 298 → 498 not taken.
|
6 | llvm::Value *column = builder.getInt32(node->codeLoc.col); |
| 952 |
3/6✓ Branch 299 → 300 taken 6 times.
✗ Branch 299 → 494 not taken.
✓ Branch 301 → 302 taken 6 times.
✗ Branch 301 → 491 not taken.
✓ Branch 302 → 303 taken 6 times.
✗ Branch 302 → 491 not taken.
|
6 | builder.CreateCall(pushFct, {signature, fileName, line, column}); |
| 953 | } | ||
| 954 | |||
| 955 | // Clean up all scopes between here and the enclosing function/procedure/lambda body, then return the error | ||
| 956 |
2/4✓ Branch 304 → 305 taken 120 times.
✗ Branch 304 → 498 not taken.
✓ Branch 305 → 306 taken 120 times.
✗ Branch 305 → 498 not taken.
|
120 | generateScopeCleanupUpTo(node, currentScope->getFunctionScope()); |
| 957 | 120 | blockAlreadyTerminated = true; | |
| 958 |
1/2✓ Branch 306 → 307 taken 120 times.
✗ Branch 306 → 498 not taken.
|
120 | builder.CreateRet(propagatedResult); |
| 959 | |||
| 960 | // Switch to exit block: unwrap the payload, which becomes the value of the whole expression | ||
| 961 |
1/2✓ Branch 307 → 308 taken 120 times.
✗ Branch 307 → 498 not taken.
|
120 | switchToBlock(bExit); |
| 962 |
1/2✗ Branch 308 → 309 not taken.
✓ Branch 308 → 310 taken 120 times.
|
120 | assert(node->errPropUnwrapFct != nullptr); |
| 963 |
1/2✓ Branch 310 → 311 taken 120 times.
✗ Branch 310 → 498 not taken.
|
120 | llvm::Function *unwrapFct = stdFunctionManager.getResultUnwrapFct(node->errPropUnwrapFct); |
| 964 |
3/6✓ Branch 311 → 312 taken 120 times.
✗ Branch 311 → 497 not taken.
✓ Branch 313 → 314 taken 120 times.
✗ Branch 313 → 495 not taken.
✓ Branch 314 → 315 taken 120 times.
✗ Branch 314 → 495 not taken.
|
120 | llvm::Value *unwrapped = builder.CreateCall(unwrapFct, operandPtr); |
| 965 | 120 | lhs = {.ptr = unwrapped}; | |
| 966 | 120 | break; | |
| 967 | 120 | } | |
| 968 | − | default: // GCOV_EXCL_LINE | |
| 969 | − | throw CompilerError(UNHANDLED_BRANCH, "PostfixUnaryExpr fall-through"); // GCOV_EXCL_LINE | |
| 970 | } | ||
| 971 | |||
| 972 |
1/2✓ Branch 326 → 327 taken 175098 times.
✗ Branch 326 → 510 not taken.
|
175098 | return lhs; |
| 973 |
5/14✓ Branch 17 → 18 taken 1080 times.
✗ Branch 17 → 336 not taken.
✓ Branch 18 → 19 taken 1080 times.
✗ Branch 18 → 336 not taken.
✓ Branch 19 → 20 taken 1080 times.
✗ Branch 19 → 336 not taken.
✓ Branch 20 → 21 taken 1080 times.
✗ Branch 20 → 336 not taken.
✓ Branch 21 → 22 taken 1080 times.
✗ Branch 21 → 334 not taken.
✗ Branch 336 → 337 not taken.
✗ Branch 336 → 340 not taken.
✗ Branch 338 → 339 not taken.
✗ Branch 338 → 340 not taken.
|
1080 | } |
| 974 | |||
| 975 | 704885 | std::any IRGenerator::visitAtomicExpr(const AtomicExprNode *node) { | |
| 976 | // If constant | ||
| 977 |
2/2✓ Branch 2 → 3 taken 124572 times.
✓ Branch 2 → 9 taken 580313 times.
|
704885 | if (node->constant) { |
| 978 |
2/4✓ Branch 3 → 4 taken 124572 times.
✗ Branch 3 → 82 not taken.
✓ Branch 4 → 5 taken 124572 times.
✗ Branch 4 → 80 not taken.
|
124572 | const auto constantValue = std::any_cast<llvm::Constant *>(visit(node->constant)); |
| 979 |
1/2✓ Branch 6 → 7 taken 124572 times.
✗ Branch 6 → 83 not taken.
|
249144 | return LLVMExprResult{.constant = constantValue}; |
| 980 | } | ||
| 981 | |||
| 982 | // If value | ||
| 983 |
2/2✓ Branch 9 → 10 taken 167054 times.
✓ Branch 9 → 12 taken 413259 times.
|
580313 | if (node->value) |
| 984 |
1/2✓ Branch 10 → 11 taken 167054 times.
✗ Branch 10 → 90 not taken.
|
167054 | return visit(node->value); |
| 985 | |||
| 986 | // Is assign expression | ||
| 987 |
2/2✓ Branch 12 → 13 taken 3394 times.
✓ Branch 12 → 15 taken 409865 times.
|
413259 | if (node->assignExpr) |
| 988 |
1/2✓ Branch 13 → 14 taken 3394 times.
✗ Branch 13 → 90 not taken.
|
3394 | return visit(node->assignExpr); |
| 989 | |||
| 990 |
1/2✓ Branch 15 → 16 taken 409865 times.
✗ Branch 15 → 90 not taken.
|
409865 | diGenerator.setSourceLocation(node); |
| 991 | |||
| 992 | // Identifier (local or global variable access) | ||
| 993 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 409865 times.
|
409865 | assert(!node->identifierFragments.empty()); |
| 994 | |||
| 995 | // Get symbol table entry | ||
| 996 |
1/2✓ Branch 19 → 20 taken 409865 times.
✗ Branch 19 → 90 not taken.
|
409865 | const auto &[entry, accessScope, capture] = node->data.at(manIdx); |
| 997 |
1/2✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 409865 times.
|
409865 | assert(entry != nullptr); |
| 998 |
1/2✗ Branch 22 → 23 not taken.
✓ Branch 22 → 24 taken 409865 times.
|
409865 | assert(accessScope != nullptr); |
| 999 |
1/2✓ Branch 24 → 25 taken 409865 times.
✗ Branch 24 → 90 not taken.
|
409865 | const QualType varSymbolType = entry->getQualType(); |
| 1000 |
1/2✓ Branch 25 → 26 taken 409865 times.
✗ Branch 25 → 90 not taken.
|
409865 | llvm::Type *varType = varSymbolType.toLLVMType(sourceFile); |
| 1001 | |||
| 1002 | // Check if external global variable | ||
| 1003 |
7/8✓ Branch 26 → 27 taken 9142 times.
✓ Branch 26 → 30 taken 400723 times.
✓ Branch 27 → 28 taken 9142 times.
✗ Branch 27 → 90 not taken.
✓ Branch 28 → 29 taken 572 times.
✓ Branch 28 → 30 taken 8570 times.
✓ Branch 31 → 32 taken 572 times.
✓ Branch 31 → 35 taken 409293 times.
|
409865 | if (entry->global && accessScope->isImportedBy(rootScope)) { |
| 1004 | // External global variables need to be declared and allocated in the current module | ||
| 1005 |
1/2✓ Branch 33 → 34 taken 572 times.
✗ Branch 33 → 84 not taken.
|
572 | llvm::Value *varAddress = module->getOrInsertGlobal(entry->name, varType); |
| 1006 |
1/2✓ Branch 34 → 35 taken 572 times.
✗ Branch 34 → 90 not taken.
|
572 | updateAddress(entry, varAddress); |
| 1007 | } | ||
| 1008 | |||
| 1009 | // Check if enum item | ||
| 1010 |
2/2✓ Branch 35 → 36 taken 10013 times.
✓ Branch 35 → 49 taken 399852 times.
|
409865 | if (accessScope->type == ScopeType::ENUM) { |
| 1011 |
1/2✓ Branch 36 → 37 taken 10013 times.
✗ Branch 36 → 38 not taken.
|
10013 | const auto itemNode = spice_pointer_cast<const EnumItemNode *>(entry->declNode); |
| 1012 |
1/2✓ Branch 45 → 46 taken 10013 times.
✗ Branch 45 → 90 not taken.
|
10013 | llvm::Constant *constantItemValue = llvm::ConstantInt::get(varType, itemNode->itemValue); |
| 1013 |
1/2✓ Branch 46 → 47 taken 10013 times.
✗ Branch 46 → 85 not taken.
|
20026 | return LLVMExprResult{.constant = constantItemValue, .entry = entry}; |
| 1014 | } | ||
| 1015 | |||
| 1016 |
1/2✓ Branch 49 → 50 taken 399852 times.
✗ Branch 49 → 90 not taken.
|
399852 | llvm::Value *address = getAddress(entry); |
| 1017 |
1/2✗ Branch 50 → 51 not taken.
✓ Branch 50 → 52 taken 399852 times.
|
399852 | assert(address != nullptr); |
| 1018 | |||
| 1019 | // If this is a function/procedure reference, return it as value. The fat pointer must point at a thunk that | ||
| 1020 | // carries the (ignored) leading capture-struct pointer, so it can be called through the uniform lambda ABI. | ||
| 1021 |
7/8✓ Branch 52 → 53 taken 9142 times.
✓ Branch 52 → 56 taken 390710 times.
✓ Branch 53 → 54 taken 9142 times.
✗ Branch 53 → 86 not taken.
✓ Branch 54 → 55 taken 32 times.
✓ Branch 54 → 56 taken 9110 times.
✓ Branch 57 → 58 taken 32 times.
✓ Branch 57 → 64 taken 399820 times.
|
399852 | if (entry->global && varSymbolType.isOneOf({TY_FUNCTION, TY_PROCEDURE})) { |
| 1022 |
2/4✓ Branch 58 → 59 taken 32 times.
✗ Branch 58 → 90 not taken.
✓ Branch 59 → 60 taken 32 times.
✗ Branch 59 → 90 not taken.
|
32 | llvm::Function *thunk = getOrCreateFatFctPtrThunk(llvm::cast<llvm::Function>(address)); |
| 1023 |
1/2✓ Branch 60 → 61 taken 32 times.
✗ Branch 60 → 90 not taken.
|
32 | llvm::Value *fatPtr = buildFatFctPtr(nullptr, nullptr, thunk); |
| 1024 |
1/2✓ Branch 61 → 62 taken 32 times.
✗ Branch 61 → 87 not taken.
|
64 | return LLVMExprResult{.ptr = fatPtr, .entry = entry}; |
| 1025 | } | ||
| 1026 | |||
| 1027 | // Load the address of the referenced variable | ||
| 1028 |
10/12✓ Branch 64 → 65 taken 399820 times.
✗ Branch 64 → 90 not taken.
✓ Branch 65 → 66 taken 357423 times.
✓ Branch 65 → 69 taken 42397 times.
✓ Branch 66 → 67 taken 170 times.
✓ Branch 66 → 70 taken 357253 times.
✓ Branch 67 → 68 taken 170 times.
✗ Branch 67 → 90 not taken.
✓ Branch 68 → 69 taken 38 times.
✓ Branch 68 → 70 taken 132 times.
✓ Branch 71 → 72 taken 42435 times.
✓ Branch 71 → 75 taken 357385 times.
|
399820 | if (varSymbolType.isRef() || (capture && capture->getMode() == BY_REFERENCE)) |
| 1029 |
1/2✓ Branch 72 → 73 taken 42435 times.
✗ Branch 72 → 88 not taken.
|
84870 | return LLVMExprResult{.refPtr = address, .entry = entry}; |
| 1030 | |||
| 1031 |
1/2✓ Branch 75 → 76 taken 357385 times.
✗ Branch 75 → 89 not taken.
|
714770 | return LLVMExprResult{.ptr = address, .entry = entry}; |
| 1032 | } | ||
| 1033 | |||
| 1034 | } // namespace spice::compiler | ||
| 1035 |