platform/upstream/llvm.git
23 months ago[AArch64] Use std::optional in AArch64FrameLowering.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:57:21 +0000 (21:57 -0800)]
[AArch64] Use std::optional in AArch64FrameLowering.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Support] Use std::optional in VirtualFileSystem.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:53:00 +0000 (21:53 -0800)]
[Support] Use std::optional in VirtualFileSystem.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Support] Use std::optional in RISCVISAInfo.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:48:18 +0000 (21:48 -0800)]
[Support] Use std::optional in RISCVISAInfo.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Support] Use std::optional in JSON.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:45:47 +0000 (21:45 -0800)]
[Support] Use std::optional in JSON.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Support] Use std::optional in FormatVariadic.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:25:27 +0000 (21:25 -0800)]
[Support] Use std::optional in FormatVariadic.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Support] Use std::optional in ARMAttributeParser.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:22:19 +0000 (21:22 -0800)]
[Support] Use std::optional in ARMAttributeParser.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Remarks] Use std::optional in YAMLRemarkSerializer.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:18:04 +0000 (21:18 -0800)]
[Remarks] Use std::optional in YAMLRemarkSerializer.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Remarks] Use std::optional in YAMLRemarkParser.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:15:34 +0000 (21:15 -0800)]
[Remarks] Use std::optional in YAMLRemarkParser.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Remarks] Use std::optional in RemarkParser.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 05:13:15 +0000 (21:13 -0800)]
[Remarks] Use std::optional in RemarkParser.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[ProfileData] Use std::optional in GCOV.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 04:35:43 +0000 (20:35 -0800)]
[ProfileData] Use std::optional in GCOV.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Coverage] Use std::optional in CoverageMapping.cpp (NFC)
Kazu Hirata [Sat, 26 Nov 2022 04:33:10 +0000 (20:33 -0800)]
[Coverage] Use std::optional in CoverageMapping.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[mlir][vector] Add fold pattern for InsertOp(Constant into Constant)
Jakub Kuderski [Sat, 26 Nov 2022 04:00:48 +0000 (23:00 -0500)]
[mlir][vector] Add fold pattern for InsertOp(Constant into Constant)

This pattern comes with vector size threshold to make sure we do not
introduce too many large constants.

This help clean up code created by the Wide Integer Emulation pass.

Reviewed By: dcaballe

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

23 months ago[StaticAnalyzer] Don't use Optional::create (NFC)
Kazu Hirata [Fri, 25 Nov 2022 23:38:53 +0000 (15:38 -0800)]
[StaticAnalyzer] Don't use Optional::create (NFC)

Note that std::optional does not offer create().

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months agoAdd version to all LLVM cmake package
Thomas Preud'homme [Thu, 17 Nov 2022 23:35:18 +0000 (23:35 +0000)]
Add version to all LLVM cmake package

Add a version to non-LLVM cmake package so that users needing an exact
version match can use the version parameter to find_package. Also adjust
the find_package(LLVM) to use an exact version match as well.

Reviewed By: arsenm, stellaraccident, mceier

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

23 months ago[mlir][spirv] Enable WebGPU to use UnifyAliasedResourcePass
Lei Zhang [Fri, 25 Nov 2022 21:53:37 +0000 (21:53 +0000)]
[mlir][spirv] Enable WebGPU to use UnifyAliasedResourcePass

When targeting WebGPU, we also need to transcompile SPIR-V, into
WGSL this time. We have similar limitations there like when
targeting Metal or MoltenVK.

Reviewed By: kuhar

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

23 months ago[mlir][spirv] Add a field for client API in target environment
Lei Zhang [Fri, 25 Nov 2022 21:31:12 +0000 (21:31 +0000)]
[mlir][spirv] Add a field for client API in target environment

SPIR-V can be directly consumed by APIs like Vulkan and OpenCL,
where we can use the capability list to diffferentiate. It can
also be used as a compilation target to transcompile to shading
languages like WGSL to target WebGPU. We have no way to tell
that with just the capability list, so we cannot perform certain
transformations only applicable to those targets thus far. So
this commit add a field in the target environment to indicate
the client API for such purposes.

Reviewed By: kuhar

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

23 months ago[Passes] Use std::optional in PassBuilder.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:47:46 +0000 (12:47 -0800)]
[Passes] Use std::optional in PassBuilder.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Object] Use std::optional in ELFObjectFile.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:44:51 +0000 (12:44 -0800)]
[Object] Use std::optional in ELFObjectFile.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[AIX][LTO] Teaching lto-aix-system-assembler Relative Path and Tilde Resolution
Qiongsi Wu [Fri, 25 Nov 2022 20:33:33 +0000 (15:33 -0500)]
[AIX][LTO] Teaching lto-aix-system-assembler Relative Path and Tilde Resolution

The `lto-aix-system-assembler` currently only understands absolute path. This patch teaches the option so that it can resolve relative paths and tilde.

Reviewed By: w2yehia

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

23 months ago[ObjectYAML] Use std::optional in MinidumpEmitter.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:34:10 +0000 (12:34 -0800)]
[ObjectYAML] Use std::optional in MinidumpEmitter.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months agoRevert "[LLDB] Recognize `std::noop_coroutine()` in `std::coroutine_handle` pretty...
Jason Molenda [Fri, 25 Nov 2022 20:28:28 +0000 (12:28 -0800)]
Revert "[LLDB] Recognize `std::noop_coroutine()` in `std::coroutine_handle` pretty printer"

This reverts commit 4346318f5c700f4e85f866610fb8328fc429319b.

This test case is failing on macOS, reverting until it can be
looked at more closely to unblock the macOS CI bots.

```
  File "/Volumes/work/llvm/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py", line 121, in test_libcpp
    self.do_test(USE_LIBCPP)
  File "/Volumes/work/llvm/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py", line 45, in do_test
    self.expect_expr("noop_hdl",
  File "/Volumes/work/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2441, in expect_expr
    value_check.check_value(self, eval_result, str(eval_result))
  File "/Volumes/work/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 306, in check_value
    test_base.assertEqual(self.expect_summary, val.GetSummary(),
AssertionError: 'noop_coroutine' != 'coro frame = 0x100004058'
- noop_coroutine+ coro frame = 0x100004058 : (std::coroutine_handle<void>) $1 = coro frame = 0x100004058 {
  resume = 0x0000000100003344 (a.out`___lldb_unnamed_symbol223)
  destroy = 0x0000000100003344 (a.out`___lldb_unnamed_symbol223)
}
Checking SBValue: (std::coroutine_handle<void>) $1 = coro frame = 0x100004058 {
  resume = 0x0000000100003344 (a.out`___lldb_unnamed_symbol223)
  destroy = 0x0000000100003344 (a.out`___lldb_unnamed_symbol223)
}
```

Those lldb_unnamed_symbols are synthetic names that ObjectFileMachO
adds to the symbol table, most often seen with stripped binaries,
based off of the function start addresses for all the functions -
if a function has no symbol name, lldb adds one of these names.
This change was originally landed via https://reviews.llvm.org/D132624

23 months ago[ObjectYAML] Use std::optional in CodeViewYAMLSymbols.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:31:45 +0000 (12:31 -0800)]
[ObjectYAML] Use std::optional in CodeViewYAMLSymbols.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[MC] Use std::optional in MCSchedule.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:28:42 +0000 (12:28 -0800)]
[MC] Use std::optional in MCSchedule.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[MCParser] Use std::optional in WasmAsmParser.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:26:10 +0000 (12:26 -0800)]
[MCParser] Use std::optional in WasmAsmParser.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[flang] Update fir.dispatch op lowering for tbp with character result
Valentin Clement [Fri, 25 Nov 2022 20:23:50 +0000 (21:23 +0100)]
[flang] Update fir.dispatch op lowering for tbp with character result

Take into account the result passed as arguments when computing
the pass object index.

Reviewed By: jeanPerier

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

23 months agoRevert "[LLDB] Do not dereference promise pointer in `coroutine_handle` pretty printer"
Jason Molenda [Fri, 25 Nov 2022 20:15:47 +0000 (12:15 -0800)]
Revert "[LLDB] Do not dereference promise pointer in `coroutine_handle` pretty printer"

This reverts commit cd3091a88f7c55c90d9b5fff372ce1cdfc71948d.

This change crashes on macOS systems in
formatters::StdlibCoroutineHandleSyntheticFrontEnd when
it fails to create the `ValueObjectSP promise` and calls
a method on it.  The failure causes a segfault while running
TestCoroutineHandle.py on the "LLDB Incremental" CI bot,
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/

This change originally landed via https://reviews.llvm.org/D132815

23 months ago[MCParser] Use std::optional in MasmParser.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:20:51 +0000 (12:20 -0800)]
[MCParser] Use std::optional in MasmParser.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Linker] Use std::optional in IRMover.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:18:23 +0000 (12:18 -0800)]
[Linker] Use std::optional in IRMover.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[InterfaceStub] Use std::optional in ELFObjHandler.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:14:22 +0000 (12:14 -0800)]
[InterfaceStub] Use std::optional in ELFObjHandler.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months agoRevert "[lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE"
Jason Molenda [Fri, 25 Nov 2022 20:11:37 +0000 (12:11 -0800)]
Revert "[lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE"

The changes in https://reviews.llvm.org/D138612 cause a testsuite
failure on Darwin systems in TestCPPAccelerator.py, first flagged
by the "LLDB Incremental" CI bot.
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/
with the specific failure text appended to the phabracator.

This reverts commit c3c423b6cb2e1c00483e951ce8cc4d935e31cd14.

23 months ago[IR] Use std::optional in Verifier.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:11:44 +0000 (12:11 -0800)]
[IR] Use std::optional in Verifier.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[IR] Use std::optional in PassManager.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:08:56 +0000 (12:08 -0800)]
[IR] Use std::optional in PassManager.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[IR] Use std::optional in Module.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:06:20 +0000 (12:06 -0800)]
[IR] Use std::optional in Module.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[IR] Use std::optional in IntrinsicInst.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:03:40 +0000 (12:03 -0800)]
[IR] Use std::optional in IntrinsicInst.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[IR] Use std::optional in AsmWriter.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 20:01:12 +0000 (12:01 -0800)]
[IR] Use std::optional in AsmWriter.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Symbolize] Use std::optional in MarkupFilter.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:58:33 +0000 (11:58 -0800)]
[Symbolize] Use std::optional in MarkupFilter.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Native] Use std::optional in NativeTypeEnum.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:55:58 +0000 (11:55 -0800)]
[Native] Use std::optional in NativeTypeEnum.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[GSYM] Use std::optional in FunctionInfo.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:52:53 +0000 (11:52 -0800)]
[GSYM] Use std::optional in FunctionInfo.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[GSYM] Use std::optional in DwarfTransformer.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:49:32 +0000 (11:49 -0800)]
[GSYM] Use std::optional in DwarfTransformer.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[mlir][vector] Update stale comment. NFC.
Jakub Kuderski [Fri, 25 Nov 2022 19:48:23 +0000 (14:48 -0500)]
[mlir][vector] Update stale comment. NFC.

23 months ago[openmp] Support building for armv7 Windows with mingw tools
Martin Storsjö [Thu, 10 Nov 2022 13:02:05 +0000 (15:02 +0200)]
[openmp] Support building for armv7 Windows with mingw tools

This does things in the same way as
D137168 / a356782426f5bf54a00570e1f925345e5fda7b2e and
D101173 / 4fb0aaf03381473ec8af727edb4b5d59b64b0d60 did for aarch64.

This adds a C implementation of __kmp_invoke_microtask in the same
way as the fallback C implementation in z_Linux_util.cpp.

Both the existing C fallback used on arm linux, and this one added here,
fail test/misc_bugs/many-microtask-args.c similarly (which could be
considered as an XFAIL).

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

23 months ago[openmp] Fix build break for less common architectures
Martin Storsjö [Fri, 25 Nov 2022 12:17:24 +0000 (14:17 +0200)]
[openmp] Fix build break for less common architectures

fb947c358661b3bd3d5e1fa776ec74cc0f308854 introduced the gas
macro COMMON, but it was only defined within ifdefs of the form:

    #if (KMP_OS_LINUX || KMP_OS_DARWIN || KMP_OS_WINDOWS) && KMP_ARCH_AARCH64

It was used, however, within other conditions:

    #if KMP_ARCH_ARM || KMP_ARCH_MIPS

and:

    #if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64

Move the definition of the COMMON macro out from the current ifdef,
so that it always gets defined (as it's only dependent on the target
platform).

This fixes building on ARM (and presumably all the other mentioned
architectures except aarch64).

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

23 months ago[DWARF] Use std::optional in DWARFFormValue.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:45:47 +0000 (11:45 -0800)]
[DWARF] Use std::optional in DWARFFormValue.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[mlir][vector] Update fold pattern name. NFC.
Jakub Kuderski [Fri, 25 Nov 2022 19:43:13 +0000 (14:43 -0500)]
[mlir][vector] Update fold pattern name. NFC.

23 months ago[DWARF] Use std::optional in DWARFDebugFrame.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:41:44 +0000 (11:41 -0800)]
[DWARF] Use std::optional in DWARFDebugFrame.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[CodeView] Use std::optional in TypeStreamMerger.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:37:32 +0000 (11:37 -0800)]
[CodeView] Use std::optional in TypeStreamMerger.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Reader] Use std::optional in BitcodeReader.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:33:19 +0000 (11:33 -0800)]
[Reader] Use std::optional in BitcodeReader.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in ValueTracking.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:30:34 +0000 (11:30 -0800)]
[Analysis] Use std::optional in ValueTracking.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in ScalarEvolution.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 19:25:45 +0000 (11:25 -0800)]
[Analysis] Use std::optional in ScalarEvolution.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[AArch64] Assembly support for FEAT_LRCPC3
Tomas Matheson [Tue, 8 Mar 2022 16:46:50 +0000 (16:46 +0000)]
[AArch64] Assembly support for FEAT_LRCPC3

This patch implements assembly support for the 2022 A-Profile Architecture
extension FEAT_LRCPC3. FEAT_LRCPC3 is AArch64 only and introduces new
variants of load/store instructions with release consistency ordering.

Specs for individual instructions can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09/Base-Instructions/

This feature is optionally available from v8.2a and therefore not enabled by
default.

Contributors:
  Lucas Prates
  Sam Elliot
  Son Tuan Vu
  Tomas Matheson

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

23 months ago[mlir][vector] Add fold for ExtractStridedSlice(non-splat ConstantOp)
Jakub Kuderski [Fri, 25 Nov 2022 18:41:24 +0000 (13:41 -0500)]
[mlir][vector] Add fold for ExtractStridedSlice(non-splat ConstantOp)

This allows us to better canonicalize/clean-up code created by the Wide
Integer Emulation pass.

Reviewed By: antiagainst

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

23 months ago[mlir][vector] Constant fold sub-vector extraction
Jakub Kuderski [Fri, 25 Nov 2022 18:39:35 +0000 (13:39 -0500)]
[mlir][vector] Constant fold sub-vector extraction

This generalizes the existing fold for `ExtractOp(non-splat constant)`
to work with vector results. The vector case is handled by extracting
the subrange of attribute array.

My main use it to clean up code generated by the Wide Integer Emulation
pass.

Reviewed By: antiagainst

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

23 months ago[Analysis] Use std::optional in MemoryLocation.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 18:32:21 +0000 (10:32 -0800)]
[Analysis] Use std::optional in MemoryLocation.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in LoopAnalysisManager.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 18:28:54 +0000 (10:28 -0800)]
[Analysis] Use std::optional in LoopAnalysisManager.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in LazyValueInfo.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 18:25:36 +0000 (10:25 -0800)]
[Analysis] Use std::optional in LazyValueInfo.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in InlineCost.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 18:22:33 +0000 (10:22 -0800)]
[Analysis] Use std::optional in InlineCost.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in CGSCCPassManager.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 18:18:53 +0000 (10:18 -0800)]
[Analysis] Use std::optional in CGSCCPassManager.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in CFLAndersAliasAnalysis.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 18:16:32 +0000 (10:16 -0800)]
[Analysis] Use std::optional in CFLAndersAliasAnalysis.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::optional in BasicAliasAnalysis.cpp (NFC)
Kazu Hirata [Fri, 25 Nov 2022 18:11:42 +0000 (10:11 -0800)]
[Analysis] Use std::optional in BasicAliasAnalysis.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[include-cleaner] Fix a warning
Kazu Hirata [Fri, 25 Nov 2022 17:51:25 +0000 (09:51 -0800)]
[include-cleaner] Fix a warning

This patch fixes:

  clang-tools-extra/include-cleaner/lib/HTMLReport.cpp:240:51: error:
  missing field 'Locations' initializer
  [-Werror,-Wmissing-field-initializers]

23 months ago[RISCV] Add ADD to getRegAllocationHints to improve to improve use of c.add.
Craig Topper [Fri, 25 Nov 2022 16:57:34 +0000 (08:57 -0800)]
[RISCV] Add ADD to getRegAllocationHints to improve to improve use of c.add.

add can always be compressed to c.add if one of the sources is the
same as the destination.

The same is not true for c.addw where the registers need to be x8-x15.

23 months ago[libc++][NFC] Add missing include to ext/__hash
Louis Dionne [Fri, 25 Nov 2022 15:25:57 +0000 (10:25 -0500)]
[libc++][NFC] Add missing include to ext/__hash

Note that we use <stddef.h> instead of <cstddef> because we're
using size_t (not std::size_t) and we're outside of namespace std.

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

23 months ago[RISCV] Use register allocation hints to improve use of compressed instructions.
Craig Topper [Fri, 25 Nov 2022 16:39:44 +0000 (08:39 -0800)]
[RISCV] Use register allocation hints to improve use of compressed instructions.

Compressed instructions usually require one of the source registers
to also be the source register. The register allocator doesn't have
that bias on its own.

This patch adds register allocation hints to introduce this bias.
I've started with ADDI, ADDIW, and SLLI. These all have a 5-bit
field for the register. If the source and dest register are the
same they are guaranteed to compress as long as the immediate is
also 6 bits.

This code was inspired by similar code from the SystemZ target.

Reviewed By: reames

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

23 months ago[mlir][Vector] Add a LowerVectorsOp to VectorTransformOps
Nicolas Vasilache [Fri, 25 Nov 2022 16:13:08 +0000 (08:13 -0800)]
[mlir][Vector] Add a LowerVectorsOp to VectorTransformOps

This op significantly improves transfor dialect usage when using vector abstractions.
It also brings us closer to writing simple end-to-end unit tests that guard against subtle regressions in how patterns combine.

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

23 months ago[X86] lowerShuffleAsDecomposedShuffleMerge - try to match unpck(permute(x),permute...
Simon Pilgrim [Fri, 25 Nov 2022 16:24:56 +0000 (16:24 +0000)]
[X86] lowerShuffleAsDecomposedShuffleMerge - try to match unpck(permute(x),permute(y)) for v4i32/v2i64 shuffles

We're using lowerShuffleAsPermuteAndUnpack, which can probably be improved to handle 256/512-bit types pretty easily.

First step towards trying to address the poor vector-shuffle-sse4a.ll pre-SSSE3 codegen mentioned on D127115

23 months ago[X86] oddshuffles.ll - update check-prefixes
Simon Pilgrim [Fri, 25 Nov 2022 16:13:14 +0000 (16:13 +0000)]
[X86] oddshuffles.ll - update check-prefixes

Share AVX common prefix with XOP as well as AVX1/AVX2

23 months agoRevert "[clang][modules] NFCI: Pragma diagnostic mappings: write/read FileID instead...
Alexander Kornienko [Fri, 25 Nov 2022 15:33:47 +0000 (16:33 +0100)]
Revert "[clang][modules] NFCI: Pragma diagnostic mappings: write/read FileID instead of SourceLocation"

This reverts commit f61c135a69084e470b73c26a8134785808ee246f. The commit affects
some build setups. See https://reviews.llvm.org/D137213#3939959.

23 months ago[libc++][NFC] Remove unused includes from poll_with_backoff.h
Louis Dionne [Thu, 24 Nov 2022 21:20:11 +0000 (16:20 -0500)]
[libc++][NFC] Remove unused includes from poll_with_backoff.h

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

23 months ago[LV] Use separate index to access StoredValues in vectorizeInterleave.
Florian Hahn [Fri, 25 Nov 2022 15:28:04 +0000 (15:28 +0000)]
[LV] Use separate index to access StoredValues in vectorizeInterleave.

StoredValues only has entries for members of the interleave group. If
there are gaps, then using the index i here will either access a wrong
entry or be out-of-bounds.

Instead use a dedicated index that only gets incremented for members of
the interleave group.

Fixes #59090.

23 months ago[libc++][NFC] Consistently use newline between license and include guard
Louis Dionne [Fri, 25 Nov 2022 15:25:10 +0000 (10:25 -0500)]
[libc++][NFC] Consistently use newline between license and include guard

23 months ago[AMDGPU][MC] Refactor MC Code Emitter to avoid using magic values
Dmitry Preobrazhensky [Fri, 25 Nov 2022 14:37:24 +0000 (17:37 +0300)]
[AMDGPU][MC] Refactor MC Code Emitter to avoid using magic values

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

23 months ago[X86] Move lowerShuffleAsPermuteAndUnpack earlier in the source next to similar helpe...
Simon Pilgrim [Fri, 25 Nov 2022 14:56:34 +0000 (14:56 +0000)]
[X86] Move lowerShuffleAsPermuteAndUnpack earlier in the source next to similar helpers. NFC.

I'm currently investigating using this inside lowerShuffleAsDecomposedShuffleMerge

23 months ago[libc++] Bump AppleClang compiler requirement
Louis Dionne [Thu, 24 Nov 2022 20:18:26 +0000 (15:18 -0500)]
[libc++] Bump AppleClang compiler requirement

Per our policy, the latest released AppleClang has been 14 for a while,
so libc++ is removing support for AppleClang 13. Our CI bots have been
moved to AppleClang 14 a few weeks ago.

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

23 months ago[clang-tidy] Ignore cxxRewrittenBinaryOperator in defaulted function decls in moderni...
Jens Massberg [Fri, 25 Nov 2022 14:29:57 +0000 (15:29 +0100)]
[clang-tidy] Ignore cxxRewrittenBinaryOperator in defaulted function decls in modernize-use-nullptr

The check has produced false positives when checking the default implementation of the spaceship operator.
The default implementation should be skipped by the check.

Modified the existing test so that the check runs into the bug without this fix and add another test case.

Fixes #53961.

Patch by Jens Massberg.

Reviewed By: ilya-biryukov

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

23 months ago[NFC] Clean up printing of UnwrappedLines.
Manuel Klimek [Fri, 25 Nov 2022 13:28:55 +0000 (13:28 +0000)]
[NFC] Clean up printing of UnwrappedLines.

Move print functions to start of UnwarppedLineParser so they can be
used from everywhere in the file.
Pull out function that doesn't hard-code the stream.

23 months ago[libc++] Use builtins when redeclaring <string.h> functions
Louis Dionne [Thu, 24 Nov 2022 19:28:48 +0000 (14:28 -0500)]
[libc++] Use builtins when redeclaring <string.h> functions

When we define the const-correct overloads of <string.h> functions in
libc++ itself, use builtins whenever possible. This avoids depending on
the presence of these functions in the C library headers.

Also, as a fly-by, improve the tests for these functions since we
basically didn't check anything but their signature. We could have
used the wrong builtin (as long as the signature matched) without ever
noticing, which was quite scary.

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

23 months agoRevert "[Support] Move getHostNumPhysicalCores to Threading.h"
Florian Hahn [Fri, 25 Nov 2022 14:11:56 +0000 (14:11 +0000)]
Revert "[Support] Move getHostNumPhysicalCores to Threading.h"

This reverts commit 5577207d6d3e0642ea047a8dfbfcf3ad372a7f25.

This breaks building LLVM on recent macOS. Error messages below:

llvm/lib/Support/Threading.cpp:190:3: error: use of undeclared
identifier 'sysctlbyname'
  sysctlbyname("hw.physicalcpu", &count, &len, NULL, 0);
    ^

llvm/lib/Support/Threading.cpp:193:13: error: use of undeclared
identifier 'CTL_HW'
    nm[0] = CTL_HW;
            ^

llvm/lib/Support/Threading.cpp:194:13: error: use of undeclared identifier 'HW_AVAILCPU'
    nm[1] = HW_AVAILCPU;
            ^

llvm/lib/Support/Threading.cpp:195:5: error: use of undeclared identifier 'sysctl'
    sysctl(nm, 2, &count, &len, NULL, 0);
    ^

23 months ago[NFC] Refactor loop peeling code for calculating phi invariance.
Jamie Schmeiser [Fri, 25 Nov 2022 14:05:59 +0000 (09:05 -0500)]
[NFC] Refactor loop peeling code for calculating phi invariance.

Summary:
Refactor loop peeling code by moving code for calculating phi invariance
into a separate class that does the calculation.  Redescribe and rework
the algorithm in preparation for adding increased functionality.  Add
test case that does not exhibit peeling that will be subsequently supported.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: mkazantsev (Max Kazantsev)
Differential Revision: https://reviews.llvm.org/D138232

23 months agoFix test output regression from ee88c0cf09969ba44307068797e12533b94768a6.
Manuel Klimek [Fri, 25 Nov 2022 13:53:34 +0000 (13:53 +0000)]
Fix test output regression from ee88c0cf09969ba44307068797e12533b94768a6.

The unused variable fix also remove the test output of the tokens
that do not match, making debugging tests harder. Undo the semantic
changes of the build fix.

23 months ago[flang] Allow fir.rebox to unlimited polymorphic box
Valentin Clement [Fri, 25 Nov 2022 13:41:41 +0000 (14:41 +0100)]
[flang] Allow fir.rebox to unlimited polymorphic box

This patch relaxes the verifier for the fir.rebox operation
to allow reboxing to unlimited polymoprhic box.

Reviewed By: jeanPerier, PeteSteinfeld

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

23 months ago[gn build] Port ed34590c1acb
LLVM GN Syncbot [Fri, 25 Nov 2022 13:20:54 +0000 (13:20 +0000)]
[gn build] Port ed34590c1acb

23 months ago[LLDB] Add LoongArch register definitions and operations
Tiezhu Yang [Fri, 25 Nov 2022 13:18:41 +0000 (21:18 +0800)]
[LLDB] Add LoongArch register definitions and operations

Use the same register layout as Linux kernel, implement the
related read and write operations.

Reviewed By: SixWeining, xen0n, DavidSpickett

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

23 months agoRevert "[Lex] Fix suggested spelling of /usr/bin/../include/foo"
Sam McCall [Fri, 25 Nov 2022 13:01:06 +0000 (14:01 +0100)]
Revert "[Lex] Fix suggested spelling of /usr/bin/../include/foo"

This reverts commit 8bed59c7e7da2fea41a9167e15c15a8f58a5ede7.

Breaks bots e.g. https://lab.llvm.org/buildbot/#/builders/216/builds/13282

23 months ago[mlir][Vector] Vector transform skeleton
Nicolas Vasilache [Tue, 21 Jun 2022 13:52:01 +0000 (06:52 -0700)]
[mlir][Vector] Vector transform skeleton

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

23 months ago[Support] Move getHostNumPhysicalCores to Threading.h
Archibald Elliott [Fri, 25 Nov 2022 12:14:48 +0000 (12:14 +0000)]
[Support] Move getHostNumPhysicalCores to Threading.h

This change is focussed on simplifying `Support/Host.h` to only do
target detection. In this case, this function is close in usage to
existing functions in `Support/Threading.h`, so I moved it into there.
The function is also renamed to `llvm::get_physical_cores()` to match
the style of threading's functions.

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

23 months ago[lldb][nfc] Deindent ProcessGDBRemote::SetThreadStopInfo by two levels
Pavel Labath [Fri, 25 Nov 2022 12:48:00 +0000 (13:48 +0100)]
[lldb][nfc] Deindent ProcessGDBRemote::SetThreadStopInfo by two levels

23 months ago[flang] Avoid crash in lowering for unlimited polymorphic function return
Valentin Clement [Fri, 25 Nov 2022 12:47:25 +0000 (13:47 +0100)]
[flang] Avoid crash in lowering for unlimited polymorphic function return

The dynamic type of an unlimited polymorphic entity has the
derived category but does not have derived type spec. This leads
to a crash for a nullptr dereference. This patch avoids this crash
by checking if that the dynamic type is not unlimited polymorphic
before dereferencing the derived type spec.

Reviewed By: PeteSteinfeld

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

23 months ago[RISCV] Branchless lowering for (select (x < 0), TrueConstant, FalseConstant) and...
LiaoChunyu [Thu, 17 Nov 2022 09:15:27 +0000 (17:15 +0800)]
[RISCV] Branchless lowering for (select (x < 0), TrueConstant, FalseConstant) and (select (x >= 0), TrueConstant, FalseConstant)

This patch reduces the number of unpredictable branches

(select (x < 0), y, z)  -> x >> (XLEN - 1) & (y - z) + z
(select (x >= 0), y, z) -> x >> (XLEN - 1) & (z - y) + y

Reviewed By: craig.topper, reames

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

23 months ago[include-cleaner] Make HTMLReport impl simpler/safer. NFC
Sam McCall [Fri, 25 Nov 2022 12:11:15 +0000 (13:11 +0100)]
[include-cleaner] Make HTMLReport impl simpler/safer. NFC

Targets and Refs are 1:1, so merge them.

Don't sort Refs array we keep indices into. (Currently we're done using
those indices by the time we sort, but this is fragile)

23 months agoDrop redundant pipe to opt -instnamer in clang tests
Alex Richardson [Thu, 24 Nov 2022 16:10:47 +0000 (16:10 +0000)]
Drop redundant pipe to opt -instnamer in clang tests

This used to be required, but the difference between asserts/!asserts
builds no longer exists for %clang_cc1 (only for %clang), so they pass
just fine without this flag.

23 months ago[BPF] Avoid checking for intrinsics using string comparisons. NFC
Alex Richardson [Fri, 25 Nov 2022 11:27:00 +0000 (11:27 +0000)]
[BPF] Avoid checking for intrinsics using string comparisons. NFC

Use a dyn_cast<> to IntrinsicInst and an enum compare instead.
While touching this code also re-generate the test to use positive check
lines instead of negative ones and remove some unneeded metadata.

Reviewed By: yonghong-song

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

23 months ago[ARM] Move ARM::parseBranchProtection into ARMTargetParserCommon
Archibald Elliott [Fri, 18 Nov 2022 13:15:49 +0000 (13:15 +0000)]
[ARM] Move ARM::parseBranchProtection into ARMTargetParserCommon

This should live with the Arm targets, given they have target-specific
target parsers.

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

23 months ago[X86] combineScalarAndWithMaskSetcc - handle (concat_vectors (and (vYi1 setcc, vYi1...
Simon Pilgrim [Fri, 25 Nov 2022 11:05:54 +0000 (11:05 +0000)]
[X86] combineScalarAndWithMaskSetcc - handle (concat_vectors (and (vYi1 setcc, vYi1 x), undef)) patterns

If one of the AND operands is a setcc then we're implicitly zeroing the upper mask bits

Similar pattern to regressions identified in D127115 (masked comparisons)

23 months ago[X86] Add test case for (any_extend (bitcast (concat_vectors (and (vYi1 setcc, vYi1...
Simon Pilgrim [Fri, 25 Nov 2022 10:54:21 +0000 (10:54 +0000)]
[X86] Add test case for (any_extend (bitcast (concat_vectors (and (vYi1 setcc, vYi1 x), undef)))) pattern

Similar pattern to a regression identified in D127115

23 months ago[include-cleaner] HTMLReport shows headers that would be inserted
Sam McCall [Thu, 24 Nov 2022 16:33:40 +0000 (17:33 +0100)]
[include-cleaner] HTMLReport shows headers that would be inserted

Demo: https://htmlpreview.github.io/?https://gist.githubusercontent.com/sam-mccall/9730f933a2cf2e003365520b6636f731/raw/7911d8251ceab7c244e0510285105027cd0a9403/PathMapping.cpp.html

Header insertion doesn't actually work that well (not this patch's fault):
- we don't have ranking of locations/headers yet, so inserted header is pretty
  random
- on my system, we get a lot of absolute "/usr/bin/../include/..." paths.
  This is a HeaderSearch bug introduced in D60873 that I'll send a fix for

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

23 months ago[lldb/test] Remove the module cache directory in module-ownership.mm
Pavel Labath [Fri, 25 Nov 2022 10:51:10 +0000 (11:51 +0100)]
[lldb/test] Remove the module cache directory in module-ownership.mm

The stale cache directory can cause compilation to fail when ast
serialization changes.

23 months ago[lldb] Prevent an infinite loop while reading memory regions
Pavel Labath [Fri, 25 Nov 2022 10:36:28 +0000 (11:36 +0100)]
[lldb] Prevent an infinite loop  while reading memory regions

A malformed qMemoryRegionInfo response can easily trigger an infinite
loop if regions end (base + size) wraps the address space. A
particularly interesting is the case where base+size=0, which a stub
could use to say that the rest of the memory space is unmapped, even
though lldb expects 0xff... in this case.

One could argue which behavior is more correct (technically, the
current behavior does not say anything about the last byte), but unless
we stop using 0xff... to mean "invalid address", that discussion is very
academic. This patch truncates address ranges which wraps the address
space, which handles the zero case as well as other kinds of malformed
packets.

23 months agoRevert: Add version to all LLVM cmake package
Thomas Preud'homme [Fri, 25 Nov 2022 10:54:58 +0000 (10:54 +0000)]
Revert: Add version to all LLVM cmake package

Summary: This reverts commit ad485b71b51168ce13282ae159bd8feff48baf84.

Reviewers:

Subscribers:

23 months ago[TargetLowering][AArch64] Teach DemandedBits about SVE count intrinsics
Benjamin Maxwell [Fri, 25 Nov 2022 09:57:08 +0000 (09:57 +0000)]
[TargetLowering][AArch64] Teach DemandedBits about SVE count intrinsics

This allows DemandedBits to see that the SVE count intrinsics (CNTB,
CNTH, CNTW, CNTD) sans multiplier will only ever produce small
positive integers. The maximum value you could get here is 256, which
is CNTB on a machine with a 2048bit vector size (the maximum for SVE).

Using this various redundant operations (zexts, sexts, ands, ors, etc)
can be eliminated.

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

23 months ago[Hexagon] Apply 7f06a5824cdb297a19b7c82bb191c22539f34070 to another copy of the same...
Benjamin Kramer [Fri, 25 Nov 2022 10:14:14 +0000 (11:14 +0100)]
[Hexagon] Apply 7f06a5824cdb297a19b7c82bb191c22539f34070 to another copy of the same code