Skip to content

Commit a2f0056

Browse files
committed
Replace direct call to orc_rt_elfnix_register_object_sections with AllocActions.
1 parent a5008e1 commit a2f0056

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

compiler-rt/lib/orc/elfnix_platform.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ Error ELFNixPlatformRuntimeState::registerObjectSections(
213213
return Error::success();
214214
}
215215

216+
Error ELFNixPlatformRuntimeState::deregisterObjectSections(
217+
ELFNixPerObjectSectionsToRegister POSR) {
218+
if (POSR.EHFrameSection.Start)
219+
deregisterEHFrameSection(POSR.EHFrameSection.Start.toPtr<const char *>());
220+
221+
return Error::success();
222+
}
223+
216224
Error ELFNixPlatformRuntimeState::registerJITDylib(std::string &Name, void *Handle) {
217225
std::lock_guard<std::recursive_mutex> Lock(JDStatesMutex);
218226

@@ -297,14 +305,6 @@ Error ELFNixPlatformRuntimeState::deregisterInits(
297305
return Error::success();
298306
}
299307

300-
Error ELFNixPlatformRuntimeState::deregisterObjectSections(
301-
ELFNixPerObjectSectionsToRegister POSR) {
302-
if (POSR.EHFrameSection.Start)
303-
deregisterEHFrameSection(POSR.EHFrameSection.Start.toPtr<const char *>());
304-
305-
return Error::success();
306-
}
307-
308308
const char *ELFNixPlatformRuntimeState::dlerror() { return DLFcnError.c_str(); }
309309

310310
void *ELFNixPlatformRuntimeState::dlopen(std::string_view Path, int Mode) {

llvm/include/llvm/ExecutionEngine/Orc/ELFNixPlatform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class ELFNixPlatform : public Platform {
190190
// Records the addresses of runtime symbols used by the platform.
191191
Error bootstrapELFNixRuntime(JITDylib &PlatformJD);
192192

193-
Error registerPerObjectSections(const ELFPerObjectSectionsToRegister &POSR);
193+
Error registerPerObjectSections(
194+
jitlink::LinkGraph &G,const ELFPerObjectSectionsToRegister &POSR);
194195

195196
Expected<uint64_t> createPThreadKey();
196197

llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,9 @@ Error ELFNixPlatform::bootstrapELFNixRuntime(JITDylib &PlatformJD) {
546546
}
547547

548548
for (auto &D : DeferredPOSRs)
549-
if (auto Err = registerPerObjectSections(D))
549+
if (auto Err = ES.callSPSWrapper<void(
550+
SPSELFPerObjectSectionsToRegister)>(
551+
orc_rt_elfnix_register_object_sections, D))
550552
return Err;
551553

552554
for (auto KV : JDBootstrapStates) {
@@ -563,20 +565,22 @@ Error ELFNixPlatform::bootstrapELFNixRuntime(JITDylib &PlatformJD) {
563565
}
564566

565567
Error ELFNixPlatform::registerPerObjectSections(
566-
const ELFPerObjectSectionsToRegister &POSR) {
568+
jitlink::LinkGraph &G, const ELFPerObjectSectionsToRegister &POSR) {
567569

568570
if (!orc_rt_elfnix_register_object_sections)
569571
return make_error<StringError>("Attempting to register per-object "
570572
"sections, but runtime support has not "
571573
"been loaded yet",
572574
inconvertibleErrorCode());
573575

574-
Error ErrResult = Error::success();
575-
if (auto Err = ES.callSPSWrapper<shared::SPSError(
576-
SPSELFPerObjectSectionsToRegister)>(
577-
orc_rt_elfnix_register_object_sections, ErrResult, POSR))
578-
return Err;
579-
return ErrResult;
576+
using SPSRegisterObjSectionsArgs = SPSArgList<SPSELFPerObjectSectionsToRegister>;
577+
G.allocActions().push_back(
578+
{cantFail(WrapperFunctionCall::Create<SPSRegisterObjSectionsArgs>(
579+
orc_rt_elfnix_register_object_sections, POSR)),
580+
cantFail(WrapperFunctionCall::Create<SPSRegisterObjSectionsArgs>(
581+
orc_rt_elfnix_deregister_object_sections, POSR))});
582+
583+
return Error::success();
580584
}
581585

582586
Expected<uint64_t> ELFNixPlatform::createPThreadKey() {
@@ -738,7 +742,7 @@ void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
738742
}
739743

740744
// Otherwise register it immediately.
741-
if (auto Err = MP.registerPerObjectSections(POSR))
745+
if (auto Err = MP.registerPerObjectSections(G,POSR))
742746
return Err;
743747
}
744748

0 commit comments

Comments
 (0)