Skip to content

Commit 8ad3438

Browse files
committed
merge main into amd-staging
2 parents 83f072d + 98ffdf3 commit 8ad3438

File tree

98 files changed

+1084
-921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1084
-921
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,13 @@ static bool interp__builtin_isinf(InterpState &S, CodePtr OpPC,
459459
const InterpFrame *Frame, bool CheckSign,
460460
const CallExpr *Call) {
461461
const Floating &Arg = S.Stk.pop<Floating>();
462-
bool IsInf = Arg.isInf();
462+
APFloat F = Arg.getAPFloat();
463+
bool IsInf = F.isInfinity();
463464

464465
if (CheckSign)
465-
pushInteger(S, IsInf ? (Arg.isNegative() ? -1 : 1) : 0, Call->getType());
466+
pushInteger(S, IsInf ? (F.isNegative() ? -1 : 1) : 0, Call->getType());
466467
else
467-
pushInteger(S, Arg.isInf(), Call->getType());
468+
pushInteger(S, IsInf, Call->getType());
468469
return true;
469470
}
470471

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ namespace lower {
3636
namespace omp {
3737
bool DataSharingProcessor::OMPConstructSymbolVisitor::isSymbolDefineBy(
3838
const semantics::Symbol *symbol, lower::pft::Evaluation &eval) const {
39-
return eval.visit(
40-
common::visitors{[&](const parser::OpenMPConstruct &functionParserNode) {
41-
return symDefMap.count(symbol) &&
42-
symDefMap.at(symbol) == &functionParserNode;
43-
},
44-
[](const auto &functionParserNode) { return false; }});
39+
return eval.visit(common::visitors{
40+
[&](const parser::OpenMPConstruct &functionParserNode) {
41+
return symDefMap.count(symbol) &&
42+
symDefMap.at(symbol) == ConstructPtr(&functionParserNode);
43+
},
44+
[](const auto &functionParserNode) { return false; }});
4545
}
4646

4747
static bool isConstructWithTopLevelTarget(lower::pft::Evaluation &eval) {
@@ -558,8 +558,16 @@ void DataSharingProcessor::collectSymbols(
558558
return sym->test(semantics::Symbol::Flag::OmpImplicit);
559559
}
560560

561-
if (collectPreDetermined)
562-
return sym->test(semantics::Symbol::Flag::OmpPreDetermined);
561+
if (collectPreDetermined) {
562+
// Collect pre-determined symbols only if they are defined by the current
563+
// OpenMP evaluation. If `sym` is not defined by the current OpenMP
564+
// evaluation then it is defined by a block nested within the OpenMP
565+
// construct. This, in turn, means that the private allocation for the
566+
// symbol will be emitted as part of the nested block and there is no need
567+
// to privatize it within the OpenMP construct.
568+
return visitor.isSymbolDefineBy(sym, eval) &&
569+
sym->test(semantics::Symbol::Flag::OmpPreDetermined);
570+
}
563571

564572
return !sym->test(semantics::Symbol::Flag::OmpImplicit) &&
565573
!sym->test(semantics::Symbol::Flag::OmpPreDetermined);

flang/lib/Lower/OpenMP/DataSharingProcessor.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "flang/Parser/parse-tree.h"
2020
#include "flang/Semantics/symbol.h"
2121
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
22+
#include <variant>
2223

2324
namespace mlir {
2425
namespace omp {
@@ -58,20 +59,30 @@ class DataSharingProcessor {
5859
}
5960

6061
void Post(const parser::Name &name) {
61-
auto *current = !constructs.empty() ? constructs.back() : nullptr;
62+
auto current = !constructs.empty() ? constructs.back() : ConstructPtr();
6263
symDefMap.try_emplace(name.symbol, current);
6364
}
6465

65-
llvm::SmallVector<const parser::OpenMPConstruct *> constructs;
66-
llvm::DenseMap<semantics::Symbol *, const parser::OpenMPConstruct *>
67-
symDefMap;
66+
bool Pre(const parser::DeclarationConstruct &decl) {
67+
constructs.push_back(&decl);
68+
return true;
69+
}
70+
71+
void Post(const parser::DeclarationConstruct &decl) {
72+
constructs.pop_back();
73+
}
6874

6975
/// Given a \p symbol and an \p eval, returns true if eval is the OMP
7076
/// construct that defines symbol.
7177
bool isSymbolDefineBy(const semantics::Symbol *symbol,
7278
lower::pft::Evaluation &eval) const;
7379

7480
private:
81+
using ConstructPtr = std::variant<const parser::OpenMPConstruct *,
82+
const parser::DeclarationConstruct *>;
83+
llvm::SmallVector<ConstructPtr> constructs;
84+
llvm::DenseMap<semantics::Symbol *, ConstructPtr> symDefMap;
85+
7586
unsigned version;
7687
};
7788

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
! Fixes a bug when a block variable is marked as pre-determined private. In such
2+
! case, we can simply ignore privatizing that symbol within the context of the
3+
! currrent OpenMP construct since the "private" allocation for the symbol will
4+
! be emitted within the nested block anyway.
5+
6+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
7+
8+
subroutine block_predetermined_privatization
9+
implicit none
10+
integer :: i
11+
12+
!$omp parallel
13+
do i=1,10
14+
block
15+
integer :: j
16+
do j=1,10
17+
end do
18+
end block
19+
end do
20+
!$omp end parallel
21+
end subroutine
22+
23+
! CHECK-LABEL: func.func @_QPblock_predetermined_privatization() {
24+
! CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "{{.*}}Ei"}
25+
! CHECK: omp.parallel private(@{{.*}}Ei_private_i32 %[[I_DECL]]#0 -> %{{.*}} : !fir.ref<i32>) {
26+
! CHECK: fir.do_loop {{.*}} {
27+
! Verify that `j` is allocated whithin the same scope of its block (i.e. inside
28+
! the `parallel` loop).
29+
! CHECK: fir.alloca i32 {bindc_name = "j", {{.*}}}
30+
! CHECK: }
31+
! CHECK: }
32+
! CHECK: }

libcxx/include/__tree

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@
2727
#include <__type_traits/copy_cvref.h>
2828
#include <__type_traits/enable_if.h>
2929
#include <__type_traits/invoke.h>
30-
#include <__type_traits/is_const.h>
3130
#include <__type_traits/is_constructible.h>
3231
#include <__type_traits/is_nothrow_assignable.h>
3332
#include <__type_traits/is_nothrow_constructible.h>
3433
#include <__type_traits/is_same.h>
34+
#include <__type_traits/is_specialization.h>
3535
#include <__type_traits/is_swappable.h>
3636
#include <__type_traits/remove_const.h>
37-
#include <__type_traits/remove_const_ref.h>
38-
#include <__type_traits/remove_cvref.h>
3937
#include <__utility/forward.h>
4038
#include <__utility/move.h>
4139
#include <__utility/pair.h>
@@ -51,13 +49,6 @@ _LIBCPP_PUSH_MACROS
5149

5250
_LIBCPP_BEGIN_NAMESPACE_STD
5351

54-
template <class _Tp, class _Compare, class _Allocator>
55-
class __tree;
56-
template <class _Tp, class _NodePtr, class _DiffType>
57-
class __tree_iterator;
58-
template <class _Tp, class _ConstNodePtr, class _DiffType>
59-
class __tree_const_iterator;
60-
6152
template <class _Pointer>
6253
class __tree_end_node;
6354
template <class _VoidPtr>
@@ -68,13 +59,6 @@ class __tree_node;
6859
template <class _Key, class _Value>
6960
struct __value_type;
7061

71-
template <class _Allocator>
72-
class __map_node_destructor;
73-
template <class _TreeIterator>
74-
class __map_iterator;
75-
template <class _TreeIterator>
76-
class __map_const_iterator;
77-
7862
/*
7963
8064
_NodePtr algorithms
@@ -492,16 +476,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEP
492476
// node traits
493477

494478
template <class _Tp>
495-
struct __is_tree_value_type_imp : false_type {};
496-
497-
template <class _Key, class _Value>
498-
struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};
499-
500-
template <class... _Args>
501-
struct __is_tree_value_type : false_type {};
502-
503-
template <class _One>
504-
struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {};
479+
inline const bool __is_tree_value_type_v = __is_specialization_v<_Tp, __value_type>;
505480

506481
template <class _Tp>
507482
struct __get_tree_key_type {
@@ -974,23 +949,23 @@ public:
974949
return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first;
975950
}
976951

977-
template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
952+
template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
978953
_LIBCPP_HIDE_FROM_ABI void
979954
__insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) {
980955
__emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
981956
}
982957

983-
template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
958+
template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
984959
_LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) {
985960
__emplace_hint_unique(__p, std::move(__value));
986961
}
987962

988-
template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
963+
template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
989964
_LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) {
990965
__emplace_hint_multi(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
991966
}
992967

993-
template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
968+
template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
994969
_LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) {
995970
__emplace_hint_multi(__p, std::move(__value));
996971
}
@@ -1137,7 +1112,7 @@ private:
11371112
}
11381113
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
11391114

1140-
template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
1115+
template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
11411116
_LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
11421117
using __key_type = __remove_const_t<typename value_type::first_type>;
11431118

@@ -1147,7 +1122,7 @@ private:
11471122
__lhs.second = std::forward<_From>(__rhs).second;
11481123
}
11491124

1150-
template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
1125+
template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
11511126
_LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) {
11521127
__lhs = std::forward<_From>(__rhs);
11531128
}

libcxx/include/__type_traits/is_specialization.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,11 @@
3030

3131
_LIBCPP_BEGIN_NAMESPACE_STD
3232

33-
#if _LIBCPP_STD_VER >= 17
34-
3533
template <class _Tp, template <class...> class _Template>
36-
inline constexpr bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template
34+
inline const bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template
3735

3836
template <template <class...> class _Template, class... _Args>
39-
inline constexpr bool __is_specialization_v<_Template<_Args...>, _Template> = true;
40-
41-
#endif // _LIBCPP_STD_VER >= 17
37+
inline const bool __is_specialization_v<_Template<_Args...>, _Template> = true;
4238

4339
_LIBCPP_END_NAMESPACE_STD
4440

llvm/include/llvm/CodeGen/CallingConvLower.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ struct ForwardedRegister {
154154

155155
/// CCAssignFn - This function assigns a location for Val, updating State to
156156
/// reflect the change. It returns 'true' if it failed to handle Val.
157-
typedef bool CCAssignFn(unsigned ValNo, MVT ValVT,
158-
MVT LocVT, CCValAssign::LocInfo LocInfo,
159-
ISD::ArgFlagsTy ArgFlags, CCState &State);
157+
typedef bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT,
158+
CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
159+
Type *OrigTy, CCState &State);
160160

161161
/// CCCustomFn - This function assigns a location for Val, possibly updating
162162
/// all args to reflect changes and indicates if it handled it. It must set
@@ -290,6 +290,7 @@ class CCState {
290290
/// and argument flags.
291291
LLVM_ABI void AnalyzeCallOperands(SmallVectorImpl<MVT> &ArgVTs,
292292
SmallVectorImpl<ISD::ArgFlagsTy> &Flags,
293+
SmallVectorImpl<Type *> &OrigTys,
293294
CCAssignFn Fn);
294295

295296
/// The function will invoke AnalyzeCallOperands.
@@ -310,7 +311,7 @@ class CCState {
310311

311312
/// AnalyzeCallResult - Same as above except it's specialized for calls which
312313
/// produce a single value.
313-
LLVM_ABI void AnalyzeCallResult(MVT VT, CCAssignFn Fn);
314+
LLVM_ABI void AnalyzeCallResult(MVT VT, Type *OrigTy, CCAssignFn Fn);
314315

315316
/// getFirstUnallocated - Return the index of the first unallocated register
316317
/// in the set, or Regs.size() if they are all allocated.

llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class LLVM_ABI CallLowering {
198198
CCValAssign::LocInfo LocInfo, const ArgInfo &Info,
199199
ISD::ArgFlagsTy Flags, CCState &State) {
200200
if (getAssignFn(State.isVarArg())(ValNo, ValVT, LocVT, LocInfo, Flags,
201-
State))
201+
Info.Ty, State))
202202
return true;
203203
StackSize = State.getStackSize();
204204
return false;

llvm/include/llvm/CodeGen/TargetCallingConv.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ namespace ISD {
205205
ArgFlagsTy Flags;
206206
MVT VT = MVT::Other;
207207
EVT ArgVT;
208+
Type *OrigTy = nullptr;
208209
bool Used = false;
209210

210211
/// Index original Function's argument.
@@ -218,9 +219,10 @@ namespace ISD {
218219
unsigned PartOffset;
219220

220221
InputArg() = default;
221-
InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
222+
InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, Type *OrigTy, bool used,
222223
unsigned origIdx, unsigned partOffs)
223-
: Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
224+
: Flags(flags), OrigTy(OrigTy), Used(used), OrigArgIndex(origIdx),
225+
PartOffset(partOffs) {
224226
VT = vt.getSimpleVT();
225227
ArgVT = argvt;
226228
}
@@ -243,6 +245,7 @@ namespace ISD {
243245
ArgFlagsTy Flags;
244246
MVT VT;
245247
EVT ArgVT;
248+
Type *OrigTy = nullptr;
246249

247250
/// Index original Function's argument.
248251
unsigned OrigArgIndex;
@@ -253,9 +256,10 @@ namespace ISD {
253256
unsigned PartOffset;
254257

255258
OutputArg() = default;
256-
OutputArg(ArgFlagsTy flags, MVT vt, EVT argvt, unsigned origIdx,
257-
unsigned partOffs)
258-
: Flags(flags), OrigArgIndex(origIdx), PartOffset(partOffs) {
259+
OutputArg(ArgFlagsTy flags, MVT vt, EVT argvt, Type *OrigTy,
260+
unsigned origIdx, unsigned partOffs)
261+
: Flags(flags), OrigTy(OrigTy), OrigArgIndex(origIdx),
262+
PartOffset(partOffs) {
259263
VT = vt;
260264
ArgVT = argvt;
261265
}

llvm/include/llvm/IR/PatternMatch.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,45 +1327,6 @@ inline BinaryOp_match<LHS, RHS, Instruction::AShr> m_AShr(const LHS &L,
13271327
return BinaryOp_match<LHS, RHS, Instruction::AShr>(L, R);
13281328
}
13291329

1330-
template <typename LHS_t, unsigned Opcode> struct ShiftLike_match {
1331-
LHS_t L;
1332-
uint64_t &R;
1333-
1334-
ShiftLike_match(const LHS_t &LHS, uint64_t &RHS) : L(LHS), R(RHS) {}
1335-
1336-
template <typename OpTy> bool match(OpTy *V) const {
1337-
if (auto *Op = dyn_cast<BinaryOperator>(V)) {
1338-
if (Op->getOpcode() == Opcode)
1339-
return m_ConstantInt(R).match(Op->getOperand(1)) &&
1340-
L.match(Op->getOperand(0));
1341-
}
1342-
// Interpreted as shiftop V, 0
1343-
R = 0;
1344-
return L.match(V);
1345-
}
1346-
};
1347-
1348-
/// Matches shl L, ConstShAmt or L itself.
1349-
template <typename LHS>
1350-
inline ShiftLike_match<LHS, Instruction::Shl> m_ShlOrSelf(const LHS &L,
1351-
uint64_t &R) {
1352-
return ShiftLike_match<LHS, Instruction::Shl>(L, R);
1353-
}
1354-
1355-
/// Matches lshr L, ConstShAmt or L itself.
1356-
template <typename LHS>
1357-
inline ShiftLike_match<LHS, Instruction::LShr> m_LShrOrSelf(const LHS &L,
1358-
uint64_t &R) {
1359-
return ShiftLike_match<LHS, Instruction::LShr>(L, R);
1360-
}
1361-
1362-
/// Matches ashr L, ConstShAmt or L itself.
1363-
template <typename LHS>
1364-
inline ShiftLike_match<LHS, Instruction::AShr> m_AShrOrSelf(const LHS &L,
1365-
uint64_t &R) {
1366-
return ShiftLike_match<LHS, Instruction::AShr>(L, R);
1367-
}
1368-
13691330
template <typename LHS_t, typename RHS_t, unsigned Opcode,
13701331
unsigned WrapFlags = 0, bool Commutable = false>
13711332
struct OverflowingBinaryOp_match {

0 commit comments

Comments
 (0)