Skip to content

Commit 36855b8

Browse files
authored
Merge branch 'main' into Documentation-Revision-and-Proof-Read-for-Features.html
2 parents 279c263 + 2ee5671 commit 36855b8

File tree

56 files changed

+3965
-1713
lines changed

Some content is hidden

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

56 files changed

+3965
-1713
lines changed

clang/lib/AST/ASTImporter.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,10 +1740,21 @@ ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
17401740
}
17411741

17421742
ExpectedType ASTNodeImporter::VisitTagType(const TagType *T) {
1743-
Expected<TagDecl *> ToDeclOrErr = import(T->getOriginalDecl());
1743+
TagDecl *DeclForType = T->getOriginalDecl();
1744+
Expected<TagDecl *> ToDeclOrErr = import(DeclForType);
17441745
if (!ToDeclOrErr)
17451746
return ToDeclOrErr.takeError();
17461747

1748+
if (DeclForType->isUsed()) {
1749+
// If there is a definition of the 'OriginalDecl', it should be imported to
1750+
// have all information for the type in the "To" AST. (In some cases no
1751+
// other reference may exist to the definition decl and it would not be
1752+
// imported otherwise.)
1753+
Expected<TagDecl *> ToDefDeclOrErr = import(DeclForType->getDefinition());
1754+
if (!ToDefDeclOrErr)
1755+
return ToDefDeclOrErr.takeError();
1756+
}
1757+
17471758
if (T->isCanonicalUnqualified())
17481759
return Importer.getToContext().getCanonicalTagType(*ToDeclOrErr);
17491760

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
5+
// RUN: %clang_cc1 -emit-pch -o %t/import.c.ast %t/import.c
6+
7+
// RUN: %clang_extdef_map -- -x c %t/import.c >> %t/externalDefMap.txt
8+
// RUN: sed -i='' 's/$/.ast/' %t/externalDefMap.txt
9+
10+
// RUN: %clang_cc1 -analyze \
11+
// RUN: -analyzer-checker=core \
12+
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
13+
// RUN: -analyzer-config display-ctu-progress=true \
14+
// RUN: -analyzer-config ctu-dir=%t \
15+
// RUN: -verify %t/main.c
16+
17+
//--- main.c
18+
19+
// expected-no-diagnostics
20+
21+
typedef struct X_s X_t;
22+
unsigned long f_import(struct X_s *xPtr);
23+
24+
static void freeWriteFileResources(struct X_s *xPtr) {
25+
f_import(xPtr);
26+
}
27+
28+
//--- import.c
29+
30+
typedef struct Y_s Y_t;
31+
32+
struct Y_s {
33+
};
34+
35+
struct X_s {
36+
Y_t y;
37+
};
38+
39+
unsigned long f_import(struct X_s *xPtr) {
40+
if (xPtr != 0) {
41+
}
42+
return 0;
43+
}

flang/lib/Lower/ConvertConstant.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,34 @@ class DenseGlobalBuilder {
145145
fir::FirOpBuilder &builder,
146146
const Fortran::evaluate::Constant<Fortran::evaluate::Type<TC, KIND>>
147147
&constant) {
148+
using Element =
149+
Fortran::evaluate::Scalar<Fortran::evaluate::Type<TC, KIND>>;
150+
148151
static_assert(TC != Fortran::common::TypeCategory::Character,
149152
"must be numerical or logical");
150153
auto attrTc = TC == Fortran::common::TypeCategory::Logical
151154
? Fortran::common::TypeCategory::Integer
152155
: TC;
153156
attributeElementType =
154157
Fortran::lower::getFIRType(builder.getContext(), attrTc, KIND, {});
155-
for (auto element : constant.values())
158+
159+
const std::vector<Element> &values = constant.values();
160+
auto sameElements = [&]() -> bool {
161+
if (values.empty())
162+
return false;
163+
164+
return std::all_of(values.begin(), values.end(),
165+
[&](const auto &v) { return v == values.front(); });
166+
};
167+
168+
if (sameElements()) {
169+
auto attr = convertToAttribute<TC, KIND>(builder, values.front(),
170+
attributeElementType);
171+
attributes.assign(values.size(), attr);
172+
return;
173+
}
174+
175+
for (auto element : values)
156176
attributes.push_back(
157177
convertToAttribute<TC, KIND>(builder, element, attributeElementType));
158178
}

libcxx/docs/Status/Cxx2cIssues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"`LWG4076 <https://wg21.link/LWG4076>`__","``concat_view`` should be freestanding","2024-06 (St. Louis)","","",""
7171
"`LWG4079 <https://wg21.link/LWG4079>`__","Missing Preconditions in ``concat_view::iterator``\`s conversion constructor","2024-06 (St. Louis)","","",""
7272
"`LWG4082 <https://wg21.link/LWG4082>`__","``views::concat(r)`` is well-formed when ``r`` is an ``output_range``","2024-06 (St. Louis)","","",""
73-
"`LWG4083 <https://wg21.link/LWG4083>`__","``views::as_rvalue`` should reject non-input ranges","2024-06 (St. Louis)","","",""
73+
"`LWG4083 <https://wg21.link/LWG4083>`__","``views::as_rvalue`` should reject non-input ranges","2024-06 (St. Louis)","|Complete|","22",""
7474
"`LWG4096 <https://wg21.link/LWG4096>`__","``views::iota(views::iota(0))`` should be rejected","2024-06 (St. Louis)","|Complete|","22",""
7575
"`LWG4098 <https://wg21.link/LWG4098>`__","``views::adjacent<0>`` should reject non-forward ranges","2024-06 (St. Louis)","","",""
7676
"`LWG4105 <https://wg21.link/LWG4105>`__","``ranges::ends_with``\`s Returns misses difference casting","2024-06 (St. Louis)","","",""

libcxx/include/__ranges/as_rvalue_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct __fn : __range_adaptor_closure<__fn> {
117117
return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range));
118118
}
119119

120-
template <class _Range>
120+
template <input_range _Range>
121121
requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>>
122122
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
123123
operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range))))

libcxx/test/std/ranges/range.adaptors/range.as.rvalue/adaptor.pass.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ struct move_iterator_range {
4848
static_assert(!std::ranges::view<move_iterator_range>);
4949
static_assert(std::ranges::range<move_iterator_range>);
5050

51+
// LWG4083: views::as_rvalue should reject non-input ranges
52+
struct I {
53+
int operator*();
54+
using difference_type = int;
55+
I& operator++();
56+
void operator++(int);
57+
};
58+
static_assert(!std::is_invocable_v<decltype(std::views::as_rvalue),
59+
decltype(std::ranges::subrange{I{}, std::unreachable_sentinel})>);
60+
static_assert(
61+
!HasPipe<decltype(std::ranges::subrange{I{}, std::unreachable_sentinel}), decltype(std::views::as_rvalue)>);
62+
5163
constexpr bool test() {
5264
{ // view | views::as_rvalue
5365
DefaultConstructibleView v{{}, 3};

llvm/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -706,18 +706,6 @@ endif()
706706

707707
option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF)
708708

709-
# While adding scalable vector support to LLVM, we temporarily want to
710-
# allow an implicit conversion of TypeSize to uint64_t, and to allow
711-
# code to get the fixed number of elements from a possibly scalable vector.
712-
# This CMake flag enables a more strict mode where it asserts that the type
713-
# is not a scalable vector type.
714-
#
715-
# Enabling this flag makes it easier to find cases where the compiler makes
716-
# assumptions on the size being 'fixed size', when building tests for
717-
# SVE/SVE2 or other scalable vector architectures.
718-
option(LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS
719-
"Enable assertions that type is not scalable in implicit conversion from TypeSize to uint64_t and calls to getNumElements" OFF)
720-
721709
set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
722710
"Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
723711

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,6 @@ if (LLVM_USES_LIBSTDCXX)
201201
endif()
202202
endif()
203203

204-
if (LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS)
205-
add_compile_definitions(STRICT_FIXED_SIZE_VECTORS)
206-
endif()
207-
208204
string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)
209205

210206
if( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "WITH_ASSERTS" )

llvm/include/llvm/Analysis/LoopAccessAnalysis.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ class MemoryDepChecker {
183183
MemoryDepChecker(PredicatedScalarEvolution &PSE, AssumptionCache *AC,
184184
DominatorTree *DT, const Loop *L,
185185
const DenseMap<Value *, const SCEV *> &SymbolicStrides,
186-
unsigned MaxTargetVectorWidthInBits)
186+
unsigned MaxTargetVectorWidthInBits,
187+
std::optional<ScalarEvolution::LoopGuards> &LoopGuards)
187188
: PSE(PSE), AC(AC), DT(DT), InnermostLoop(L),
188189
SymbolicStrides(SymbolicStrides),
189-
MaxTargetVectorWidthInBits(MaxTargetVectorWidthInBits) {}
190+
MaxTargetVectorWidthInBits(MaxTargetVectorWidthInBits),
191+
LoopGuards(LoopGuards) {}
190192

191193
/// Register the location (instructions are given increasing numbers)
192194
/// of a write access.
@@ -373,7 +375,7 @@ class MemoryDepChecker {
373375
PointerBounds;
374376

375377
/// Cache for the loop guards of InnermostLoop.
376-
std::optional<ScalarEvolution::LoopGuards> LoopGuards;
378+
std::optional<ScalarEvolution::LoopGuards> &LoopGuards;
377379

378380
/// Check whether there is a plausible dependence between the two
379381
/// accesses.
@@ -531,8 +533,9 @@ class RuntimePointerChecking {
531533
AliasSetId(AliasSetId), Expr(Expr), NeedsFreeze(NeedsFreeze) {}
532534
};
533535

534-
RuntimePointerChecking(MemoryDepChecker &DC, ScalarEvolution *SE)
535-
: DC(DC), SE(SE) {}
536+
RuntimePointerChecking(MemoryDepChecker &DC, ScalarEvolution *SE,
537+
std::optional<ScalarEvolution::LoopGuards> &LoopGuards)
538+
: DC(DC), SE(SE), LoopGuards(LoopGuards) {}
536539

537540
/// Reset the state of the pointer runtime information.
538541
void reset() {
@@ -646,6 +649,9 @@ class RuntimePointerChecking {
646649
/// Holds a pointer to the ScalarEvolution analysis.
647650
ScalarEvolution *SE;
648651

652+
/// Cache for the loop guards of the loop.
653+
std::optional<ScalarEvolution::LoopGuards> &LoopGuards;
654+
649655
/// Set of run-time checks required to establish independence of
650656
/// otherwise may-aliasing pointers in the loop.
651657
SmallVector<RuntimePointerCheck, 4> Checks;
@@ -821,6 +827,9 @@ class LoopAccessInfo {
821827

822828
Loop *TheLoop;
823829

830+
/// Cache for the loop guards of TheLoop.
831+
std::optional<ScalarEvolution::LoopGuards> LoopGuards;
832+
824833
/// Determines whether we should generate partial runtime checks when not all
825834
/// memory accesses could be analyzed.
826835
bool AllowPartial;
@@ -938,7 +947,8 @@ LLVM_ABI std::pair<const SCEV *, const SCEV *> getStartAndEndForAccess(
938947
const SCEV *MaxBTC, ScalarEvolution *SE,
939948
DenseMap<std::pair<const SCEV *, Type *>,
940949
std::pair<const SCEV *, const SCEV *>> *PointerBounds,
941-
DominatorTree *DT, AssumptionCache *AC);
950+
DominatorTree *DT, AssumptionCache *AC,
951+
std::optional<ScalarEvolution::LoopGuards> &LoopGuards);
942952

943953
class LoopAccessInfoManager {
944954
/// The cache.

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,6 +3338,14 @@ namespace ISD {
33383338
return St && St->getAddressingMode() == ISD::UNINDEXED;
33393339
}
33403340

3341+
/// Returns true if the specified node is a non-extending and unindexed
3342+
/// masked load.
3343+
inline bool isNormalMaskedLoad(const SDNode *N) {
3344+
auto *Ld = dyn_cast<MaskedLoadSDNode>(N);
3345+
return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
3346+
Ld->getAddressingMode() == ISD::UNINDEXED;
3347+
}
3348+
33413349
/// Attempt to match a unary predicate against a scalar/splat constant or
33423350
/// every element of a constant BUILD_VECTOR.
33433351
/// If AllowUndef is true, then UNDEF elements will pass nullptr to Match.

0 commit comments

Comments
 (0)