| 52 | } |
| 53 | |
| 54 | BeValue* BeInliner::Remap(BeValue* srcValue) |
| 55 | { |
| 56 | if (srcValue == NULL) |
| 57 | return NULL; |
| 58 | |
| 59 | // Try to unwrap mdnode |
| 60 | if (auto inlinedScope = BeValueDynCast<BeDbgInlinedScope>(srcValue)) |
| 61 | srcValue = inlinedScope->mScope; |
| 62 | |
| 63 | BeValue** valuePtr = NULL; |
| 64 | /*auto itr = mValueMap.find(srcValue); |
| 65 | if (itr != mValueMap.end()) |
| 66 | return itr->second;*/ |
| 67 | if (mValueMap.TryGetValue(srcValue, &valuePtr)) |
| 68 | return *valuePtr; |
| 69 | |
| 70 | BeMDNode* wrapMDNode = NULL; |
| 71 | |
| 72 | if (auto dbgFunction = BeValueDynCast<BeDbgFunction>(srcValue)) |
| 73 | { |
| 74 | wrapMDNode = dbgFunction; |
| 75 | } |
| 76 | if (auto dbgLexBlock = BeValueDynCast<BeDbgLexicalBlock>(srcValue)) |
| 77 | { |
| 78 | wrapMDNode = dbgLexBlock; |
| 79 | } |
| 80 | |
| 81 | if (auto callInst = BeValueDynCast<BeCallInst>(srcValue)) |
| 82 | { |
| 83 | if (callInst->mInlineResult != NULL) |
| 84 | return Remap(callInst->mInlineResult); |
| 85 | } |
| 86 | |
| 87 | if (wrapMDNode != NULL) |
| 88 | { |
| 89 | auto destMDNode = mOwnedValueVec->Alloc<BeDbgInlinedScope>(); |
| 90 | destMDNode->mScope = wrapMDNode; |
| 91 | mValueMap[srcValue] = destMDNode; |
| 92 | return destMDNode; |
| 93 | } |
| 94 | |
| 95 | return srcValue; |
| 96 | } |
| 97 | |
| 98 | // Insert 'mCallInst->mDbgLoc' at the head of the inline chain |
| 99 | BeDbgLoc* BeInliner::ExtendInlineDbgLoc(BeDbgLoc* srcInlineAt) |