12
12
#include " llvm/Config/llvm-config.h"
13
13
#include " llvm/ExecutionEngine/Orc/DebugUtils.h"
14
14
#include " llvm/ExecutionEngine/Orc/Shared/OrcError.h"
15
- #include " llvm/Support/Debug.h"
16
15
#include " llvm/Support/FormatVariadic.h"
17
16
#include " llvm/Support/MSVCErrorWorkarounds.h"
18
17
#include " llvm/Support/raw_ostream.h"
@@ -166,15 +165,17 @@ std::error_code MissingSymbolDefinitions::convertToErrorCode() const {
166
165
}
167
166
168
167
void MissingSymbolDefinitions::log (raw_ostream &OS) const {
169
- OS << " Missing definitions in module " << ModuleName << " : " << Symbols;
168
+ OS << " Missing definitions in module " << ModuleName
169
+ << " : " << Symbols;
170
170
}
171
171
172
172
std::error_code UnexpectedSymbolDefinitions::convertToErrorCode () const {
173
173
return orcError (OrcErrorCode::UnexpectedSymbolDefinitions);
174
174
}
175
175
176
176
void UnexpectedSymbolDefinitions::log (raw_ostream &OS) const {
177
- OS << " Unexpected definitions in module " << ModuleName << " : " << Symbols;
177
+ OS << " Unexpected definitions in module " << ModuleName
178
+ << " : " << Symbols;
178
179
}
179
180
180
181
void SymbolInstance::lookupAsync (LookupAsyncOnCompleteFn OnComplete) const {
@@ -739,7 +740,7 @@ JITDylib::defineMaterializing(MaterializationResponsibility &FromMR,
739
740
continue ;
740
741
} else
741
742
EntryItr =
742
- Symbols.insert (std::make_pair (Name, SymbolTableEntry (Flags))).first ;
743
+ Symbols.insert (std::make_pair (Name, SymbolTableEntry (Flags))).first ;
743
744
744
745
AddedSyms.push_back (NonOwningSymbolStringPtr (Name));
745
746
EntryItr->second .setState (SymbolState::Materializing);
@@ -761,62 +762,63 @@ Error JITDylib::replace(MaterializationResponsibility &FromMR,
761
762
std::unique_ptr<MaterializationUnit> MustRunMU;
762
763
std::unique_ptr<MaterializationResponsibility> MustRunMR;
763
764
764
- auto Err = ES.runSessionLocked ([&, this ]() -> Error {
765
- if (FromMR.RT ->isDefunct ())
766
- return make_error<ResourceTrackerDefunct>(std::move (FromMR.RT ));
765
+ auto Err =
766
+ ES.runSessionLocked ([&, this ]() -> Error {
767
+ if (FromMR.RT ->isDefunct ())
768
+ return make_error<ResourceTrackerDefunct>(std::move (FromMR.RT ));
767
769
768
770
#ifndef NDEBUG
769
- for (auto &KV : MU->getSymbols ()) {
770
- auto SymI = Symbols.find (KV.first );
771
- assert (SymI != Symbols.end () && " Replacing unknown symbol" );
772
- assert (SymI->second .getState () == SymbolState::Materializing &&
773
- " Can not replace a symbol that ha is not materializing" );
774
- assert (!SymI->second .hasMaterializerAttached () &&
775
- " Symbol should not have materializer attached already" );
776
- assert (UnmaterializedInfos.count (KV.first ) == 0 &&
777
- " Symbol being replaced should have no UnmaterializedInfo" );
778
- }
771
+ for (auto &KV : MU->getSymbols ()) {
772
+ auto SymI = Symbols.find (KV.first );
773
+ assert (SymI != Symbols.end () && " Replacing unknown symbol" );
774
+ assert (SymI->second .getState () == SymbolState::Materializing &&
775
+ " Can not replace a symbol that ha is not materializing" );
776
+ assert (!SymI->second .hasMaterializerAttached () &&
777
+ " Symbol should not have materializer attached already" );
778
+ assert (UnmaterializedInfos.count (KV.first ) == 0 &&
779
+ " Symbol being replaced should have no UnmaterializedInfo" );
780
+ }
779
781
#endif // NDEBUG
780
782
781
- // If the tracker is defunct we need to bail out immediately.
782
-
783
- // If any symbol has pending queries against it then we need to
784
- // materialize MU immediately.
785
- for (auto &KV : MU->getSymbols ()) {
786
- auto MII = MaterializingInfos.find (KV.first );
787
- if (MII != MaterializingInfos.end ()) {
788
- if (MII->second .hasQueriesPending ()) {
789
- MustRunMR = ES.createMaterializationResponsibility (
790
- *FromMR.RT , std::move (MU->SymbolFlags ),
791
- std::move (MU->InitSymbol ));
792
- MustRunMU = std::move (MU);
793
- return Error::success ();
783
+ // If the tracker is defunct we need to bail out immediately.
784
+
785
+ // If any symbol has pending queries against it then we need to
786
+ // materialize MU immediately.
787
+ for (auto &KV : MU->getSymbols ()) {
788
+ auto MII = MaterializingInfos.find (KV.first );
789
+ if (MII != MaterializingInfos.end ()) {
790
+ if (MII->second .hasQueriesPending ()) {
791
+ MustRunMR = ES.createMaterializationResponsibility (
792
+ *FromMR.RT , std::move (MU->SymbolFlags ),
793
+ std::move (MU->InitSymbol ));
794
+ MustRunMU = std::move (MU);
795
+ return Error::success ();
796
+ }
797
+ }
794
798
}
795
- }
796
- }
797
799
798
- // Otherwise, make MU responsible for all the symbols.
799
- auto UMI =
800
- std::make_shared<UnmaterializedInfo>( std::move (MU), FromMR.RT .get ());
801
- for (auto &KV : UMI->MU ->getSymbols ()) {
802
- auto SymI = Symbols.find (KV.first );
803
- assert (SymI->second .getState () == SymbolState::Materializing &&
804
- " Can not replace a symbol that is not materializing" );
805
- assert (!SymI->second .hasMaterializerAttached () &&
806
- " Can not replace a symbol that has a materializer attached" );
807
- assert (UnmaterializedInfos.count (KV.first ) == 0 &&
808
- " Unexpected materializer entry in map" );
809
- SymI->second .setAddress (SymI->second .getAddress ());
810
- SymI->second .setMaterializerAttached (true );
811
-
812
- auto &UMIEntry = UnmaterializedInfos[KV.first ];
813
- assert ((!UMIEntry || !UMIEntry->MU ) &&
814
- " Replacing symbol with materializer still attached" );
815
- UMIEntry = UMI;
816
- }
800
+ // Otherwise, make MU responsible for all the symbols.
801
+ auto UMI = std::make_shared<UnmaterializedInfo>( std::move (MU),
802
+ FromMR.RT .get ());
803
+ for (auto &KV : UMI->MU ->getSymbols ()) {
804
+ auto SymI = Symbols.find (KV.first );
805
+ assert (SymI->second .getState () == SymbolState::Materializing &&
806
+ " Can not replace a symbol that is not materializing" );
807
+ assert (!SymI->second .hasMaterializerAttached () &&
808
+ " Can not replace a symbol that has a materializer attached" );
809
+ assert (UnmaterializedInfos.count (KV.first ) == 0 &&
810
+ " Unexpected materializer entry in map" );
811
+ SymI->second .setAddress (SymI->second .getAddress ());
812
+ SymI->second .setMaterializerAttached (true );
813
+
814
+ auto &UMIEntry = UnmaterializedInfos[KV.first ];
815
+ assert ((!UMIEntry || !UMIEntry->MU ) &&
816
+ " Replacing symbol with materializer still attached" );
817
+ UMIEntry = UMI;
818
+ }
817
819
818
- return Error::success ();
819
- });
820
+ return Error::success ();
821
+ });
820
822
821
823
if (Err)
822
824
return Err;
@@ -920,12 +922,9 @@ Error JITDylib::resolve(MaterializationResponsibility &MR,
920
922
(SymI->second .getFlags () & ~JITSymbolFlags::Common) &&
921
923
" Resolving symbol with incorrect flags" );
922
924
923
- } else {
924
- /*
925
+ } else
925
926
assert (KV.second .getFlags () == SymI->second .getFlags () &&
926
927
" Resolved flags should match the declared flags" );
927
- */
928
- }
929
928
930
929
Worklist.push_back (
931
930
{SymI, {KV.second .getAddress (), SymI->second .getFlags ()}});
@@ -2056,8 +2055,7 @@ bool ExecutionSession::verifySessionState(Twine Phase) {
2056
2055
// Pending queries should be for subsequent states.
2057
2056
auto CurState = static_cast <SymbolState>(
2058
2057
static_cast <std::underlying_type_t <SymbolState>>(
2059
- SymItr->second .getState ()) +
2060
- 1 );
2058
+ SymItr->second .getState ()) + 1 );
2061
2059
for (auto &Q : MII.PendingQueries ) {
2062
2060
if (Q->getRequiredState () != CurState) {
2063
2061
if (Q->getRequiredState () > CurState)
@@ -2901,14 +2899,6 @@ Error ExecutionSession::OL_notifyResolved(MaterializationResponsibility &MR,
2901
2899
#ifndef NDEBUG
2902
2900
for (auto &KV : Symbols) {
2903
2901
auto I = MR.SymbolFlags .find (KV.first );
2904
-
2905
- LLVM_DEBUG (dbgs () << " Flags for " << KV.first << " : "
2906
- << formatv (" expected {0:x}" , I->second .getRawFlagsValue ())
2907
- << " "
2908
- << formatv (" found {0:x}" ,
2909
- KV.second .getFlags ().getRawFlagsValue ())
2910
- << " \n " );
2911
-
2912
2902
assert (I != MR.SymbolFlags .end () &&
2913
2903
" Resolving symbol outside this responsibility set" );
2914
2904
assert (!I->second .hasMaterializationSideEffectsOnly () &&
@@ -2920,12 +2910,9 @@ Error ExecutionSession::OL_notifyResolved(MaterializationResponsibility &MR,
2920
2910
assert ((KV.second .getFlags () & ~WeakOrCommon) ==
2921
2911
(I->second & ~JITSymbolFlags::Common) &&
2922
2912
" Resolving symbol with incorrect flags" );
2923
- } else {
2924
- /*
2913
+ } else
2925
2914
assert (KV.second .getFlags () == I->second &&
2926
2915
" Resolving symbol with incorrect flags" );
2927
- */
2928
- }
2929
2916
}
2930
2917
#endif
2931
2918
0 commit comments