2011-02-19 05:50:34 +08:00
|
|
|
//===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the TargetLibraryInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-01-15 10:16:27 +08:00
|
|
|
#include "llvm/Analysis/TargetLibraryInfo.h"
|
2011-02-19 05:50:34 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
const char* TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =
|
2011-11-17 09:27:36 +08:00
|
|
|
{
|
2013-03-06 05:47:40 +08:00
|
|
|
"_IO_getc",
|
|
|
|
"_IO_putc",
|
2012-08-29 23:32:21 +08:00
|
|
|
"_ZdaPv",
|
2013-07-22 07:11:42 +08:00
|
|
|
"_ZdaPvRKSt9nothrow_t",
|
2014-10-04 04:17:06 +08:00
|
|
|
"_ZdaPvj",
|
|
|
|
"_ZdaPvm",
|
2012-08-29 23:32:21 +08:00
|
|
|
"_ZdlPv",
|
2013-07-22 07:11:42 +08:00
|
|
|
"_ZdlPvRKSt9nothrow_t",
|
2014-10-04 04:17:06 +08:00
|
|
|
"_ZdlPvj",
|
|
|
|
"_ZdlPvm",
|
2012-08-29 23:32:21 +08:00
|
|
|
"_Znaj",
|
|
|
|
"_ZnajRKSt9nothrow_t",
|
|
|
|
"_Znam",
|
|
|
|
"_ZnamRKSt9nothrow_t",
|
|
|
|
"_Znwj",
|
|
|
|
"_ZnwjRKSt9nothrow_t",
|
|
|
|
"_Znwm",
|
|
|
|
"_ZnwmRKSt9nothrow_t",
|
2013-11-03 14:48:38 +08:00
|
|
|
"__cospi",
|
|
|
|
"__cospif",
|
2012-08-03 12:06:22 +08:00
|
|
|
"__cxa_atexit",
|
|
|
|
"__cxa_guard_abort",
|
|
|
|
"__cxa_guard_acquire",
|
|
|
|
"__cxa_guard_release",
|
2013-03-06 05:47:40 +08:00
|
|
|
"__isoc99_scanf",
|
|
|
|
"__isoc99_sscanf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"__memcpy_chk",
|
2014-11-13 05:23:34 +08:00
|
|
|
"__memmove_chk",
|
|
|
|
"__memset_chk",
|
2013-11-03 14:48:38 +08:00
|
|
|
"__sincospi_stret",
|
2014-02-05 00:28:20 +08:00
|
|
|
"__sincospif_stret",
|
2013-11-03 14:48:38 +08:00
|
|
|
"__sinpi",
|
|
|
|
"__sinpif",
|
2013-05-27 23:44:35 +08:00
|
|
|
"__sqrt_finite",
|
|
|
|
"__sqrtf_finite",
|
|
|
|
"__sqrtl_finite",
|
2014-11-13 05:23:34 +08:00
|
|
|
"__stpcpy_chk",
|
|
|
|
"__stpncpy_chk",
|
|
|
|
"__strcpy_chk",
|
2013-03-06 05:47:40 +08:00
|
|
|
"__strdup",
|
2014-11-13 05:23:34 +08:00
|
|
|
"__strncpy_chk",
|
2013-03-06 05:47:40 +08:00
|
|
|
"__strndup",
|
|
|
|
"__strtok_r",
|
2012-11-22 23:36:42 +08:00
|
|
|
"abs",
|
2013-03-06 05:47:40 +08:00
|
|
|
"access",
|
2011-12-01 03:19:00 +08:00
|
|
|
"acos",
|
|
|
|
"acosf",
|
2012-08-22 07:28:56 +08:00
|
|
|
"acosh",
|
|
|
|
"acoshf",
|
|
|
|
"acoshl",
|
2012-08-03 12:06:22 +08:00
|
|
|
"acosl",
|
2011-12-01 03:19:00 +08:00
|
|
|
"asin",
|
|
|
|
"asinf",
|
2012-08-22 07:28:56 +08:00
|
|
|
"asinh",
|
|
|
|
"asinhf",
|
|
|
|
"asinhl",
|
2012-08-03 12:06:22 +08:00
|
|
|
"asinl",
|
2011-12-01 03:19:00 +08:00
|
|
|
"atan",
|
2011-12-02 01:54:37 +08:00
|
|
|
"atan2",
|
|
|
|
"atan2f",
|
2012-08-03 12:06:22 +08:00
|
|
|
"atan2l",
|
|
|
|
"atanf",
|
2012-08-22 07:28:56 +08:00
|
|
|
"atanh",
|
|
|
|
"atanhf",
|
|
|
|
"atanhl",
|
2012-08-03 12:06:22 +08:00
|
|
|
"atanl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"atof",
|
|
|
|
"atoi",
|
|
|
|
"atol",
|
|
|
|
"atoll",
|
|
|
|
"bcmp",
|
|
|
|
"bcopy",
|
|
|
|
"bzero",
|
2012-08-29 23:32:21 +08:00
|
|
|
"calloc",
|
2012-08-22 07:28:56 +08:00
|
|
|
"cbrt",
|
|
|
|
"cbrtf",
|
|
|
|
"cbrtl",
|
2011-12-01 03:19:00 +08:00
|
|
|
"ceil",
|
|
|
|
"ceilf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"ceill",
|
2013-03-06 05:47:40 +08:00
|
|
|
"chmod",
|
|
|
|
"chown",
|
|
|
|
"clearerr",
|
|
|
|
"closedir",
|
2011-12-09 06:15:21 +08:00
|
|
|
"copysign",
|
|
|
|
"copysignf",
|
|
|
|
"copysignl",
|
2011-12-01 03:19:00 +08:00
|
|
|
"cos",
|
|
|
|
"cosf",
|
|
|
|
"cosh",
|
|
|
|
"coshf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"coshl",
|
|
|
|
"cosl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"ctermid",
|
2011-12-01 03:19:00 +08:00
|
|
|
"exp",
|
2012-08-22 07:28:56 +08:00
|
|
|
"exp10",
|
|
|
|
"exp10f",
|
|
|
|
"exp10l",
|
2011-12-01 03:19:00 +08:00
|
|
|
"exp2",
|
|
|
|
"exp2f",
|
2012-08-03 12:06:22 +08:00
|
|
|
"exp2l",
|
|
|
|
"expf",
|
|
|
|
"expl",
|
2011-12-01 03:19:00 +08:00
|
|
|
"expm1",
|
2012-04-18 07:05:54 +08:00
|
|
|
"expm1f",
|
2012-08-03 12:06:22 +08:00
|
|
|
"expm1l",
|
2011-12-01 03:19:00 +08:00
|
|
|
"fabs",
|
|
|
|
"fabsf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"fabsl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"fclose",
|
|
|
|
"fdopen",
|
|
|
|
"feof",
|
|
|
|
"ferror",
|
|
|
|
"fflush",
|
2012-11-22 23:36:42 +08:00
|
|
|
"ffs",
|
|
|
|
"ffsl",
|
|
|
|
"ffsll",
|
2013-03-06 05:47:40 +08:00
|
|
|
"fgetc",
|
|
|
|
"fgetpos",
|
|
|
|
"fgets",
|
|
|
|
"fileno",
|
2012-08-03 12:06:22 +08:00
|
|
|
"fiprintf",
|
2013-03-06 05:47:40 +08:00
|
|
|
"flockfile",
|
2011-12-01 03:19:00 +08:00
|
|
|
"floor",
|
|
|
|
"floorf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"floorl",
|
2013-12-17 06:42:40 +08:00
|
|
|
"fmax",
|
|
|
|
"fmaxf",
|
|
|
|
"fmaxl",
|
|
|
|
"fmin",
|
|
|
|
"fminf",
|
|
|
|
"fminl",
|
2011-12-02 01:54:37 +08:00
|
|
|
"fmod",
|
|
|
|
"fmodf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"fmodl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"fopen",
|
|
|
|
"fopen64",
|
2012-11-22 23:36:42 +08:00
|
|
|
"fprintf",
|
2012-07-25 05:00:36 +08:00
|
|
|
"fputc",
|
2011-11-30 09:51:49 +08:00
|
|
|
"fputs",
|
2013-03-06 05:47:40 +08:00
|
|
|
"fread",
|
2012-08-29 23:32:21 +08:00
|
|
|
"free",
|
2013-03-06 05:47:40 +08:00
|
|
|
"frexp",
|
|
|
|
"frexpf",
|
|
|
|
"frexpl",
|
|
|
|
"fscanf",
|
|
|
|
"fseek",
|
|
|
|
"fseeko",
|
|
|
|
"fseeko64",
|
|
|
|
"fsetpos",
|
|
|
|
"fstat",
|
|
|
|
"fstat64",
|
|
|
|
"fstatvfs",
|
|
|
|
"fstatvfs64",
|
|
|
|
"ftell",
|
|
|
|
"ftello",
|
|
|
|
"ftello64",
|
|
|
|
"ftrylockfile",
|
|
|
|
"funlockfile",
|
2011-11-30 09:51:49 +08:00
|
|
|
"fwrite",
|
2013-03-06 05:47:40 +08:00
|
|
|
"getc",
|
|
|
|
"getc_unlocked",
|
|
|
|
"getchar",
|
|
|
|
"getenv",
|
|
|
|
"getitimer",
|
|
|
|
"getlogin_r",
|
|
|
|
"getpwnam",
|
|
|
|
"gets",
|
2013-07-03 12:00:51 +08:00
|
|
|
"gettimeofday",
|
2013-03-06 05:47:40 +08:00
|
|
|
"htonl",
|
|
|
|
"htons",
|
2011-11-30 09:51:49 +08:00
|
|
|
"iprintf",
|
2012-11-22 23:36:42 +08:00
|
|
|
"isascii",
|
|
|
|
"isdigit",
|
|
|
|
"labs",
|
2013-03-06 05:47:40 +08:00
|
|
|
"lchown",
|
2014-02-05 04:27:23 +08:00
|
|
|
"ldexp",
|
|
|
|
"ldexpf",
|
|
|
|
"ldexpl",
|
2012-11-22 23:36:42 +08:00
|
|
|
"llabs",
|
2011-12-01 03:19:00 +08:00
|
|
|
"log",
|
|
|
|
"log10",
|
|
|
|
"log10f",
|
2012-08-03 12:06:22 +08:00
|
|
|
"log10l",
|
2011-12-01 03:19:00 +08:00
|
|
|
"log1p",
|
|
|
|
"log1pf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"log1pl",
|
|
|
|
"log2",
|
|
|
|
"log2f",
|
|
|
|
"log2l",
|
2012-08-22 07:28:56 +08:00
|
|
|
"logb",
|
|
|
|
"logbf",
|
|
|
|
"logbl",
|
2012-08-03 12:06:22 +08:00
|
|
|
"logf",
|
|
|
|
"logl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"lstat",
|
|
|
|
"lstat64",
|
2012-08-29 23:32:21 +08:00
|
|
|
"malloc",
|
2013-03-06 05:47:40 +08:00
|
|
|
"memalign",
|
|
|
|
"memccpy",
|
2012-07-25 05:00:36 +08:00
|
|
|
"memchr",
|
|
|
|
"memcmp",
|
2011-11-17 09:27:36 +08:00
|
|
|
"memcpy",
|
|
|
|
"memmove",
|
2013-03-06 05:47:40 +08:00
|
|
|
"memrchr",
|
2011-11-30 09:51:49 +08:00
|
|
|
"memset",
|
2011-11-17 09:27:36 +08:00
|
|
|
"memset_pattern16",
|
2013-03-06 05:47:40 +08:00
|
|
|
"mkdir",
|
|
|
|
"mktime",
|
|
|
|
"modf",
|
|
|
|
"modff",
|
|
|
|
"modfl",
|
2011-12-09 06:15:21 +08:00
|
|
|
"nearbyint",
|
|
|
|
"nearbyintf",
|
|
|
|
"nearbyintl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"ntohl",
|
|
|
|
"ntohs",
|
|
|
|
"open",
|
|
|
|
"open64",
|
|
|
|
"opendir",
|
|
|
|
"pclose",
|
|
|
|
"perror",
|
|
|
|
"popen",
|
2012-08-29 23:32:21 +08:00
|
|
|
"posix_memalign",
|
2011-12-01 03:19:00 +08:00
|
|
|
"pow",
|
|
|
|
"powf",
|
|
|
|
"powl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"pread",
|
2012-11-22 23:36:42 +08:00
|
|
|
"printf",
|
2013-03-06 05:47:40 +08:00
|
|
|
"putc",
|
2012-07-25 05:00:36 +08:00
|
|
|
"putchar",
|
|
|
|
"puts",
|
2013-03-06 05:47:40 +08:00
|
|
|
"pwrite",
|
|
|
|
"qsort",
|
|
|
|
"read",
|
|
|
|
"readlink",
|
2012-08-29 23:32:21 +08:00
|
|
|
"realloc",
|
|
|
|
"reallocf",
|
2013-03-06 05:47:40 +08:00
|
|
|
"realpath",
|
|
|
|
"remove",
|
|
|
|
"rename",
|
|
|
|
"rewind",
|
2011-12-09 06:15:21 +08:00
|
|
|
"rint",
|
|
|
|
"rintf",
|
|
|
|
"rintl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"rmdir",
|
2012-04-18 07:05:54 +08:00
|
|
|
"round",
|
|
|
|
"roundf",
|
|
|
|
"roundl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"scanf",
|
|
|
|
"setbuf",
|
|
|
|
"setitimer",
|
|
|
|
"setvbuf",
|
2011-12-02 01:54:37 +08:00
|
|
|
"sin",
|
|
|
|
"sinf",
|
2011-12-02 02:26:19 +08:00
|
|
|
"sinh",
|
|
|
|
"sinhf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"sinhl",
|
|
|
|
"sinl",
|
2011-12-02 02:26:19 +08:00
|
|
|
"siprintf",
|
2013-03-06 05:47:40 +08:00
|
|
|
"snprintf",
|
2012-11-22 23:36:42 +08:00
|
|
|
"sprintf",
|
2011-11-30 07:57:10 +08:00
|
|
|
"sqrt",
|
2011-12-02 01:54:37 +08:00
|
|
|
"sqrtf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"sqrtl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"sscanf",
|
|
|
|
"stat",
|
|
|
|
"stat64",
|
|
|
|
"statvfs",
|
|
|
|
"statvfs64",
|
2012-11-10 11:11:06 +08:00
|
|
|
"stpcpy",
|
2013-03-06 05:47:40 +08:00
|
|
|
"stpncpy",
|
|
|
|
"strcasecmp",
|
2012-07-25 01:25:06 +08:00
|
|
|
"strcat",
|
2012-07-25 05:00:36 +08:00
|
|
|
"strchr",
|
2012-11-10 11:11:06 +08:00
|
|
|
"strcmp",
|
2013-03-06 05:47:40 +08:00
|
|
|
"strcoll",
|
2012-07-25 01:25:06 +08:00
|
|
|
"strcpy",
|
2012-11-10 11:11:06 +08:00
|
|
|
"strcspn",
|
2012-08-29 23:32:21 +08:00
|
|
|
"strdup",
|
2012-07-25 01:25:06 +08:00
|
|
|
"strlen",
|
2013-03-06 05:47:40 +08:00
|
|
|
"strncasecmp",
|
2012-07-25 01:25:06 +08:00
|
|
|
"strncat",
|
2012-07-25 05:00:36 +08:00
|
|
|
"strncmp",
|
2012-07-25 01:25:06 +08:00
|
|
|
"strncpy",
|
2012-08-29 23:32:21 +08:00
|
|
|
"strndup",
|
2012-07-25 01:25:06 +08:00
|
|
|
"strnlen",
|
2012-11-10 11:11:06 +08:00
|
|
|
"strpbrk",
|
|
|
|
"strrchr",
|
|
|
|
"strspn",
|
|
|
|
"strstr",
|
|
|
|
"strtod",
|
|
|
|
"strtof",
|
2013-03-06 05:47:40 +08:00
|
|
|
"strtok",
|
|
|
|
"strtok_r",
|
2012-11-10 11:11:06 +08:00
|
|
|
"strtol",
|
|
|
|
"strtold",
|
|
|
|
"strtoll",
|
|
|
|
"strtoul",
|
|
|
|
"strtoull",
|
2013-03-06 05:47:40 +08:00
|
|
|
"strxfrm",
|
|
|
|
"system",
|
2011-12-02 01:54:37 +08:00
|
|
|
"tan",
|
|
|
|
"tanf",
|
|
|
|
"tanh",
|
2011-12-09 06:15:21 +08:00
|
|
|
"tanhf",
|
2012-08-03 12:06:22 +08:00
|
|
|
"tanhl",
|
|
|
|
"tanl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"times",
|
|
|
|
"tmpfile",
|
|
|
|
"tmpfile64",
|
2012-11-22 23:36:42 +08:00
|
|
|
"toascii",
|
2011-12-09 06:15:21 +08:00
|
|
|
"trunc",
|
|
|
|
"truncf",
|
2012-08-29 23:32:21 +08:00
|
|
|
"truncl",
|
2013-03-06 05:47:40 +08:00
|
|
|
"uname",
|
|
|
|
"ungetc",
|
|
|
|
"unlink",
|
|
|
|
"unsetenv",
|
|
|
|
"utime",
|
|
|
|
"utimes",
|
|
|
|
"valloc",
|
|
|
|
"vfprintf",
|
|
|
|
"vfscanf",
|
|
|
|
"vprintf",
|
|
|
|
"vscanf",
|
|
|
|
"vsnprintf",
|
|
|
|
"vsprintf",
|
|
|
|
"vsscanf",
|
|
|
|
"write"
|
2011-11-17 09:27:36 +08:00
|
|
|
};
|
|
|
|
|
2013-11-03 14:48:38 +08:00
|
|
|
static bool hasSinCosPiStret(const Triple &T) {
|
|
|
|
// Only Darwin variants have _stret versions of combined trig functions.
|
2014-10-09 13:43:30 +08:00
|
|
|
if (!T.isOSDarwin())
|
2013-11-03 14:48:38 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// The ABI is rather complicated on x86, so don't do anything special there.
|
|
|
|
if (T.getArch() == Triple::x86)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (T.isMacOSX() && T.isMacOSXVersionLT(10, 9))
|
|
|
|
return false;
|
|
|
|
|
2014-10-09 13:43:30 +08:00
|
|
|
if (T.isiOS() && T.isOSVersionLT(7, 0))
|
2013-11-03 14:48:38 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-02-19 05:50:34 +08:00
|
|
|
/// 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.
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
|
2012-08-03 12:06:22 +08:00
|
|
|
const char **StandardNames) {
|
|
|
|
#ifndef NDEBUG
|
|
|
|
// Verify that the StandardNames array is in alphabetical order.
|
|
|
|
for (unsigned F = 1; F < LibFunc::NumLibFuncs; ++F) {
|
|
|
|
if (strcmp(StandardNames[F-1], StandardNames[F]) >= 0)
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
llvm_unreachable("TargetLibraryInfoImpl function names must be sorted");
|
2012-08-03 12:06:22 +08:00
|
|
|
}
|
|
|
|
#endif // !NDEBUG
|
2014-04-03 03:53:29 +08:00
|
|
|
|
2015-01-07 09:17:37 +08:00
|
|
|
// There are no library implementations of mempcy and memset for AMD gpus and
|
2014-04-03 03:53:29 +08:00
|
|
|
// these can be difficult to lower in the backend.
|
2015-01-07 09:17:37 +08:00
|
|
|
if (T.getArch() == Triple::r600 ||
|
|
|
|
T.getArch() == Triple::amdgcn) {
|
2014-04-03 03:53:29 +08:00
|
|
|
TLI.setUnavailable(LibFunc::memcpy);
|
|
|
|
TLI.setUnavailable(LibFunc::memset);
|
|
|
|
TLI.setUnavailable(LibFunc::memset_pattern16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-08 02:08:54 +08:00
|
|
|
// memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
|
2011-04-20 08:14:25 +08:00
|
|
|
if (T.isMacOSX()) {
|
|
|
|
if (T.isMacOSXVersionLT(10, 5))
|
2011-04-20 04:44:08 +08:00
|
|
|
TLI.setUnavailable(LibFunc::memset_pattern16);
|
2013-08-30 04:23:14 +08:00
|
|
|
} else if (T.isiOS()) {
|
2011-04-20 04:44:08 +08:00
|
|
|
if (T.isOSVersionLT(3, 0))
|
|
|
|
TLI.setUnavailable(LibFunc::memset_pattern16);
|
|
|
|
} else {
|
2011-02-19 05:50:34 +08:00
|
|
|
TLI.setUnavailable(LibFunc::memset_pattern16);
|
2011-04-20 04:44:08 +08:00
|
|
|
}
|
2011-03-03 21:17:51 +08:00
|
|
|
|
2013-11-03 14:48:38 +08:00
|
|
|
if (!hasSinCosPiStret(T)) {
|
|
|
|
TLI.setUnavailable(LibFunc::sinpi);
|
|
|
|
TLI.setUnavailable(LibFunc::sinpif);
|
|
|
|
TLI.setUnavailable(LibFunc::cospi);
|
|
|
|
TLI.setUnavailable(LibFunc::cospif);
|
|
|
|
TLI.setUnavailable(LibFunc::sincospi_stret);
|
2014-02-05 00:28:20 +08:00
|
|
|
TLI.setUnavailable(LibFunc::sincospif_stret);
|
2013-11-03 14:48:38 +08:00
|
|
|
}
|
|
|
|
|
2011-11-17 09:27:36 +08:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2011-06-09 19:11:45 +08:00
|
|
|
// iprintf and friends are only available on XCore and TCE.
|
|
|
|
if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) {
|
2011-03-03 21:17:51 +08:00
|
|
|
TLI.setUnavailable(LibFunc::iprintf);
|
2011-03-03 22:09:28 +08:00
|
|
|
TLI.setUnavailable(LibFunc::siprintf);
|
2011-03-03 22:20:22 +08:00
|
|
|
TLI.setUnavailable(LibFunc::fiprintf);
|
2011-03-03 22:09:28 +08:00
|
|
|
}
|
2012-04-18 07:05:54 +08:00
|
|
|
|
2014-07-25 06:09:06 +08:00
|
|
|
if (T.isOSWindows() && !T.isOSCygMing()) {
|
2012-04-18 07:05:54 +08:00
|
|
|
// Win32 does not support long double
|
|
|
|
TLI.setUnavailable(LibFunc::acosl);
|
|
|
|
TLI.setUnavailable(LibFunc::asinl);
|
|
|
|
TLI.setUnavailable(LibFunc::atanl);
|
|
|
|
TLI.setUnavailable(LibFunc::atan2l);
|
|
|
|
TLI.setUnavailable(LibFunc::ceill);
|
|
|
|
TLI.setUnavailable(LibFunc::copysignl);
|
|
|
|
TLI.setUnavailable(LibFunc::cosl);
|
|
|
|
TLI.setUnavailable(LibFunc::coshl);
|
|
|
|
TLI.setUnavailable(LibFunc::expl);
|
|
|
|
TLI.setUnavailable(LibFunc::fabsf); // Win32 and Win64 both lack fabsf
|
|
|
|
TLI.setUnavailable(LibFunc::fabsl);
|
|
|
|
TLI.setUnavailable(LibFunc::floorl);
|
2013-12-17 06:42:40 +08:00
|
|
|
TLI.setUnavailable(LibFunc::fmaxl);
|
|
|
|
TLI.setUnavailable(LibFunc::fminl);
|
2012-04-18 07:05:54 +08:00
|
|
|
TLI.setUnavailable(LibFunc::fmodl);
|
2013-03-06 05:47:40 +08:00
|
|
|
TLI.setUnavailable(LibFunc::frexpl);
|
2014-02-05 04:27:23 +08:00
|
|
|
TLI.setUnavailable(LibFunc::ldexpf);
|
|
|
|
TLI.setUnavailable(LibFunc::ldexpl);
|
2012-04-18 07:05:54 +08:00
|
|
|
TLI.setUnavailable(LibFunc::logl);
|
2013-03-06 05:47:40 +08:00
|
|
|
TLI.setUnavailable(LibFunc::modfl);
|
2012-04-18 07:05:54 +08:00
|
|
|
TLI.setUnavailable(LibFunc::powl);
|
|
|
|
TLI.setUnavailable(LibFunc::sinl);
|
|
|
|
TLI.setUnavailable(LibFunc::sinhl);
|
|
|
|
TLI.setUnavailable(LibFunc::sqrtl);
|
|
|
|
TLI.setUnavailable(LibFunc::tanl);
|
|
|
|
TLI.setUnavailable(LibFunc::tanhl);
|
|
|
|
|
|
|
|
// Win32 only has C89 math
|
2012-08-22 07:28:56 +08:00
|
|
|
TLI.setUnavailable(LibFunc::acosh);
|
|
|
|
TLI.setUnavailable(LibFunc::acoshf);
|
|
|
|
TLI.setUnavailable(LibFunc::acoshl);
|
|
|
|
TLI.setUnavailable(LibFunc::asinh);
|
|
|
|
TLI.setUnavailable(LibFunc::asinhf);
|
|
|
|
TLI.setUnavailable(LibFunc::asinhl);
|
|
|
|
TLI.setUnavailable(LibFunc::atanh);
|
|
|
|
TLI.setUnavailable(LibFunc::atanhf);
|
|
|
|
TLI.setUnavailable(LibFunc::atanhl);
|
|
|
|
TLI.setUnavailable(LibFunc::cbrt);
|
|
|
|
TLI.setUnavailable(LibFunc::cbrtf);
|
|
|
|
TLI.setUnavailable(LibFunc::cbrtl);
|
2012-04-18 07:05:54 +08:00
|
|
|
TLI.setUnavailable(LibFunc::exp2);
|
|
|
|
TLI.setUnavailable(LibFunc::exp2f);
|
|
|
|
TLI.setUnavailable(LibFunc::exp2l);
|
|
|
|
TLI.setUnavailable(LibFunc::expm1);
|
|
|
|
TLI.setUnavailable(LibFunc::expm1f);
|
|
|
|
TLI.setUnavailable(LibFunc::expm1l);
|
|
|
|
TLI.setUnavailable(LibFunc::log2);
|
|
|
|
TLI.setUnavailable(LibFunc::log2f);
|
|
|
|
TLI.setUnavailable(LibFunc::log2l);
|
|
|
|
TLI.setUnavailable(LibFunc::log1p);
|
|
|
|
TLI.setUnavailable(LibFunc::log1pf);
|
|
|
|
TLI.setUnavailable(LibFunc::log1pl);
|
2012-08-22 07:28:56 +08:00
|
|
|
TLI.setUnavailable(LibFunc::logb);
|
|
|
|
TLI.setUnavailable(LibFunc::logbf);
|
|
|
|
TLI.setUnavailable(LibFunc::logbl);
|
2012-04-18 07:05:54 +08:00
|
|
|
TLI.setUnavailable(LibFunc::nearbyint);
|
|
|
|
TLI.setUnavailable(LibFunc::nearbyintf);
|
|
|
|
TLI.setUnavailable(LibFunc::nearbyintl);
|
|
|
|
TLI.setUnavailable(LibFunc::rint);
|
|
|
|
TLI.setUnavailable(LibFunc::rintf);
|
|
|
|
TLI.setUnavailable(LibFunc::rintl);
|
|
|
|
TLI.setUnavailable(LibFunc::round);
|
|
|
|
TLI.setUnavailable(LibFunc::roundf);
|
|
|
|
TLI.setUnavailable(LibFunc::roundl);
|
|
|
|
TLI.setUnavailable(LibFunc::trunc);
|
|
|
|
TLI.setUnavailable(LibFunc::truncf);
|
|
|
|
TLI.setUnavailable(LibFunc::truncl);
|
|
|
|
|
|
|
|
// Win32 provides some C99 math with mangled names
|
|
|
|
TLI.setAvailableWithName(LibFunc::copysign, "_copysign");
|
|
|
|
|
|
|
|
if (T.getArch() == Triple::x86) {
|
|
|
|
// Win32 on x86 implements single-precision math functions as macros
|
|
|
|
TLI.setUnavailable(LibFunc::acosf);
|
|
|
|
TLI.setUnavailable(LibFunc::asinf);
|
|
|
|
TLI.setUnavailable(LibFunc::atanf);
|
|
|
|
TLI.setUnavailable(LibFunc::atan2f);
|
|
|
|
TLI.setUnavailable(LibFunc::ceilf);
|
|
|
|
TLI.setUnavailable(LibFunc::copysignf);
|
|
|
|
TLI.setUnavailable(LibFunc::cosf);
|
|
|
|
TLI.setUnavailable(LibFunc::coshf);
|
|
|
|
TLI.setUnavailable(LibFunc::expf);
|
|
|
|
TLI.setUnavailable(LibFunc::floorf);
|
2013-12-17 06:42:40 +08:00
|
|
|
TLI.setUnavailable(LibFunc::fminf);
|
|
|
|
TLI.setUnavailable(LibFunc::fmaxf);
|
2012-04-18 07:05:54 +08:00
|
|
|
TLI.setUnavailable(LibFunc::fmodf);
|
|
|
|
TLI.setUnavailable(LibFunc::logf);
|
|
|
|
TLI.setUnavailable(LibFunc::powf);
|
|
|
|
TLI.setUnavailable(LibFunc::sinf);
|
|
|
|
TLI.setUnavailable(LibFunc::sinhf);
|
|
|
|
TLI.setUnavailable(LibFunc::sqrtf);
|
|
|
|
TLI.setUnavailable(LibFunc::tanf);
|
|
|
|
TLI.setUnavailable(LibFunc::tanhf);
|
|
|
|
}
|
2012-11-10 11:11:06 +08:00
|
|
|
|
2013-03-06 05:47:40 +08:00
|
|
|
// Win32 does *not* provide provide these functions, but they are
|
|
|
|
// generally available on POSIX-compliant systems:
|
|
|
|
TLI.setUnavailable(LibFunc::access);
|
|
|
|
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);
|
2012-11-22 23:36:42 +08:00
|
|
|
TLI.setUnavailable(LibFunc::ffs);
|
2013-03-06 05:47:40 +08:00
|
|
|
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::getc_unlocked);
|
|
|
|
TLI.setUnavailable(LibFunc::getitimer);
|
|
|
|
TLI.setUnavailable(LibFunc::getlogin_r);
|
|
|
|
TLI.setUnavailable(LibFunc::getpwnam);
|
2013-07-03 12:00:51 +08:00
|
|
|
TLI.setUnavailable(LibFunc::gettimeofday);
|
2013-03-06 05:47:40 +08:00
|
|
|
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);
|
2012-11-22 23:36:42 +08:00
|
|
|
|
2013-03-06 05:47:40 +08:00
|
|
|
// Win32 does *not* provide provide these functions, but they are
|
|
|
|
// specified by C99:
|
|
|
|
TLI.setUnavailable(LibFunc::atoll);
|
|
|
|
TLI.setUnavailable(LibFunc::frexpf);
|
2012-11-22 23:36:42 +08:00
|
|
|
TLI.setUnavailable(LibFunc::llabs);
|
2013-12-27 03:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (T.getOS()) {
|
|
|
|
case Triple::MacOSX:
|
2013-12-28 10:40:19 +08:00
|
|
|
// exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
|
|
|
|
// and their names are __exp10 and __exp10f. exp10l is not available on
|
|
|
|
// OS X or iOS.
|
2013-12-27 03:17:04 +08:00
|
|
|
TLI.setUnavailable(LibFunc::exp10l);
|
|
|
|
if (T.isMacOSXVersionLT(10, 9)) {
|
|
|
|
TLI.setUnavailable(LibFunc::exp10);
|
|
|
|
TLI.setUnavailable(LibFunc::exp10f);
|
|
|
|
} else {
|
|
|
|
TLI.setAvailableWithName(LibFunc::exp10, "__exp10");
|
|
|
|
TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Triple::IOS:
|
|
|
|
TLI.setUnavailable(LibFunc::exp10l);
|
|
|
|
if (T.isOSVersionLT(7, 0)) {
|
|
|
|
TLI.setUnavailable(LibFunc::exp10);
|
|
|
|
TLI.setUnavailable(LibFunc::exp10f);
|
|
|
|
} else {
|
|
|
|
TLI.setAvailableWithName(LibFunc::exp10, "__exp10");
|
|
|
|
TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f");
|
|
|
|
}
|
|
|
|
break;
|
2013-12-28 10:40:19 +08:00
|
|
|
case Triple::Linux:
|
|
|
|
// exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
|
|
|
|
// buggy prior to glibc version 2.18. Until this version is widely deployed
|
|
|
|
// or we have a reasonable detection strategy, we cannot use exp10 reliably
|
|
|
|
// on Linux.
|
|
|
|
//
|
|
|
|
// Fall through to disable all of them.
|
2013-12-27 03:17:04 +08:00
|
|
|
default:
|
|
|
|
TLI.setUnavailable(LibFunc::exp10);
|
|
|
|
TLI.setUnavailable(LibFunc::exp10f);
|
|
|
|
TLI.setUnavailable(LibFunc::exp10l);
|
2012-11-22 23:36:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
|
|
|
|
// Linux (GLIBC):
|
|
|
|
// http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
|
|
|
|
// http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsl.c
|
|
|
|
// http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
|
|
|
|
switch (T.getOS()) {
|
|
|
|
case Triple::Darwin:
|
|
|
|
case Triple::MacOSX:
|
|
|
|
case Triple::IOS:
|
|
|
|
case Triple::FreeBSD:
|
|
|
|
case Triple::Linux:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
TLI.setUnavailable(LibFunc::ffsl);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ffsll is available on at least FreeBSD and Linux (GLIBC):
|
|
|
|
// http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsll.c
|
|
|
|
// http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
|
|
|
|
switch (T.getOS()) {
|
|
|
|
case Triple::FreeBSD:
|
|
|
|
case Triple::Linux:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
TLI.setUnavailable(LibFunc::ffsll);
|
2012-04-18 07:05:54 +08:00
|
|
|
}
|
2013-03-06 05:47:40 +08:00
|
|
|
|
|
|
|
// The following functions are available on at least Linux:
|
2013-08-30 04:23:14 +08:00
|
|
|
if (!T.isOSLinux()) {
|
2013-03-06 05:47:40 +08:00
|
|
|
TLI.setUnavailable(LibFunc::dunder_strdup);
|
|
|
|
TLI.setUnavailable(LibFunc::dunder_strtok_r);
|
|
|
|
TLI.setUnavailable(LibFunc::dunder_isoc99_scanf);
|
|
|
|
TLI.setUnavailable(LibFunc::dunder_isoc99_sscanf);
|
|
|
|
TLI.setUnavailable(LibFunc::under_IO_getc);
|
|
|
|
TLI.setUnavailable(LibFunc::under_IO_putc);
|
|
|
|
TLI.setUnavailable(LibFunc::memalign);
|
|
|
|
TLI.setUnavailable(LibFunc::fopen64);
|
|
|
|
TLI.setUnavailable(LibFunc::fseeko64);
|
|
|
|
TLI.setUnavailable(LibFunc::fstat64);
|
|
|
|
TLI.setUnavailable(LibFunc::fstatvfs64);
|
|
|
|
TLI.setUnavailable(LibFunc::ftello64);
|
|
|
|
TLI.setUnavailable(LibFunc::lstat64);
|
|
|
|
TLI.setUnavailable(LibFunc::open64);
|
|
|
|
TLI.setUnavailable(LibFunc::stat64);
|
|
|
|
TLI.setUnavailable(LibFunc::statvfs64);
|
|
|
|
TLI.setUnavailable(LibFunc::tmpfile64);
|
|
|
|
}
|
2011-02-19 05:50:34 +08:00
|
|
|
}
|
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
|
2011-02-19 05:50:34 +08:00
|
|
|
// Default to everything being available.
|
|
|
|
memset(AvailableArray, -1, sizeof(AvailableArray));
|
|
|
|
|
2012-08-03 12:06:22 +08:00
|
|
|
initialize(*this, Triple(), StandardNames);
|
2011-02-19 05:50:34 +08:00
|
|
|
}
|
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
|
2011-02-19 05:50:34 +08:00
|
|
|
// Default to everything being available.
|
|
|
|
memset(AvailableArray, -1, sizeof(AvailableArray));
|
2015-01-15 18:41:28 +08:00
|
|
|
|
2012-08-03 12:06:22 +08:00
|
|
|
initialize(*this, T, StandardNames);
|
2011-02-19 05:50:34 +08:00
|
|
|
}
|
2011-02-19 06:34:03 +08:00
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI)
|
2015-01-15 19:39:46 +08:00
|
|
|
: CustomNames(TLI.CustomNames) {
|
2011-05-22 04:09:13 +08:00
|
|
|
memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
|
2015-01-15 19:39:46 +08:00
|
|
|
}
|
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI)
|
2015-01-15 19:39:46 +08:00
|
|
|
: CustomNames(std::move(TLI.CustomNames)) {
|
|
|
|
std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
|
|
|
|
AvailableArray);
|
|
|
|
}
|
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoImpl &TLI) {
|
2011-11-17 09:27:36 +08:00
|
|
|
CustomNames = TLI.CustomNames;
|
2015-01-15 19:39:46 +08:00
|
|
|
memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&TLI) {
|
2015-01-15 19:39:46 +08:00
|
|
|
CustomNames = std::move(TLI.CustomNames);
|
|
|
|
std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
|
|
|
|
AvailableArray);
|
|
|
|
return *this;
|
2011-05-22 04:09:13 +08:00
|
|
|
}
|
|
|
|
|
2013-03-09 21:48:23 +08:00
|
|
|
namespace {
|
|
|
|
struct StringComparator {
|
|
|
|
/// Compare two strings and return true if LHS is lexicographically less than
|
|
|
|
/// RHS. Requires that RHS doesn't contain any zero bytes.
|
|
|
|
bool operator()(const char *LHS, StringRef RHS) const {
|
|
|
|
// Compare prefixes with strncmp. If prefixes match we know that LHS is
|
|
|
|
// greater or equal to RHS as RHS can't contain any '\0'.
|
|
|
|
return std::strncmp(LHS, RHS.data(), RHS.size()) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Provided for compatibility with MSVC's debug mode.
|
|
|
|
bool operator()(StringRef LHS, const char *RHS) const { return LHS < RHS; }
|
|
|
|
bool operator()(StringRef LHS, StringRef RHS) const { return LHS < RHS; }
|
2013-03-13 21:50:47 +08:00
|
|
|
bool operator()(const char *LHS, const char *RHS) const {
|
|
|
|
return std::strcmp(LHS, RHS) < 0;
|
|
|
|
}
|
2013-03-09 21:48:23 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
|
2012-08-03 12:06:22 +08:00
|
|
|
LibFunc::Func &F) const {
|
|
|
|
const char **Start = &StandardNames[0];
|
|
|
|
const char **End = &StandardNames[LibFunc::NumLibFuncs];
|
2013-03-09 21:48:23 +08:00
|
|
|
|
|
|
|
// Filter out empty names and names containing null bytes, those can't be in
|
|
|
|
// our table.
|
|
|
|
if (funcName.empty() || funcName.find('\0') != StringRef::npos)
|
|
|
|
return false;
|
|
|
|
|
2013-03-06 05:47:40 +08:00
|
|
|
// Check for \01 prefix that is used to mangle __asm declarations and
|
|
|
|
// strip it if present.
|
2013-03-09 21:48:23 +08:00
|
|
|
if (funcName.front() == '\01')
|
2013-03-06 05:47:40 +08:00
|
|
|
funcName = funcName.substr(1);
|
2013-03-09 21:48:23 +08:00
|
|
|
const char **I = std::lower_bound(Start, End, funcName, StringComparator());
|
2012-08-03 12:06:22 +08:00
|
|
|
if (I != End && *I == funcName) {
|
|
|
|
F = (LibFunc::Func)(I - Start);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-22 04:09:13 +08:00
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
void TargetLibraryInfoImpl::disableAllFunctions() {
|
2011-02-19 06:34:03 +08:00
|
|
|
memset(AvailableArray, 0, sizeof(AvailableArray));
|
|
|
|
}
|
2015-01-15 18:41:28 +08:00
|
|
|
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
TargetLibraryInfo TargetLibraryAnalysis::run(Module &M) {
|
|
|
|
if (PresetInfoImpl)
|
|
|
|
return TargetLibraryInfo(*PresetInfoImpl);
|
|
|
|
|
|
|
|
return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple())));
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetLibraryInfo TargetLibraryAnalysis::run(Function &F) {
|
|
|
|
if (PresetInfoImpl)
|
|
|
|
return TargetLibraryInfo(*PresetInfoImpl);
|
|
|
|
|
|
|
|
return TargetLibraryInfo(
|
|
|
|
lookupInfoImpl(Triple(F.getParent()->getTargetTriple())));
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(Triple T) {
|
|
|
|
std::unique_ptr<TargetLibraryInfoImpl> &Impl =
|
|
|
|
Impls[T.normalize()];
|
|
|
|
if (!Impl)
|
|
|
|
Impl.reset(new TargetLibraryInfoImpl(T));
|
|
|
|
|
|
|
|
return *Impl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-15 18:41:28 +08:00
|
|
|
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
: ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) {
|
2015-01-15 18:41:28 +08:00
|
|
|
initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
: ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) {
|
2015-01-15 18:41:28 +08:00
|
|
|
initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
|
[PM] Rework how the TargetLibraryInfo pass integrates with the new pass
manager to support the actual uses of it. =]
When I ported instcombine to the new pass manager I discover that it
didn't work because TLI wasn't available in the right places. This is
a somewhat surprising and/or subtle aspect of the new pass manager
design that came up before but I think is useful to be reminded of:
While the new pass manager *allows* a function pass to query a module
analysis, it requires that the module analysis is already run and cached
prior to the function pass manager starting up, possibly with
a 'require<foo>' style utility in the pass pipeline. This is an
intentional hurdle because using a module analysis from a function pass
*requires* that the module analysis is run prior to entering the
function pass manager. Otherwise the other functions in the module could
be in who-knows-what state, etc.
A somewhat surprising consequence of this design decision (at least to
me) is that you have to design a function pass that leverages
a module analysis to do so as an optional feature. Even if that means
your function pass does no work in the absence of the module analysis,
you have to handle that possibility and remain conservatively correct.
This is a natural consequence of things being able to invalidate the
module analysis and us being unable to re-run it. And it's a generally
good thing because it lets us reorder passes arbitrarily without
breaking correctness, etc.
This ends up causing problems in one case. What if we have a module
analysis that is *definitionally* impossible to invalidate. In the
places this might come up, the analysis is usually also definitionally
trivial to run even while other transformation passes run on the module,
regardless of the state of anything. And so, it follows that it is
natural to have a hard requirement on such analyses from a function
pass.
It turns out, that TargetLibraryInfo is just such an analysis, and
InstCombine has a hard requirement on it.
The approach I've taken here is to produce an analysis that models this
flexibility by making it both a module and a function analysis. This
exposes the fact that it is in fact safe to compute at any point. We can
even make it a valid CGSCC analysis at some point if that is useful.
However, we don't want to have a copy of the actual target library info
state for each function! This state is specific to the triple. The
somewhat direct and blunt approach here is to turn TLI into a pimpl,
with the state and mutators in the implementation class and the query
routines primarily in the wrapper. Then the analysis can lazily
construct and cache the implementations, keyed on the triple, and
on-demand produce wrappers of them for each function.
One minor annoyance is that we will end up with a wrapper for each
function in the module. While this is a bit wasteful (one pointer per
function) it seems tolerable. And it has the advantage of ensuring that
we pay the absolute minimum synchronization cost to access this
information should we end up with a nice parallel function pass manager
in the future. We could look into trying to mark when analysis results
are especially cheap to recompute and more eagerly GC-ing the cached
results, or we could look at supporting a variant of analyses whose
results are specifically *not* cached and expected to just be used and
discarded by the consumer. Either way, these seem like incremental
enhancements that should happen when we start profiling the memory and
CPU usage of the new pass manager and not before.
The other minor annoyance is that if we end up using the TLI in both
a module pass and a function pass, those will be produced by two
separate analyses, and thus will point to separate copies of the
implementation state. While a minor issue, I dislike this and would like
to find a way to cleanly allow a single analysis instance to be used
across multiple IR unit managers. But I don't have a good solution to
this today, and I don't want to hold up all of the work waiting to come
up with one. This too seems like a reasonable thing to incrementally
improve later.
llvm-svn: 226981
2015-01-24 10:06:09 +08:00
|
|
|
const TargetLibraryInfoImpl &TLIImpl)
|
|
|
|
: ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) {
|
2015-01-15 18:41:28 +08:00
|
|
|
initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
2015-01-15 19:39:46 +08:00
|
|
|
char TargetLibraryAnalysis::PassID;
|
|
|
|
|
2015-01-15 18:41:28 +08:00
|
|
|
// Register the basic pass.
|
|
|
|
INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo",
|
|
|
|
"Target Library Information", false, true)
|
|
|
|
char TargetLibraryInfoWrapperPass::ID = 0;
|
|
|
|
|
|
|
|
void TargetLibraryInfoWrapperPass::anchor() {}
|