@@ -597,6 +597,14 @@ Function *AArch64Arm64ECCallLowering::buildEntryThunk(Function *F) {
597
597
return Thunk;
598
598
}
599
599
600
+ std::optional<std::string> getArm64ECMangledFunctionName (GlobalValue &GV) {
601
+ if (!GV.hasName ()) {
602
+ GV.setName (" __unnamed" );
603
+ }
604
+
605
+ return llvm::getArm64ECMangledFunctionName (GV.getName ());
606
+ }
607
+
600
608
// Builds the "guest exit thunk", a helper to call a function which may or may
601
609
// not be an exit thunk. (We optimistically assume non-dllimport function
602
610
// declarations refer to functions defined in AArch64 code; if the linker
@@ -608,7 +616,7 @@ Function *AArch64Arm64ECCallLowering::buildGuestExitThunk(Function *F) {
608
616
getThunkType (F->getFunctionType (), F->getAttributes (),
609
617
Arm64ECThunkType::GuestExit, NullThunkName, Arm64Ty, X64Ty,
610
618
ArgTranslations);
611
- auto MangledName = getArm64ECMangledFunctionName (F-> getName (). str () );
619
+ auto MangledName = getArm64ECMangledFunctionName (*F );
612
620
assert (MangledName && " Can't guest exit to function that's already native" );
613
621
std::string ThunkName = *MangledName;
614
622
if (ThunkName[0 ] == ' ?' && ThunkName.find (" @" ) != std::string::npos) {
@@ -790,7 +798,7 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
790
798
if (!F)
791
799
continue ;
792
800
if (std::optional<std::string> MangledName =
793
- getArm64ECMangledFunctionName (A. getName (). str () )) {
801
+ getArm64ECMangledFunctionName (A)) {
794
802
F->addMetadata (" arm64ec_unmangled_name" ,
795
803
*MDNode::get (M->getContext (),
796
804
MDString::get (M->getContext (), A.getName ())));
@@ -807,7 +815,7 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
807
815
cast<GlobalValue>(F.getPersonalityFn ()->stripPointerCasts ());
808
816
if (PersFn->getValueType () && PersFn->getValueType ()->isFunctionTy ()) {
809
817
if (std::optional<std::string> MangledName =
810
- getArm64ECMangledFunctionName (PersFn-> getName (). str () )) {
818
+ getArm64ECMangledFunctionName (* PersFn)) {
811
819
PersFn->setName (MangledName.value ());
812
820
}
813
821
}
@@ -821,7 +829,7 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
821
829
// Rename hybrid patchable functions and change callers to use a global
822
830
// alias instead.
823
831
if (std::optional<std::string> MangledName =
824
- getArm64ECMangledFunctionName (F. getName (). str () )) {
832
+ getArm64ECMangledFunctionName (F)) {
825
833
std::string OrigName (F.getName ());
826
834
F.setName (MangledName.value () + HybridPatchableTargetSuffix);
827
835
@@ -926,7 +934,7 @@ bool AArch64Arm64ECCallLowering::processFunction(
926
934
// FIXME: Handle functions with weak linkage?
927
935
if (!F.hasLocalLinkage () || F.hasAddressTaken ()) {
928
936
if (std::optional<std::string> MangledName =
929
- getArm64ECMangledFunctionName (F. getName (). str () )) {
937
+ getArm64ECMangledFunctionName (F)) {
930
938
F.addMetadata (" arm64ec_unmangled_name" ,
931
939
*MDNode::get (M->getContext (),
932
940
MDString::get (M->getContext (), F.getName ())));
0 commit comments