mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Add support for custom names for library functions in TargetLibraryInfo. Add a custom name for fwrite and fputs on x86-32 OSX. Make SimplifyLibCalls honor the custom
names for fwrite and fputs. Fixes <rdar://problem/9815881>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144876 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,6 +20,19 @@ INITIALIZE_PASS(TargetLibraryInfo, "targetlibinfo",
|
||||
"Target Library Information", false, true)
|
||||
char TargetLibraryInfo::ID = 0;
|
||||
|
||||
const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
|
||||
{
|
||||
"memset",
|
||||
"memcpy",
|
||||
"memmove",
|
||||
"memset_pattern16",
|
||||
"iprintf",
|
||||
"siprintf",
|
||||
"fiprintf",
|
||||
"fwrite",
|
||||
"fputs"
|
||||
};
|
||||
|
||||
/// initialize - Initialize the set of available library functions based on the
|
||||
/// specified target triple. This should be carefully written so that a missing
|
||||
/// target triple gets a sane set of defaults.
|
||||
@@ -38,6 +51,17 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T) {
|
||||
TLI.setUnavailable(LibFunc::memset_pattern16);
|
||||
}
|
||||
|
||||
if (T.isMacOSX() && T.getArch() == Triple::x86 &&
|
||||
!T.isMacOSXVersionLT(10, 7)) {
|
||||
// x86-32 OSX has a scheme where fwrite and fputs (and some other functions
|
||||
// we don't care about) have two versions; on recent OSX, the one we want
|
||||
// has a $UNIX2003 suffix. The two implementations are identical except
|
||||
// for the return value in some edge cases. However, we don't want to
|
||||
// generate code that depends on the old symbols.
|
||||
TLI.setAvailableWithName(LibFunc::fwrite, "fwrite$UNIX2003");
|
||||
TLI.setAvailableWithName(LibFunc::fputs, "fputs$UNIX2003");
|
||||
}
|
||||
|
||||
// iprintf and friends are only available on XCore and TCE.
|
||||
if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) {
|
||||
TLI.setUnavailable(LibFunc::iprintf);
|
||||
@@ -64,6 +88,7 @@ TargetLibraryInfo::TargetLibraryInfo(const Triple &T) : ImmutablePass(ID) {
|
||||
TargetLibraryInfo::TargetLibraryInfo(const TargetLibraryInfo &TLI)
|
||||
: ImmutablePass(ID) {
|
||||
memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
|
||||
CustomNames = TLI.CustomNames;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user