Skip to content

Commit 9c69339

Browse files
committed
Merge from 'main' to 'sycl-web' (28 commits)
CONFLICT (content): Merge conflict in libclc/cmake/modules/AddLibclc.cmake
2 parents 7a84974 + 68c609b commit 9c69339

File tree

194 files changed

+3012
-1435
lines changed

Some content is hidden

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

194 files changed

+3012
-1435
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
@@ -317,17 +317,10 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
317317
}
318318
}
319319
} else if (const auto *CE = dyn_cast<CXXConstructExpr>(E)) {
320-
if (const CXXConstructorDecl *Ctor = CE->getConstructor()) {
321-
const NamedDecl *OffendingDecl = nullptr;
322-
const auto *A = Ctor->getAttr<WarnUnusedResultAttr>();
323-
if (!A) {
324-
OffendingDecl = Ctor->getParent();
325-
A = OffendingDecl->getAttr<WarnUnusedResultAttr>();
326-
}
327-
if (DiagnoseNoDiscard(S, OffendingDecl, A, Loc, R1, R2,
328-
/*isCtor=*/true))
329-
return;
330-
}
320+
auto [OffendingDecl, A] = CE->getUnusedResultAttr(S.Context);
321+
if (DiagnoseNoDiscard(S, OffendingDecl, A, Loc, R1, R2,
322+
/*isCtor=*/true))
323+
return;
331324
} else if (const auto *ILE = dyn_cast<InitListExpr>(E)) {
332325
if (const TagDecl *TD = ILE->getType()->getAsTagDecl()) {
333326

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: }

libc/config/baremetal/aarch64/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,9 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
760760
libc.src.math.bf16add
761761
libc.src.math.bf16addf
762762
libc.src.math.bf16addl
763+
libc.src.math.bf16mul
764+
libc.src.math.bf16mulf
765+
libc.src.math.bf16mull
763766
libc.src.math.bf16sub
764767
libc.src.math.bf16subf
765768
libc.src.math.bf16subl
@@ -777,6 +780,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
777780
list(APPEND TARGET_LIBM_ENTRYPOINTS
778781
# math.h C++23 mixed bfloat16 and _Float128 entrypoints
779782
libc.src.math.bf16addf128
783+
libc.src.math.bf16mulf128
780784
libc.src.math.bf16subf128
781785
)
782786
endif()

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
763763
libc.src.math.bf16add
764764
libc.src.math.bf16addf
765765
libc.src.math.bf16addl
766+
libc.src.math.bf16mul
767+
libc.src.math.bf16mulf
768+
libc.src.math.bf16mull
766769
libc.src.math.bf16sub
767770
libc.src.math.bf16subf
768771
libc.src.math.bf16subl
@@ -780,6 +783,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
780783
list(APPEND TARGET_LIBM_ENTRYPOINTS
781784
# math.h C++23 mixed bfloat16 and _Float128 entrypoints
782785
libc.src.math.bf16addf128
786+
libc.src.math.bf16mulf128
783787
libc.src.math.bf16subf128
784788
)
785789
endif()

libc/config/baremetal/riscv/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
763763
libc.src.math.bf16add
764764
libc.src.math.bf16addf
765765
libc.src.math.bf16addl
766+
libc.src.math.bf16mul
767+
libc.src.math.bf16mulf
768+
libc.src.math.bf16mull
766769
libc.src.math.bf16sub
767770
libc.src.math.bf16subf
768771
libc.src.math.bf16subl
@@ -780,6 +783,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
780783
list(APPEND TARGET_LIBM_ENTRYPOINTS
781784
# math.h C++23 mixed bfloat16 and _Float128 entrypoints
782785
libc.src.math.bf16addf128
786+
libc.src.math.bf16mulf128
783787
libc.src.math.bf16subf128
784788
)
785789
endif()

libc/config/darwin/aarch64/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
593593
libc.src.math.bf16add
594594
libc.src.math.bf16addf
595595
libc.src.math.bf16addl
596+
libc.src.math.bf16mul
597+
libc.src.math.bf16mulf
598+
libc.src.math.bf16mull
596599
libc.src.math.bf16sub
597600
libc.src.math.bf16subf
598601
libc.src.math.bf16subl
@@ -610,6 +613,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
610613
list(APPEND TARGET_LIBM_ENTRYPOINTS
611614
# math.h C++23 mixed bfloat16 and _Float128 entrypoints
612615
libc.src.math.bf16addf128
616+
libc.src.math.bf16mulf128
613617
libc.src.math.bf16subf128
614618
)
615619
endif()

0 commit comments

Comments
 (0)