Skip to content

Commit 280cfc2

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge llvm/main into amd-debug
2 parents aa45ea9 + 9bbf22c commit 280cfc2

File tree

15 files changed

+139
-167
lines changed

15 files changed

+139
-167
lines changed

clang/test/Driver/config-file3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230

231231
//--- Tilde expansion in user configuration file directory
232232
//
233-
// RUN: HOME=%S/Inputs/config %clang -### --config-user-dir=~ -v 2>&1 | FileCheck %s --check-prefix=CHECK-TILDE
233+
// RUN: env HOME=%S/Inputs/config %clang -### --config-user-dir=~ -v 2>&1 | FileCheck %s --check-prefix=CHECK-TILDE
234234
// CHECK-TILDE: User configuration file directory: {{.*}}/Inputs/config
235235

236236
//--- Fallback to stripping OS versions

libcxx/include/__tree

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,21 @@ public:
862862
using const_iterator = __tree_const_iterator<_Tp, __node_pointer, difference_type>;
863863

864864
_LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(
865-
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value);
866-
_LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a);
867-
_LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a);
865+
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)
866+
: __size_(0), __value_comp_(__comp) {
867+
__begin_node_ = __end_node();
868+
}
869+
870+
_LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a)
871+
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) {
872+
__begin_node_ = __end_node();
873+
}
874+
875+
_LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a)
876+
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
877+
__begin_node_ = __end_node();
878+
}
879+
868880
_LIBCPP_HIDE_FROM_ABI __tree(const __tree& __t);
869881
_LIBCPP_HIDE_FROM_ABI __tree& operator=(const __tree& __t);
870882
template <class _ForwardIterator>
@@ -874,13 +886,20 @@ public:
874886
_LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_(
875887
is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value);
876888
_LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a);
889+
877890
_LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t)
878891
_NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
879892
((__node_traits::propagate_on_container_move_assignment::value &&
880893
is_nothrow_move_assignable<__node_allocator>::value) ||
881-
allocator_traits<__node_allocator>::is_always_equal::value));
894+
allocator_traits<__node_allocator>::is_always_equal::value)) {
895+
__move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
896+
return *this;
897+
}
882898

883-
_LIBCPP_HIDE_FROM_ABI ~__tree();
899+
_LIBCPP_HIDE_FROM_ABI ~__tree() {
900+
static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible.");
901+
destroy(__root());
902+
}
884903

885904
_LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node_); }
886905
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__begin_node_); }
@@ -1204,7 +1223,7 @@ private:
12041223
_LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
12051224

12061225
// TODO: Make this _LIBCPP_HIDE_FROM_ABI
1207-
_LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT;
1226+
_LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT { (__tree_deleter(__node_alloc_))(__nd); }
12081227

12091228
_LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);
12101229
_LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
@@ -1373,25 +1392,6 @@ private:
13731392
}
13741393
};
13751394

1376-
template <class _Tp, class _Compare, class _Allocator>
1377-
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_(
1378-
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)
1379-
: __size_(0), __value_comp_(__comp) {
1380-
__begin_node_ = __end_node();
1381-
}
1382-
1383-
template <class _Tp, class _Compare, class _Allocator>
1384-
__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
1385-
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) {
1386-
__begin_node_ = __end_node();
1387-
}
1388-
1389-
template <class _Tp, class _Compare, class _Allocator>
1390-
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a)
1391-
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
1392-
__begin_node_ = __end_node();
1393-
}
1394-
13951395
// Precondition: __size_ != 0
13961396
template <class _Tp, class _Compare, class _Allocator>
13971397
typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
@@ -1588,27 +1588,6 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
15881588
}
15891589
}
15901590

1591-
template <class _Tp, class _Compare, class _Allocator>
1592-
__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)
1593-
_NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
1594-
((__node_traits::propagate_on_container_move_assignment::value &&
1595-
is_nothrow_move_assignable<__node_allocator>::value) ||
1596-
allocator_traits<__node_allocator>::is_always_equal::value)) {
1597-
__move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
1598-
return *this;
1599-
}
1600-
1601-
template <class _Tp, class _Compare, class _Allocator>
1602-
__tree<_Tp, _Compare, _Allocator>::~__tree() {
1603-
static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible.");
1604-
destroy(__root());
1605-
}
1606-
1607-
template <class _Tp, class _Compare, class _Allocator>
1608-
void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {
1609-
(__tree_deleter(__node_alloc_))(__nd);
1610-
}
1611-
16121591
template <class _Tp, class _Compare, class _Allocator>
16131592
void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
16141593
#if _LIBCPP_STD_VER <= 11

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Changes to the LLVM tools
152152
---------------------------------
153153

154154
* `llvm-readelf` now dumps all hex format values in lower-case mode.
155+
* Some code paths for supporting Python 2.7 in `llvm-lit` have been removed.
155156

156157
Changes to LLDB
157158
---------------------------------

llvm/include/llvm/Support/type_traits.h

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
namespace llvm {
2121

22-
2322
/// Metafunction that determines whether the given type is either an
2423
/// integral type or an enumeration type, including enum classes.
2524
///
@@ -40,8 +39,10 @@ template <typename T> class is_integral_or_enum {
4039
};
4140

4241
/// If T is a pointer, just return it. If it is not, return T&.
43-
template<typename T, typename Enable = void>
44-
struct add_lvalue_reference_if_not_pointer { using type = T &; };
42+
template <typename T, typename Enable = void>
43+
struct add_lvalue_reference_if_not_pointer {
44+
using type = T &;
45+
};
4546

4647
template <typename T>
4748
struct add_lvalue_reference_if_not_pointer<
@@ -51,8 +52,9 @@ struct add_lvalue_reference_if_not_pointer<
5152

5253
/// If T is a pointer to X, return a pointer to const X. If it is not,
5354
/// return const T.
54-
template<typename T, typename Enable = void>
55-
struct add_const_past_pointer { using type = const T; };
55+
template <typename T, typename Enable = void> struct add_const_past_pointer {
56+
using type = const T;
57+
};
5658

5759
template <typename T>
5860
struct add_const_past_pointer<T, std::enable_if_t<std::is_pointer_v<T>>> {
@@ -69,29 +71,29 @@ struct const_pointer_or_const_ref<T, std::enable_if_t<std::is_pointer_v<T>>> {
6971
};
7072

7173
namespace detail {
72-
template<class T>
73-
union trivial_helper {
74-
T t;
74+
template <class T> union trivial_helper {
75+
T t;
7576
};
7677

77-
} // end namespace detail
78+
} // namespace detail
7879

79-
template <typename T>
80-
struct is_copy_assignable {
81-
template<class F>
82-
static auto get(F*) -> decltype(std::declval<F &>() = std::declval<const F &>(), std::true_type{});
83-
static std::false_type get(...);
84-
static constexpr bool value = decltype(get((T*)nullptr))::value;
80+
template <typename T> struct is_copy_assignable {
81+
template <class F>
82+
static auto get(F *)
83+
-> decltype(std::declval<F &>() = std::declval<const F &>(),
84+
std::true_type{});
85+
static std::false_type get(...);
86+
static constexpr bool value = decltype(get((T *)nullptr))::value;
8587
};
8688

87-
template <typename T>
88-
struct is_move_assignable {
89-
template<class F>
90-
static auto get(F*) -> decltype(std::declval<F &>() = std::declval<F &&>(), std::true_type{});
91-
static std::false_type get(...);
92-
static constexpr bool value = decltype(get((T*)nullptr))::value;
89+
template <typename T> struct is_move_assignable {
90+
template <class F>
91+
static auto get(F *)
92+
-> decltype(std::declval<F &>() = std::declval<F &&>(), std::true_type{});
93+
static std::false_type get(...);
94+
static constexpr bool value = decltype(get((T *)nullptr))::value;
9395
};
9496

95-
} // end namespace llvm
97+
} // namespace llvm
9698

9799
#endif // LLVM_SUPPORT_TYPE_TRAITS_H

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ static void emitSCSPrologue(MachineFunction &MF, MachineBasicBlock &MBB,
106106
MachineBasicBlock::iterator MI,
107107
const DebugLoc &DL) {
108108
const auto &STI = MF.getSubtarget<RISCVSubtarget>();
109+
// We check Zimop instead of (Zimop || Zcmop) to determine whether HW shadow
110+
// stack is available despite the fact that sspush/sspopchk both have a
111+
// compressed form, because if only Zcmop is available, we would need to
112+
// reserve X5 due to c.sspopchk only takes X5 and we currently do not support
113+
// using X5 as the return address register.
114+
// However, we can still aggressively use c.sspush x1 if zcmop is available.
109115
bool HasHWShadowStack = MF.getFunction().hasFnAttribute("hw-shadow-stack") &&
110-
STI.hasStdExtZicfiss();
116+
STI.hasStdExtZimop();
111117
bool HasSWShadowStack =
112118
MF.getFunction().hasFnAttribute(Attribute::ShadowCallStack);
113119
if (!HasHWShadowStack && !HasSWShadowStack)
@@ -124,7 +130,12 @@ static void emitSCSPrologue(MachineFunction &MF, MachineBasicBlock &MBB,
124130

125131
const RISCVInstrInfo *TII = STI.getInstrInfo();
126132
if (HasHWShadowStack) {
127-
BuildMI(MBB, MI, DL, TII->get(RISCV::SSPUSH)).addReg(RAReg);
133+
if (STI.hasStdExtZcmop()) {
134+
static_assert(RAReg == RISCV::X1, "C.SSPUSH only accepts X1");
135+
BuildMI(MBB, MI, DL, TII->get(RISCV::PseudoMOP_C_SSPUSH));
136+
} else {
137+
BuildMI(MBB, MI, DL, TII->get(RISCV::PseudoMOP_SSPUSH)).addReg(RAReg);
138+
}
128139
return;
129140
}
130141

@@ -172,7 +183,7 @@ static void emitSCSEpilogue(MachineFunction &MF, MachineBasicBlock &MBB,
172183
const DebugLoc &DL) {
173184
const auto &STI = MF.getSubtarget<RISCVSubtarget>();
174185
bool HasHWShadowStack = MF.getFunction().hasFnAttribute("hw-shadow-stack") &&
175-
STI.hasStdExtZicfiss();
186+
STI.hasStdExtZimop();
176187
bool HasSWShadowStack =
177188
MF.getFunction().hasFnAttribute(Attribute::ShadowCallStack);
178189
if (!HasHWShadowStack && !HasSWShadowStack)
@@ -186,7 +197,7 @@ static void emitSCSEpilogue(MachineFunction &MF, MachineBasicBlock &MBB,
186197

187198
const RISCVInstrInfo *TII = STI.getInstrInfo();
188199
if (HasHWShadowStack) {
189-
BuildMI(MBB, MI, DL, TII->get(RISCV::SSPOPCHK)).addReg(RAReg);
200+
BuildMI(MBB, MI, DL, TII->get(RISCV::PseudoMOP_SSPOPCHK)).addReg(RAReg);
190201
return;
191202
}
192203

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,6 @@ include "RISCVInstrInfoZalasr.td"
23282328
include "RISCVInstrInfoZimop.td"
23292329
include "RISCVInstrInfoZicbo.td"
23302330
include "RISCVInstrInfoZicond.td"
2331-
include "RISCVInstrInfoZicfiss.td"
23322331
include "RISCVInstrInfoZilsd.td"
23332332

23342333
// Scalar FP
@@ -2357,6 +2356,9 @@ include "RISCVInstrInfoZc.td"
23572356
include "RISCVInstrInfoZcmop.td"
23582357
include "RISCVInstrInfoZclsd.td"
23592358

2359+
// Control Flow Integriy, this requires Zimop/Zcmop
2360+
include "RISCVInstrInfoZicfiss.td"
2361+
23602362
// Short Forward Branch
23612363
include "RISCVInstrInfoSFB.td"
23622364

llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ defm SSAMOSWAP_W : AMO_rr_aq_rl<0b01001, 0b010, "ssamoswap.w">;
6262
let Predicates = [HasStdExtZicfiss, IsRV64] in
6363
defm SSAMOSWAP_D : AMO_rr_aq_rl<0b01001, 0b011, "ssamoswap.d">;
6464

65+
let Predicates = [HasStdExtZimop] in {
66+
let hasSideEffects = 1, mayLoad = 0, mayStore = 1 in
67+
def PseudoMOP_SSPUSH : Pseudo<(outs), (ins GPRX1X5:$rs2), []>,
68+
PseudoInstExpansion<(MOP_RR_7 X0, X0, GPR:$rs2)>;
69+
let hasSideEffects = 1, mayLoad = 1, mayStore = 0 in
70+
def PseudoMOP_SSPOPCHK : Pseudo<(outs), (ins GPRX1X5:$rs1), []>,
71+
PseudoInstExpansion<(MOP_R_28 X0, GPR:$rs1)>;
72+
} // Predicates = [HasStdExtZimop]
73+
74+
let Predicates = [HasStdExtZcmop] in {
75+
let Uses = [X1], hasSideEffects = 1, mayLoad = 0, mayStore = 1 in
76+
def PseudoMOP_C_SSPUSH : Pseudo<(outs), (ins), []>,
77+
PseudoInstExpansion<(C_MOP_1)>;
78+
} // Predicates = [HasStdExtZcmop]
79+
6580
//===----------------------------------------------------------------------===/
6681
// Compress Instruction tablegen backend.
6782
//===----------------------------------------------------------------------===//

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,6 @@ unsigned X86RegisterInfo::findDeadCallerSavedReg(
10021002
if (MF->callsEHReturn())
10031003
return 0;
10041004

1005-
const TargetRegisterClass &AvailableRegs = *getGPRsForTailCall(*MF);
1006-
10071005
if (MBBI == MBB.end())
10081006
return 0;
10091007

@@ -1025,20 +1023,16 @@ unsigned X86RegisterInfo::findDeadCallerSavedReg(
10251023
case X86::TCRETURNmi64:
10261024
case X86::EH_RETURN:
10271025
case X86::EH_RETURN64: {
1028-
SmallSet<uint16_t, 8> Uses;
1029-
for (MachineOperand &MO : MBBI->operands()) {
1030-
if (!MO.isReg() || MO.isDef())
1031-
continue;
1032-
Register Reg = MO.getReg();
1033-
if (!Reg)
1034-
continue;
1035-
for (MCRegAliasIterator AI(Reg, this, true); AI.isValid(); ++AI)
1036-
Uses.insert(*AI);
1026+
LiveRegUnits LRU(*this);
1027+
LRU.addLiveOuts(MBB);
1028+
LRU.stepBackward(*MBBI);
1029+
1030+
const TargetRegisterClass &RC =
1031+
Is64Bit ? X86::GR64_NOSPRegClass : X86::GR32_NOSPRegClass;
1032+
for (MCRegister Reg : RC) {
1033+
if (LRU.available(Reg))
1034+
return Reg;
10371035
}
1038-
1039-
for (auto CS : AvailableRegs)
1040-
if (!Uses.count(CS) && CS != X86::RIP && CS != X86::RSP && CS != X86::ESP)
1041-
return CS;
10421036
}
10431037
}
10441038

0 commit comments

Comments
 (0)