From cc0c266c034dfeaab28d0ede3c3d81b57c607918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Thu, 13 Aug 2020 21:11:59 +0200 Subject: [PATCH] [ORC][NFC] Refactor loop to determine name of init symbol in IRMaterializationUnit This loop caused me a little headache once, because I didn't see the assigned variable is a member. The refactored version appears more readable to me. Differential Revision: https://reviews.llvm.org/D85922 --- lib/ExecutionEngine/Orc/Layer.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/ExecutionEngine/Orc/Layer.cpp b/lib/ExecutionEngine/Orc/Layer.cpp index 61e7ab5ae68..0a5d5577e99 100644 --- a/lib/ExecutionEngine/Orc/Layer.cpp +++ b/lib/ExecutionEngine/Orc/Layer.cpp @@ -83,17 +83,14 @@ IRMaterializationUnit::IRMaterializationUnit( if (!llvm::empty(getStaticInitGVs(M))) { size_t Counter = 0; - while (true) { + do { std::string InitSymbolName; raw_string_ostream(InitSymbolName) << "$." << M.getModuleIdentifier() << ".__inits." << Counter++; InitSymbol = ES.intern(InitSymbolName); - if (SymbolFlags.count(InitSymbol)) - continue; - SymbolFlags[InitSymbol] = - JITSymbolFlags::MaterializationSideEffectsOnly; - break; - } + } while (SymbolFlags.count(InitSymbol)); + + SymbolFlags[InitSymbol] = JITSymbolFlags::MaterializationSideEffectsOnly; } }); }