[MinGW] Mark a number of library functions unavailable for mingw targets

These functions were marked unavailable for MSVC targets before,
within an "T.isOSWindows() && !T.isOSCygMing()" block, but these ones
are unavailable on MinGW targets too.

This avoids generating calls to stpcpy for MinGW targets, which has
been happening since 6dbf0cfcf7 (in
some cases).

This fixes https://github.com/mstorsjo/llvm-mingw/issues/201.

Differential Revision: https://reviews.llvm.org/D102946
This commit is contained in:
Martin Storsjö 2021-05-21 00:47:39 +03:00
parent b604301be3
commit c5638a71d8
2 changed files with 27 additions and 22 deletions

View File

@ -352,59 +352,63 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
// Win32 does not support these functions, but
// they are generally available on POSIX-compliant systems.
TLI.setUnavailable(LibFunc_access);
TLI.setUnavailable(LibFunc_chmod);
TLI.setUnavailable(LibFunc_closedir);
TLI.setUnavailable(LibFunc_fdopen);
TLI.setUnavailable(LibFunc_fileno);
TLI.setUnavailable(LibFunc_fseeko);
TLI.setUnavailable(LibFunc_fstat);
TLI.setUnavailable(LibFunc_ftello);
TLI.setUnavailable(LibFunc_gettimeofday);
TLI.setUnavailable(LibFunc_memccpy);
TLI.setUnavailable(LibFunc_mkdir);
TLI.setUnavailable(LibFunc_open);
TLI.setUnavailable(LibFunc_opendir);
TLI.setUnavailable(LibFunc_pclose);
TLI.setUnavailable(LibFunc_popen);
TLI.setUnavailable(LibFunc_read);
TLI.setUnavailable(LibFunc_rmdir);
TLI.setUnavailable(LibFunc_stat);
TLI.setUnavailable(LibFunc_strcasecmp);
TLI.setUnavailable(LibFunc_strncasecmp);
TLI.setUnavailable(LibFunc_unlink);
TLI.setUnavailable(LibFunc_utime);
TLI.setUnavailable(LibFunc_write);
}
if (T.isOSWindows() && !T.isWindowsCygwinEnvironment()) {
// These functions aren't available in either MSVC or MinGW environments.
TLI.setUnavailable(LibFunc_bcmp);
TLI.setUnavailable(LibFunc_bcopy);
TLI.setUnavailable(LibFunc_bzero);
TLI.setUnavailable(LibFunc_chmod);
TLI.setUnavailable(LibFunc_chown);
TLI.setUnavailable(LibFunc_closedir);
TLI.setUnavailable(LibFunc_ctermid);
TLI.setUnavailable(LibFunc_fdopen);
TLI.setUnavailable(LibFunc_ffs);
TLI.setUnavailable(LibFunc_fileno);
TLI.setUnavailable(LibFunc_flockfile);
TLI.setUnavailable(LibFunc_fseeko);
TLI.setUnavailable(LibFunc_fstat);
TLI.setUnavailable(LibFunc_fstatvfs);
TLI.setUnavailable(LibFunc_ftello);
TLI.setUnavailable(LibFunc_ftrylockfile);
TLI.setUnavailable(LibFunc_funlockfile);
TLI.setUnavailable(LibFunc_getitimer);
TLI.setUnavailable(LibFunc_getlogin_r);
TLI.setUnavailable(LibFunc_getpwnam);
TLI.setUnavailable(LibFunc_gettimeofday);
TLI.setUnavailable(LibFunc_htonl);
TLI.setUnavailable(LibFunc_htons);
TLI.setUnavailable(LibFunc_lchown);
TLI.setUnavailable(LibFunc_lstat);
TLI.setUnavailable(LibFunc_memccpy);
TLI.setUnavailable(LibFunc_mkdir);
TLI.setUnavailable(LibFunc_ntohl);
TLI.setUnavailable(LibFunc_ntohs);
TLI.setUnavailable(LibFunc_open);
TLI.setUnavailable(LibFunc_opendir);
TLI.setUnavailable(LibFunc_pclose);
TLI.setUnavailable(LibFunc_popen);
TLI.setUnavailable(LibFunc_pread);
TLI.setUnavailable(LibFunc_pwrite);
TLI.setUnavailable(LibFunc_read);
TLI.setUnavailable(LibFunc_readlink);
TLI.setUnavailable(LibFunc_realpath);
TLI.setUnavailable(LibFunc_rmdir);
TLI.setUnavailable(LibFunc_setitimer);
TLI.setUnavailable(LibFunc_stat);
TLI.setUnavailable(LibFunc_statvfs);
TLI.setUnavailable(LibFunc_stpcpy);
TLI.setUnavailable(LibFunc_stpncpy);
TLI.setUnavailable(LibFunc_strcasecmp);
TLI.setUnavailable(LibFunc_strncasecmp);
TLI.setUnavailable(LibFunc_times);
TLI.setUnavailable(LibFunc_uname);
TLI.setUnavailable(LibFunc_unlink);
TLI.setUnavailable(LibFunc_unsetenv);
TLI.setUnavailable(LibFunc_utime);
TLI.setUnavailable(LibFunc_utimes);
TLI.setUnavailable(LibFunc_write);
}
switch (T.getOS()) {

View File

@ -4,6 +4,7 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefixes=CHECK,CHECK-IPRINTF
; RUN: opt < %s -mtriple=i386-pc-windows-msvc -instcombine -S | FileCheck %s --check-prefixes=CHECK,WIN
; RUN: opt < %s -mtriple=i386-mingw32 -instcombine -S | FileCheck %s --check-prefixes=CHECK,WIN
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"