platform/upstream/llvm.git
4 years ago[lldb] Fix exception breakpoint not being resolved when set on dummy target
Martin Svensson [Fri, 22 Nov 2019 10:18:47 +0000 (11:18 +0100)]
[lldb] Fix exception breakpoint not being resolved when set on dummy target

Summary: Ensure that breakpoint ivar is properly set in exception breakpoint resolver so that exception breakpoints set on dummy targets are resolved once real targets are created and run.

Reviewers: jingham

Reviewed By: jingham

Subscribers: teemperor, JDevlieghere, lldb-commits

Tags: #lldb

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

4 years agoTest commit.
Pankaj Gode [Fri, 22 Nov 2019 09:16:43 +0000 (14:46 +0530)]
Test commit.

4 years ago[DWARFVerifier] Use the new location list api
Pavel Labath [Fri, 8 Nov 2019 14:33:54 +0000 (15:33 +0100)]
[DWARFVerifier] Use the new location list api

Summary:
Instead of going to the debug_loc section directly, use new
DWARFDie::getLocations instead. This means that the code will now
automatically support debug_loclists sections.

This is the last usage of the old debug_loc methods, and they can now be
removed.

Reviewers: dblaikie, JDevlieghere, aprantl, SouraVX

Subscribers: hiraditya, probinson, llvm-commits

Tags: #llvm

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

4 years ago[PowerPC] Implement the vector extend sign instruction pattern match
QingShan Zhang [Fri, 22 Nov 2019 08:55:13 +0000 (08:55 +0000)]
[PowerPC] Implement the vector extend sign instruction pattern match
Power9 has instructions to implement the semantics of SIGN_EXTEND_INREG for vector type.
Mark it as legal and add the match pattern.

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

4 years agogn build: Merge f7170d17a84
LLVM GN Syncbot [Fri, 22 Nov 2019 08:12:49 +0000 (08:12 +0000)]
gn build: Merge f7170d17a84

4 years agogn build: Merge aa981c1802d
LLVM GN Syncbot [Fri, 22 Nov 2019 08:12:48 +0000 (08:12 +0000)]
gn build: Merge aa981c1802d

4 years agogn build: Merge 95fe54931fd
LLVM GN Syncbot [Fri, 22 Nov 2019 08:12:48 +0000 (08:12 +0000)]
gn build: Merge 95fe54931fd

4 years agogn build: (manually) merge dep from f65cfff6
Nico Weber [Fri, 22 Nov 2019 08:12:25 +0000 (03:12 -0500)]
gn build: (manually) merge dep from f65cfff6

4 years agoRevert "[DAGCombiner] Allow zextended load combines."
Clement Courbet [Fri, 22 Nov 2019 08:00:16 +0000 (09:00 +0100)]
Revert "[DAGCombiner] Allow zextended load combines."

Breaks some bots.

4 years ago[clang-tidy] new performance-no-automatic-move check.
Clement Courbet [Mon, 18 Nov 2019 12:22:10 +0000 (13:22 +0100)]
[clang-tidy] new performance-no-automatic-move check.

Summary: The check flags constructs that prevent automatic move of local variables.

Reviewers: aaron.ballman

Subscribers: mgorny, xazax.hun, cfe-commits

Tags: #clang

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

4 years ago[DAGCombiner] Allow zextended load combines.
Clement Courbet [Tue, 19 Nov 2019 15:24:43 +0000 (16:24 +0100)]
[DAGCombiner] Allow zextended load combines.

Summary: or(zext(load8(base)), zext(load8(base+1)) -> zext(load16 base)

Reviewers: apilipenko, RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[lldb] Don't enable expression log in TestEmptyStdModule.py
Raphael Isemann [Fri, 22 Nov 2019 07:34:04 +0000 (08:34 +0100)]
[lldb] Don't enable expression log in TestEmptyStdModule.py

Thanks for pointing this out Jason!

4 years ago[CFG] Fix a flaky crash in CFGBlock::getLastCondition().
Artem Dergachev [Fri, 22 Nov 2019 05:53:50 +0000 (21:53 -0800)]
[CFG] Fix a flaky crash in CFGBlock::getLastCondition().

Using an end iterator of an empty CFG block was causing
a garbage pointer dereference.

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

4 years ago[CMake] Fix LLVM build non-determinism on RHEL
Amy Kwan [Fri, 22 Nov 2019 05:06:33 +0000 (23:06 -0600)]
[CMake] Fix LLVM build non-determinism on RHEL

On RHEL, the OS tooling (ar, ranlib) is not deterministic by default.
Therefore, we cannot get bit-for-bit identical builds.

The goal of this patch is that it adds the flags required to force determinism.

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

4 years ago[PowerPC] combine rlwinm+rlwinm to rlwinm
czhengsz [Fri, 22 Nov 2019 05:00:33 +0000 (00:00 -0500)]
[PowerPC] combine rlwinm+rlwinm to rlwinm
combine
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12

to
x3 = rlwinm x3, 14, 0, 12

Reviewed by: steven.zhang

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

4 years ago[X86] Add option 'disable-strictnode-mutation' for tests that respect
Wang, Pengfei [Fri, 22 Nov 2019 04:24:38 +0000 (12:24 +0800)]
[X86] Add option 'disable-strictnode-mutation' for tests that respect
strict fp semantics. NFCI.

4 years ago[RISCV] Support mutilib in baremetal environment
Zakk Chen [Thu, 21 Nov 2019 09:12:48 +0000 (01:12 -0800)]
[RISCV] Support mutilib in baremetal environment

1. Currently only support the set of multilibs same to riscv-gnu-toolchain.
2. Fix testcase typo causes fail on Windows.
3. Fix testcases to set empty sysroot.

Reviewers: espindola, asb, kito-cheng, lenary

Reviewed By: lenary

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

4 years agoclang/Modules: Move Serialization/Module.{h,cpp} to ModuleFile, NFC
Duncan P. N. Exon Smith [Fri, 22 Nov 2019 02:49:05 +0000 (18:49 -0800)]
clang/Modules: Move Serialization/Module.{h,cpp} to ModuleFile, NFC

Remove some cognitive load by renaming clang/Serialization/Module.h to
clang/Serialization/ModuleFile.h, since it declares the ModuleFile
class.  This also makes editing a bit easier, since the basename of the
file no long conflicts with clang/Basic/Module.h, which declares the
Module class.  Also move lib/Serialization/Module.cpp to
lib/Serialization/ModuleFile.cpp.

4 years ago[analyzer] Fix Objective-C accessor body farms after 2073dd2d.
Artem Dergachev [Fri, 22 Nov 2019 02:13:48 +0000 (18:13 -0800)]
[analyzer] Fix Objective-C accessor body farms after 2073dd2d.

Fix a canonicalization problem for the newly added property accessor stubs that
was causing a wrong decl to be used for 'self' in the accessor's body farm.

Fix a crash when constructing a body farm for accessors of a property
that is declared and @synthesize'd in different (but related) interfaces.

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

4 years ago[analyzer] NFC: Don't clean up range constraints twice.
Artem Dergachev [Fri, 22 Nov 2019 02:12:26 +0000 (18:12 -0800)]
[analyzer] NFC: Don't clean up range constraints twice.

Slightly improves static analysis speed.

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

4 years ago[X86] Add test cases for most of the constrained fp libcalls with fp128.
Craig Topper [Fri, 22 Nov 2019 02:15:53 +0000 (18:15 -0800)]
[X86] Add test cases for most of the constrained fp libcalls with fp128.

Add explicit setOperation actions for some to match their none
strict counterparts. This isn't required, but makes the code
self documenting that we didn't forget about strict fp. I've
used LibCall instead of Expand since that's more explicitly what
we want.

Only lrint/llrint/lround/llround are missing now.

4 years ago[X86] Mark fp128 FMA as LibCall instead of Expand. Add STRICT_FMA as well.
Craig Topper [Fri, 22 Nov 2019 01:06:41 +0000 (17:06 -0800)]
[X86] Mark fp128 FMA as LibCall instead of Expand. Add STRICT_FMA as well.

The Expand code would fall back to LibCall, but this makes it
more explicit.

4 years ago[CFG] Add a test for a flaky crash in CFGBlock::getLastCondition().
Artem Dergachev [Fri, 22 Nov 2019 02:05:19 +0000 (18:05 -0800)]
[CFG] Add a test for a flaky crash in CFGBlock::getLastCondition().

Push the test separately ahead of time in order to find out whether
our Memory Sanitizer bots will be able to find the problem.

If not, I'll add a much more expensive test that repeats the current
test multiple times in order to show up on normal buildbots.
I really apologize for the potential temporary inconvenience!
I'll commit the fix as soon as I get the signal.

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

4 years ago[FPEnv] Add an option to disable strict float node mutating to an normal
Pengfei Wang [Fri, 22 Nov 2019 01:17:19 +0000 (17:17 -0800)]
[FPEnv] Add an option to disable strict float node mutating to an normal
float node

This patch add an option 'disable-strictnode-mutation' to prevent strict
node mutating to an normal node.
So we can make sure that the patch which sets strict-node as legal works
correctly.

Patch by Chen Liu(LiuChen3)

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

4 years ago[LoopInstSimplify] Move MemorySSA verification under flag.
Alina Sbirlea [Fri, 22 Nov 2019 00:58:37 +0000 (16:58 -0800)]
[LoopInstSimplify] Move MemorySSA verification under flag.

The verification inside loop passes should be done under the
VerifyMemorySSA flag (enabled by EXPESIVE_CHECKS or explicitly with
opt), in order to not add to compile time during regular builds.

4 years ago[libFuzzer] don't use /dev/null for DiscardOuput in Fuchsia.
Marco Vanotti [Tue, 29 Oct 2019 22:38:51 +0000 (15:38 -0700)]
[libFuzzer] don't use /dev/null for DiscardOuput in Fuchsia.

Summary:

This commit moves the `DiscardOutput` function in FuzzerIO to
FuzzerUtil, so fuchsia can have its own specialized version.

In fuchsia, accessing `/dev/null` is not supported, and there's nothing
similar to a file that discards everything that is written to it. The
way of doing something similar in fuchsia is by using `fdio_null_create`
and binding that to a file descriptor with `fdio_bind_to_fd`.

This change should fix one of the issues with the `-close_fd_mask` flag
in libfuzzer, in which closing stdout was not working due to
`fopen("/dev/null", "w")` returning `NULL`.

Reviewers: kcc, aarongreen

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[clangd] Inactive regions support as an extension to semantic highlighting
Nathan Ridge [Tue, 24 Sep 2019 22:17:55 +0000 (18:17 -0400)]
[clangd] Inactive regions support as an extension to semantic highlighting

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

4 years ago[LegalizeDAG][X86] Add support for turning STRICT_FADD/SUB/MUL/DIV into libcalls...
Craig Topper [Thu, 21 Nov 2019 23:53:01 +0000 (15:53 -0800)]
[LegalizeDAG][X86] Add support for turning STRICT_FADD/SUB/MUL/DIV into libcalls. Use it for fp128 on x86-64.

This requires a minor hack for f32/f64 strict fadd/fsub to avoid
turning those into libcalls.

4 years ago[X86] Mark vector STRICT_FADD/STRICT_FSUB as Legal and add mutation to X86ISelDAGToDAG
Craig Topper [Thu, 21 Nov 2019 22:24:32 +0000 (14:24 -0800)]
[X86] Mark vector STRICT_FADD/STRICT_FSUB as Legal and add mutation to X86ISelDAGToDAG

The prevents LegalizeVectorOps from scalarizing them. We'll need
to remove the X86 mutation code when we add isel patterns.

4 years ago[X86] Remove regcall calling convention from fp-strict-scalar.ll. Add 32-bit and...
Craig Topper [Thu, 21 Nov 2019 21:03:14 +0000 (13:03 -0800)]
[X86] Remove regcall calling convention from fp-strict-scalar.ll. Add 32-bit and 64-bit check prefixes.

The regcall was making 32-bit mode pass things in xmm registers
which made 32-bit and 64-bit more similar. But I have upcoming
patches that require them to be separated anyway.

4 years ago[llvm-lipo] Add support for -extract
Alexander Shaposhnikov [Thu, 21 Nov 2019 02:16:11 +0000 (18:16 -0800)]
[llvm-lipo] Add support for -extract

This diff adds support for -extract.

Test plan: make check-all

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

4 years ago[Clang] Enable RISC-V support for Fuchsia
Petr Hosek [Wed, 20 Nov 2019 03:56:54 +0000 (19:56 -0800)]
[Clang] Enable RISC-V support for Fuchsia

We don't have a full sysroot yet, so for now we only include compiler
support and compiler-rt builtins, the rest of the runtimes will get
enabled later.

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

4 years ago[libFuzzer] Fix unwinding for Fuchsia
Marco Vanotti [Tue, 29 Oct 2019 15:48:46 +0000 (08:48 -0700)]
[libFuzzer] Fix unwinding for Fuchsia

Summary:
This commit fixes part of the issues with stack unwinding in fuchsia for
arm64 and x86_64. It consists of multiple fixes:

(1) The cfa_offset calculation was wrong, instead of pointing to the
previous stack pointer, it was pointing to the current  one. It worked in
most of the cases because the crashing functions already had a
prologue and had their cfa information relative to another register. The
fix consists on adding a constant that can be used to calculate the
crashing function's stack pointer, and base all the cfi information
relative to that offset.

(2) (arm64) Due to errors with the syntax for the dwarf information, most
of the `OP_NUM` macros were not working. The problem was that they were
referred to as `r##NUM` (like `r14`), when it should have been `x##num`
(like `x14`), or even without the x.

(3) (arm64) The link register was being considered a part of the main
registers (`r30`), when in the real struct it has its own field. Given
that the link register is in the same spot in the struct as r[30] would be,
and that C++ doesn't care about anything, the calculation was still correct.

(4) (x86_64) The stack doesn't need to be aligned to 16 bytes when we
jump to the trampoline function, but it needs to be before performing
call instructions. Encoding that logic in cfi information was tricky, so
we decided to make the cfa information relative to `rbp` and align `rsp`.
Note that this could have been done using another register directly,
but it seems cleaner to make a new fake stack frame.

There are some other minor changes like adding a `brk 1` instruction in
arm64 to make sure that we never return to the crash trampoline (similar to
what we do in x86_64).

Sadly this commit does not fix unwinding for all use cases for arm64.
Crashing functions that do not add information related to the return column in
their cfi information will fail to unwind due to a bug in libunwinder.

Reviewers: mcgrathr, jakehehrlich, phosek, kcc, aarongreen

Subscribers: aprantl, kristof.beyls, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[LoopPred] Robustly handle partially unswitched loops
Philip Reames [Thu, 21 Nov 2019 23:26:58 +0000 (15:26 -0800)]
[LoopPred] Robustly handle partially unswitched loops

We may end up with a case where we have a widenable branch above the loop, but not all widenable branches within the loop have been removed.  Since a widenable branch inhibit SCEVs ability to reason about exit counts (by design), we have a tradeoff between effectiveness of this optimization and allowing future widening of the branches within the loop.  LoopPred is thought to be one of the most important optimizations for range check elimination, so let's pay the cost.

4 years agoEarly-exitify ClangASTContext::AddObjCClassProperty() (NFC)
Adrian Prantl [Thu, 21 Nov 2019 23:40:50 +0000 (15:40 -0800)]
Early-exitify ClangASTContext::AddObjCClassProperty() (NFC)

4 years ago[Object][RISCV] Resolve R_RISCV_32_PCREL
Luís Marques [Thu, 21 Nov 2019 23:33:01 +0000 (23:33 +0000)]
[Object][RISCV] Resolve R_RISCV_32_PCREL

Summary: Add support for resolving `R_RISCV_32_PCREL` relocations. Those aren't
actually resolved AFAIK, but support is still needed to avoid llvm-dwarfdump
errors. The use of these relocations was introduced in D66419 but the
corresponding resolving wasn't added then. The test adds a check that should
catch future unresolved relocations.

Reviewers: asb, lenary
Reviewed By: asb
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70204

4 years ago[AArch64] [FrameLowering] Allow conditional insertion of CFI instruction
David Tellenbach [Thu, 21 Nov 2019 23:09:50 +0000 (00:09 +0100)]
[AArch64] [FrameLowering] Allow conditional insertion of CFI instruction

Summary:
The insertion of most CFI instructions during AArch64 frame lowering can
be disabled (e.g. using the function attribute `nounwind`).

This patch enables conditional insertion for one more CFI instruction.

Reviewers: t.p.northover, ostannard

Reviewed By: ostannard

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[libFuzzer] Fix fd check in DupAndCloseStderr.
Marco Vanotti [Thu, 10 Oct 2019 05:47:30 +0000 (22:47 -0700)]
[libFuzzer] Fix fd check in DupAndCloseStderr.

Summary:
This commit fixes the check in the return value from the `DuplicateFile`
function, which returns a new file descriptor. `DuplicateFile` can
return 0 if that file descriptor is available (for example, if stdin has
already been closed).

In particular, this could cause a bug with the `-close_fd_mask` flag in
some platforms: just call the fuzzer with stdin closed and the
`-close_fd_mask=2` flag, and stderr will not be muted.

Example fuzzer:

```

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
  fprintf(stderr, "STDERR\n");
  fprintf(stdout, "STDOUT\n");
  return 0;
}
```

Invocation (muting both stderr and stdout):
```
./test -close_fd_mask=3 -runs=1 0<&-
INFO: Seed: 1155116940
INFO: Loaded 1 modules   (1 inline 8-bit counters): 1 [0x48b020, 0x48b021),
INFO: Loaded 1 PC tables (1 PCs): 1 [0x478dc8,0x478dd8),
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
STDERR
INFO: A corpus is not provided, starting from an empty corpus
STDERR
Done 2 runs in 0 second(s)
```

Reviewers: mcgrathr, jakehehrlich, phosek, kcc, aarongreen

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[TSan] Make `mach_vm_allocate.c` test less flaky
Julian Lettner [Wed, 20 Nov 2019 20:25:05 +0000 (12:25 -0800)]
[TSan] Make `mach_vm_allocate.c` test less flaky

rdar://57365733

4 years agoFurther cleanup manipulation of widenable branches [NFC]
Philip Reames [Thu, 21 Nov 2019 23:06:01 +0000 (15:06 -0800)]
Further cleanup manipulation of widenable branches [NFC]

This is a follow on to aaea24802bf5.  In post commit discussion, Artur and I realized we could cleanup the code using Uses; this patch does so.

4 years ago[FileCheck] Make FILECHECK_OPTS useful for its test suite
Joel E. Denny [Wed, 20 Nov 2019 22:12:29 +0000 (17:12 -0500)]
[FileCheck] Make FILECHECK_OPTS useful for its test suite

Without this patch, `FILECHECK_OPTS` isn't propagated to FileCheck's
test suite so that `FILECHECK_OPTS` doesn't inadvertently affect test
results by affecting the output of FileCheck calls under test.  As a
result, `FILECHECK_OPTS` is useless for debugging FileCheck's test
suite.

In `llvm/test/FileCheck/lit.local.cfg`, this patch provides a new
subsitution, `%ProtectFileCheckOutput`, to address this problem for
both `FILECHECK_OPTS` and the deprecated
`FILECHECK_DUMP_INPUT_ON_FAILURE`.  The rest of the patch uses
`%ProtectFileCheckOutput` throughout the test suite

Fixes PR40284.

Reviewed By: probinson, thopre

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

4 years ago[Object][RISCV] Fix R_RISCV_SET6 and R_RISCV_SUB6 relocations resolution
Luís Marques [Thu, 21 Nov 2019 22:52:51 +0000 (22:52 +0000)]
[Object][RISCV] Fix R_RISCV_SET6 and R_RISCV_SUB6 relocations resolution

Summary: These relocations had a suspicious resolution logic, given their name.
This patch makes the resolution match the LLD one, which makes more sense.

Reviewers: asb, lenary, HsiangKai, jrtc27
Reviewed By: HsiangKai
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70396

4 years ago[PGO][PGSO] DAG.shouldOptForSize part.
Hiroshi Yamauchi [Mon, 11 Nov 2019 18:59:36 +0000 (10:59 -0800)]
[PGO][PGSO] DAG.shouldOptForSize part.

Summary:
(Split of off D67120)

SelectionDAG::shouldOptForSize changes for profile guided size optimization.

Reviewers: davidxl

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoClang-trunk Generates Wrong Debug values with -O1
Vedant Kumar [Thu, 21 Nov 2019 21:53:10 +0000 (13:53 -0800)]
Clang-trunk Generates Wrong Debug values with -O1

Bit-Tracking Dead Code Elimination (bdce) do not mark dbg.value as undef after
deleting instruction.  which shows invalid state of variable in debugger.  This
patches fixes this by marking the dbg.value as undef which depends on dead
instruction.

This fixes https://bugs.llvm.org/show_bug.cgi?id=41925

Patch by kamlesh kumar!

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

4 years ago[OPENMP]Remove unused template parameter, NFC.
Alexey Bataev [Thu, 21 Nov 2019 21:36:49 +0000 (16:36 -0500)]
[OPENMP]Remove unused template parameter, NFC.

4 years ago[Driver] Fix newline at the end of help output
Jonas Devlieghere [Thu, 21 Nov 2019 21:36:36 +0000 (13:36 -0800)]
[Driver] Fix newline at the end of help output

Print a regular newline at the end of the help output. The current
string literal seems to throw off shells.

4 years ago[Reproducer] Make 'reproducer xcrash' behave the same during capture & replay
Jonas Devlieghere [Thu, 21 Nov 2019 21:34:01 +0000 (13:34 -0800)]
[Reproducer] Make 'reproducer xcrash' behave the same during capture & replay

There's no point in preventing this command from running during replay.
We should simulate the same crash as during capture.

4 years ago[Reproducer] Instruct users to replay reproducer
Jonas Devlieghere [Thu, 21 Nov 2019 21:25:43 +0000 (13:25 -0800)]
[Reproducer] Instruct users to replay reproducer

Improve the message printed when LLDB crashes by asking the user to
replay the reproducer before attaching it to a bugreport..

********************
Crash reproducer for lldb version 10.0.0 (git@github.com:llvm/llvm-project.git revision ...)
  clang revision ...
  llvm revision ...

Reproducer written to '/path/to/reproducer'

Before attaching the reproducer to a bug report:
 - Look at the directory to ensure you're willing to share its content.
 - Make sure the reproducer works by replaying the reproducer.

Replay the reproducer with the following command:
./bin/lldb -replay /path/to/reproducer
********************

4 years ago[test] Mark TestEditline as skipped with ASan.
Jonas Devlieghere [Thu, 21 Nov 2019 21:09:40 +0000 (13:09 -0800)]
[test] Mark TestEditline as skipped with ASan.

As discussed in https://reviews.llvm.org/D70324.

4 years ago[JumpThreading] Refactor ThreadEdge
Kazu Hirata [Thu, 21 Nov 2019 16:27:17 +0000 (08:27 -0800)]
[JumpThreading] Refactor ThreadEdge

Summary:
This patch moves various checks from ThreadEdge to new function
TryThreadEdge The rational behind this is that I'd like to use
ThreadEdge without its checks in my upcoming patch.

This patch preserves lightweight checks as assertions in ThreadEdge.
ThreadEdge does not repeat the cost check, however.

Reviewers: wmi

Subscribers: hiraditya, jfb, llvm-commits

Tags: #llvm

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

4 years ago[X86] Change legalization action for f128 fadd/fsub/fmul/fdiv from Custom to LibCall.
Craig Topper [Thu, 21 Nov 2019 19:27:04 +0000 (11:27 -0800)]
[X86] Change legalization action for f128 fadd/fsub/fmul/fdiv from Custom to LibCall.

The custom code just emits a libcall, but we can do the same
with generic code. The only difference is that the generic code
can form tail calls where the custom code couldn't. This is
responsible for the test changes.

This avoids needing to modify the Custom handling for strict fp.

4 years ago[X86] Add test case for f128 fma. NFC
Craig Topper [Thu, 21 Nov 2019 19:12:35 +0000 (11:12 -0800)]
[X86] Add test case for f128 fma. NFC

This should be turned into a libcall to fmal. We already do it
correctly, but we had no test to confirm.

4 years ago[PowerPC] Add new Future CPU for PowerPC
Stefan Pintilie [Thu, 21 Nov 2019 19:28:51 +0000 (13:28 -0600)]
[PowerPC] Add new Future CPU for PowerPC

This patch will add -mcpu=future into clang for PowerPC.

A CPU type is required for work that may possibly be enabled for some future
Power CPU. The CPU type future will serve that purpose. This patch introduces
no new functionality. It is an incremental patch on top of which Power PC work
for some future CPU can be done.

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

4 years ago[Test] Split up TestIntegerTypes.py
Jonas Devlieghere [Thu, 21 Nov 2019 19:14:25 +0000 (11:14 -0800)]
[Test] Split up TestIntegerTypes.py

The unsplit test is timing out on GreenDragon's sanitized bot. By
splitting the test we avoid this issue and increase parallelism.

4 years agoDebug info: Emit objc_direct methods as members of their containing class
Adrian Prantl [Thu, 21 Nov 2019 17:56:01 +0000 (09:56 -0800)]
Debug info: Emit objc_direct methods as members of their containing class

even in DWARF 4 and earlier. This allows the debugger to recognize
them as direct functions as opposed to Objective-C methods.

<rdar://problem/57327663>

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

4 years ago[cmake] Explicitly mark libraries defined in lib/ as "Component Libraries"
Tom Stellard [Thu, 14 Nov 2019 05:39:58 +0000 (05:39 +0000)]
[cmake] Explicitly mark libraries defined in lib/ as "Component Libraries"

Summary:
Most libraries are defined in the lib/ directory but there are also a
few libraries defined in tools/ e.g. libLLVM, libLTO.  I'm defining
"Component Libraries" as libraries defined in lib/ that may be included in
libLLVM.so.  Explicitly marking the libraries in lib/ as component
libraries allows us to remove some fragile checks that attempt to
differentiate between lib/ libraries and tools/ libraires:

1. In tools/llvm-shlib, because
llvm_map_components_to_libnames(LIB_NAMES "all") returned a list of
all libraries defined in the whole project, there was custom code
needed to filter out libraries defined in tools/, none of which should
be included in libLLVM.so.  This code assumed that any library
defined as static was from lib/ and everything else should be
excluded.

With this change, llvm_map_components_to_libnames(LIB_NAMES, "all")
only returns libraries that have been added to the LLVM_COMPONENT_LIBS
global cmake property, so this custom filtering logic can be removed.
Doing this also fixes the build with BUILD_SHARED_LIBS=ON
and LLVM_BUILD_LLVM_DYLIB=ON.

2. There was some code in llvm_add_library that assumed that
libraries defined in lib/ would not have LLVM_LINK_COMPONENTS or
ARG_LINK_COMPONENTS set.  This is only true because libraries
defined lib lib/ use LLVMBuild.txt and don't set these values.
This code has been fixed now to check if the library has been
explicitly marked as a component library, which should now make it
easier to remove LLVMBuild at some point in the future.

I have tested this patch on Windows, MacOS and Linux with release builds
and the following combinations of CMake options:

- "" (No options)
- -DLLVM_BUILD_LLVM_DYLIB=ON
- -DLLVM_LINK_LLVM_DYLIB=ON
- -DBUILD_SHARED_LIBS=ON
- -DBUILD_SHARED_LIBS=ON -DLLVM_BUILD_LLVM_DYLIB=ON
- -DBUILD_SHARED_LIBS=ON -DLLVM_LINK_LLVM_DYLIB=ON

Reviewers: beanz, smeenai, compnerd, phosek

Reviewed By: beanz

Subscribers: wuzish, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, mgorny, mehdi_amini, sbc100, jgravelle-google, hiraditya, aheejin, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, steven_wu, rogfer01, MartinMosbeck, brucehoult, the_o, dexonsmith, PkmX, jocewei, jsji, dang, Jim, lenary, s.egerton, pzheng, sameer.abuasal, llvm-commits

Tags: #llvm

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

4 years agoBroaden the definition of a "widenable branch"
Philip Reames [Thu, 21 Nov 2019 18:44:13 +0000 (10:44 -0800)]
Broaden the definition of a "widenable branch"

As a reminder, a "widenable branch" is the pattern "br i1 (and i1 X, WC()), label %taken, label %untaken" where "WC" is the widenable condition intrinsics. The semantics of such a branch (derived from the semantics of WC) is that a new condition can be added into the condition arbitrarily without violating legality.

Broaden the definition in two ways:
    Allow swapped operands to the br (and X, WC()) form
    Allow widenable branch w/trivial condition (i.e. true) which takes form of br i1 WC()

The former is just general robustness (e.g. for X = non-instruction this is what instcombine produces). The later is specifically important as partial unswitching of a widenable range check produces exactly this form above the loop.

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

4 years ago[Tests] Autogenerate a bunch of SCEV trip count tests for readability. Will likely...
Philip Reames [Thu, 21 Nov 2019 18:37:58 +0000 (10:37 -0800)]
[Tests] Autogenerate a bunch of SCEV trip count tests for readability.  Will likely merge some of these files soon.

4 years ago[OPENMP50]Add device/kind context selector support.
Alexey Bataev [Tue, 5 Nov 2019 20:13:30 +0000 (15:13 -0500)]
[OPENMP50]Add device/kind context selector support.

Summary: Added basic parsing/sema support for device/kind context selector.

Reviewers: jdoerfert

Subscribers: rampitec, aheejin, fedor.sergeev, simoncook, guansong, s.egerton, hfinkel, kkwli0, caomhin, cfe-commits

Tags: #clang

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

4 years ago[SCEV] Add a mode to skip classification when printing analysis
Philip Reames [Thu, 21 Nov 2019 18:22:49 +0000 (10:22 -0800)]
[SCEV] Add a mode to skip classification when printing analysis

For the various trip-count tests, the classification isn't useful and makes the auto-generated tests super verbose.  By skipping it, we make the auto-gen tests closer to the manually written ones.  Up next: auto-genning a bunch of the existings tests.

4 years ago[scudo][standalone] Minor optimization & improvements
Kostya Kortchinsky [Tue, 19 Nov 2019 18:18:38 +0000 (10:18 -0800)]
[scudo][standalone] Minor optimization & improvements

Summary:
A few small improvements and optimizations:
- when refilling the free list, push back the last batch and return
  the front one: this allows to keep the allocations towards the front
  of the region;
- instead of using 48 entries in the shuffle array, use a multiple of
  `MaxNumCached`;
- make the maximum number of batches to create on refil a constant;
  ultimately it should be configurable, but that's for later;
- `initCache` doesn't need to zero out the cache, it's already done.
- it turns out that when using `||` or `&&`, the compiler is adamant
  on adding a short circuit for every part of the expression. Which
  ends up making somewhat annoying asm with lots of test and
  conditional jump. I am changing that to bitwise `|` or `&` in two
  place so that the generated code looks better. Added comments since
  it might feel weird to people.

This yields to some small performance gains overall, nothing drastic
though.

Reviewers: hctim, morehouse, cferris, eugenis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[Docs] Generate the LLDB man page with Sphinx
Jonas Devlieghere [Wed, 20 Nov 2019 22:53:37 +0000 (14:53 -0800)]
[Docs] Generate the LLDB man page with Sphinx

This patch replaces the existing out-of-date man page for lldb and
replaces it with an RST file from which sphinx generates the actual
troff file. This is similar to how man pages are generated for the rest
of the LLVM utilities.

The man page is generated by building the `docs-lldb-man` target.

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

4 years ago[SCEV] Be robust against IR generated by simple-loop-unswitch
Philip Reames [Thu, 21 Nov 2019 17:52:38 +0000 (09:52 -0800)]
[SCEV] Be robust against IR generated by simple-loop-unswitch

Simple loop unswitch likes to leave around unsimplified and/or/xors. SCEV today bails out on these idioms which is unfortunate in general, and specifically for the unswitch interaction.

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

4 years ago[ELF] Error if -Ttext-segment is specified
Fangrui Song [Tue, 19 Nov 2019 22:16:04 +0000 (14:16 -0800)]
[ELF] Error if -Ttext-segment is specified

In GNU ld, -Ttext sets the address of the .text section and -Ttext-segment sets the address of the text segment (RX).

gold only supports the -Ttext-segment semantic and treats -Ttext as an alias for -Ttext-segment.

lld only supports the -Ttext semantic and treats -Ttext-segment as an
alias for -Ttext.  The text segment will be assigned to an address less
than the specified -Ttext-segment value.

This patch drops the -Ttext-segment alias.

The text segment is traditionally the first segment. Users who specify
-Ttext-segment may actually want to specify --image-base, the lld way to
express this. Unfortunately currently this is supported by GNU ld's
COFF port but not by its ELF port. gold does not support this option.
With -z separate-code, the behavior of GNU ld -Ttext-segment is weird (see https://sourceware.org/bugzilla/show_bug.cgi?id=25207)

rL289827 introduced the alias for linking qemu's non-pie user mode
binaries. As explained previously, this actually assigns the text
segment to an address less than 0x60000000. I feel that a better fix is
on the qemu side:
https://lists.nongnu.org/archive/html/qemu-devel/2019-11/msg02480.html

Reviewed By: grimar, ruiu

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

4 years ago[llvm-objcopy][MachO] Implement --strip-debug
Fangrui Song [Mon, 18 Nov 2019 23:25:04 +0000 (15:25 -0800)]
[llvm-objcopy][MachO] Implement --strip-debug

Reviewed By: alexshap

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

4 years ago[llvm-objcopy][MachO] Fix symbol order in the symbol table
Fangrui Song [Wed, 20 Nov 2019 01:27:25 +0000 (17:27 -0800)]
[llvm-objcopy][MachO] Fix symbol order in the symbol table

Only consider isUndefinedSymbol() when the symbol is not local. This
fixes an assert failure when copying the symbol table, if a n_type=0x20
symbol is followed by a n_type=0x64 symbol.

Reviewed By: alexshap, seiya

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

4 years ago[BranchFolding] Fix PR43964 about branch folder not being debug invariant
Bjorn Pettersson [Mon, 11 Nov 2019 17:20:40 +0000 (18:20 +0100)]
[BranchFolding] Fix PR43964 about branch folder not being debug invariant

Summary:
The fix in BranchFolder related to non debug invariant problems
done in commit ec32dff0b075055 actually introduced some new
problems with debug invariance.

Before that patch ComputeCommonTailLength would move iterators
back, past debug instructions, in order to make ProfitableToMerge
make consistent answers "when one block differs from the other
only by whether debugging pseudos are present at the beginning".
But the changes in ec32dff0b075055 undid that by moving the iterators
forward again.

This patch refactors ComputeCommonTailLength. The function was
really complex, considering that the SkipTopCFIAndReturn part
always moved the iterators forward to the first "real" instruction
in the found tail after ec32dff0b075055.

The patch also restores the logic to "back past possible debugging
pseudos at beginning of block" to make sure ProfitableToMerge
gives consistent answers independent of DBG_VALUE instructions
before the tail. That is now done by ProfitableToMerge instead of
being hidden as a side-effect in ComputeCommonTailLength.

Reviewers: probinson, yechunliang, jmorse

Reviewed By: jmorse

Subscribers: Orlando, mehdi_amini, dexonsmith, aprantl, hiraditya, llvm-commits

Tags: #llvm

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

4 years agoFix compilation warning. NFC.
Michael Liao [Thu, 21 Nov 2019 17:06:32 +0000 (12:06 -0500)]
Fix compilation warning. NFC.

4 years ago[NFC] Refactor and improve comments in CommandObjectTarget
Adrian McCarthy [Tue, 19 Nov 2019 20:51:00 +0000 (12:51 -0800)]
[NFC] Refactor and improve comments in CommandObjectTarget

Made small improvements while debugging through
CommandObjectTarget::AddModuleSymbols.

1.  Refactored error case for an early out, reducing the indentation of
the rest of this long function.
2.  Clarified some comments by correcting spelling and punctuation.
3.  Reduced duplicate code at the end of the function.

Tested with `ninja check-lldb`

Differential Review: https://reviews.llvm.org/D70458

4 years agoReduce the number of iterations in testcase. (NFC)
Adrian Prantl [Thu, 21 Nov 2019 16:32:42 +0000 (08:32 -0800)]
Reduce the number of iterations in testcase. (NFC)

4 years ago[OPENMP]Fix datasharing checks for if clause in parallel taskloop
Alexey Bataev [Thu, 21 Nov 2019 16:03:26 +0000 (11:03 -0500)]
[OPENMP]Fix datasharing checks for if clause in parallel taskloop
directives.

If the default datasharing is set to none, the datasharing attributes
for variables in the condition of the if clause for the inner taskloop
  directive must be verified.

4 years ago[InstCombine] add assert in SimplifyDemandedVectorElts and improve readability; NFC
Sanjay Patel [Wed, 20 Nov 2019 20:23:03 +0000 (15:23 -0500)]
[InstCombine] add assert in SimplifyDemandedVectorElts and improve readability; NFC

4 years agoFix unused variable warning. NFCI.
Simon Pilgrim [Thu, 21 Nov 2019 16:09:19 +0000 (16:09 +0000)]
Fix unused variable warning. NFCI.

4 years agoLLD: Don't use the stderrOS stream in link before it's reassigned.
James Y Knight [Wed, 20 Nov 2019 15:08:18 +0000 (10:08 -0500)]
LLD: Don't use the stderrOS stream in link before it's reassigned.

Remove the lld::enableColors function, as it just obscures which
stream it's affecting, and replace with explicit calls to the stream's
enable_colors.

Also, assign the stderrOS and stdoutOS globals first in link function,
just to ensure nothing might use them.

(Either change individually fixes the issue of using the old
stream, but both together seems best.)

Follow-up to b11386f9be9b2dc7276a758d64f66833da10bdea.

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

4 years ago[Hexagon] Remove incorrect intrinsic definition and invalid testcase
Krzysztof Parzyszek [Thu, 21 Nov 2019 15:06:14 +0000 (09:06 -0600)]
[Hexagon] Remove incorrect intrinsic definition and invalid testcase

The intrinsic int_hexagon_S2_asr_i_vh was mapped to S2_asr_r_vh, which
is wrong. The testcase vasrh.select.ll was using an invalid immediate
for that intrinsic. This is not a proper testcase, since at the MIR
level such use of this intrinsic should never appear.

Together with 824b25fc02, this completes the fix for llvm.org/PR44090.

4 years ago[OPENMP50]Add if clause in for simd directive.
Alexey Bataev [Wed, 20 Nov 2019 20:59:03 +0000 (15:59 -0500)]
[OPENMP50]Add if clause in for simd directive.

According to OpenMP 5.0, if clause can be used in for simd directive. If
condition in the if clause if false, the non-vectorized version of the
loop must be executed.

4 years ago[mips] Add a 'generic' Mips CPU
Miloš Stojanović [Thu, 21 Nov 2019 14:17:21 +0000 (15:17 +0100)]
[mips] Add a 'generic' Mips CPU

Having a generic CPU removes a warning when creating a subtarget without
the CPU being explicitly specified.

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

4 years ago[DAGCombiner] Use the right thumbv7meb triple for ARM big-endian test.
Clement Courbet [Thu, 21 Nov 2019 13:55:53 +0000 (14:55 +0100)]
[DAGCombiner] Use the right thumbv7meb triple for ARM big-endian test.

4 years ago[LV] PreferPredicateOverEpilog respecting option
Sjoerd Meijer [Thu, 21 Nov 2019 14:03:28 +0000 (14:03 +0000)]
[LV] PreferPredicateOverEpilog respecting option

Follow-up of cb47b8783: don't query TTI->preferPredicateOverEpilogue when
option -prefer-predicate-over-epilog is set to false, i.e. when we prefer not
to predicate the loop.

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

4 years ago[lldb][NFC] Modernize string handling in ClangExpressionDeclMap::FindExternalVisibleDecl
Raphael Isemann [Thu, 21 Nov 2019 13:40:45 +0000 (14:40 +0100)]
[lldb][NFC] Modernize string handling in ClangExpressionDeclMap::FindExternalVisibleDecl

4 years ago[lldb][NFC] Move searching functions in ClangExpressionDeclMap to own function
Raphael Isemann [Thu, 21 Nov 2019 12:58:48 +0000 (13:58 +0100)]
[lldb][NFC] Move searching functions in ClangExpressionDeclMap to own function

4 years ago[DeclCXX] Remove unknown external linkage specifications
Ehud Katz [Thu, 7 Nov 2019 10:28:48 +0000 (12:28 +0200)]
[DeclCXX] Remove unknown external linkage specifications

Partial revert of r372681 "Support for DWARF-5 C++ language tags".

The change introduced new external linkage languages ("C++11" and
"C++14") which not supported in C++.

It also changed the definition of the existing enum to use the DWARF
constants. The problem is that "LinkageSpecDeclBits.Language" (the field
that reserves this enum) is actually defined as 3 bits length
(bitfield), which cannot contain the new DWARF constants. Defining the
enum as integer literals is more appropriate for maintaining valid
values.

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

4 years ago[Debuginfo][NFC] removes redundant semicolon.
Alexey Lapshin [Thu, 21 Nov 2019 12:00:40 +0000 (15:00 +0300)]
[Debuginfo][NFC] removes redundant semicolon.

4 years ago[lldb][NFC] Reduce scope of some variables in ClangExpressionDeclMap::FindExternalVis...
Raphael Isemann [Thu, 21 Nov 2019 12:43:48 +0000 (13:43 +0100)]
[lldb][NFC] Reduce scope of some variables in ClangExpressionDeclMap::FindExternalVisibleDecls

4 years agoMake coding standards document more inclusive
Dmitri Gribenko [Tue, 19 Nov 2019 17:49:37 +0000 (18:49 +0100)]
Make coding standards document more inclusive

Summary: Patch by Doug Gregor, Tres Popp, and Dmitri Gribenko.

Reviewers: chandlerc

Subscribers: hfinkel, bmcreusillet, arsenm, doug.gregor, mgrang, arphaman, llvm-commits

Tags: #llvm

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

4 years agoRevert "[RISCV] Support mutilib in baremetal environment"
Zakk Chen [Thu, 21 Nov 2019 12:34:10 +0000 (04:34 -0800)]
Revert "[RISCV] Support mutilib in baremetal environment"

This reverts commit df876a026981b7a125b31bbb85ba4b1144edb0f9.
Clang::riscv32-toolchain.c Clang::riscv64-toolchain.c fails on Windows.

4 years ago[DAGCombiner] Add tests for thumb load-combine.
Clement Courbet [Thu, 21 Nov 2019 12:05:54 +0000 (13:05 +0100)]
[DAGCombiner] Add tests for thumb load-combine.

4 years agoStatistic - Fix MSVC shadow warning against global PrintOnExit static variable. NFC.
Simon Pilgrim [Thu, 21 Nov 2019 11:56:48 +0000 (11:56 +0000)]
Statistic - Fix MSVC shadow warning against global PrintOnExit static variable. NFC.

4 years agoFix Wshadow warning against global None variable. NFC.
Simon Pilgrim [Thu, 21 Nov 2019 11:54:35 +0000 (11:54 +0000)]
Fix Wshadow warning against global None variable. NFC.

4 years ago[lldb][NFC] Remove test directory completely
Tatyana Krasnukha [Thu, 21 Nov 2019 11:12:10 +0000 (14:12 +0300)]
[lldb][NFC] Remove test directory completely

The test was moved to "completion-in-lambda-and-unnamed-class" by D66175.

+ Fix typo in the directory name.

4 years ago[lldb][NFC] Move searching local variables into own function
Raphael Isemann [Thu, 21 Nov 2019 11:16:00 +0000 (12:16 +0100)]
[lldb][NFC] Move searching local variables into own function

4 years ago[Driver] Fix a shadowing warning. NFC
Ilya Biryukov [Thu, 21 Nov 2019 11:17:55 +0000 (12:17 +0100)]
[Driver] Fix a shadowing warning. NFC

Found by the following buildbot:
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/30084

4 years ago[lldb][NFC] Move searching the ClangModulesDeclVendor into own function
Raphael Isemann [Thu, 21 Nov 2019 10:29:59 +0000 (11:29 +0100)]
[lldb][NFC] Move searching the ClangModulesDeclVendor into own function

4 years agoReland 9f3fdb0d7fab: [Driver] Use VFS to check if sanitizer blacklists exist
Ilya Biryukov [Thu, 21 Nov 2019 10:32:17 +0000 (11:32 +0100)]
Reland 9f3fdb0d7fab: [Driver] Use VFS to check if sanitizer blacklists exist

With updates to various LLVM tools that use SpecialCastList.

It was tempting to use RealFileSystem as the default, but that makes it
too easy to accidentally forget passing VFS in clang code.

4 years agodwarfdump --statistics: Use new location list api
Pavel Labath [Tue, 19 Nov 2019 14:14:59 +0000 (15:14 +0100)]
dwarfdump --statistics: Use new location list api

Summary:
This patch removes manual location list handling in the statistics code
and replaces it with the new DWARFDie api, which provides access to a
"cooked" location list. This has the following effects:
- the code now properly handles split-dwarf location lists
- it will automatically support dwarf5 location lists once support for
  those is added
- it properly handles location lists with base address selection entries
- it fixes a bug where the location list code was using the first
  DW_AT_ranges range as a "base address" of the compile unit (it should
  have used DW_AT_low_pc instead. The effect of this was that the
  computation of the start address of a variable in its scope was broken
  for these kinds of compile units. This only manifested itself on
  linked files, since in object files the first DW_AT_ranges range
  normally starts at 0.

Since pretty much every kind of location list was broken in some way,
it's hard to verify that the new implementation is correct -- the output
will be different in all non-trivial cases, and mostly with good reason.

Most of the existing statistics tests continue to pass though, and a
visual inspection of the statistics for non-trivial inputs shows that
the data is more "reasonable" now. I have updated the "dwo statistics"
test to include the new numbers, as the previous ones were completely
bogus, and I have added a targeted test for the "base address" bug.

Reviewers: dblaikie, cmtice, vsk

Subscribers: aprantl, SouraVX, JDevlieghere, djtodoro, llvm-commits

Tags: #llvm

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

4 years ago[mips] Rename test case. NFC
Simon Atanasyan [Thu, 21 Nov 2019 09:57:01 +0000 (12:57 +0300)]
[mips] Rename test case. NFC

4 years ago[mips] Remove unused `IsPCRelativeLoad` MIPS instructions attribute. NFC
Simon Atanasyan [Thu, 21 Nov 2019 09:48:23 +0000 (12:48 +0300)]
[mips] Remove unused `IsPCRelativeLoad` MIPS instructions attribute. NFC

This attribute is always set to zero.

4 years ago[mips] Remove addresses from the test case. NFC
Simon Atanasyan [Thu, 21 Nov 2019 09:34:05 +0000 (12:34 +0300)]
[mips] Remove addresses from the test case. NFC

It reduces "diff" after addition more tests in the future.

4 years agoRevert "[DependenceAnalysis] Dependecies for loads marked with "ivnariant.load" shoul...
Benjamin Kramer [Thu, 21 Nov 2019 10:35:29 +0000 (11:35 +0100)]
Revert "[DependenceAnalysis] Dependecies for loads marked with "ivnariant.load" should not be shared with general accesses. Fix for https://bugs.llvm.org/show_bug.cgi?id=42151"

Summary:
Revert "[DependenceAnalysis] Dependecies for loads marked with "ivnariant.load" should not be shared with general accesses. Fix for https://bugs.llvm.org/show_bug.cgi?id=42151"

 This reverts commit 5f026b6d9e882941fde9b7e5dc0a2d807f7f24f5.

We're (tensorflow.org/xla team) seeing some misscompiles with the new change, only at -O3, with fast math disabled.

I'm still trying to come up with a useful/small/external example, but for now, the following IR:

```
; ModuleID = '__compute_module'
source_filename = "__compute_module"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"

@0 = private unnamed_addr constant [4 x i8] c"\DB\0F\C9@"
@1 = private unnamed_addr constant [4 x i8] c"\00\00\00?"

; Function Attrs: uwtable
define void @jit_wrapped_fun.31(i8* %retval, i8* noalias %run_options, i8** noalias %params, i8** noalias %buffer_table, i64* noalias %prof_counters) #0 {
entry:
  %fusion.invar_address.dim.2 = alloca i64
  %fusion.invar_address.dim.1 = alloca i64
  %fusion.invar_address.dim.0 = alloca i64
  %fusion.1.invar_address.dim.2 = alloca i64
  %fusion.1.invar_address.dim.1 = alloca i64
  %fusion.1.invar_address.dim.0 = alloca i64
  %0 = getelementptr inbounds i8*, i8** %buffer_table, i64 1
  %1 = load i8*, i8** %0, !invariant.load !0, !dereferenceable !1, !align !2
  %parameter.3 = bitcast i8* %1 to [2 x [1 x [4 x float]]]*
  %2 = getelementptr inbounds i8*, i8** %buffer_table, i64 5
  %3 = load i8*, i8** %2, !invariant.load !0, !dereferenceable !1, !align !2
  %fusion.1 = bitcast i8* %3 to [2 x [1 x [4 x float]]]*
  store i64 0, i64* %fusion.1.invar_address.dim.0
  br label %fusion.1.loop_header.dim.0

fusion.1.loop_header.dim.0:                       ; preds = %fusion.1.loop_exit.dim.1, %entry
  %fusion.1.indvar.dim.0 = load i64, i64* %fusion.1.invar_address.dim.0
  %4 = icmp uge i64 %fusion.1.indvar.dim.0, 2
  br i1 %4, label %fusion.1.loop_exit.dim.0, label %fusion.1.loop_body.dim.0

fusion.1.loop_body.dim.0:                         ; preds = %fusion.1.loop_header.dim.0
  store i64 0, i64* %fusion.1.invar_address.dim.1
  br label %fusion.1.loop_header.dim.1

fusion.1.loop_header.dim.1:                       ; preds = %fusion.1.loop_exit.dim.2, %fusion.1.loop_body.dim.0
  %fusion.1.indvar.dim.1 = load i64, i64* %fusion.1.invar_address.dim.1
  %5 = icmp uge i64 %fusion.1.indvar.dim.1, 1
  br i1 %5, label %fusion.1.loop_exit.dim.1, label %fusion.1.loop_body.dim.1

fusion.1.loop_body.dim.1:                         ; preds = %fusion.1.loop_header.dim.1
  store i64 0, i64* %fusion.1.invar_address.dim.2
  br label %fusion.1.loop_header.dim.2

fusion.1.loop_header.dim.2:                       ; preds = %fusion.1.loop_body.dim.2, %fusion.1.loop_body.dim.1
  %fusion.1.indvar.dim.2 = load i64, i64* %fusion.1.invar_address.dim.2
  %6 = icmp uge i64 %fusion.1.indvar.dim.2, 4
  br i1 %6, label %fusion.1.loop_exit.dim.2, label %fusion.1.loop_body.dim.2

fusion.1.loop_body.dim.2:                         ; preds = %fusion.1.loop_header.dim.2
  %7 = load float, float* bitcast ([4 x i8]* @0 to float*)
  %8 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %parameter.3, i64 0, i64 %fusion.1.indvar.dim.0, i64 0, i64 %fusion.1.indvar.dim.2
  %9 = load float, float* %8, !invariant.load !0, !noalias !3
  %10 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %parameter.3, i64 0, i64 %fusion.1.indvar.dim.0, i64 0, i64 %fusion.1.indvar.dim.2
  %11 = load float, float* %10, !invariant.load !0, !noalias !3
  %12 = fmul float %9, %11
  %13 = fmul float %7, %12
  %14 = call float @llvm.log.f32(float %13)
  %15 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %fusion.1, i64 0, i64 %fusion.1.indvar.dim.0, i64 0, i64 %fusion.1.indvar.dim.2
  store float %14, float* %15, !alias.scope !7, !noalias !8
  %invar.inc2 = add nuw nsw i64 %fusion.1.indvar.dim.2, 1
  store i64 %invar.inc2, i64* %fusion.1.invar_address.dim.2
  br label %fusion.1.loop_header.dim.2

fusion.1.loop_exit.dim.2:                         ; preds = %fusion.1.loop_header.dim.2
  %invar.inc1 = add nuw nsw i64 %fusion.1.indvar.dim.1, 1
  store i64 %invar.inc1, i64* %fusion.1.invar_address.dim.1
  br label %fusion.1.loop_header.dim.1

fusion.1.loop_exit.dim.1:                         ; preds = %fusion.1.loop_header.dim.1
  %invar.inc = add nuw nsw i64 %fusion.1.indvar.dim.0, 1
  store i64 %invar.inc, i64* %fusion.1.invar_address.dim.0
  br label %fusion.1.loop_header.dim.0

fusion.1.loop_exit.dim.0:                         ; preds = %fusion.1.loop_header.dim.0
  %16 = getelementptr inbounds i8*, i8** %buffer_table, i64 4
  %17 = load i8*, i8** %16, !invariant.load !0, !dereferenceable !9, !align !2
  %parameter.1 = bitcast i8* %17 to float*
  %18 = getelementptr inbounds i8*, i8** %buffer_table, i64 2
  %19 = load i8*, i8** %18, !invariant.load !0, !dereferenceable !10, !align !2
  %parameter.2 = bitcast i8* %19 to [3 x [1 x float]]*
  %20 = getelementptr inbounds i8*, i8** %buffer_table, i64 0
  %21 = load i8*, i8** %20, !invariant.load !0, !dereferenceable !11, !align !2
  %fusion = bitcast i8* %21 to [2 x [3 x [4 x float]]]*
  store i64 0, i64* %fusion.invar_address.dim.0
  br label %fusion.loop_header.dim.0

fusion.loop_header.dim.0:                         ; preds = %fusion.loop_exit.dim.1, %fusion.1.loop_exit.dim.0
  %fusion.indvar.dim.0 = load i64, i64* %fusion.invar_address.dim.0
  %22 = icmp uge i64 %fusion.indvar.dim.0, 2
  br i1 %22, label %fusion.loop_exit.dim.0, label %fusion.loop_body.dim.0

fusion.loop_body.dim.0:                           ; preds = %fusion.loop_header.dim.0
  store i64 0, i64* %fusion.invar_address.dim.1
  br label %fusion.loop_header.dim.1

fusion.loop_header.dim.1:                         ; preds = %fusion.loop_exit.dim.2, %fusion.loop_body.dim.0
  %fusion.indvar.dim.1 = load i64, i64* %fusion.invar_address.dim.1
  %23 = icmp uge i64 %fusion.indvar.dim.1, 3
  br i1 %23, label %fusion.loop_exit.dim.1, label %fusion.loop_body.dim.1

fusion.loop_body.dim.1:                           ; preds = %fusion.loop_header.dim.1
  store i64 0, i64* %fusion.invar_address.dim.2
  br label %fusion.loop_header.dim.2

fusion.loop_header.dim.2:                         ; preds = %fusion.loop_body.dim.2, %fusion.loop_body.dim.1
  %fusion.indvar.dim.2 = load i64, i64* %fusion.invar_address.dim.2
  %24 = icmp uge i64 %fusion.indvar.dim.2, 4
  br i1 %24, label %fusion.loop_exit.dim.2, label %fusion.loop_body.dim.2

fusion.loop_body.dim.2:                           ; preds = %fusion.loop_header.dim.2
  %25 = mul nuw nsw i64 %fusion.indvar.dim.2, 1
  %26 = add nuw nsw i64 0, %25
  %27 = udiv i64 %26, 4
  %28 = mul nuw nsw i64 %fusion.indvar.dim.0, 1
  %29 = add nuw nsw i64 0, %28
  %30 = udiv i64 %29, 2
  %31 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %fusion.1, i64 0, i64 %29, i64 0, i64 %26
  %32 = load float, float* %31, !alias.scope !7, !noalias !8
  %33 = mul nuw nsw i64 %fusion.indvar.dim.1, 1
  %34 = add nuw nsw i64 0, %33
  %35 = udiv i64 %34, 3
  %36 = load float, float* %parameter.1, !invariant.load !0, !noalias !3
  %37 = getelementptr inbounds [3 x [1 x float]], [3 x [1 x float]]* %parameter.2, i64 0, i64 %34, i64 0
  %38 = load float, float* %37, !invariant.load !0, !noalias !3
  %39 = fsub float %36, %38
  %40 = fmul float %39, %39
  %41 = mul nuw nsw i64 %fusion.indvar.dim.2, 1
  %42 = add nuw nsw i64 0, %41
  %43 = udiv i64 %42, 4
  %44 = mul nuw nsw i64 %fusion.indvar.dim.0, 1
  %45 = add nuw nsw i64 0, %44
  %46 = udiv i64 %45, 2
  %47 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %parameter.3, i64 0, i64 %45, i64 0, i64 %42
  %48 = load float, float* %47, !invariant.load !0, !noalias !3
  %49 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %parameter.3, i64 0, i64 %45, i64 0, i64 %42
  %50 = load float, float* %49, !invariant.load !0, !noalias !3
  %51 = fmul float %48, %50
  %52 = fdiv float %40, %51
  %53 = fadd float %32, %52
  %54 = fneg float %53
  %55 = load float, float* bitcast ([4 x i8]* @1 to float*)
  %56 = fmul float %54, %55
  %57 = getelementptr inbounds [2 x [3 x [4 x float]]], [2 x [3 x [4 x float]]]* %fusion, i64 0, i64 %fusion.indvar.dim.0, i64 %fusion.indvar.dim.1, i64 %fusion.indvar.dim.2
  store float %56, float* %57, !alias.scope !8, !noalias !12
  %invar.inc5 = add nuw nsw i64 %fusion.indvar.dim.2, 1
  store i64 %invar.inc5, i64* %fusion.invar_address.dim.2
  br label %fusion.loop_header.dim.2

fusion.loop_exit.dim.2:                           ; preds = %fusion.loop_header.dim.2
  %invar.inc4 = add nuw nsw i64 %fusion.indvar.dim.1, 1
  store i64 %invar.inc4, i64* %fusion.invar_address.dim.1
  br label %fusion.loop_header.dim.1

fusion.loop_exit.dim.1:                           ; preds = %fusion.loop_header.dim.1
  %invar.inc3 = add nuw nsw i64 %fusion.indvar.dim.0, 1
  store i64 %invar.inc3, i64* %fusion.invar_address.dim.0
  br label %fusion.loop_header.dim.0

fusion.loop_exit.dim.0:                           ; preds = %fusion.loop_header.dim.0
  %58 = getelementptr inbounds i8*, i8** %buffer_table, i64 3
  %59 = load i8*, i8** %58, !invariant.load !0, !dereferenceable !2, !align !2
  %tuple.30 = bitcast i8* %59 to [1 x i8*]*
  %60 = bitcast [2 x [3 x [4 x float]]]* %fusion to i8*
  %61 = getelementptr inbounds [1 x i8*], [1 x i8*]* %tuple.30, i64 0, i64 0
  store i8* %60, i8** %61, !alias.scope !14, !noalias !8
  ret void
}

; Function Attrs: nounwind readnone speculatable willreturn
declare float @llvm.log.f32(float) #1

attributes #0 = { uwtable "no-frame-pointer-elim"="false" }
attributes #1 = { nounwind readnone speculatable willreturn }

!0 = !{}
!1 = !{i64 32}
!2 = !{i64 8}
!3 = !{!4, !6}
!4 = !{!"buffer: {index:0, offset:0, size:96}", !5}
!5 = !{!"XLA global AA domain"}
!6 = !{!"buffer: {index:5, offset:0, size:32}", !5}
!7 = !{!6}
!8 = !{!4}
!9 = !{i64 4}
!10 = !{i64 12}
!11 = !{i64 96}
!12 = !{!13, !6}
!13 = !{!"buffer: {index:3, offset:0, size:8}", !5}
!14 = !{!13}
```

gets (correctly) optimized to the one below without the change:

```
; ModuleID = '__compute_module'
source_filename = "__compute_module"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"

; Function Attrs: nofree nounwind uwtable
define void @jit_wrapped_fun.31(i8* nocapture readnone %retval, i8* noalias nocapture readnone %run_options, i8** noalias nocapture readnone %params, i8** noalias nocapture readonly %buffer_table, i64* noalias nocapture readnone %prof_counters) local_unnamed_addr #0 {
entry:
  %0 = getelementptr inbounds i8*, i8** %buffer_table, i64 1
  %1 = bitcast i8** %0 to [2 x [1 x [4 x float]]]**
  %2 = load [2 x [1 x [4 x float]]]*, [2 x [1 x [4 x float]]]** %1, align 8, !invariant.load !0, !dereferenceable !1, !align !2
  %3 = getelementptr inbounds i8*, i8** %buffer_table, i64 5
  %4 = bitcast i8** %3 to [2 x [1 x [4 x float]]]**
  %5 = load [2 x [1 x [4 x float]]]*, [2 x [1 x [4 x float]]]** %4, align 8, !invariant.load !0, !dereferenceable !1, !align !2
  %6 = bitcast [2 x [1 x [4 x float]]]* %2 to <4 x float>*
  %7 = load <4 x float>, <4 x float>* %6, align 8, !invariant.load !0, !noalias !3
  %8 = fmul <4 x float> %7, %7
  %9 = fmul <4 x float> %8, <float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000>
  %10 = call <4 x float> @llvm.log.v4f32(<4 x float> %9)
  %11 = bitcast [2 x [1 x [4 x float]]]* %5 to <4 x float>*
  store <4 x float> %10, <4 x float>* %11, align 8, !alias.scope !7, !noalias !8
  %12 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %2, i64 0, i64 1, i64 0, i64 0
  %13 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %5, i64 0, i64 1, i64 0, i64 0
  %14 = bitcast float* %12 to <4 x float>*
  %15 = load <4 x float>, <4 x float>* %14, align 8, !invariant.load !0, !noalias !3
  %16 = fmul <4 x float> %15, %15
  %17 = fmul <4 x float> %16, <float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000>
  %18 = call <4 x float> @llvm.log.v4f32(<4 x float> %17)
  %19 = bitcast float* %13 to <4 x float>*
  store <4 x float> %18, <4 x float>* %19, align 8, !alias.scope !7, !noalias !8
  %20 = getelementptr inbounds i8*, i8** %buffer_table, i64 4
  %21 = bitcast i8** %20 to float**
  %22 = load float*, float** %21, align 8, !invariant.load !0, !dereferenceable !9, !align !2
  %23 = getelementptr inbounds i8*, i8** %buffer_table, i64 2
  %24 = bitcast i8** %23 to [3 x [1 x float]]**
  %25 = load [3 x [1 x float]]*, [3 x [1 x float]]** %24, align 8, !invariant.load !0, !dereferenceable !10, !align !2
  %26 = load i8*, i8** %buffer_table, align 8, !invariant.load !0, !dereferenceable !11, !align !2
  %27 = load float, float* %22, align 8, !invariant.load !0, !noalias !3
  %.phi.trans.insert28 = getelementptr inbounds [3 x [1 x float]], [3 x [1 x float]]* %25, i64 0, i64 2, i64 0
  %.pre29 = load float, float* %.phi.trans.insert28, align 8, !invariant.load !0, !noalias !3
  %28 = bitcast [3 x [1 x float]]* %25 to <2 x float>*
  %29 = load <2 x float>, <2 x float>* %28, align 8, !invariant.load !0, !noalias !3
  %30 = insertelement <2 x float> undef, float %27, i32 0
  %31 = shufflevector <2 x float> %30, <2 x float> undef, <2 x i32> zeroinitializer
  %32 = fsub <2 x float> %31, %29
  %33 = fmul <2 x float> %32, %32
  %shuffle30 = shufflevector <2 x float> %33, <2 x float> undef, <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1>
  %34 = fsub float %27, %.pre29
  %35 = fmul float %34, %34
  %36 = insertelement <4 x float> undef, float %35, i32 0
  %37 = shufflevector <4 x float> %36, <4 x float> undef, <4 x i32> zeroinitializer
  %shuffle = shufflevector <4 x float> %10, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
  %38 = fmul <4 x float> %7, %7
  %shuffle31 = shufflevector <4 x float> %38, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
  %39 = fdiv <8 x float> %shuffle30, %shuffle31
  %40 = fadd <8 x float> %shuffle, %39
  %41 = fmul <8 x float> %40, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %42 = bitcast i8* %26 to <8 x float>*
  store <8 x float> %41, <8 x float>* %42, align 8, !alias.scope !8, !noalias !12
  %43 = getelementptr inbounds i8, i8* %26, i64 32
  %44 = fdiv <4 x float> %37, %38
  %45 = fadd <4 x float> %10, %44
  %46 = fmul <4 x float> %45, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %47 = bitcast i8* %43 to <4 x float>*
  store <4 x float> %46, <4 x float>* %47, align 8, !alias.scope !8, !noalias !12
  %.phi.trans.insert = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %5, i64 0, i64 1, i64 0, i64 0
  %.phi.trans.insert12 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %2, i64 0, i64 1, i64 0, i64 0
  %48 = bitcast float* %.phi.trans.insert to <4 x float>*
  %49 = load <4 x float>, <4 x float>* %48, align 8, !alias.scope !7, !noalias !8
  %50 = bitcast float* %.phi.trans.insert12 to <4 x float>*
  %51 = load <4 x float>, <4 x float>* %50, align 8, !invariant.load !0, !noalias !3
  %shuffle.1 = shufflevector <4 x float> %49, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
  %52 = getelementptr inbounds i8, i8* %26, i64 48
  %53 = fmul <4 x float> %51, %51
  %shuffle31.1 = shufflevector <4 x float> %53, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
  %54 = fdiv <8 x float> %shuffle30, %shuffle31.1
  %55 = fadd <8 x float> %shuffle.1, %54
  %56 = fmul <8 x float> %55, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %57 = bitcast i8* %52 to <8 x float>*
  store <8 x float> %56, <8 x float>* %57, align 8, !alias.scope !8, !noalias !12
  %58 = getelementptr inbounds i8, i8* %26, i64 80
  %59 = fdiv <4 x float> %37, %53
  %60 = fadd <4 x float> %49, %59
  %61 = fmul <4 x float> %60, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %62 = bitcast i8* %58 to <4 x float>*
  store <4 x float> %61, <4 x float>* %62, align 8, !alias.scope !8, !noalias !12
  %63 = getelementptr inbounds i8*, i8** %buffer_table, i64 3
  %64 = bitcast i8** %63 to [1 x i8*]**
  %65 = load [1 x i8*]*, [1 x i8*]** %64, align 8, !invariant.load !0, !dereferenceable !2, !align !2
  %66 = getelementptr inbounds [1 x i8*], [1 x i8*]* %65, i64 0, i64 0
  store i8* %26, i8** %66, align 8, !alias.scope !14, !noalias !8
  ret void
}

; Function Attrs: nounwind readnone speculatable willreturn
declare <4 x float> @llvm.log.v4f32(<4 x float>) #1

attributes #0 = { nofree nounwind uwtable "no-frame-pointer-elim"="false" }
attributes #1 = { nounwind readnone speculatable willreturn }

!0 = !{}
!1 = !{i64 32}
!2 = !{i64 8}
!3 = !{!4, !6}
!4 = !{!"buffer: {index:0, offset:0, size:96}", !5}
!5 = !{!"XLA global AA domain"}
!6 = !{!"buffer: {index:5, offset:0, size:32}", !5}
!7 = !{!6}
!8 = !{!4}
!9 = !{i64 4}
!10 = !{i64 12}
!11 = !{i64 96}
!12 = !{!13, !6}
!13 = !{!"buffer: {index:3, offset:0, size:8}", !5}
!14 = !{!13}

```

and (incorrectly) optimized to the one below with the change:

```
; ModuleID = '__compute_module'
source_filename = "__compute_module"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"

; Function Attrs: nofree nounwind uwtable
define void @jit_wrapped_fun.31(i8* nocapture readnone %retval, i8* noalias nocapture readnone %run_options, i8** noalias nocapture readnone %params, i8** noalias nocapture readonly %buffer_table, i64* noalias nocapture readnone %prof_counters) local_unnamed_addr #0 {
entry:
  %0 = getelementptr inbounds i8*, i8** %buffer_table, i64 1
  %1 = bitcast i8** %0 to [2 x [1 x [4 x float]]]**
  %2 = load [2 x [1 x [4 x float]]]*, [2 x [1 x [4 x float]]]** %1, align 8, !invariant.load !0, !dereferenceable !1, !align !2
  %3 = getelementptr inbounds i8*, i8** %buffer_table, i64 5
  %4 = bitcast i8** %3 to [2 x [1 x [4 x float]]]**
  %5 = load [2 x [1 x [4 x float]]]*, [2 x [1 x [4 x float]]]** %4, align 8, !invariant.load !0, !dereferenceable !1, !align !2
  %6 = bitcast [2 x [1 x [4 x float]]]* %2 to <4 x float>*
  %7 = load <4 x float>, <4 x float>* %6, align 8, !invariant.load !0, !noalias !3
  %8 = fmul <4 x float> %7, %7
  %9 = fmul <4 x float> %8, <float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000>
  %10 = call <4 x float> @llvm.log.v4f32(<4 x float> %9)
  %11 = bitcast [2 x [1 x [4 x float]]]* %5 to <4 x float>*
  store <4 x float> %10, <4 x float>* %11, align 8, !alias.scope !7, !noalias !8
  %12 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %2, i64 0, i64 1, i64 0, i64 0
  %13 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %5, i64 0, i64 1, i64 0, i64 0
  %14 = bitcast float* %12 to <4 x float>*
  %15 = load <4 x float>, <4 x float>* %14, align 8, !invariant.load !0, !noalias !3
  %16 = fmul <4 x float> %15, %15
  %17 = fmul <4 x float> %16, <float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000, float 0x401921FB60000000>
  %18 = call <4 x float> @llvm.log.v4f32(<4 x float> %17)
  %19 = bitcast float* %13 to <4 x float>*
  store <4 x float> %18, <4 x float>* %19, align 8, !alias.scope !7, !noalias !8
  %20 = getelementptr inbounds i8*, i8** %buffer_table, i64 4
  %21 = bitcast i8** %20 to float**
  %22 = load float*, float** %21, align 8, !invariant.load !0, !dereferenceable !9, !align !2
  %23 = getelementptr inbounds i8*, i8** %buffer_table, i64 2
  %24 = bitcast i8** %23 to [3 x [1 x float]]**
  %25 = load [3 x [1 x float]]*, [3 x [1 x float]]** %24, align 8, !invariant.load !0, !dereferenceable !10, !align !2
  %26 = load i8*, i8** %buffer_table, align 8, !invariant.load !0, !dereferenceable !11, !align !2
  %27 = load float, float* %22, align 8, !invariant.load !0, !noalias !3
  %.phi.trans.insert28 = getelementptr inbounds [3 x [1 x float]], [3 x [1 x float]]* %25, i64 0, i64 2, i64 0
  %.pre29 = load float, float* %.phi.trans.insert28, align 8, !invariant.load !0, !noalias !3
  %28 = bitcast [3 x [1 x float]]* %25 to <2 x float>*
  %29 = load <2 x float>, <2 x float>* %28, align 8, !invariant.load !0, !noalias !3
  %30 = insertelement <2 x float> undef, float %27, i32 0
  %31 = shufflevector <2 x float> %30, <2 x float> undef, <2 x i32> zeroinitializer
  %32 = fsub <2 x float> %31, %29
  %33 = fmul <2 x float> %32, %32
  %shuffle32 = shufflevector <2 x float> %33, <2 x float> undef, <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1>
  %34 = fsub float %27, %.pre29
  %35 = fmul float %34, %34
  %36 = insertelement <4 x float> undef, float %35, i32 0
  %37 = shufflevector <4 x float> %36, <4 x float> undef, <4 x i32> zeroinitializer
  %shuffle = shufflevector <4 x float> %10, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
  %38 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %5, i64 0, i64 0, i64 0, i64 3
  %39 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %2, i64 0, i64 0, i64 0, i64 3
  %40 = fmul <4 x float> %7, %7
  %41 = shufflevector <4 x float> %40, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
  %42 = fdiv <8 x float> %shuffle32, %41
  %43 = fadd <8 x float> %shuffle, %42
  %44 = fmul <8 x float> %43, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %45 = bitcast i8* %26 to <8 x float>*
  store <8 x float> %44, <8 x float>* %45, align 8, !alias.scope !8, !noalias !12
  %46 = extractelement <4 x float> %10, i32 0
  %47 = getelementptr inbounds i8, i8* %26, i64 32
  %48 = extractelement <4 x float> %10, i32 1
  %49 = extractelement <4 x float> %10, i32 2
  %50 = load float, float* %38, align 4, !alias.scope !7, !noalias !8
  %51 = load float, float* %39, align 4, !invariant.load !0, !noalias !3
  %52 = fmul float %51, %51
  %53 = insertelement <4 x float> undef, float %52, i32 3
  %54 = fdiv <4 x float> %37, %53
  %55 = insertelement <4 x float> undef, float %46, i32 0
  %56 = insertelement <4 x float> %55, float %48, i32 1
  %57 = insertelement <4 x float> %56, float %49, i32 2
  %58 = insertelement <4 x float> %57, float %50, i32 3
  %59 = fadd <4 x float> %58, %54
  %60 = fmul <4 x float> %59, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %61 = bitcast i8* %47 to <4 x float>*
  store <4 x float> %60, <4 x float>* %61, align 8, !alias.scope !8, !noalias !12
  %.phi.trans.insert = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %5, i64 0, i64 1, i64 0, i64 0
  %.phi.trans.insert12 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %2, i64 0, i64 1, i64 0, i64 0
  %62 = bitcast float* %.phi.trans.insert to <4 x float>*
  %63 = load <4 x float>, <4 x float>* %62, align 8, !alias.scope !7, !noalias !8
  %64 = bitcast float* %.phi.trans.insert12 to <4 x float>*
  %65 = load <4 x float>, <4 x float>* %64, align 8, !invariant.load !0, !noalias !3
  %shuffle.1 = shufflevector <4 x float> %63, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
  %66 = getelementptr inbounds i8, i8* %26, i64 48
  %67 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %5, i64 0, i64 1, i64 0, i64 3
  %68 = getelementptr inbounds [2 x [1 x [4 x float]]], [2 x [1 x [4 x float]]]* %2, i64 0, i64 1, i64 0, i64 3
  %69 = fmul <4 x float> %65, %65
  %70 = shufflevector <4 x float> %69, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
  %71 = fdiv <8 x float> %shuffle32, %70
  %72 = fadd <8 x float> %shuffle.1, %71
  %73 = fmul <8 x float> %72, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %74 = bitcast i8* %66 to <8 x float>*
  store <8 x float> %73, <8 x float>* %74, align 8, !alias.scope !8, !noalias !12
  %75 = extractelement <4 x float> %69, i32 0
  %76 = extractelement <4 x float> %63, i32 0
  %77 = getelementptr inbounds i8, i8* %26, i64 80
  %78 = extractelement <4 x float> %69, i32 1
  %79 = extractelement <4 x float> %63, i32 1
  %80 = extractelement <4 x float> %69, i32 2
  %81 = extractelement <4 x float> %63, i32 2
  %82 = load float, float* %67, align 4, !alias.scope !7, !noalias !8
  %83 = load float, float* %68, align 4, !invariant.load !0, !noalias !3
  %84 = fmul float %83, %83
  %85 = insertelement <4 x float> undef, float %75, i32 0
  %86 = insertelement <4 x float> %85, float %78, i32 1
  %87 = insertelement <4 x float> %86, float %80, i32 2
  %88 = insertelement <4 x float> %87, float %84, i32 3
  %89 = fdiv <4 x float> %37, %88
  %90 = insertelement <4 x float> undef, float %76, i32 0
  %91 = insertelement <4 x float> %90, float %79, i32 1
  %92 = insertelement <4 x float> %91, float %81, i32 2
  %93 = insertelement <4 x float> %92, float %82, i32 3
  %94 = fadd <4 x float> %93, %89
  %95 = fmul <4 x float> %94, <float -5.000000e-01, float -5.000000e-01, float -5.000000e-01, float -5.000000e-01>
  %96 = bitcast i8* %77 to <4 x float>*
  store <4 x float> %95, <4 x float>* %96, align 8, !alias.scope !8, !noalias !12
  %97 = getelementptr inbounds i8*, i8** %buffer_table, i64 3
  %98 = bitcast i8** %97 to [1 x i8*]**
  %99 = load [1 x i8*]*, [1 x i8*]** %98, align 8, !invariant.load !0, !dereferenceable !2, !align !2
  %100 = getelementptr inbounds [1 x i8*], [1 x i8*]* %99, i64 0, i64 0
  store i8* %26, i8** %100, align 8, !alias.scope !14, !noalias !8
  ret void
}

; Function Attrs: nounwind readnone speculatable willreturn
declare <4 x float> @llvm.log.v4f32(<4 x float>) #1

attributes #0 = { nofree nounwind uwtable "no-frame-pointer-elim"="false" }
attributes #1 = { nounwind readnone speculatable willreturn }

!0 = !{}
!1 = !{i64 32}
!2 = !{i64 8}
!3 = !{!4, !6}
!4 = !{!"buffer: {index:0, offset:0, size:96}", !5}
!5 = !{!"XLA global AA domain"}
!6 = !{!"buffer: {index:5, offset:0, size:32}", !5}
!7 = !{!6}
!8 = !{!4}
!9 = !{i64 4}
!10 = !{i64 12}
!11 = !{i64 96}
!12 = !{!13, !6}
!13 = !{!"buffer: {index:3, offset:0, size:8}", !5}
!14 = !{!13}

```

This results in bad numerical answers when used through XLA.
Again, it's not that easy to give a small fully-reproducible example, but the misscompare is:

```
Expected literal:
(
f32[2,3,4] {
{
  { nan, -inf, -3181.35, -inf },
  { nan, -inf, -28.2577019, -inf },
  { nan, -inf, -28.2577019, -inf }
},
{
  { -inf, -inf, -inf, -inf },
  { -6.60753046e+28, -1.47314833e+23, -inf, -inf },
  { -2.43504347e+30, -5.42892693e+24, -inf, -inf }
}
}
)

Actual literal:
(
f32[2,3,4] {
{
  { nan, -inf, -3181.35, -inf },
  { nan, -inf, -inf, -inf },
  { inf, -inf, -28.2577019, -inf }
},
{
  { -inf, -inf, -inf, -inf },
  { -6.60753046e+28, -1.47314833e+23, -inf, -inf },
  { -2.43504347e+30, -5.42892693e+24, -inf, -inf }
}
}
)
```

Reviewers: sanjoy.google, sanjoy, ebrevnov, jdoerfert, reames, chandlerc

Subscribers: hiraditya, Charusso, llvm-commits

Tags: #llvm

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

4 years ago[OpenCL] Fix address space for base method call (PR43145)
Sven van Haastregt [Thu, 21 Nov 2019 10:39:33 +0000 (10:39 +0000)]
[OpenCL] Fix address space for base method call (PR43145)

Clang was creating an UncheckedDerivedToBase ImplicitCastExpr that was
also casting between address spaces.  Insert an ImplicitCastExpr node
for doing the address space conversion.

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