Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM and SPIRV-LLVM-Translator pulldown (WW29) #10427

Closed
wants to merge 2,783 commits into from
Closed

Conversation

sys-ce-bb
Copy link
Contributor

krzysz00 and others added 30 commits July 13, 2023 14:49
When I landed the EmulateUnsupportedFloats, I'd negligently included
an assert that needed to run for the pass to be correct. Previous
emergency fix commits removed the assert. This commit re-adds the
"can't happen" testing as an emitOpError() and aborting the rewrite,
thus allowing it to function in no-assertions builds.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D155088
Combine mul (f32) + fptrunc (f32->f16) to "v_fma_mixlo_f16 mulSrc1, mulSrc2, 0".

Differential Revision: https://reviews.llvm.org/D153544
Reviewers: arsenm, foad
SubOpAliases maps a sub-operand name to the respective operand's index
and the sub-operand number within this operand. The operand index is
used for the Operands array.

Currently MIOperandNo is used as the operand index, which is not
correct. For example, if there are 2 operands with 3 sub-operands each:

  (ins (bdladdr12onlylen4 $B1, $D1, $L1):$BDL1,
       (bdladdr12onlylen4 $B2, $D2, $L2):$BDL2)

then B2's operand index will be 3, but the correct value is 1.

Reviewed By: jyknight

Differential Revision: https://reviews.llvm.org/D155158
There was a bug with the -funderscoring / -fno-underscoring options from (https://reviews.llvm.org/D140795) that prevented the driver option from controlling the underscoring behaviour and instead the behaviour could only be controlled by the pass option instead of the driver option. The driver test case did not catch the bug and also needed to be updated.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D155042
…nfc]

This is a subset of Luke's D155063.  I'm splitting pieces and landing them in the process of convincing myself all the individual transforms are in fact correct.

In this case, we're simplifying based on the assumption that all of our vmerge operands have mask operands.  This is a fundemental property of a vmerge.
Remove duplicate of the getDesignatorNameIfDataRef() function.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D155105
Check the combination of reduction operator and types. This is
currently not checking common block and composite types.

Depends on D155105

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D155106
Removing the x86-specific node helps further folding and improves commutativity
This seems to match https://gcc.gnu.org/install/specific.html#powerpc-x-eabi

It seems that anything with OS `none` (although that doesn’t seem to be distinguished from `unknown`) or with environment `eabi` should be treated as bare-metal.
Since this seems to have been handled on a case-by-case basis in the past ([arm](https://reviews.llvm.org/D33259), [riscv](https://reviews.llvm.org/D91442), [aarch64](https://reviews.llvm.org/D111134)), what I am proposing here is to add another case to the list to also handle `powerpc[64][le]-unknown-unknown-eabi` using the `BareMetal` toolchain, following the example of the existing cases. (We don’t care about powerpc64 and powerpc[64]le, but it seemed appropriate to lump them in.)

At Indel, we have been building bare-metal embedded applications that run on custom PowerPC and ARM systems with Clang and LLD for a couple of years now, using target triples `powerpc-indel-eabi`, `powerpc-indel-eabi750`, `arm-indel-eabi`, `aarch64-indel-eabi` (which I just learned from D153430 is wrong and should be `aarch64-indel-elf` instead, but that’s a different matter). This has worked fine for ARM, but for PowerPC we have been unable to call the linker (LLD) through the Clang driver, because it would insist on calling GCC as the linker, even when told `-fuse-ld=lld`. That does not work for us, there is no GCC around. Instead we had to call `ld.lld` directly, introducing some special cases in our build system to translate between linker-via-driver and linker-called-directly command line arguments. I have now dug into why that is, and found that the difference between ARM and PowerPC is that `arm-indel-eabi` hits a special case that causes the Clang driver to instantiate a `BareMetal` toolchain that is able to call LLD and works the way we need, whereas `powerpc-indel-eabi` lands in the default case of a `Generic_ELF` (subclass of `Generic_GCC`) toolchain which expects GCC.

Reviewed By: MaskRay, michaelplatings, #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D154357
The problem appeared as a segfault for case like this:
```
type t
character(11), allocatable :: c
end type
character(12), alloctable :: x
type(t) y
y = t(x)
```

The frontend representes `y = t(x)` as `y=t(c=%SET_LENGTH(x,11_8))`.
When 'x' is unallocated the hlfir.set_length lowering results in
segfault. It could probably be handled in hlfir.set_length lowering
by using NULL base for the hlfir.declare depending on the allocation
status of 'x', but I am not sure if !hlfir.expr, in general, is supposed
to represent an expression created from unallocated allocatable.
I believe in Fortran that would mean referencing an unallocated
allocatable, which is not allowed.

I decided to special case `SET_LENGTH` in structure constructor,
so that we use its 'x' operand as the RHS for the assign operation
implying the isAllocatable check for cases when 'x' is allocatable.
This requires setting keep_lhs_length_if_realloc flag for the assign
operation. Note that when the component being intialized has
deferred length the frontend does not produce `SET_LENGTH`.

Differential Revision: https://reviews.llvm.org/D155151
…VMergeAndVOps [nfc]

We have the SEW operand access repeating in all paths, common it up to make the code easier to read.

This is a subset of Luke's D155063.  I'm splitting pieces and landing them in the process of convincing myself all the individual transforms are in fact correct.
The early outlining pass was erasing target functions that need to be
kept. It should only erase functions that contain target ops.
Very minor change, just making sure each step is obvious and easy to follow.

This is a subset of Luke's D155063.  I'm splitting pieces and landing them in the process of convincing myself all the individual transforms are in fact correct.
…for declare target

This is an attempt at mimicing the method in which
threadprivate handles the following type of variables:

program main
  integer :: i
  !$omp declare target to(i)
end

Which essentially generates a GlobalOp for the variable (which
would normally only be an alloca) when it's instantiated. The
main difference is there is no operation generated within the
function, instead the declare target attribute is appended
later within handleDeclareTarget.

Reviewers: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D152037
…:begin

To fix expensive check builds that were failing when using MSVC's
std::string_view::iterator::operator*, I added a few expressions like
&*std::string_view::begin.  @nico pointed out that this is literally the
same thing and more clearly expressed as std::string_view::data.

Link: llvm/llvm-project#63740

Reviewed By: #libc_abi, ldionne, philnik, MaskRay

Differential Revision: https://reviews.llvm.org/D154876
…AndVOps [nfc]

This is a subset of Luke's D155063.  I'm splitting pieces and landing them in the process of convincing myself all the individual transforms are in fact correct.

This particular change involves a slightly ugly bit of code to match the glue to the mask.  I'm staging it this way as I ran into a bit of weirdness when commoning mask operands, and wanted to isolate the complexity.
ENABLE_X86_RELAX_RELOCATIONS has defaulted to on
(c41a18c) for nearly 3 years.
As a clean-up, remove overrides from some early adopters.

Change OHOS to use true as agreed by the patch author D145227.
Setting initial offset of DIE to input DIE. This is to make "printf" debugging
easier.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D155031
…rseLt

Also makes some minor consistency edits in the cuSparseLt wrapper lib.

Reviewed By: Peiming, K-Wu

Differential Revision: https://reviews.llvm.org/D155139
…rinsic. NFC

The greediness of the operand matching regular expressions made
the test pass even though an operand is missing.
…onstraint.

GCC and existing codebases allow the use of integral values to be used
with this constraint. A recent change D133914 in this area started causing asserts.
Removing the assert is enough as the rest of the code works fine.

rdar://109675485

Differential Revision: https://reviews.llvm.org/D155023
The DWO Unit DIE, doesn't have low_pc/high_pc, so we were printing this error
for valid cases.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D155032
There are cases in DWARF4 when Skeleton CU has ranges, but dwo CU doesn't.
Bug was introduced in new DWARFRewriter where for DWARF4 it would fall through
to DWARF5 case.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D155033
This patch moves a few tests that were still using std::fprintf to
using TEST_REQUIRE instead, which provides a single point to tweak
for platforms that don't implement fprintf. As a fly-by fix, it also
avoids including `time_utils.h` in filesystem_clock.cpp when it is
not required, since that header makes some pretty large assumptions
about the platform it is on.

Differential Revision: https://reviews.llvm.org/D155019
This test has been failing on sanitizer-x86_64-linux-bootstrap-asan
since it was commited. Removing this test while I work on reproducing
this.

Example: https://lab.llvm.org/buildbot/#/builders/168/builds/14579
Read ORC (oops rewind capability) info used for unwinding the stack by
Linux Kernel. The info is stored in .orc_unwind and .orc_unwind_ip
sections. There is also a related .orc_lookup section that is being
populated by the kernel during runtime. Contents of the sections are
sorted for quicker lookup by a post-link objtool.

Unless we modify stack access instructions, we don't have to change ORC
info attributed to instructions in the binary. However, we need to
update instruction addresses and sort both sections based on the new
layout.

For pretty printing, we add "--print-orc" option that prints ORC info
next to instructions in code dumps.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D154815
…ineVMergeAndVOps [nfc]

This is a subset of Luke's D155063.  I'm splitting pieces and landing them in the process of convincing myself all the individual transforms are in fact correct.

The code structure here is overly verbose.  I'm landing this staging change with the code structure exactly matching the non-masked case to make the following cleanup that commons this all obviously correct.
Add MetadataRewriter::postCFGInitializer().

Reviewed By: jobnoorman

Differential Revision: https://reviews.llvm.org/D155153
@Chenyang-L
Copy link
Contributor

@bader I think this is ready to merge. The cmath*.ll tests are flaky from what I've seen and everything else is passing.

@bader
Copy link
Contributor

bader commented Aug 4, 2023

The cmath*.ll tests are flaky from what I've seen and everything else is passing.

Do you mean sycl/test-e2e/DeviceLib/cmath*.cpp test? AFAIK, these are quite stable in the sycl branch, so I suppose failures are caused by the PR changes.

I see you did changes on top of what we pull from the community. I'd like code owners to approve them before merging.

@intel/dpcpp-spirv-reviewers, @intel/dpcpp-tools-reviewers, @intel/llvm-reviewers-runtime, @intel/dpcpp-esimd-reviewers, please, take a look at changes and let me if it's okay to merge. Here is the link with the diff for the latest 10 commits in this PR: https://github.com/intel/llvm/pull/10427/files/bbd88b0a0acc0c946f59e3a50c3788408e890dfc..HEAD. Please, review everything except lld changes.

E.g. b2c98d5 - the test passes on Windows (see latest pre-commit results). We need to figure out why it doesn't work on Linux.

@Chenyang-L, did you open a tracker for all the tests disabled in this PR?

@Chenyang-L
Copy link
Contributor

Chenyang-L commented Aug 4, 2023

The cmath*.ll tests are flaky from what I've seen and everything else is passing.

Do you mean sycl/test-e2e/DeviceLib/cmath*.cpp test? AFAIK, these are quite stable in the sycl branch, so I suppose failures are caused by the PR changes.

I see you did changes on top of what we pull from the community. I'd like code owners to approve them before merging.

@intel/dpcpp-spirv-reviewers, @intel/dpcpp-tools-reviewers, @intel/llvm-reviewers-runtime, @intel/dpcpp-esimd-reviewers, please, take a look at changes and let me if it's okay to merge. Here is the link with the diff for the latest 10 commits in this PR: https://github.com/intel/llvm/pull/10427/files/bbd88b0a0acc0c946f59e3a50c3788408e890dfc..b2c98d5d27e70a6f817b34fd15553154198026ad. Please, review everything except lld changes.

E.g. b2c98d5 - the test passes on Windows (see latest pre-commit results). We need to figure out why it doesn't work on Linux.

@Chenyang-L, did you open a tracker for all the tests disabled in this PR?

I opened a tracker for the lit tests disabled in this PR. I just noticed I included some Intel related changes that preserved some of the previous typed pointer code. If needed, those can be removed.

@sarnex
Copy link
Contributor

sarnex commented Aug 7, 2023

For ESIMD, I have no idea why sycl/test-e2e/ESIMD/private_memory.cpp is failing, IMO it's okay to merge this but please open a tracker and assign it to me to investigate.

@bader
Copy link
Contributor

bader commented Aug 7, 2023

For ESIMD, I have no idea why sycl/test-e2e/ESIMD/private_memory.cpp is failing, IMO it's okay to merge this but please open a tracker and assign it to me to investigate.

@sarnex, thanks for confirming.

@intel/dpcpp-spirv-reviewers, @intel/dpcpp-tools-reviewers, @intel/llvm-reviewers-runtime, we need your confirmation too. Please, take a look at changes and let me if it's okay to merge. Details are in my previous comment - #10427 (comment).

@jsji
Copy link
Contributor

jsji commented Aug 9, 2023

@intel/dpcpp-spirv-doc-reviewers @intel/dpcpp-tools-reviewers @intel/llvm-reviewers-runtime Can you please have a look? We need to get this merged ASAP, as we have HUGE backlog (sycl branch is 1.5 months behind main now), we need to start another pulldown soon. Thanks.

@bader
Copy link
Contributor

bader commented Aug 9, 2023

E.g. b2c98d5 - the test passes on Windows (see latest pre-commit results).

Maybe it wasn't clear from the previous message, but we need to fix the status of the test on Windows. CI checks results are "fail" on Windows. @Chenyang-L, @jsji, please, make sure there are no regressions in CI checks except clang-format check.

@jsji
Copy link
Contributor

jsji commented Aug 9, 2023

E.g. b2c98d5 - the test passes on Windows (see latest pre-commit results).

Maybe it wasn't clear from the previous message, but we need to fix the status of the test on Windows. CI checks results are "fail" on Windows. @Chenyang-L, @jsji, please, make sure there are no regressions in CI checks except clang-format check.

Did I interpret the result correctly? It is a unexpected pass? @Chenyang-L @bader ?
FYI. @tylanphear @wwXing0 Let us take over this to get this merged. Thanks.

Unexpectedly Passed Tests (1):
SYCL :: DeviceLib/cmath_test.cpp

@jsji jsji force-pushed the llvmspirv_pulldown branch from b2c98d5 to 3cdff00 Compare August 9, 2023 19:14
@jsji
Copy link
Contributor

jsji commented Aug 9, 2023

Did I interpret the result correctly? It is a unexpected pass? @Chenyang-L @bader ? FYI. @tylanphear @wwXing0 Let us take over this to get this merged. Thanks.

Unexpectedly Passed Tests (1): SYCL :: DeviceLib/cmath_test.cpp

I force-pushed to XFAIL this on Linux only. Let us see the test result.

@jsji jsji force-pushed the llvmspirv_pulldown branch from 3cdff00 to 3541c3e Compare August 9, 2023 23:58
@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

Hmm.. Looks like we have some sort of CI env differences?
There is NO source code change, I only changed the XFAIL in in the test file ESIMD/private_memory.cpp.

2 hours ago, CI is telling me, this test is XPASS:
https://github.com/intel/llvm/actions/runs/5813164854/job/15762998873

So I reverted it back to original state.
Then the CI 24 minutes ago is telling me , this test is now XFAIL!
https://github.com/intel/llvm/actions/runs/5815260358/job/15767274830

Looking at the log:

XPASS one is with only L0 runtime:

"::group::sycl-ls --verbose"
[ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Iris(R) Xe Graphics 1.3 [1.3.26370]

: 'RUN: at line 13'; D:/github/actions-runner/_work/llvm/llvm/install/bin/clang++.exe -fsycl -fsycl-targets=spir64 D:\github\actions-runner_work\llvm\llvm\llvm\sycl\test-e2e\ESIMD\private_memory.cpp -fsycl-device-code-split=per_kernel -o D:\github\actions-runner_work\llvm\llvm\build-e2e\ESIMD\Output\private_memory.cpp.tmp.out
: 'RUN: at line 14'; env ONEAPI_DEVICE_SELECTOR=ext_oneapi_level_zero:gpu D:\github\actions-runner_work\llvm\llvm\build-e2e\ESIMD\Output\private_memory.cpp.tmp.out

XFAILED one is with both OCL and L0 runtime:

[opencl:gpu:0] Intel(R) OpenCL Graphics, Intel(R) Iris(R) Xe Graphics OpenCL 3.0 NEO [31.0.101.4502]
[ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Iris(R) Xe Graphics 1.3 [1.3.26370]

: 'RUN: at line 13'; D:/github/_work/llvm/llvm/install/bin/clang++.exe -fsycl -fsycl-targets=spir64 D:\github_work\llvm\llvm\llvm\sycl\test-e2e\ESIMD\private_memory.cpp -fsycl-device-code-split=per_kernel -o D:\github_work\llvm\llvm\build-e2e\ESIMD\Output\private_memory.cpp.tmp.out
: 'RUN: at line 14'; env ONEAPI_DEVICE_SELECTOR=ext_oneapi_level_zero:gpu D:\github_work\llvm\llvm\build-e2e\ESIMD\Output\private_memory.cpp.tmp.out

But both are testing L0 runtime.
So looks like we have different build env here? I suspect that we did not clobber build in the 2nd run in Machine name: 'JFEW-TL-119893'

@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

Hmm, I am really confused by the CI here. I need some help to investigate what is really wrong here. @aelovikov-intel @bader Can either of you help here? Thanks.

eg: I pushed a commit, and there are two Post-commit CI triggered, one for the commit and passed, the other for the PR it failed. What are the difference of these two Post-commit CI? Why we need to run two times?

LLVM and SPIRV-LLVM-Translator pulldown (WW29)
SYCL Post Commit #4171: Pull request #10427 synchronize by jsji
llvmspirv_pulldown
6 hours ago
3h 41m 51s
mark 2 sycl tests XFAIL
SYCL Post Commit #4170: Commit 3cdff00 pushed by jsji
llvmspirv_pulldown
6 hours ago
3h 22m 20s

The PR run was successful: https://github.com/intel/llvm/actions/runs/5815261173
But the commit itself is failing: https://github.com/intel/llvm/actions/runs/5815260358

@bader
Copy link
Contributor

bader commented Aug 10, 2023

@intel/dpcpp-spirv-reviewers, @intel/dpcpp-tools-reviewers, @intel/llvm-reviewers-runtime, we need your confirmation too. Please, take a look at changes and let me if it's okay to merge. Details are in my previous comment - #10427 (comment).

Ping.

@bader
Copy link
Contributor

bader commented Aug 10, 2023

I think we can drop this commit - fb840cd. It's not needed as we switched to opaque pointers by default.

@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

I think we can drop this commit - fb840cd. It's not needed as we switched to opaque pointers by default.

If we are going to do this, then we need to get rid of more:

Let me try to reorg the commit a little bit, but it might cause additional efforts to clean up these tests due to the outdated code.

@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

23 successful, 4 failing, and 1 skipped checks

Mark the current status -- the 4 failure are known failures -- 2 clang-format failures, 2 MacOS failures also seen in sycl.

@jsji jsji force-pushed the llvmspirv_pulldown branch from c35f82b to 3963ab4 Compare August 10, 2023 20:37
@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

Force pushed to include only necessary changes -- discard all other opaque pointer lit changes first for now. Will cherry-pick some of them if we see failures in CI.

@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

Hmm, I am really confused by the CI here. I need some help to investigate what is really wrong here. @aelovikov-intel @bader Can either of you help here? Thanks.

eg: I pushed a commit, and there are two Post-commit CI triggered, one for the commit and passed, the other for the PR it failed. What are the difference of these two Post-commit CI? Why we need to run two times?

LLVM and SPIRV-LLVM-Translator pulldown (WW29) SYCL Post Commit #4171: Pull request #10427 synchronize by jsji llvmspirv_pulldown 6 hours ago 3h 41m 51s mark 2 sycl tests XFAIL SYCL Post Commit #4170: Commit 3cdff00 pushed by jsji llvmspirv_pulldown 6 hours ago 3h 22m 20s

The PR run was successful: https://github.com/intel/llvm/actions/runs/5815261173 But the commit itself is failing: https://github.com/intel/llvm/actions/runs/5815260358

For completeness, the two CI run is somehow a bug or know limitation in CI, one (push) is running against branch itself, the other one (PR) is running against sycl branch , and since we switched the opaque pointer in sycl branch, we end up getting opposite result here.
That is why I HAVE to merge sycl branch into this PR again.

Thanks @aelovikov-intel for helping to sorting out this, and follow up to get rid of duplicate post-commit CI run.

@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

I think we can drop this commit - fb840cd. It's not needed as we switched to opaque pointers by default.

If we are going to do this, then we need to get rid of more:

Let me try to reorg the commit a little bit, but it might cause additional efforts to clean up these tests due to the outdated code.

So, looks like we DO need those commits like - fb840cd. 34b54f4 6a06f3e for the current stage of pulldown.

We have two choice:

  1. Merge this PR and keep those commits for now. Fixing them in next pulldown.
  2. Abandon this PR, doing a pulldown to get latest state of sycl-web and llvm-spirv code.

#2 will be better as it will get rid of these middle states of lit changes etc,
but apparently we will need more time to stabilize it.

@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

Close this first, try to do a new pulldown PR with latest state instead.

@jsji jsji closed this Aug 10, 2023
@bader
Copy link
Contributor

bader commented Aug 10, 2023

We have two choice:

  1. Merge this PR and keep those commits for now. Fixing them in next pulldown.
  2. Abandon this PR, doing a pulldown to get latest state of sycl-web and llvm-spirv code.

@jsji, I'm okay with option 1, if option 2 takes a lot of time.

@jsji jsji deleted the llvmspirv_pulldown branch August 10, 2023 21:54
@jsji
Copy link
Contributor

jsji commented Aug 10, 2023

We have two choice:

  1. Merge this PR and keep those commits for now. Fixing them in next pulldown.
  2. Abandon this PR, doing a pulldown to get latest state of sycl-web and llvm-spirv code.

@jsji, I'm okay with option 1, if option 2 takes a lot of time.

Thanks. Trying #2 in #10783 first. If we end up getting complications, then we can fall back to option 1 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disable-lint Skip linter check step and proceed with build jobs
Projects
None yet
Development

Successfully merging this pull request may close these issues.