From b0984715381cb5418737f6968e5a7f6f2b69097d Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Wed, 18 May 2011 23:53:21 +0000 Subject: Objective C functions may use a magic '\1' on the name. Handle that when dealing with them in the MCJIT. llvm-svn: 131601 --- llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp | 7 ++++++- llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'llvm/lib/ExecutionEngine') diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 8adebf3932f..96e5c6803a6 100644 --- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -102,7 +102,12 @@ void *MCJIT::getPointerToFunction(Function *F) { return Addr; } - Twine Name = TM->getMCAsmInfo()->getGlobalPrefix() + F->getName(); + // FIXME: Should we be using the mangler for this? Probably. + StringRef BaseName = F->getName(); + if (BaseName[0] == '\1') + BaseName = BaseName.substr(1); + else + Twine Name = TM->getMCAsmInfo()->getGlobalPrefix() + BaseName; return (void*)Dyld.getSymbolAddress(Name.str()); } diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h b/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h index 6cc89e057a9..40bc031a077 100644 --- a/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h +++ b/llvm/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h @@ -36,6 +36,11 @@ public: // prefix. if (Name[0] == '_') ++Name; Function *F = M->getFunction(Name); + // Some ObjC names have a prefixed \01 in the IR. If we failed to find + // the symbol and it's of the ObjC conventions (starts with "-"), try + // prepending a \01 and see if we can find it that way. + if (!F && Name[0] == '-') + F = M->getFunction((Twine("\1") + Name).str()); assert(F && "No matching function in JIT IR Module!"); return JMM->startFunctionBody(F, Size); } @@ -48,6 +53,11 @@ public: // prefix. if (Name[0] == '_') ++Name; Function *F = M->getFunction(Name); + // Some ObjC names have a prefixed \01 in the IR. If we failed to find + // the symbol and it's of the ObjC conventions (starts with "-"), try + // prepending a \01 and see if we can find it that way. + if (!F && Name[0] == '-') + F = M->getFunction((Twine("\1") + Name).str()); assert(F && "No matching function in JIT IR Module!"); JMM->endFunctionBody(F, FunctionStart, FunctionEnd); } -- cgit v1.2.3