435 changes: 435 additions & 0 deletions libc/test/src/stdlib/StrfromTest.h

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions libc/test/src/stdlib/strfromd_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for strfromd --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "StrfromTest.h"
#include "src/stdlib/strfromd.h"
#include "test/UnitTest/Test.h"

STRFROM_TEST(double, Strfromd, LIBC_NAMESPACE::strfromd)
98 changes: 2 additions & 96 deletions libc/test/src/stdlib/strfromf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,102 +6,8 @@
//
//===----------------------------------------------------------------------===//

#include "StrfromTest.h"
#include "src/stdlib/strfromf.h"
#include "test/UnitTest/Test.h"

TEST(LlvmLibcStrfromfTest, DecimalFloatFormat) {
char buff[100];
int written;

written = LIBC_NAMESPACE::strfromf(buff, 16, "%f", 1.0);
EXPECT_EQ(written, 8);
ASSERT_STREQ(buff, "1.000000");

written = LIBC_NAMESPACE::strfromf(buff, 20, "%f", 1234567890.0);
EXPECT_EQ(written, 17);
ASSERT_STREQ(buff, "1234567936.000000");

written = LIBC_NAMESPACE::strfromf(buff, 5, "%f", 1234567890.0);
EXPECT_EQ(written, 17);
ASSERT_STREQ(buff, "1234");

written = LIBC_NAMESPACE::strfromf(buff, 67, "%.3f", 1.0);
EXPECT_EQ(written, 5);
ASSERT_STREQ(buff, "1.000");

written = LIBC_NAMESPACE::strfromf(buff, 20, "%1f", 1234567890.0);
EXPECT_EQ(written, 3);
ASSERT_STREQ(buff, "%1f");
}

TEST(LlvmLibcStrfromfTest, HexExpFloatFormat) {
char buff[100];
int written;

written = LIBC_NAMESPACE::strfromf(buff, 0, "%a", 1234567890.0);
EXPECT_EQ(written, 14);

written = LIBC_NAMESPACE::strfromf(buff, 20, "%a", 1234567890.0);
EXPECT_EQ(written, 14);
ASSERT_STREQ(buff, "0x1.26580cp+30");

written = LIBC_NAMESPACE::strfromf(buff, 20, "%A", 1234567890.0);
EXPECT_EQ(written, 14);
ASSERT_STREQ(buff, "0X1.26580CP+30");
}

TEST(LlvmLibcStrfromfTest, DecimalExpFloatFormat) {
char buff[100];
int written;
written = LIBC_NAMESPACE::strfromf(buff, 20, "%.9e", 1234567890.0);
EXPECT_EQ(written, 15);
ASSERT_STREQ(buff, "1.234567936e+09");

written = LIBC_NAMESPACE::strfromf(buff, 20, "%.9E", 1234567890.0);
EXPECT_EQ(written, 15);
ASSERT_STREQ(buff, "1.234567936E+09");
}

TEST(LlvmLibcStrfromfTest, AutoDecimalFloatFormat) {
char buff[100];
int written;

written = LIBC_NAMESPACE::strfromf(buff, 20, "%.9g", 1234567890.0);
EXPECT_EQ(written, 14);
ASSERT_STREQ(buff, "1.23456794e+09");

written = LIBC_NAMESPACE::strfromf(buff, 20, "%.9G", 1234567890.0);
EXPECT_EQ(written, 14);
ASSERT_STREQ(buff, "1.23456794E+09");

written = LIBC_NAMESPACE::strfromf(buff, 0, "%G", 1.0);
EXPECT_EQ(written, 1);
}

TEST(LlvmLibcStrfromfTest, ImproperFormatString) {

char buff[100];
int retval;
retval = LIBC_NAMESPACE::strfromf(
buff, 37, "A simple string with no conversions.", 1.0);
EXPECT_EQ(retval, 36);
ASSERT_STREQ(buff, "A simple string with no conversions.");

retval = LIBC_NAMESPACE::strfromf(
buff, 37, "%A simple string with one conversion, should overwrite.", 1.0);
EXPECT_EQ(retval, 6);
ASSERT_STREQ(buff, "0X1P+0");

retval = LIBC_NAMESPACE::strfromf(buff, 74,
"A simple string with one conversion in %A "
"between, writes string as it is",
1.0);
EXPECT_EQ(retval, 73);
ASSERT_STREQ(buff, "A simple string with one conversion in %A between, "
"writes string as it is");

retval = LIBC_NAMESPACE::strfromf(buff, 36,
"A simple string with one conversion", 1.0);
EXPECT_EQ(retval, 35);
ASSERT_STREQ(buff, "A simple string with one conversion");
}
STRFROM_TEST(float, StrFromf, LIBC_NAMESPACE::strfromf)
13 changes: 13 additions & 0 deletions libc/test/src/stdlib/strfroml_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for strfroml --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "StrfromTest.h"
#include "src/stdlib/strfroml.h"
#include "test/UnitTest/Test.h"

STRFROM_TEST(long double, Strfroml, LIBC_NAMESPACE::strfroml)
6 changes: 3 additions & 3 deletions libcxx/include/__algorithm/ranges_ends_with.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace ranges {
namespace __ends_with {
struct __fn {
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_bidirectional(
_LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional(
_Iter1 __first1,
_Sent1 __last1,
_Iter2 __first2,
Expand All @@ -56,7 +56,7 @@ struct __fn {
}

template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl(
_LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl(
_Iter1 __first1,
_Sent1 __last1,
_Iter2 __first2,
Expand All @@ -65,7 +65,7 @@ struct __fn {
_Proj1& __proj1,
_Proj2& __proj2) {
if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> &&
(!std::random_access_iterator<_Sent1>)&&(!std::random_access_iterator<_Sent2>)) {
(!std::random_access_iterator<_Sent1>) && (!std::random_access_iterator<_Sent2>)) {
return __ends_with_fn_impl_bidirectional(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);

} else {
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__algorithm/ranges_starts_with.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr bool operator()(
_Iter1 __first1,
_Sent1 __last1,
_Iter2 __first2,
_Sent2 __last2,
_Pred __pred = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
_Proj2 __proj2 = {}) {
return __mismatch::__fn::__go(
std::move(__first1),
std::move(__last1),
Expand All @@ -67,8 +67,8 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr bool
operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) {
return __mismatch::__fn::__go(
ranges::begin(__range1),
ranges::end(__range1),
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/__ranges/as_rvalue_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ namespace views {
namespace __as_rvalue {
struct __fn : __range_adaptor_closure<__fn> {
template <class _Range>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
noexcept(noexcept(/**/ as_rvalue_view(std::forward<_Range>(__range))))
-> decltype(/*--*/ as_rvalue_view(std::forward<_Range>(__range))) {
return /*-------------*/ as_rvalue_view(std::forward<_Range>(__range));
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto
operator()(_Range&& __range) noexcept(noexcept(as_rvalue_view(std::forward<_Range>(__range))))
-> decltype(/*--------------------------*/ as_rvalue_view(std::forward<_Range>(__range))) {
return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range));
}

template <class _Range>
requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
noexcept(noexcept(/**/ views::all(std::forward<_Range>(__range))))
-> decltype(/*--*/ views::all(std::forward<_Range>(__range))) {
return /*-------------*/ views::all(std::forward<_Range>(__range));
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto
operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range))))
-> decltype(/*--------------------------*/ views::all(std::forward<_Range>(__range))) {
return /*---------------------------------*/ views::all(std::forward<_Range>(__range));
}
};
} // namespace __as_rvalue
Expand Down
5 changes: 2 additions & 3 deletions libcxx/include/__ranges/repeat_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,13 @@ namespace views {
namespace __repeat {
struct __fn {
template <class _Tp>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __value) const
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Tp&& __value)
noexcept(noexcept(ranges::repeat_view(std::forward<_Tp>(__value))))
-> decltype( ranges::repeat_view(std::forward<_Tp>(__value)))
{ return ranges::repeat_view(std::forward<_Tp>(__value)); }


template <class _Tp, class _Bound>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __value, _Bound&& __bound_sentinel) const
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Tp&& __value, _Bound&& __bound_sentinel)
noexcept(noexcept(ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel))))
-> decltype( ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)))
{ return ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)); }
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__ranges/to.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args)
static_assert(
!is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");

auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail)
auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static
requires requires { //
/**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);
}
Expand All @@ -223,7 +223,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args)
// clang-format off
auto __to_func = []<input_range _Range, class... _Tail,
class _DeducedExpr = typename _Deducer<_Container, _Range, _Tail...>::type>
(_Range&& __range, _Tail&& ... __tail)
(_Range&& __range, _Tail&& ... __tail) static
requires requires { //
/**/ ranges::to<_DeducedExpr>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);
}
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__ranges/zip_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,12 @@ namespace views {
namespace __zip {

struct __fn {
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view<tuple<>>{}; }
_LIBCPP_HIDE_FROM_ABI static constexpr auto operator()() noexcept { return empty_view<tuple<>>{}; }

template <class... _Ranges>
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... __rs) const
noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
-> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
_LIBCPP_HIDE_FROM_ABI static constexpr auto
operator()(_Ranges&&... __rs) noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
-> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...);
}
};
Expand Down
5 changes: 4 additions & 1 deletion lld/ELF/Relocations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,10 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {

// Process TLS relocations, including TLS optimizations. Note that
// R_TPREL and R_TPREL_NEG relocations are resolved in processAux.
if (sym.isTls()) {
//
// Some RISCV TLSDESC relocations reference a local NOTYPE symbol,
// but we need to process them in handleTlsRelocation.
if (sym.isTls() || oneof<R_TLSDESC_PC, R_TLSDESC_CALL>(expr)) {
if (unsigned processed =
handleTlsRelocation(type, sym, *sec, offset, addend, expr)) {
i += processed - 1;
Expand Down
8 changes: 8 additions & 0 deletions lld/test/ELF/riscv-tlsdesc-relax.s
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
# GD64-NEXT: c.add a0, tp
# GD64-NEXT: jal {{.*}} <foo>
## &.got[c]-. = 0x20c0+8 - 0x1020 = 0x10a8
# GD64-LABEL: <.Ltlsdesc_hi1>:
# GD64-NEXT: 1020: auipc a4, 0x1
# GD64-NEXT: ld a5, 0xa8(a4)
# GD64-NEXT: addi a0, a4, 0xa8
# GD64-NEXT: jalr t0, 0x0(a5)
# GD64-NEXT: c.add a0, tp
## &.got[c]-. = 0x20c0+8 - 0x1032 = 0x1096
# GD64-LABEL: <.Ltlsdesc_hi2>:
# GD64-NEXT: 1032: auipc a6, 0x1
# GD64-NEXT: ld a7, 0x96(a6)
# GD64-NEXT: addi a0, a6, 0x96
Expand All @@ -64,13 +66,15 @@
# LE64-NEXT: jal {{.*}} <foo>
# LE64-NEXT: R_RISCV_JAL foo
# LE64-NEXT: R_RISCV_RELAX *ABS*
# LE64-LABEL: <.Ltlsdesc_hi1>:
# LE64-NEXT: addi a0, zero, 0x7ff
# LE64-NEXT: R_RISCV_TLSDESC_HI20 b
# LE64-NEXT: R_RISCV_RELAX *ABS*
# LE64-NEXT: R_RISCV_TLSDESC_LOAD_LO12 .Ltlsdesc_hi1
# LE64-NEXT: R_RISCV_TLSDESC_ADD_LO12 .Ltlsdesc_hi1
# LE64-NEXT: R_RISCV_TLSDESC_CALL .Ltlsdesc_hi1
# LE64-NEXT: c.add a0, tp
# LE64-LABEL: <.Ltlsdesc_hi2>:
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: R_RISCV_TLSDESC_HI20 b
# LE64-NEXT: addi zero, zero, 0x0
Expand All @@ -93,9 +97,11 @@
# LE64A-NEXT: addi a0, a0, -0x479
# LE64A-NEXT: c.add a0, tp
# LE64A-NEXT: jal {{.*}} <foo>
# LE64A-LABEL: <.Ltlsdesc_hi1>:
# LE64A-NEXT: lui a0, 0x2
# LE64A-NEXT: addi a0, a0, -0x479
# LE64A-NEXT: c.add a0, tp
# LE64A-LABEL: <.Ltlsdesc_hi2>:
# LE64A-NEXT: addi zero, zero, 0x0
# LE64A-NEXT: addi zero, zero, 0x0
# LE64A-NEXT: lui a0, 0x2
Expand All @@ -115,10 +121,12 @@
# IE64-NEXT: c.add a0, tp
# IE64-NEXT: jal {{.*}} <foo>
## &.got[c]-. = 0x120e0+8 - 0x11018 = 0x10d0
# IE64-LABEL: <.Ltlsdesc_hi1>:
# IE64-NEXT: 11018: auipc a0, 0x1
# IE64-NEXT: ld a0, 0xd0(a0)
# IE64-NEXT: c.add a0, tp
## &.got[c]-. = 0x120e0+8 - 0x1102a = 0x10be
# IE64-LABEL: <.Ltlsdesc_hi2>:
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: 1102a: auipc a0, 0x1
Expand Down
27 changes: 16 additions & 11 deletions lld/test/ELF/riscv-tlsdesc.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
# RUN: ld.lld -e 0 -z now a.32.o c.32.so -o a.32.ie
# RUN: llvm-objdump --no-show-raw-insn -M no-aliases -h -d a.32.ie | FileCheck %s --check-prefix=IE32

# RUN: llvm-mc -triple=riscv64 -filetype=obj d.s -o d.64.o
# RUN: not ld.lld -shared -soname=d.64.so -o d.64.so d.64.o 2>&1 | FileCheck %s --check-prefix=BADTLSLABEL
## Prior to https://github.com/llvm/llvm-project/pull/85817 the local TLSDESC
## labels would be marked STT_TLS, resulting in an error "has an STT_TLS symbol but doesn't have an SHF_TLS section"

# RUN: llvm-mc -triple=riscv64 -filetype=obj d.s -o d.64.o
# RUN: ld.lld -shared -soname=d.64.so -o d.64.so d.64.o --fatal-warnings
# RUN: llvm-mc -triple=riscv32 -filetype=obj d.s -o d.32.o --defsym ELF32=1
# RUN: not ld.lld -shared -soname=d.32.so -o d.32.so d.32.o 2>&1 | FileCheck %s --check-prefix=BADTLSLABEL
# RUN: ld.lld -shared -soname=d.32.so -o d.32.so d.32.o --fatal-warnings

# GD64-RELA: .rela.dyn {
# GD64-RELA-NEXT: 0x2408 R_RISCV_TLSDESC - 0x7FF
Expand Down Expand Up @@ -74,35 +76,37 @@
# GD64-NEXT: add a0, a0, tp

## &.got[b]-. = 0x23e0+40 - 0x12f4 = 0x1114
# GD64-NEXT: 12f4: auipc a2, 0x1
# GD64: 12f4: auipc a2, 0x1
# GD64-NEXT: ld a3, 0x114(a2)
# GD64-NEXT: addi a0, a2, 0x114
# GD64-NEXT: jalr t0, 0x0(a3)
# GD64-NEXT: add a0, a0, tp

## &.got[c]-. = 0x23e0+24 - 0x1308 = 0x10f0
# GD64-NEXT: 1308: auipc a4, 0x1
# GD64: 1308: auipc a4, 0x1
# GD64-NEXT: ld a5, 0xf0(a4)
# GD64-NEXT: addi a0, a4, 0xf0
# GD64-NEXT: jalr t0, 0x0(a5)
# GD64-NEXT: add a0, a0, tp

# NOREL: no relocations

# LE64-LABEL: <.text>:
# LE64-LABEL: <.Ltlsdesc_hi0>:
## st_value(a) = 8
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: addi a0, zero, 0x8
# LE64-NEXT: add a0, a0, tp
## st_value(b) = 2047
# LE64-LABEL: <.Ltlsdesc_hi1>:
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: addi a0, zero, 0x7ff
# LE64-NEXT: add a0, a0, tp
## st_value(c) = 2048
# LE64-LABEL: <.Ltlsdesc_hi2>:
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: addi zero, zero, 0x0
# LE64-NEXT: lui a0, 0x1
Expand All @@ -116,18 +120,20 @@
# IE64: .got 00000010 00000000000123a8

## a and b are optimized to use LE. c is optimized to IE.
# IE64-LABEL: <.text>:
# IE64-LABEL: <.Ltlsdesc_hi0>:
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi a0, zero, 0x8
# IE64-NEXT: add a0, a0, tp
# IE64-LABEL: <.Ltlsdesc_hi1>:
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi a0, zero, 0x7ff
# IE64-NEXT: add a0, a0, tp
## &.got[c]-. = 0x123a8+8 - 0x112b8 = 0x10f8
# IE64-LABEL: <.Ltlsdesc_hi2>:
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: addi zero, zero, 0x0
# IE64-NEXT: 112b8: auipc a0, 0x1
Expand All @@ -136,29 +142,28 @@

# IE32: .got 00000008 00012248

# IE32-LABEL: <.text>:
# IE32-LABEL: <.Ltlsdesc_hi0>:
## st_value(a) = 8
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: addi a0, zero, 0x8
# IE32-NEXT: add a0, a0, tp
## st_value(b) = 2047
# IE32-LABEL: <.Ltlsdesc_hi1>:
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: addi a0, zero, 0x7ff
# IE32-NEXT: add a0, a0, tp
## &.got[c]-. = 0x12248+4 - 0x111cc = 0x1080
# IE32-LABEL: <.Ltlsdesc_hi2>:
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: addi zero, zero, 0x0
# IE32-NEXT: 111cc: auipc a0, 0x1
# IE32-NEXT: lw a0, 0x80(a0)
# IE32-NEXT: add a0, a0, tp

## FIXME This should not pass, but the code MC layer needs a fix to prevent this.
# BADTLSLABEL: error: d.{{.*}}.o has an STT_TLS symbol but doesn't have an SHF_TLS section

#--- a.s
.macro load dst, src
.ifdef ELF32
Expand Down
33 changes: 1 addition & 32 deletions lldb/packages/Python/lldbsuite/test/make/Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
#
# GNUWin32 uname gives "windows32" or "server version windows32" while
# some versions of MSYS uname return "MSYS_NT*", but most environments
# standardize on "Windows_NT", so we'll make it consistent here.
# standardize on "Windows_NT", so we'll make it consistent here.
# When running tests from Visual Studio, the environment variable isn't
# inherited all the way down to the process spawned for make.
#----------------------------------------------------------------------
Expand Down Expand Up @@ -210,12 +210,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif

ifeq "$(MAKE_DWP)" "YES"
MAKE_DWO := YES
DWP_NAME = $(EXE).dwp
DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
endif
endif

LIMIT_DEBUG_INFO_FLAGS =
Expand Down Expand Up @@ -363,7 +357,6 @@ ifneq "$(OS)" "Darwin"

OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
DWP ?= $(call replace_cc_with,dwp)
override AR = $(ARCHIVER)
endif

Expand Down Expand Up @@ -534,10 +527,6 @@ ifneq "$(CXX)" ""
endif
endif

ifeq "$(GEN_GNU_BUILD_ID)" "YES"
LDFLAGS += -Wl,--build-id
endif

#----------------------------------------------------------------------
# DYLIB_ONLY variable can be used to skip the building of a.out.
# See the sections below regarding dSYM file as well as the building of
Expand Down Expand Up @@ -576,25 +565,11 @@ else
endif
else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
cp "$(EXE)" "$(EXE).full"
endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
endif
ifeq "$(MAKE_DWP)" "YES"
$(DWP) -o "$(DWP_NAME)" $(DWOS)
endif
endif


#----------------------------------------------------------------------
# Support emitting the content of the GNU build-id into a file
# This needs to be used in conjunction with GEN_GNU_BUILD_ID := YES
#----------------------------------------------------------------------
$(EXE).uuid : $(EXE)
$(OBJCOPY) --dump-section=.note.gnu.build-id=$@ $<

#----------------------------------------------------------------------
# Make the dylib
#----------------------------------------------------------------------
Expand Down Expand Up @@ -635,15 +610,9 @@ endif
else
$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
cp "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).full"
endif
$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
endif
ifeq "$(MAKE_DWP)" "YES"
$(DWP) -o $(DYLIB_DWP_FILE) $(DYLIB_DWOS)
endif
endif

#----------------------------------------------------------------------
Expand Down
38 changes: 13 additions & 25 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4377,38 +4377,26 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
ModuleSpec module_spec;
module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
FileSpec dwp_filespec;
for (const auto &symfile : symfiles.files()) {
module_spec.GetSymbolFileSpec() =
FileSpec(symfile.GetPath() + ".dwp", symfile.GetPathStyle());
LLDB_LOG(log, "Searching for DWP using: \"{0}\"",
module_spec.GetSymbolFileSpec());
dwp_filespec =
FileSpec dwp_filespec =
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
if (FileSystem::Instance().Exists(dwp_filespec)) {
break;
}
}
if (!FileSystem::Instance().Exists(dwp_filespec)) {
LLDB_LOG(log, "No DWP file found locally");
// Fill in the UUID for the module we're trying to match for, so we can
// find the correct DWP file, as the Debuginfod plugin uses *only* this
// data to correctly match the DWP file with the binary.
module_spec.GetUUID() = m_objfile_sp->GetUUID();
dwp_filespec =
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
}
if (FileSystem::Instance().Exists(dwp_filespec)) {
LLDB_LOG(log, "Found DWP file: \"{0}\"", dwp_filespec);
DataBufferSP dwp_file_data_sp;
lldb::offset_t dwp_file_data_offset = 0;
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
GetObjectFile()->GetModule(), &dwp_filespec, 0,
FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
dwp_file_data_offset);
if (dwp_obj_file) {
m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>(
*this, dwp_obj_file, DIERef::k_file_index_mask);
LLDB_LOG(log, "Found DWP file: \"{0}\"", dwp_filespec);
DataBufferSP dwp_file_data_sp;
lldb::offset_t dwp_file_data_offset = 0;
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
GetObjectFile()->GetModule(), &dwp_filespec, 0,
FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
dwp_file_data_offset);
if (dwp_obj_file) {
m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>(
*this, dwp_obj_file, DIERef::k_file_index_mask);
break;
}
}
}
if (!m_dwp_symfile) {
Expand Down
7 changes: 1 addition & 6 deletions lldb/source/Plugins/SymbolLocator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Order matters here: the first symbol locator prevents further searching.
# For DWARF binaries that are both stripped and split, the Default plugin
# will return the stripped binary when asked for the ObjectFile, which then
# prevents an unstripped binary from being requested from the Debuginfod
# provider.
add_subdirectory(Debuginfod)
add_subdirectory(Default)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(DebugSymbols)
endif()
add_subdirectory(Debuginfod)
30 changes: 2 additions & 28 deletions lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,6 @@ llvm::StringRef SymbolVendorELF::GetPluginDescriptionStatic() {
"executables.";
}

// If this is needed elsewhere, it can be exported/moved.
static bool IsDwpSymbolFile(const lldb::ModuleSP &module_sp,
const FileSpec &file_spec) {
DataBufferSP dwp_file_data_sp;
lldb::offset_t dwp_file_data_offset = 0;
// Try to create an ObjectFile from the file_spec.
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
module_sp, &file_spec, 0, FileSystem::Instance().GetByteSize(file_spec),
dwp_file_data_sp, dwp_file_data_offset);
if (!ObjectFileELF::classof(dwp_obj_file.get()))
return false;
// The presence of a debug_cu_index section is the key identifying feature of
// a DWP file. Make sure we don't fill in the section list on dwp_obj_file
// (by calling GetSectionList(false)) as this is invoked before we may have
// all the symbol files collected and available.
return dwp_obj_file && dwp_obj_file->GetSectionList(false)->FindSectionByType(
eSectionTypeDWARFDebugCuIndex, false);
}

// CreateInstance
//
// Platforms can register a callback to use when creating symbol vendors to
Expand Down Expand Up @@ -106,15 +87,8 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
FileSpec dsym_fspec =
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
if (!dsym_fspec || IsDwpSymbolFile(module_sp, dsym_fspec)) {
// If we have a stripped binary or if we got a DWP file, we should prefer
// symbols in the executable acquired through a plugin.
ModuleSpec unstripped_spec =
PluginManager::LocateExecutableObjectFile(module_spec);
if (!unstripped_spec)
return nullptr;
dsym_fspec = unstripped_spec.GetFileSpec();
}
if (!dsym_fspec)
return nullptr;

DataBufferSP dsym_file_data_sp;
lldb::offset_t dsym_file_data_offset = 0;
Expand Down
25 changes: 0 additions & 25 deletions lldb/test/API/debuginfod/Normal/Makefile

This file was deleted.

185 changes: 0 additions & 185 deletions lldb/test/API/debuginfod/Normal/TestDebuginfod.py

This file was deleted.

7 changes: 0 additions & 7 deletions lldb/test/API/debuginfod/Normal/main.c

This file was deleted.

28 changes: 0 additions & 28 deletions lldb/test/API/debuginfod/SplitDWARF/Makefile

This file was deleted.

194 changes: 0 additions & 194 deletions lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py

This file was deleted.

7 changes: 0 additions & 7 deletions lldb/test/API/debuginfod/SplitDWARF/main.c

This file was deleted.

11 changes: 2 additions & 9 deletions llvm/docs/RemoveDIsDebugInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,15 @@ New functions (all to be deprecated)
LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
LLVMDIBuilderInsertDeclareIntrinsicAtEnd # Same as above.
LLVMDIBuilderInsertDbgValueIntrinsicBefore # Same as above.
LLVMDIBuilderInsertDbgValueIntrinsicAtEnd # Same as above.
LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above.
LLVMDIBuilderInsertDbgValueRecordBefore # Same as above.
LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above.
Existing functions (behaviour change)
-------------------------------------
LLVMDIBuilderInsertDeclareBefore # Insert a debug record (new debug info format) instead of a debug intrinsic (old debug info format).
LLVMDIBuilderInsertDeclareAtEnd # Same as above.
LLVMDIBuilderInsertDbgValueBefore # Same as above.
LLVMDIBuilderInsertDbgValueAtEnd # Same as above.
```

# Anything else?
Expand Down
60 changes: 20 additions & 40 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1249,26 +1249,21 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
LLVMMetadataRef Decl, uint32_t AlignInBits);

/*
* Insert a new Declare DbgRecord before the given instruction.
*
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
* \param Builder The DIBuilder.
* \param Storage The storage of the variable to declare.
* \param VarInfo The variable's debug info descriptor.
* \param Expr A complex location expression for the variable.
* \param DebugLoc Debug info location.
* \param Instr Instruction acting as a location for the new intrinsic.
*/
LLVMDbgRecordRef
LLVMValueRef
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
* Soon to be deprecated.
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* Only use in "old debug mode" (LLVMIsNewDbgFormat() is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
Expand All @@ -1284,7 +1279,7 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
* Soon to be deprecated.
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Only use in "new debug mode" (LLVMIsNewDbgFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a Declare DbgRecord before the given instruction.
Expand All @@ -1300,27 +1295,22 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);

/**
* Insert a new Declare DbgRecord at the end of the given basic block. If the
* basic block has a terminator instruction, the intrinsic is inserted before
* that terminator instruction.
*
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
* block. If the basic block has a terminator instruction, the intrinsic is
* inserted before that terminator instruction.
* \param Builder The DIBuilder.
* \param Storage The storage of the variable to declare.
* \param VarInfo The variable's debug info descriptor.
* \param Expr A complex location expression for the variable.
* \param DebugLoc Debug info location.
* \param Block Basic block acting as a location for the new intrinsic.
*/
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareAtEnd(
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* Only use in "old debug mode" (LLVMIsNewDbgFormat() is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
Expand All @@ -1338,7 +1328,7 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Only use in "new debug mode" (LLVMIsNewDbgFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a Declare DbgRecord at the end of the given basic block. If the basic
Expand All @@ -1356,26 +1346,21 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);

/**
* Insert a new Value DbgRecord before the given instruction.
*
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
* \param Builder The DIBuilder.
* \param Val The value of the variable.
* \param VarInfo The variable's debug info descriptor.
* \param Expr A complex location expression for the variable.
* \param DebugLoc Debug info location.
* \param Instr Instruction acting as a location for the new intrinsic.
*/
LLVMDbgRecordRef
LLVMValueRef
LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
* Soon to be deprecated.
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
Expand All @@ -1391,7 +1376,7 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
* Soon to be deprecated.
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
Expand All @@ -1407,27 +1392,22 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);

/**
* Insert a new Value DbgRecord at the end of the given basic block. If the
* basic block has a terminator instruction, the intrinsic is inserted before
* that terminator instruction.
*
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
* block. If the basic block has a terminator instruction, the intrinsic is
* inserted before that terminator instruction.
* \param Builder The DIBuilder.
* \param Val The value of the variable.
* \param VarInfo The variable's debug info descriptor.
* \param Expr A complex location expression for the variable.
* \param DebugLoc Debug info location.
* \param Block Basic block acting as a location for the new intrinsic.
*/
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
Expand All @@ -1445,7 +1425,7 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
Expand Down
31 changes: 25 additions & 6 deletions llvm/include/llvm/CodeGen/TargetRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,20 @@ class TargetRegisterInfo : public MCRegisterInfo {
unsigned RegSize, SpillSize, SpillAlignment;
unsigned VTListOffset;
};

/// SubRegCoveredBits - Emitted by tablegen: bit range covered by a subreg
/// index, -1 in any being invalid.
struct SubRegCoveredBits {
uint16_t Offset;
uint16_t Size;
};

private:
const TargetRegisterInfoDesc *InfoDesc; // Extra desc array for codegen
const char *const *SubRegIndexNames; // Names of subreg indexes.
const SubRegCoveredBits *SubRegIdxRanges; // Pointer to the subreg covered
// bit ranges array.

// Pointer to array of lane masks, one per sub-reg index.
const LaneBitmask *SubRegIndexLaneMasks;

Expand All @@ -256,12 +267,10 @@ class TargetRegisterInfo : public MCRegisterInfo {
unsigned HwMode;

protected:
TargetRegisterInfo(const TargetRegisterInfoDesc *ID,
regclass_iterator RCB,
regclass_iterator RCE,
const char *const *SRINames,
const LaneBitmask *SRILaneMasks,
LaneBitmask CoveringLanes,
TargetRegisterInfo(const TargetRegisterInfoDesc *ID, regclass_iterator RCB,
regclass_iterator RCE, const char *const *SRINames,
const SubRegCoveredBits *SubIdxRanges,
const LaneBitmask *SRILaneMasks, LaneBitmask CoveringLanes,
const RegClassInfo *const RCIs,
const MVT::SimpleValueType *const RCVTLists,
unsigned Mode = 0);
Expand Down Expand Up @@ -382,6 +391,16 @@ class TargetRegisterInfo : public MCRegisterInfo {
return SubRegIndexNames[SubIdx-1];
}

/// Get the size of the bit range covered by a sub-register index.
/// If the index isn't continuous, return the sum of the sizes of its parts.
/// If the index is used to access subregisters of different sizes, return -1.
unsigned getSubRegIdxSize(unsigned Idx) const;

/// Get the offset of the bit range covered by a sub-register index.
/// If an Offset doesn't make sense (the index isn't continuous, or is used to
/// access sub-registers at different offsets), return -1.
unsigned getSubRegIdxOffset(unsigned Idx) const;

/// Return a bitmask representing the parts of a register that are covered by
/// SubIdx \see LaneBitmask.
///
Expand Down
21 changes: 0 additions & 21 deletions llvm/include/llvm/MC/MCRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ class MCRegisterInfo {
bool operator<(DwarfLLVMRegPair RHS) const { return FromReg < RHS.FromReg; }
};

/// SubRegCoveredBits - Emitted by tablegen: bit range covered by a subreg
/// index, -1 in any being invalid.
struct SubRegCoveredBits {
uint16_t Offset;
uint16_t Size;
};

private:
const MCRegisterDesc *Desc; // Pointer to the descriptor array
unsigned NumRegs; // Number of entries in the array
Expand All @@ -176,8 +169,6 @@ class MCRegisterInfo {
const char *RegClassStrings; // Pointer to the class strings.
const uint16_t *SubRegIndices; // Pointer to the subreg lookup
// array.
const SubRegCoveredBits *SubRegIdxRanges; // Pointer to the subreg covered
// bit ranges array.
unsigned NumSubRegIndices; // Number of subreg indices.
const uint16_t *RegEncodingTable; // Pointer to array of register
// encodings.
Expand Down Expand Up @@ -278,7 +269,6 @@ class MCRegisterInfo {
const int16_t *DL, const LaneBitmask *RUMS,
const char *Strings, const char *ClassStrings,
const uint16_t *SubIndices, unsigned NumIndices,
const SubRegCoveredBits *SubIdxRanges,
const uint16_t *RET) {
Desc = D;
NumRegs = NR;
Expand All @@ -294,7 +284,6 @@ class MCRegisterInfo {
NumRegUnits = NRU;
SubRegIndices = SubIndices;
NumSubRegIndices = NumIndices;
SubRegIdxRanges = SubIdxRanges;
RegEncodingTable = RET;

// Initialize DWARF register mapping variables
Expand Down Expand Up @@ -387,16 +376,6 @@ class MCRegisterInfo {
/// otherwise.
unsigned getSubRegIndex(MCRegister RegNo, MCRegister SubRegNo) const;

/// Get the size of the bit range covered by a sub-register index.
/// If the index isn't continuous, return the sum of the sizes of its parts.
/// If the index is used to access subregisters of different sizes, return -1.
unsigned getSubRegIdxSize(unsigned Idx) const;

/// Get the offset of the bit range covered by a sub-register index.
/// If an Offset doesn't make sense (the index isn't continuous, or is used to
/// access sub-registers at different offsets), return -1.
unsigned getSubRegIdxOffset(unsigned Idx) const;

/// Return the human-readable symbolic target-specific name for the
/// specified physical register.
const char *getName(MCRegister RegNo) const {
Expand Down
5 changes: 2 additions & 3 deletions llvm/include/llvm/Support/BalancedPartitioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ class BalancedPartitioning {
std::optional<BPThreadPool> &TP) const;

/// Run bisection iterations
void runIterations(const FunctionNodeRange Nodes, unsigned RecDepth,
unsigned LeftBucket, unsigned RightBucket,
std::mt19937 &RNG) const;
void runIterations(const FunctionNodeRange Nodes, unsigned LeftBucket,
unsigned RightBucket, std::mt19937 &RNG) const;

/// Run a bisection iteration to improve the optimization goal
/// \returns the total number of moved FunctionNodes
Expand Down
36 changes: 22 additions & 14 deletions llvm/lib/CodeGen/TargetRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,16 @@ static cl::opt<unsigned>
"high compile time cost in global splitting."),
cl::init(5000));

TargetRegisterInfo::TargetRegisterInfo(const TargetRegisterInfoDesc *ID,
regclass_iterator RCB, regclass_iterator RCE,
const char *const *SRINames,
const LaneBitmask *SRILaneMasks,
LaneBitmask SRICoveringLanes,
const RegClassInfo *const RCIs,
const MVT::SimpleValueType *const RCVTLists,
unsigned Mode)
: InfoDesc(ID), SubRegIndexNames(SRINames),
SubRegIndexLaneMasks(SRILaneMasks),
RegClassBegin(RCB), RegClassEnd(RCE),
CoveringLanes(SRICoveringLanes),
RCInfos(RCIs), RCVTLists(RCVTLists), HwMode(Mode) {
}
TargetRegisterInfo::TargetRegisterInfo(
const TargetRegisterInfoDesc *ID, regclass_iterator RCB,
regclass_iterator RCE, const char *const *SRINames,
const SubRegCoveredBits *SubIdxRanges, const LaneBitmask *SRILaneMasks,
LaneBitmask SRICoveringLanes, const RegClassInfo *const RCIs,
const MVT::SimpleValueType *const RCVTLists, unsigned Mode)
: InfoDesc(ID), SubRegIndexNames(SRINames), SubRegIdxRanges(SubIdxRanges),
SubRegIndexLaneMasks(SRILaneMasks), RegClassBegin(RCB), RegClassEnd(RCE),
CoveringLanes(SRICoveringLanes), RCInfos(RCIs), RCVTLists(RCVTLists),
HwMode(Mode) {}

TargetRegisterInfo::~TargetRegisterInfo() = default;

Expand Down Expand Up @@ -596,6 +592,18 @@ bool TargetRegisterInfo::getCoveringSubRegIndexes(
return BestIdx;
}

unsigned TargetRegisterInfo::getSubRegIdxSize(unsigned Idx) const {
assert(Idx && Idx < getNumSubRegIndices() &&
"This is not a subregister index");
return SubRegIdxRanges[Idx].Size;
}

unsigned TargetRegisterInfo::getSubRegIdxOffset(unsigned Idx) const {
assert(Idx && Idx < getNumSubRegIndices() &&
"This is not a subregister index");
return SubRegIdxRanges[Idx].Offset;
}

Register
TargetRegisterInfo::lookThruCopyLike(Register SrcReg,
const MachineRegisterInfo *MRI) const {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ extern "C" {
// We put information about the JITed function in this global, which the
// debugger reads. Make sure to specify the version statically, because the
// debugger checks the version before we can set it during runtime.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
struct jit_descriptor __jit_debug_descriptor = {JitDescriptorVersion, 0,
nullptr, nullptr};

// Debuggers that implement the GDB JIT interface put a special breakpoint in
// this function.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
LLVM_ATTRIBUTE_NOINLINE void __jit_debug_register_code() {
// The noinline and the asm prevent calls to this function from being
// optimized out.
Expand Down
121 changes: 40 additions & 81 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1665,12 +1665,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
unwrapDI<MDNode>(Decl), nullptr, AlignInBits));
}

LLVMDbgRecordRef
LLVMValueRef
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMValueRef Instr) {
return LLVMDIBuilderInsertDeclareRecordBefore(Builder, Storage, VarInfo, Expr,
DL, Instr);
return LLVMDIBuilderInsertDeclareIntrinsicBefore(Builder, Storage, VarInfo,
Expr, DL, Instr);
}
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
Expand All @@ -1679,142 +1679,101 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
unwrap<Instruction>(Instr));
// This assert will fail if the module is in the new debug info format.
// This function should only be called if the module is in the old
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
"Function unexpectedly in new debug info format");
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
unwrap<Instruction>(Instr));
// This assert will fail if the module is in the old debug info format.
// This function should only be called if the module is in the new
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<DbgRecord *>(DbgInst) &&
"Function unexpectedly in old debug info format");
return wrap(cast<DbgRecord *>(DbgInst));
return wrap(
unwrap(Builder)
->insertDeclare(unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
unwrap<Instruction>(Instr))
.get<DbgRecord *>());
}

LLVMDbgRecordRef
LLVMValueRef
LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
return LLVMDIBuilderInsertDeclareRecordAtEnd(Builder, Storage, VarInfo, Expr,
DL, Block);
return LLVMDIBuilderInsertDeclareIntrinsicAtEnd(Builder, Storage, VarInfo,
Expr, DL, Block);
}
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
// This assert will fail if the module is in the new debug info format.
// This function should only be called if the module is in the old
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
"Function unexpectedly in new debug info format");
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
// This assert will fail if the module is in the old debug info format.
// This function should only be called if the module is in the new
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<DbgRecord *>(DbgInst) &&
"Function unexpectedly in old debug info format");
return wrap(cast<DbgRecord *>(DbgInst));
return wrap(unwrap(Builder)
->insertDeclare(unwrap(Storage),
unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr),
unwrap<DILocation>(DL), unwrap(Block))
.get<DbgRecord *>());
}

LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueBefore(
LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
return LLVMDIBuilderInsertDbgValueRecordBefore(Builder, Val, VarInfo, Expr,
DebugLoc, Instr);
return LLVMDIBuilderInsertDbgValueIntrinsicBefore(Builder, Val, VarInfo, Expr,
DebugLoc, Instr);
}
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr));
// This assert will fail if the module is in the new debug info format.
// This function should only be called if the module is in the old
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
"Function unexpectedly in new debug info format");
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr));
// This assert will fail if the module is in the old debug info format.
// This function should only be called if the module is in the new
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<DbgRecord *>(DbgInst) &&
"Function unexpectedly in old debug info format");
return wrap(cast<DbgRecord *>(DbgInst));
return wrap(unwrap(Builder)
->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
unwrap<Instruction>(Instr))
.get<DbgRecord *>());
}

LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
return LLVMDIBuilderInsertDbgValueRecordAtEnd(Builder, Val, VarInfo, Expr,
DebugLoc, Block);
return LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(Builder, Val, VarInfo, Expr,
DebugLoc, Block);
}
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap(Block));
// This assert will fail if the module is in the new debug info format.
// This function should only be called if the module is in the old
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
"Function unexpectedly in new debug info format");
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap(Block));
// This assert will fail if the module is in the old debug info format.
// This function should only be called if the module is in the new
// debug info format.
// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<DbgRecord *>(DbgInst) &&
"Function unexpectedly in old debug info format");
return wrap(cast<DbgRecord *>(DbgInst));
return wrap(unwrap(Builder)
->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
unwrap(Block))
.get<DbgRecord *>());
}

LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(
Expand Down
12 changes: 0 additions & 12 deletions llvm/lib/MC/MCRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ unsigned MCRegisterInfo::getSubRegIndex(MCRegister Reg,
return 0;
}

unsigned MCRegisterInfo::getSubRegIdxSize(unsigned Idx) const {
assert(Idx && Idx < getNumSubRegIndices() &&
"This is not a subregister index");
return SubRegIdxRanges[Idx].Size;
}

unsigned MCRegisterInfo::getSubRegIdxOffset(unsigned Idx) const {
assert(Idx && Idx < getNumSubRegIndices() &&
"This is not a subregister index");
return SubRegIdxRanges[Idx].Offset;
}

int MCRegisterInfo::getDwarfRegNum(MCRegister RegNum, bool isEH) const {
const DwarfLLVMRegPair *M = isEH ? EHL2DwarfRegs : L2DwarfRegs;
unsigned Size = isEH ? EHL2DwarfRegsSize : L2DwarfRegsSize;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Support/BalancedPartitioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void BalancedPartitioning::bisect(const FunctionNodeRange Nodes,
// Split into two and assign to the left and right buckets
split(Nodes, LeftBucket);

runIterations(Nodes, RecDepth, LeftBucket, RightBucket, RNG);
runIterations(Nodes, LeftBucket, RightBucket, RNG);

// Split nodes wrt the resulting buckets
auto NodesMid =
Expand All @@ -163,7 +163,7 @@ void BalancedPartitioning::bisect(const FunctionNodeRange Nodes,
}

void BalancedPartitioning::runIterations(const FunctionNodeRange Nodes,
unsigned RecDepth, unsigned LeftBucket,
unsigned LeftBucket,
unsigned RightBucket,
std::mt19937 &RNG) const {
unsigned NumNodes = std::distance(Nodes.begin(), Nodes.end());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64SchedAmpere1.td
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def Ampere1Model : SchedMachineModel {
let IssueWidth = 4; // 4-way decode and dispatch
let MicroOpBufferSize = 174; // micro-op re-order buffer size
let MicroOpBufferSize = 192; // re-order buffer size
let LoadLatency = 4; // Optimistic load latency
let MispredictPenalty = 10; // Branch mispredict penalty
let LoopMicroOpBufferSize = 32; // Instruction queue size
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64SchedAmpere1B.td
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def Ampere1BModel : SchedMachineModel {
let IssueWidth = 12; // Maximum micro-ops dispatch rate.
let MicroOpBufferSize = 192; // micro-op re-order buffer size
let MicroOpBufferSize = 208; // micro-op re-order buffer size
let LoadLatency = 3; // Optimistic load latency
let MispredictPenalty = 10; // Branch mispredict penalty
let LoopMicroOpBufferSize = 32; // Instruction queue size
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ SIRegisterInfo::SIRegisterInfo(const GCNSubtarget &ST)
for (auto &Row : SubRegFromChannelTable)
Row.fill(AMDGPU::NoSubRegister);
for (unsigned Idx = 1; Idx < getNumSubRegIndices(); ++Idx) {
unsigned Width = AMDGPUSubRegIdxRanges[Idx].Size / 32;
unsigned Offset = AMDGPUSubRegIdxRanges[Idx].Offset / 32;
unsigned Width = getSubRegIdxSize(Idx) / 32;
unsigned Offset = getSubRegIdxOffset(Idx) / 32;
assert(Width < SubRegFromChannelTableWidthMap.size());
Width = SubRegFromChannelTableWidthMap[Width];
if (Width == 0)
Expand Down
29 changes: 29 additions & 0 deletions llvm/lib/Target/DirectX/DirectXPassRegistry.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===- DirectXPassRegistry.def - Registry of DirectX passes -----*- C++--*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is used as the registry of passes that are part of the
// DirectX backend.
//
//===----------------------------------------------------------------------===//

// NOTE: NO INCLUDE GUARD DESIRED!

#ifndef MODULE_ANALYSIS
#define MODULE_ANALYSIS(NAME, CREATE_PASS)
#endif
MODULE_ANALYSIS("dx-shader-flags", dxil::ShaderFlagsAnalysis())
MODULE_ANALYSIS("dxil-resource", DXILResourceAnalysis())
#undef MODULE_ANALYSIS

#ifndef MODULE_PASS
#define MODULE_PASS(NAME, CREATE_PASS)
#endif
// TODO: rename to print<foo> after NPM switch
MODULE_PASS("print-dx-shader-flags", DXILResourcePrinterPass(dbgs()))
MODULE_PASS("print-dxil-resource", DXILResourcePrinterPass(dbgs()))
#undef MODULE_PASS
20 changes: 2 additions & 18 deletions llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,8 @@ DirectXTargetMachine::~DirectXTargetMachine() {}

void DirectXTargetMachine::registerPassBuilderCallbacks(
PassBuilder &PB, bool PopulateClassToPassNames) {
PB.registerPipelineParsingCallback(
[](StringRef PassName, ModulePassManager &PM,
ArrayRef<PassBuilder::PipelineElement>) {
if (PassName == "print-dxil-resource") {
PM.addPass(DXILResourcePrinterPass(dbgs()));
return true;
}
if (PassName == "print-dx-shader-flags") {
PM.addPass(dxil::ShaderFlagsAnalysisPrinter(dbgs()));
return true;
}
return false;
});

PB.registerAnalysisRegistrationCallback([](ModuleAnalysisManager &MAM) {
MAM.registerPass([&] { return DXILResourceAnalysis(); });
MAM.registerPass([&] { return dxil::ShaderFlagsAnalysis(); });
});
#define GET_PASS_REGISTRY "DirectXPassRegistry.def"
#include "llvm/Passes/TargetPassRegistry.inc"
}

bool DirectXTargetMachine::addPassesToEmitFile(
Expand Down
40 changes: 40 additions & 0 deletions llvm/lib/Target/NVPTX/NVPTXPassRegistry.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//===- NVPTXPassRegistry.def - Registry of NVPTX passes ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is used as the registry of passes that are part of the
// NVPTX backend.
//
//===----------------------------------------------------------------------===//

// NOTE: NO INCLUDE GUARD DESIRED!

#ifndef MODULE_PASS
#define MODULE_PASS(NAME, CREATE_PASS)
#endif
MODULE_PASS("generic-to-nvvm", GenericToNVVMPass())
MODULE_PASS("nvptx-lower-ctor-dtor", NVPTXCtorDtorLoweringPass())
#undef MODULE_PASS

#ifndef FUNCTION_ANALYSIS
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
#endif

#ifndef FUNCTION_ALIAS_ANALYSIS
#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
FUNCTION_ANALYSIS(NAME, CREATE_PASS)
#endif
FUNCTION_ALIAS_ANALYSIS("nvptx-aa", NVPTXAA())
#undef FUNCTION_ALIAS_ANALYSIS
#undef FUNCTION_ANALYSIS

#ifndef FUNCTION_PASS
#define FUNCTION_PASS(NAME, CREATE_PASS)
#endif
FUNCTION_PASS("nvvm-intr-range", NVVMIntrRangePass())
FUNCTION_PASS("nvvm-reflect", NVVMReflectPass())
#undef FUNCTION_PASS
41 changes: 2 additions & 39 deletions llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,45 +227,8 @@ void NVPTXTargetMachine::registerDefaultAliasAnalyses(AAManager &AAM) {

void NVPTXTargetMachine::registerPassBuilderCallbacks(
PassBuilder &PB, bool PopulateClassToPassNames) {
PB.registerPipelineParsingCallback(
[](StringRef PassName, FunctionPassManager &PM,
ArrayRef<PassBuilder::PipelineElement>) {
if (PassName == "nvvm-reflect") {
PM.addPass(NVVMReflectPass());
return true;
}
if (PassName == "nvvm-intr-range") {
PM.addPass(NVVMIntrRangePass());
return true;
}
return false;
});

PB.registerAnalysisRegistrationCallback([](FunctionAnalysisManager &FAM) {
FAM.registerPass([&] { return NVPTXAA(); });
});

PB.registerParseAACallback([](StringRef AAName, AAManager &AAM) {
if (AAName == "nvptx-aa") {
AAM.registerFunctionAnalysis<NVPTXAA>();
return true;
}
return false;
});

PB.registerPipelineParsingCallback(
[](StringRef PassName, ModulePassManager &PM,
ArrayRef<PassBuilder::PipelineElement>) {
if (PassName == "nvptx-lower-ctor-dtor") {
PM.addPass(NVPTXCtorDtorLoweringPass());
return true;
}
if (PassName == "generic-to-nvvm") {
PM.addPass(GenericToNVVMPass());
return true;
}
return false;
});
#define GET_PASS_REGISTRY "NVPTXPassRegistry.def"
#include "llvm/Passes/TargetPassRegistry.inc"

PB.registerPipelineStartEPCallback(
[this](ModulePassManager &PM, OptimizationLevel Level) {
Expand Down
31 changes: 4 additions & 27 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3081,34 +3081,11 @@ void RISCVAsmParser::emitToStreamer(MCStreamer &S, const MCInst &Inst) {

void RISCVAsmParser::emitLoadImm(MCRegister DestReg, int64_t Value,
MCStreamer &Out) {
RISCVMatInt::InstSeq Seq = RISCVMatInt::generateInstSeq(Value, getSTI());

MCRegister SrcReg = RISCV::X0;
for (const RISCVMatInt::Inst &Inst : Seq) {
switch (Inst.getOpndKind()) {
case RISCVMatInt::Imm:
emitToStreamer(Out,
MCInstBuilder(Inst.getOpcode()).addReg(DestReg).addImm(Inst.getImm()));
break;
case RISCVMatInt::RegX0:
emitToStreamer(
Out, MCInstBuilder(Inst.getOpcode()).addReg(DestReg).addReg(SrcReg).addReg(
RISCV::X0));
break;
case RISCVMatInt::RegReg:
emitToStreamer(
Out, MCInstBuilder(Inst.getOpcode()).addReg(DestReg).addReg(SrcReg).addReg(
SrcReg));
break;
case RISCVMatInt::RegImm:
emitToStreamer(
Out, MCInstBuilder(Inst.getOpcode()).addReg(DestReg).addReg(SrcReg).addImm(
Inst.getImm()));
break;
}
SmallVector<MCInst, 8> Seq;
RISCVMatInt::generateMCInstSeq(Value, getSTI(), DestReg, Seq);

// Only the first instruction has X0 as its source.
SrcReg = DestReg;
for (MCInst &Inst : Seq) {
emitToStreamer(Out, Inst);
}
}

Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ void RISCVMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
case VK_RISCV_TLS_GOT_HI:
case VK_RISCV_TLS_GD_HI:
case VK_RISCV_TLSDESC_HI:
case VK_RISCV_TLSDESC_ADD_LO:
case VK_RISCV_TLSDESC_LOAD_LO:
break;
}

Expand Down
38 changes: 38 additions & 0 deletions llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "RISCVMatInt.h"
#include "MCTargetDesc/RISCVMCTargetDesc.h"
#include "llvm/ADT/APInt.h"
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/Support/MathExtras.h"
using namespace llvm;

Expand Down Expand Up @@ -436,6 +437,43 @@ InstSeq generateInstSeq(int64_t Val, const MCSubtargetInfo &STI) {
return Res;
}

void generateMCInstSeq(int64_t Val, const MCSubtargetInfo &STI,
MCRegister DestReg, SmallVectorImpl<MCInst> &Insts) {
RISCVMatInt::InstSeq Seq = RISCVMatInt::generateInstSeq(Val, STI);

MCRegister SrcReg = RISCV::X0;
for (RISCVMatInt::Inst &Inst : Seq) {
switch (Inst.getOpndKind()) {
case RISCVMatInt::Imm:
Insts.push_back(MCInstBuilder(Inst.getOpcode())
.addReg(DestReg)
.addImm(Inst.getImm()));
break;
case RISCVMatInt::RegX0:
Insts.push_back(MCInstBuilder(Inst.getOpcode())
.addReg(DestReg)
.addReg(SrcReg)
.addReg(RISCV::X0));
break;
case RISCVMatInt::RegReg:
Insts.push_back(MCInstBuilder(Inst.getOpcode())
.addReg(DestReg)
.addReg(SrcReg)
.addReg(SrcReg));
break;
case RISCVMatInt::RegImm:
Insts.push_back(MCInstBuilder(Inst.getOpcode())
.addReg(DestReg)
.addReg(SrcReg)
.addImm(Inst.getImm()));
break;
}

// Only the first instruction has X0 as its source.
SrcReg = DestReg;
}
}

InstSeq generateTwoRegInstSeq(int64_t Val, const MCSubtargetInfo &STI,
unsigned &ShiftAmt, unsigned &AddOpc) {
int64_t LoVal = SignExtend64<32>(Val);
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_MATINT_H

#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCRegister.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include <cstdint>

Expand Down Expand Up @@ -48,6 +49,10 @@ using InstSeq = SmallVector<Inst, 8>;
// instruction selection.
InstSeq generateInstSeq(int64_t Val, const MCSubtargetInfo &STI);

// Helper to generate the generateInstSeq instruction sequence using MCInsts
void generateMCInstSeq(int64_t Val, const MCSubtargetInfo &STI,
MCRegister DestReg, SmallVectorImpl<MCInst> &Insts);

// Helper to generate an instruction sequence that can materialize the given
// immediate value into a register using an additional temporary register. This
// handles cases where the constant can be generated by (ADD (SLLI X, C), X) or
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCV.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ include "RISCVSystemOperands.td"
// Registers, calling conventions, instruction descriptions.
//===----------------------------------------------------------------------===//

include "RISCVSchedule.td"
include "RISCVRegisterInfo.td"
include "RISCVSchedule.td"
include "RISCVCallingConv.td"
include "RISCVInstrInfo.td"
include "GISel/RISCVRegisterBanks.td"
Expand Down
38 changes: 38 additions & 0 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ SystemZTargetLowering::SystemZTargetLowering(const TargetMachine &TM,
// Handle prefetches with PFD or PFDRL.
setOperationAction(ISD::PREFETCH, MVT::Other, Custom);

// Handle readcyclecounter with STCKF.
setOperationAction(ISD::READCYCLECOUNTER, MVT::i64, Custom);

for (MVT VT : MVT::fixedlen_vector_valuetypes()) {
// Assume by default that all vector operations need to be expanded.
for (unsigned Opcode = 0; Opcode < ISD::BUILTIN_OP_END; ++Opcode)
Expand Down Expand Up @@ -6077,6 +6080,27 @@ SDValue SystemZTargetLowering::lowerIS_FPCLASS(SDValue Op,
return getCCResult(DAG, Intr);
}

SDValue SystemZTargetLowering::lowerREADCYCLECOUNTER(SDValue Op,
SelectionDAG &DAG) const {
SDLoc DL(Op);
SDValue Chain = Op.getOperand(0);

// STCKF only supports a memory operand, so we have to use a temporary.
SDValue StackPtr = DAG.CreateStackTemporary(MVT::i64);
int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
MachinePointerInfo MPI =
MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), SPFI);

// Use STCFK to store the TOD clock into the temporary.
SDValue StoreOps[] = {Chain, StackPtr};
Chain = DAG.getMemIntrinsicNode(
SystemZISD::STCKF, DL, DAG.getVTList(MVT::Other), StoreOps, MVT::i64,
MPI, MaybeAlign(), MachineMemOperand::MOStore);

// And read it back from there.
return DAG.getLoad(MVT::i64, DL, Chain, StackPtr, MPI);
}

SDValue SystemZTargetLowering::LowerOperation(SDValue Op,
SelectionDAG &DAG) const {
switch (Op.getOpcode()) {
Expand Down Expand Up @@ -6199,6 +6223,8 @@ SDValue SystemZTargetLowering::LowerOperation(SDValue Op,
return lowerIS_FPCLASS(Op, DAG);
case ISD::GET_ROUNDING:
return lowerGET_ROUNDING(Op, DAG);
case ISD::READCYCLECOUNTER:
return lowerREADCYCLECOUNTER(Op, DAG);
default:
llvm_unreachable("Unexpected node to lower");
}
Expand Down Expand Up @@ -6425,6 +6451,7 @@ const char *SystemZTargetLowering::getTargetNodeName(unsigned Opcode) const {
OPCODE(STRV);
OPCODE(VLER);
OPCODE(VSTER);
OPCODE(STCKF);
OPCODE(PREFETCH);
OPCODE(ADA_ENTRY);
}
Expand Down Expand Up @@ -6985,6 +7012,17 @@ SDValue SystemZTargetLowering::combineSTORE(
}
}

// Combine STORE (READCYCLECOUNTER) into STCKF.
if (!SN->isTruncatingStore() &&
Op1.getOpcode() == ISD::READCYCLECOUNTER &&
Op1.hasOneUse() &&
N->getOperand(0).reachesChainWithoutSideEffects(SDValue(Op1.getNode(), 1))) {
SDValue Ops[] = { Op1.getOperand(0), N->getOperand(2) };
return DAG.getMemIntrinsicNode(SystemZISD::STCKF, SDLoc(N),
DAG.getVTList(MVT::Other),
Ops, MemVT, SN->getMemOperand());
}

// Transform a store of an i128 moved from GPRs into two separate stores.
if (MemVT == MVT::i128 && SN->isSimple() && ISD::isNormalStore(SN)) {
SDValue LoPart, HiPart;
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ enum NodeType : unsigned {
// Element swapping load/store. Same operands as regular load/store.
VLER, VSTER,

// Use STORE CLOCK FAST to store current TOD clock value.
STCKF,

// Prefetch from the second operand using the 4-bit control code in
// the first operand. The code is 1 for a load prefetch and 2 for
// a store prefetch.
Expand Down Expand Up @@ -717,6 +720,7 @@ class SystemZTargetLowering : public TargetLowering {
SDValue lowerShift(SDValue Op, SelectionDAG &DAG, unsigned ByScalar) const;
SDValue lowerIS_FPCLASS(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;

bool canTreatAsByteVector(EVT VT) const;
SDValue combineExtract(const SDLoc &DL, EVT ElemVT, EVT VecVT, SDValue OrigOp,
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/SystemZ/SystemZInstrSystem.td
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ let hasSideEffects = 1 in
// Store clock (fast / extended).
let hasSideEffects = 1, Defs = [CC] in {
def STCK : StoreInherentS<"stck", 0xB205, null_frag, 8>;
def STCKF : StoreInherentS<"stckf", 0xB27C, null_frag, 8>;
def STCKF : StoreInherentS<"stckf", 0xB27C, z_stckf, 8>;
def STCKE : StoreInherentS<"stcke", 0xB278, null_frag, 16>;
}

Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/SystemZ/SystemZOperators.td
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def SDT_ZIPM : SDTypeProfile<1, 1,
def SDT_ZPrefetch : SDTypeProfile<0, 2,
[SDTCisVT<0, i32>,
SDTCisPtrTy<1>]>;
def SDT_ZStoreInherent : SDTypeProfile<0, 1,
[SDTCisPtrTy<0>]>;
def SDT_ZTBegin : SDTypeProfile<1, 2,
[SDTCisVT<0, i32>,
SDTCisPtrTy<1>,
Expand Down Expand Up @@ -307,6 +309,8 @@ def z_loadeswap : SDNode<"SystemZISD::VLER", SDTLoad,
[SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
def z_storeeswap : SDNode<"SystemZISD::VSTER", SDTStore,
[SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
def z_stckf : SDNode<"SystemZISD::STCKF", SDT_ZStoreInherent,
[SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;

def z_tdc : SDNode<"SystemZISD::TDC", SDT_ZTest>;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15959,7 +15959,7 @@ class HorizontalReduction {
LLVM_DEBUG(dbgs() << "SLP: Found cost = " << Cost
<< " for reduction\n");
if (!Cost.isValid())
return nullptr;
break;
if (Cost >= -SLPCostThreshold) {
V.getORE()->emit([&]() {
return OptimizationRemarkMissed(
Expand Down
8 changes: 3 additions & 5 deletions llvm/test/CodeGen/AArch64/stack-tagging-stack-coloring.ll
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
; Test that storage for allocas with disjoint lifetimes is reused with stack
; tagging.

; RUN: opt -S -aarch64-stack-tagging -stack-tagging-use-stack-safety=0 %s -o - | \
; RUN: llc --mattr=+mte -no-stack-coloring=false -o - | \
; RUN: llc --mattr=+mte -no-stack-coloring=false -stack-tagging-use-stack-safety=0 -o - %s | \
; RUN: FileCheck %s --check-prefix=COLOR
; RUN: opt -S -aarch64-stack-tagging %s -stack-tagging-use-stack-safety=0 -o - | \
; RUN: llc --mattr=+mte -no-stack-coloring=true -o - | \
; RUN: llc --mattr=+mte -no-stack-coloring=true -stack-tagging-use-stack-safety=0 -o - %s | \
; RUN: FileCheck %s --check-prefix=NOCOLOR

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"

; COLOR: sub sp, sp, #208
; COLOR: sub sp, sp, #192
; NOCOLOR: sub sp, sp, #336

define i32 @myCall_w2(i32 %in) sanitize_memtag {
Expand Down
27 changes: 27 additions & 0 deletions llvm/test/CodeGen/SystemZ/readcyclecounter.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=s390x-ibm-linux | FileCheck %s

; Verify that we correctly lower ISD::READCYCLECOUNTER.

define i64 @test_builtin_readcyclecounter1() {
; CHECK-LABEL: test_builtin_readcyclecounter1:
; CHECK: # %bb.0:
; CHECK-NEXT: aghi %r15, -168
; CHECK-NEXT: .cfi_def_cfa_offset 328
; CHECK-NEXT: stckf 160(%r15)
; CHECK-NEXT: lg %r2, 160(%r15)
; CHECK-NEXT: aghi %r15, 168
; CHECK-NEXT: br %r14
%1 = tail call i64 @llvm.readcyclecounter()
ret i64 %1
}

define void @test_builtin_readcyclecounter2(ptr %ptr) {
; CHECK-LABEL: test_builtin_readcyclecounter2:
; CHECK: # %bb.0:
; CHECK-NEXT: stckf 0(%r2)
; CHECK-NEXT: br %r14
%1 = tail call i64 @llvm.readcyclecounter()
store i64 %1, ptr %ptr
ret void
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s -passes=slp-vectorizer -S | FileCheck %s

target triple = "riscv64-unknown-linux-gnu"

define void @partial_vec_invalid_cost() #0 {
; CHECK-LABEL: define void @partial_vec_invalid_cost(
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[LSHR_1:%.*]] = lshr i96 0, 0
; CHECK-NEXT: [[LSHR_2:%.*]] = lshr i96 0, 0
; CHECK-NEXT: [[TRUNC_I96_1:%.*]] = trunc i96 [[LSHR_1]] to i32
; CHECK-NEXT: [[TRUNC_I96_2:%.*]] = trunc i96 [[LSHR_2]] to i32
; CHECK-NEXT: [[TRUNC_I96_3:%.*]] = trunc i96 0 to i32
; CHECK-NEXT: [[TRUNC_I96_4:%.*]] = trunc i96 0 to i32
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> zeroinitializer)
; CHECK-NEXT: [[OP_RDX:%.*]] = or i32 [[TMP0]], [[TRUNC_I96_2]]
; CHECK-NEXT: [[OP_RDX1:%.*]] = or i32 [[TRUNC_I96_1]], [[TRUNC_I96_3]]
; CHECK-NEXT: [[OP_RDX2:%.*]] = or i32 [[OP_RDX]], [[OP_RDX1]]
; CHECK-NEXT: [[OP_RDX3:%.*]] = or i32 [[OP_RDX2]], [[TRUNC_I96_4]]
; CHECK-NEXT: [[STORE_THIS:%.*]] = zext i32 [[OP_RDX3]] to i96
; CHECK-NEXT: store i96 [[STORE_THIS]], ptr null, align 16
; CHECK-NEXT: ret void
;
entry:

%lshr.1 = lshr i96 0, 0 ; These ops
%lshr.2 = lshr i96 0, 0 ; return an
%add.0 = add i96 0, 0 ; invalid
%add.1 = add i96 0, 0 ; vector cost.

%trunc.i96.1 = trunc i96 %lshr.1 to i32 ; These ops
%trunc.i96.2 = trunc i96 %lshr.2 to i32 ; return an
%trunc.i96.3 = trunc i96 %add.0 to i32 ; invalid
%trunc.i96.4 = trunc i96 %add.1 to i32 ; vector cost.

%or.0 = or i32 %trunc.i96.1, %trunc.i96.2
%or.1 = or i32 %or.0, %trunc.i96.3
%or.2 = or i32 %or.1, %trunc.i96.4

%zext.0 = zext i1 0 to i32 ; These
%zext.1 = zext i1 0 to i32 ; ops
%zext.2 = zext i1 0 to i32 ; are
%zext.3 = zext i1 0 to i32 ; vectorized

%or.3 = or i32 %or.2, %zext.0 ; users
%or.4 = or i32 %or.3, %zext.1 ; of
%or.5 = or i32 %or.4, %zext.2 ; vectorized
%or.6 = or i32 %or.5, %zext.3 ; ops

%store.this = zext i32 %or.6 to i96

store i96 %store.this, ptr null, align 16
ret void
}

attributes #0 = { "target-features"="+v" }
13 changes: 6 additions & 7 deletions llvm/tools/llvm-c-test/debuginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,37 +136,36 @@ int llvm_test_dibuilder(bool NewDebugInfoFormat) {
LLVMMetadataRef FooParamVar1 =
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "a", 1, 1, File,
42, Int64Ty, true, 0);

if (LLVMIsNewDbgInfoFormat(M))
LLVMDIBuilderInsertDeclareAtEnd(
LLVMDIBuilderInsertDeclareRecordAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
FooParamExpression, FooParamLocation, FooEntryBlock);
else
LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMDIBuilderInsertDeclareAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
FooParamExpression, FooParamLocation, FooEntryBlock);
LLVMMetadataRef FooParamVar2 =
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "b", 1, 2, File,
42, Int64Ty, true, 0);

if (LLVMIsNewDbgInfoFormat(M))
LLVMDIBuilderInsertDeclareAtEnd(
LLVMDIBuilderInsertDeclareRecordAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
FooParamExpression, FooParamLocation, FooEntryBlock);
else
LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMDIBuilderInsertDeclareAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
FooParamExpression, FooParamLocation, FooEntryBlock);

LLVMMetadataRef FooParamVar3 =
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "c", 1, 3, File,
42, VectorTy, true, 0);
if (LLVMIsNewDbgInfoFormat(M))
LLVMDIBuilderInsertDeclareAtEnd(
LLVMDIBuilderInsertDeclareRecordAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
FooParamExpression, FooParamLocation, FooEntryBlock);
else
LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMDIBuilderInsertDeclareAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
FooParamExpression, FooParamLocation, FooEntryBlock);

Expand Down
Loading