Skip to content

LLVM and SPIRV-LLVM-Translator pulldown (WW09-10) #3312

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

Closed
wants to merge 1,431 commits into from

Conversation

vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo commented Mar 5, 2021

kazutakahirata and others added 30 commits February 26, 2021 16:32
For ELF targets, GCC 11 will set SHF_GNU_RETAIN on the section of a
`__attribute__((retain))` function/variable to prevent linker garbage
collection. (See AttrDocs.td for the linker support).

This patch adds `retain` functions/variables to the `llvm.used` list, which has
the desired linker GC semantics. Note: `retain` does not imply `used`,
so an unused function/variable can be dropped by Sema.

Before 'retain' was introduced, previous ELF solutions require inline asm or
linker tricks, e.g.  `asm volatile(".reloc 0, R_X86_64_NONE, target");`
(architecture dependent) or define a non-local symbol in the section and use
`ld -u`. There was no elegant source-level solution.

With D97448, `__attribute__((retain))` will set `SHF_GNU_RETAIN` on ELF targets.

Differential Revision: https://reviews.llvm.org/D97447
If a global object is listed in `@llvm.used`, place it in a unique section with
the `SHF_GNU_RETAIN` flag. The section is a GC root under `ld --gc-sections`
with LLD>=13 or GNU ld>=2.36.

For front ends which do not expect to see multiple sections of the same name,
consider emitting `@llvm.compiler.used` instead of `@llvm.used`.

SHF_GNU_RETAIN is restricted to ELFOSABI_GNU and ELFOSABI_FREEBSD in
binutils. We don't do the restriction - see the rationale in D95749.

The integrated assembler has supported SHF_GNU_RETAIN since D95730.
GNU as>=2.36 supports section flag 'R'.
We don't need to worry about GNU ld support because older GNU ld just ignores
the unknown SHF_GNU_RETAIN.

With this change, `__attribute__((retain))` functions/variables emitted
by clang will get the SHF_GNU_RETAIN flag.

Differential Revision: https://reviews.llvm.org/D97448
…per object. NFC

Currently, the IslAst library is a C library that would be incompatible with the rest of the LLVM because LLVM is written in C++.
I took one function, IsInnermostParallel(), and refactored it so that it would take the C++ wrapper object instead of using reference counters with the C ISL library. As well, all the references that use IsInnermostParallel() will use manage_copy() since they are still expecting the C object.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D97425
Specifically:

- InputChunk::outputOffset -> outSecOffset
- Symbol::get/setVirtualAddress -> get/setVA
- add InputChunk::getOffset helper that takes an offset

These are mostly in preparation for adding support for
SHF_MERGE/SHF_STRINGS but its also good to align with ELF where
possible.

Differential Revision: https://reviews.llvm.org/D97595
D97247 added the reverse mapping from unwind destination to their
source, but it had a critical bug; sources can be multiple, because
multiple BBs can have a single BB as their unwind destination.

This changes `WasmEHFuncInfo::getUnwindSrc` to `getUnwindSrcs` and makes
it return a vector rather than a single BB. It does not return the const
reference to the existing vector but creates a new vector because
`WasmEHFuncInfo` stores not `BasicBlock*` or `MachineBasicBlock*` but
`PointerUnion` of them. Also I hoped to unify those methods for
`BasicBlock` and `MachineBasicBlock` into one using templates to reduce
duplication, but failed because various usages require `BasicBlock*` to
be `const` but it's hard to make it `const` for `MachineBasicBlock`
usages.

Fixes emscripten-core/emscripten#13514.
(More precisely, fixes
emscripten-core/emscripten#13514 (comment))

Reviewed By: dschuff, tlively

Differential Revision: https://reviews.llvm.org/D97583
  - add ops: rebox, insert_on_range, absent, is_present
  - embox, coordinate_of: replace old hand-written parser/pretty-printer with assembly format
  - remove dead floating point ops, since buitlins work for all types
  - update call op
  - update documentation
  - misc. NFC to formatting
  - add op round trip tests

Authors: Eric Schweitz, Jean Perier, Zachary Selk, Kiran Chandramohan, et.al.

Differential Revision: https://reviews.llvm.org/D97500
This should now be about as style-conforming as TableGen'ed code ever
can reasonably be.
Includes a lowering for tosa.const, tosa.if, and tosa.while to Standard/SCF dialects. TosaToStandard is
used for constant lowerings and TosaToSCF handles the if/while ops.

Resubmission of https://reviews.llvm.org/D97518 with ASAN fixes.

Differential Revision: https://reviews.llvm.org/D97529
… to the Context/Dialect

This also exposed a bug in Dialect loading where it was not correctly identifying identifiers that had the dialect namespace as a prefix.

Differential Revision: https://reviews.llvm.org/D97431
This function will be used in subsequent upstreaming merges.

Author: Jean Perier

Differential Revision: https://reviews.llvm.org/D97502
…be null in DWARFLinker::loadClangModule

Split from D91844.

The local variable `Unit` in function `DWARFLinker::loadClangModule`
in file `llvm/lib/DWARFLinker/DWARFLinker.cpp`. If the variable is not set
in the loop below its definition, it will trigger a null pointer dereference
after the loop.

Patch By: OikawaKirie

Reviewed By: avl

Differential Revision: https://reviews.llvm.org/D97185
Per the discussion in D97453. We currently disable it due to it's not a
common scenario and has some problem in implementation.

Differential Revision: https://reviews.llvm.org/D97453
In the example based on:
https://llvm.org/PR49218
...we are crashing because poison is a subclass of undef, so we merge blocks and create:

PHI node has multiple entries for the same basic block with different incoming values!
  %k3 = phi i64 [ poison, %entry ], [ %k3, %g ], [ undef, %entry ]

If both poison and undef values are incoming, we soften the poison values to undef.

Differential Revision: https://reviews.llvm.org/D97495
… the BlockArgumentImpl

This avoids linear search in BlockArgument::getArgNumber().

Differential Revision: https://reviews.llvm.org/D97596
svenvh and others added 4 commits March 5, 2021 15:20
Update for LLVM commit d39bc36 ("[debug-info] refactor
emitDwarfUnitLength", 2021-02-25).

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@e219ce0
* [SPIRV] Encode debug info producer in SPIR-V

This is a workaround to keep debug info producer information throughout the
translation. We need it because the debug info specification doesn't provide
means to carry this information.

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@601e4a5
Add processing of a new parameter To/FromSign that specifies if integer value
to cast to/from is signed or not for ArbitraryFloatCastTo/FromInt functions.

See spec update (intel#1934): https://github.com/intel/llvm/blob/ea96f3ccee007e04074af6e275dbfce4fce13717/sycl/doc/extensions/SPIRV/SPV_INTEL_arbitrary_precision_floating_point.asciidoc

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@d46ee75
@vmaksimo
Copy link
Contributor Author

vmaksimo commented Mar 5, 2021

/summary:run

mdtoguchi
mdtoguchi previously approved these changes Mar 10, 2021
@vmaksimo
Copy link
Contributor Author

/summary:run

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
20 lit tests for CUDA are failed with the following assert:
"clang-13: llvm/lib/Transforms/Utils/CloneFunction.cpp:152:
 void llvm::CloneFunctionInto(llvm::Function*, const llvm::Function*,
                              llvm::ValueToValueMapTy&,
                              llvm::CloneFunctionChangeType,
                              llvm::SmallVectorImpl<llvm::ReturnInst*>&,
                              const char*, llvm::ClonedCodeInfo*,
                              llvm::ValueMapTypeRemapper*,
                              llvm::ValueMaterializer*)
   : Assertion `(NewFunc->getParent() == nullptr ||
                 NewFunc->getParent() != OldFunc->getParent()) &&
                "Set SameModule to true if the new function is in the same module"' failed."

Change CloneFunctionChangeType to pass those lit tests.

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
@mlychkov mlychkov requested a review from erichkeane March 11, 2021 14:19
@mlychkov
Copy link
Contributor

@mlychkov mlychkov removed the request for review from erichkeane March 11, 2021 14:22
@erichkeane
Copy link
Contributor

* @erichkeane @sndmitriev @rolandschulz @steffenlarsen @Pennycook
  Could you please review change in [e294673](https://github.com/intel/llvm/commit/e294673fb7860e89267600a10a037d7bae13f21b) for its correctness?

I don't really have any idea about the CloneFunction pass nor what CloneFunctionChangeType does.

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
@vmaksimo
Copy link
Contributor Author

/summary:run

mlychkov added a commit to mlychkov/llvm-test-suite that referenced this pull request Mar 24, 2021
The following tests have started to fail after intel/llvm#3312:
  SYCL :: Basic/context-with-multiple-devices.cpp
  SYCL :: Basic/fpga_tests/fpga_aocx.cpp
  SYCL :: Basic/fpga_tests/fpga_aocx_win.cpp
  SYCL :: Basic/fpga_tests/global_fpga_device_selector.cpp
  SYCL :: DeviceLib/complex-fpga.cpp
  SYCL :: Scheduler/DataMovement.cpp

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
SemaOpenCL/func.cl started to fail after intel#3312.

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
@mlychkov
Copy link
Contributor

Precommit LLVM_Test_Suite_Lin with XFAILed FPGA tests (intel/llvm-test-suite#192) is passed: http://icl-jenkins.sc.intel.com:8080/job/SYCL_CI/job/intel/job/Lin/job/LLVM_Test_Suite/2753
Precommit LLVM_Test_Suite_Win with XFAILed FPGA tests (intel/llvm-test-suite#192) is passed: http://icl-jenkins.sc.intel.com:8080/job/SYCL_CI/job/intel/job/Win/job/Test_Suite/1953/

@bader
Copy link
Contributor

bader commented Mar 25, 2021

/summary:run

@vmaksimo
Copy link
Contributor Author

These LLVM and SPIRV-LLVM-Translator changes were merged as a part of #3425

@vmaksimo vmaksimo closed this Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.