Index: llvm/include/llvm/CodeGen/ReachingDefAnalysis.h =================================================================== --- llvm/include/llvm/CodeGen/ReachingDefAnalysis.h +++ llvm/include/llvm/CodeGen/ReachingDefAnalysis.h @@ -55,7 +55,7 @@ /// The first instruction in each basic block is 0. int CurInstr; - /// Maps instructions to their instruction Ids, relative to the begining of + /// Maps instructions to their instruction Ids, relative to the beginning of /// their basic blocks. DenseMap InstIds; Index: llvm/lib/CodeGen/ReachingDefAnalysis.cpp =================================================================== --- llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -214,10 +214,17 @@ if (InstId < 0) return nullptr; - for (auto &MI : *MBB) { - if (InstIds.count(&MI) && InstIds.lookup(&MI) == InstId) - return &MI; - } + auto It = std::find_if(MBB->begin(), MBB->end(), [&](const MachineInstr &MI) { + auto F = InstIds.find(&MI); + if (F->first != MBB->end() && F->second == InstId) + return true; + else + return false; + }); + + if (It != MBB->end()) + return &*It; + return nullptr; }