From cc896f712dc2cda89ef7fcea351995b01fc1ed1c Mon Sep 17 00:00:00 2001 From: Ruiling Song Date: Thu, 4 Aug 2016 14:13:22 +0800 Subject: [PATCH] GBE: Fix a dead loop issue during bti analysis. The PHINode may introduce a endless loop for bti analysis. We should insert the newly created bti/pointerbase to the map asap, i.e. before we do further getBtiRegister() or getPointerBase(). Then the endless loop will be break. Signed-off-by: Ruiling Song --- backend/src/llvm/llvm_gen_backend.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp index 5135950..45d422e 100644 --- a/backend/src/llvm/llvm_gen_backend.cpp +++ b/backend/src/llvm/llvm_gen_backend.cpp @@ -1040,6 +1040,7 @@ namespace gbe Builder.SetInsertPoint(phi); PHINode *basePhi = Builder.CreatePHI(ptr->getType(), phi->getNumIncomingValues()); + pointerBaseMap.insert(std::make_pair(ptr, basePhi)); unsigned srcNum = pointers.size(); for (unsigned x = 0; x < srcNum; x++) { Value *base = NULL; @@ -1068,7 +1069,6 @@ namespace gbe #endif basePhi->addIncoming(base, phi->getIncomingBlock(x)); } - pointerBaseMap.insert(std::make_pair(ptr, basePhi)); return basePhi; } else { ptr->dump(); @@ -1138,6 +1138,8 @@ namespace gbe PHINode *btiPhi = Builder.CreatePHI( IntegerType::get(Val->getContext(), 32), phi->getNumIncomingValues()); + BtiValueMap.insert(std::make_pair(Val, btiPhi)); + SmallVector &pointers = (*iter).second; unsigned srcNum = pointers.size(); for (unsigned x = 0; x < srcNum; x++) { @@ -1149,7 +1151,6 @@ namespace gbe } btiPhi->addIncoming(bti, phi->getIncomingBlock(x)); } - BtiValueMap.insert(std::make_pair(Val, btiPhi)); return btiPhi; } else { Val->dump(); -- 2.4.1