328 Commits

Author SHA1 Message Date
Guillaume Chatelet
ff6e4d503c [Alignment][NFC] Finish transition for Loads
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, asbirlea, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69253

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375419 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-21 15:10:26 +00:00
Evandro Menezes
08eff29648 [InstCombine] Add test case for PR43617 (NFC)
Also, refactor check in `LibCallSimplifier::optimizeLog()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374453 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-10 21:29:10 +00:00
Evandro Menezes
0cb14ca5d8 [InstCombine] Fix PR43617
Check for `nullptr` before inspecting composite function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374243 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-09 22:03:23 +00:00
Evandro Menezes
4f283471b6 [Support] Add mathematical constants
Add own version of the mathematical constants from the upcoming C++20 `std::numbers`.

Differential revision: https://reviews.llvm.org/D68257

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374207 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-09 19:58:01 +00:00
David Bolvansky
863bc82a9a [InstCombine] Transform bcopy to memmove
bcopy is still widely used mainly for network apps. Sadly, LLVM has no optimizations for bcopy, but there are some for memmove. 
Since bcopy == memmove, it is profitable to transform bcopy to memmove and use current optimizations for memmove for free here.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373537 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 22:49:20 +00:00
David Bolvansky
d795c5c32c Revert [InstCombine] sprintf(dest, "%s", str) -> memccpy(dest, str, 0, MAX)
Seems to be slower than memcpy + strlen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373335 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 13:19:04 +00:00
David Bolvansky
9b53ccdbcd [InstCombine] sprintf(dest, "%s", str) -> memccpy(dest, str, 0, MAX)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373333 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 13:03:10 +00:00
Evandro Menezes
b665fc7193 [SimplifyLibCalls] Define the value of the Euler number
This patch fixes the build break on Windows hosts.

There must be a better way of accessing the equivalent POSIX math constant
`M_E`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373274 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-30 23:21:02 +00:00
Evandro Menezes
f1a7cbf1cb [InstCombine] Expand the simplification of log()
Expand the simplification of special cases of `log()` to include `log2()`
and `log10()` as well as intrinsics and more types.

Differential revision: https://reviews.llvm.org/D67199

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373261 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-30 20:52:21 +00:00
David Bolvansky
e2d4a45c6e [SLC] Convert some strndup calls to strdup calls
Summary:
Motivation:
- If we can fold it to strdup, we should (strndup does more things than strdup).
- Annotation mechanism. (Works for strdup well).

strdup and strndup are part of C 20 (currently posix fns), so we should optimize them.

Reviewers: efriedma, jdoerfert

Reviewed By: jdoerfert

Subscribers: lebedev.ri, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67679

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23 18:20:01 +00:00
Sanjay Patel
e700dd9b79 [SimplifyLibCalls] fix crash with empty function name (PR43347)
...and improve some variable names while here.

https://bugs.llvm.org/show_bug.cgi?id=43347

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372227 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-18 14:33:40 +00:00
David Bolvansky
833ff6adf3 Reland "[SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x, '\0', y)"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372142 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 17:12:24 +00:00
Krasimir Georgiev
d5f8516fb7 Revert "[SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x, '\0', y)"
Summary:
This reverts commit r372101.

Causes ASAN build bot failures:

http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/14176
From http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/14176/steps/64-bit%20check-asan/logs/stdio:

```
[ RUN      ] AddressSanitizer.StrNCatOOBTest
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/compiler-rt/lib/asan/tests/asan_str_test.cpp:462: Failure
Death test: strncat(to - 1, from, 0)
    Result: failed to die.
```

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67658

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372125 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 14:15:23 +00:00
David Bolvansky
d15afd3638 [SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x, '\0', y)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372101 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 10:25:38 +00:00
David Bolvansky
f0f4b7afaa [NFCI] Fixed buildbots
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372097 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 10:03:45 +00:00
Fangrui Song
2920626e02 [SimplifyLibCalls] Fix -Wunused-result after D53342/r372091
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372096 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 09:56:55 +00:00
David Bolvansky
077e4d5d58 [SimplifyLibCalls] Mark known arguments with nonnull
Reviewers: efriedma, jdoerfert

Reviewed By: jdoerfert

Subscribers: ychen, rsmith, joerg, aaron.ballman, lebedev.ri, uenoku, jdoerfert, hfinkel, javed.absar, spatel, dmgreen, llvm-commits

Differential Revision: https://reviews.llvm.org/D53342

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372091 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 09:32:52 +00:00
Evandro Menezes
af17674bf4 [InstCombine] Refactor substitution of instruction in the parent BB (NFC)
Add the new method `LibCallSimplifier::substituteInParent()` that calls
`LibCallSimplifier::replaceAllUsesWith()' and
`LibCallSimplifier::eraseFromParent()` back to back, simplifying the
resulting code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371264 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-06 22:07:11 +00:00
Sanjay Patel
0cd0037f5c [SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233)
https://bugs.llvm.org/show_bug.cgi?id=43233

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371221 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-06 16:10:18 +00:00
David Bolvansky
30f7e67339 [InstCombine] mempcpy(d,s,n) to memcpy(d,s,n) + n
Summary:
Back-end currently expands mempcpy, but middle-end should work with memcpy instead of mempcpy to enable more memcpy-optimization.

GCC backend emits mempcpy, so LLVM backend could form it too, if we know mempcpy libcall is better than memcpy + n.
https://godbolt.org/z/dOCG96

Reviewers: efriedma, spatel, craig.topper, RKSimon, jdoerfert

Reviewed By: efriedma

Subscribers: hjl.tools, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65737

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370593 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-31 18:19:05 +00:00
Evandro Menezes
a1e2fd38b5 [InstCombine] Simplify pow(2.0, itofp(y)) to ldexp(1.0, y)
Simplify `pow(2.0, itofp(y))` to `ldexp(1.0, y)`.

Differential revision: https://reviews.llvm.org/D65979

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369120 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-16 15:33:41 +00:00
David Bolvansky
0867478c7e [SLC] Dereferenceable annonation - handle valid null pointers
Reviewers: jdoerfert, reames

Reviewed By: jdoerfert

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66161

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368884 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-14 17:15:20 +00:00
David Bolvansky
f6b0f6c007 [BuildLibCalls] Noalias annotation
Summary: I think this is better solution than annotating callsites in IC/SLC.

Reviewers: jdoerfert

Reviewed By: jdoerfert

Subscribers: MaskRay, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66217

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368875 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-14 16:50:06 +00:00
David Bolvansky
724a189534 [SimplifyLibCalls] Add noalias from known callsites
Summary:
Should be fine for memcpy, strcpy, strncpy.


Reviewers: jdoerfert, efriedma

Reviewed By: jdoerfert

Subscribers: uenoku, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66135

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368724 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-13 17:18:46 +00:00
David Bolvansky
e2ecc33d0b [SLC] Improve dereferenceable bytes annotation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368715 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-13 16:44:16 +00:00
David Bolvansky
7ba7168c11 [SimplifyLibCalls] Add dereferenceable bytes from known callsites
Summary:
int mm(char *a, char *b) {
    return memcmp(a,b,16);
}

Currently:
define dso_local i32 @mm(i8* nocapture readonly %a, i8* nocapture readonly %b) local_unnamed_addr #1 {
entry:
  %call = tail call i32 @memcmp(i8* %a, i8* %b, i64 16)
  ret i32 %call
}

After patch:
define dso_local i32 @mm(i8* nocapture readonly %a, i8* nocapture readonly %b) local_unnamed_addr #1 {
entry:
  %call = tail call i32 @memcmp(i8* dereferenceable(16)  %a, i8* dereferenceable(16)  %b, i64 16)
  ret i32 %call
}




Reviewers: jdoerfert, efriedma

Reviewed By: jdoerfert

Subscribers: javed.absar, spatel, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66079

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368657 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-13 09:11:49 +00:00
Evandro Menezes
7574afba90 [InstCombine] Refactor optimizeExp2() (NFC)
Refactor `LibCallSimplifier::optimizeExp2()` to use the new
`emitBinaryFloatFnCall()` version that fetches the function name from TLI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368457 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-09 17:22:56 +00:00
Evandro Menezes
25ebdf539b [Transforms] Rename hasUnaryFloatFn() and getUnaryFloatFn() (NFC)
Rename `hasUnaryFloatFn()` to `hasFloatFn()` and `getUnaryFloatFn()` to `getFloatFnName()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368449 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-09 16:04:18 +00:00
Evandro Menezes
3d3d4d6423 [InstCombine] Swap order of checks to improve compile time (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366962 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-24 23:31:04 +00:00
Evandro Menezes
c36da86394 [InstCombine] Reorder pow() transformations (NFC)
Move the transformation from `powf(x, itofp(y))` to `powi(x, y)` to the
group of transformations related to the exponent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365851 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 00:33:49 +00:00
David Bolvansky
0f3d79f3e7 [InstCombine] Reorder recently added/improved pow transformations
Changed cases are now faster with exp2.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365758 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-11 10:55:04 +00:00
David Bolvansky
d1678ed7a7 [InstCombine] pow(C,x) -> exp2(log2(C)*x)
Summary:
Transform
pow(C,x) 

To
exp2(log2(C)*x) 

if C > 0, C != inf, C != NaN (and C is not power of 2, since we have some fold for such case already).

log(C) is folded by the compiler and exp2 is much faster to compute than pow.

Reviewers: spatel, efriedma, evandro

Reviewed By: evandro

Subscribers: lebedev.ri, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64099

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365637 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-10 14:43:27 +00:00
David Bolvansky
469bb59e0b [NFC] Strenghten isInteger condition for rL364940
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364969 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-02 21:16:34 +00:00
David Bolvansky
257696a391 [SimplifyLibCalls] powf(x, sitofp(n)) -> powi(x, n)
Summary:
Partially solves https://bugs.llvm.org/show_bug.cgi?id=42190



Reviewers: spatel, nikic, efriedma

Reviewed By: efriedma

Subscribers: efriedma, nikic, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63038

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364940 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-02 15:58:45 +00:00
Sanjay Patel
5a07a49365 [InstCombine] canonicalize fmin/fmax to LLVM intrinsics minnum/maxnum
This transform came up in D62414, but we should deal with it first.
We have LLVM intrinsics that correspond exactly to libm calls (unlike
most libm calls, these libm calls never set errno).
This holds without any fast-math-flags, so we should always canonicalize
to those intrinsics directly for better optimization.
Currently, we convert to fcmp+select only when we have FMF (nnan) because
fcmp+select does not preserve the semantics of the call in the general case.

Differential Revision: https://reviews.llvm.org/D63214

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364714 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-29 14:28:54 +00:00
Erik Pilkington
8964612be0 [SimplifyLibCalls] Fold more fortified functions into non-fortified variants
When the object size argument is -1, no checking can be done, so calling the
_chk variant is unnecessary. We already did this for a bunch of these
functions.

rdar://50797197

Differential revision: https://reviews.llvm.org/D62358

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362272 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 22:41:36 +00:00
Erik Pilkington
741ce0d406 NFC: Pull out a function to reduce some duplication
Part of https://reviews.llvm.org/D62358

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362271 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 22:41:31 +00:00
Simon Pilgrim
20c6b7a70e Pull out repeated CI->getCalledFunction() calls. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360070 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-06 19:51:54 +00:00
Clement Courbet
137f7dfd51 [SimplifyLibCalls] Simplify bcmp too.
Summary: Fixes PR40699.

Reviewers: gchatelet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61585

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360021 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-06 09:15:22 +00:00
Evandro Menezes
37c4380fae [SimplifyLibCalls] Clean up code (NFC)
Fix pointer check after dereferencing (PR41665).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359595 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-30 18:35:38 +00:00
Hiroshi Yamauchi
7716d65968 [PGO] Profile guided code size optimization.
Summary:
Enable some of the existing size optimizations for cold code under PGO.

A ~5% code size saving in big internal app under PGO.

The way it gets BFI/PSI is discussed in the RFC thread

http://lists.llvm.org/pipermail/llvm-dev/2019-March/130894.html 

Note it doesn't currently touch loop passes.

Reviewers: davidxl, eraman

Reviewed By: eraman

Subscribers: mgorny, javed.absar, smeenai, mehdi_amini, eraman, zzheng, steven_wu, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59514

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358422 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-15 16:49:00 +00:00
Evandro Menezes
d71ea05ab7 [IR] Refactor attribute methods in Function class (NFC)
Rename the functions that query the optimization kind attributes.

Differential revision: https://reviews.llvm.org/D60287

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357731 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-04 22:40:06 +00:00
Alon Zakai
683212b71c [WebAssembly] Add Emscripten OS definition + small_printf
The Emscripten OS provides a definition of __EMSCRIPTEN__, and also that it
supports iprintf optimizations.

Also define small_printf optimizations, which is a printf with float support
but not long double (which in wasm can be useful since long doubles are 128
bit and force linking of float128 emulation code). This part is based on
sunfish's https://reviews.llvm.org/D57620 (which can't land yet since
the WASI integration isn't ready yet).

Differential Revision: https://reviews.llvm.org/D60167

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357552 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 01:08:35 +00:00
Fangrui Song
e499a1a918 [SimplifyLibCalls] Simplify optimizePuts
The code might intend to replace puts("") with putchar('\n') even if the
return value is used. It failed because use_empty() was used to guard
the whole block. While returning '\n' (putchar('\n')) is technically
correct (puts is only required to return a nonnegative number on
success), doing this looks weird and there is really little benefit to
optimize puts whose return value is used. So don't do that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355921 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-12 14:20:22 +00:00
Fangrui Song
65378bcd14 [SimplifyLibCalls] Fix comments about fputs, memchr, and s[n]printf. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355905 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-12 10:31:52 +00:00
Clement Courbet
154171347b [SelectionDAG] Allow the user to specify a memeq function.
Summary:
Right now, when we encounter a string equality check,
e.g. `if (memcmp(a, b, s) == 0)`, we try to expand to a comparison if `s` is a
small compile-time constant, and fall back on calling `memcmp()` else.

This is sub-optimal because memcmp has to compute much more than
equality.

This patch replaces `memcmp(a, b, s) == 0` by `bcmp(a, b, s) == 0` on platforms
that support `bcmp`.

`bcmp` can be made much more efficient than `memcmp` because equality
compare is trivially parallel while lexicographic ordering has a chain
dependency.

Subscribers: fedor.sergeev, jyknight, ckennelly, gchatelet, llvm-commits

Differential Revision: https://reviews.llvm.org/D56593

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355672 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-08 09:07:45 +00:00
James Y Knight
3bab951f0f [opaque pointer types] Pass value type to GetElementPtr creation.
This cleans up all GetElementPtr creation in LLVM to explicitly pass a
value type rather than deriving it from the pointer's element-type.

Differential Revision: https://reviews.llvm.org/D57173

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352913 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-01 20:44:47 +00:00
James Y Knight
6c00b3f35f [opaque pointer types] Pass value type to LoadInst creation.
This cleans up all LoadInst creation in LLVM to explicitly pass the
value type rather than deriving it from the pointer's element-type.

Differential Revision: https://reviews.llvm.org/D57172

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352911 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-01 20:44:24 +00:00
James Y Knight
6029aa8149 [opaque pointer types] Pass function types to CallInst creation.
This cleans up all CallInst creation in LLVM to explicitly pass a
function type rather than deriving it from the pointer's element-type.

Differential Revision: https://reviews.llvm.org/D57170

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352909 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-01 20:43:25 +00:00
James Y Knight
9ec60d7d8f [opaque pointer types] Add a FunctionCallee wrapper type, and use it.
Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc
doesn't choke on it, hopefully.

Original Message:
The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.

Then:
- update the CallInst/InvokeInst instruction creation functions to
  take a Callee,
- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.

One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.

However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)

Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.

Differential Revision: https://reviews.llvm.org/D57315

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352827 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-01 02:28:03 +00:00