Skip to content

Commit bdb8062

Browse files
authored
Merge branch 'main' into loop-vectorize/evl-exit-cond-avlnext-zero
2 parents bd2ed44 + aea82a7 commit bdb8062

File tree

171 files changed

+2565
-1577
lines changed

Some content is hidden

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

171 files changed

+2565
-1577
lines changed

clang/include/clang/AST/ExprCXX.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,19 @@ class CXXConstructExpr : public Expr {
17121712
CXXConstructExprBits.IsImmediateEscalating = Set;
17131713
}
17141714

1715+
/// Returns the WarnUnusedResultAttr that is declared on the callee
1716+
/// or its return type declaration, together with a NamedDecl that
1717+
/// refers to the declaration the attribute is attached to.
1718+
std::pair<const NamedDecl *, const WarnUnusedResultAttr *>
1719+
getUnusedResultAttr(const ASTContext &Ctx) const {
1720+
return getUnusedResultAttrImpl(getConstructor(), getType());
1721+
}
1722+
1723+
/// Returns true if this call expression should warn on unused results.
1724+
bool hasUnusedResultAttr(const ASTContext &Ctx) const {
1725+
return getUnusedResultAttr(Ctx).second != nullptr;
1726+
}
1727+
17151728
SourceLocation getBeginLoc() const LLVM_READONLY;
17161729
SourceLocation getEndLoc() const LLVM_READONLY;
17171730
SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }

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

clang/lib/Sema/SemaStmt.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,10 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
316316
}
317317
}
318318
} else if (const auto *CE = dyn_cast<CXXConstructExpr>(E)) {
319-
if (const CXXConstructorDecl *Ctor = CE->getConstructor()) {
320-
const NamedDecl *OffendingDecl = nullptr;
321-
const auto *A = Ctor->getAttr<WarnUnusedResultAttr>();
322-
if (!A) {
323-
OffendingDecl = Ctor->getParent();
324-
A = OffendingDecl->getAttr<WarnUnusedResultAttr>();
325-
}
326-
if (DiagnoseNoDiscard(S, OffendingDecl, A, Loc, R1, R2,
327-
/*isCtor=*/true))
328-
return;
329-
}
319+
auto [OffendingDecl, A] = CE->getUnusedResultAttr(S.Context);
320+
if (DiagnoseNoDiscard(S, OffendingDecl, A, Loc, R1, R2,
321+
/*isCtor=*/true))
322+
return;
330323
} else if (const auto *ILE = dyn_cast<InitListExpr>(E)) {
331324
if (const TagDecl *TD = ILE->getType()->getAsTagDecl()) {
332325

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) {
@@ -553,8 +553,16 @@ void DataSharingProcessor::collectSymbols(
553553
return sym->test(semantics::Symbol::Flag::OmpImplicit);
554554
}
555555

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

559567
return !sym->test(semantics::Symbol::Flag::OmpImplicit) &&
560568
!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: }

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,33 @@ function(get_libclc_device_info)
199199
endif()
200200
endfunction()
201201

202+
# Install libclc artifacts.
203+
#
204+
# Arguments:
205+
# * FILES <string> ...
206+
# List of libclc artifact files to be installed.
207+
function(libclc_install)
208+
cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
209+
210+
if( NOT ARG_FILES )
211+
message( FATAL_ERROR "Must provide FILES" )
212+
endif()
213+
214+
if( NOT CMAKE_CFG_INTDIR STREQUAL "." )
215+
# Replace CMAKE_CFG_INTDIR with CMAKE_INSTALL_CONFIG_NAME for multiple-
216+
# configuration generators.
217+
string( REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}"
218+
files ${ARG_FILES} )
219+
else()
220+
set( files ${ARG_FILES} )
221+
endif()
222+
223+
install(
224+
FILES ${files}
225+
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
226+
)
227+
endfunction()
228+
202229
# Compiles a list of library source files (provided by LIB_FILES/GEN_FILES) and
203230
# compiles them to LLVM bytecode (or SPIR-V), links them together and optimizes
204231
# them.
@@ -425,10 +452,7 @@ function(add_libclc_builtin_set)
425452
# targets dependent on libclc.
426453
add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} )
427454

428-
install(
429-
FILES ${libclc_builtins_lib}
430-
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
431-
)
455+
libclc_install(FILES ${libclc_builtins_lib})
432456

433457
# SPIR-V targets can exit early here
434458
if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
@@ -470,10 +494,7 @@ function(add_libclc_builtin_set)
470494
set_target_properties( alias-${alias_suffix}
471495
PROPERTIES FOLDER "libclc/Device IR/Aliases"
472496
)
473-
install(
474-
FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
475-
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
476-
)
497+
libclc_install(FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix})
477498
endforeach( a )
478499
endfunction(add_libclc_builtin_set)
479500

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

lldb/source/Commands/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ let Command = "breakpoint set" in {
205205
"identifiers). If not set the target.language setting is used.">;
206206
def breakpoint_set_skip_prologue : Option<"skip-prologue", "K">,
207207
Arg<"Boolean">, Groups<[1,3,4,5,6,7,8,12]>,
208-
Desc<"sKip the prologue if the breakpoint is at the beginning of a "
208+
Desc<"Skip the prologue if the breakpoint is at the beginning of a "
209209
"function. If not set the target.skip-prologue setting is used.">;
210210
def breakpoint_set_breakpoint_name : Option<"breakpoint-name", "N">,
211211
Arg<"BreakpointName">,

0 commit comments

Comments
 (0)