Skip to content

Commit 416339c

Browse files
authored
Merge branch 'main' into conv2d-variable-zp
2 parents 63eedd9 + 664cbd1 commit 416339c

File tree

79 files changed

+3006
-691
lines changed

Some content is hidden

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

79 files changed

+3006
-691
lines changed

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ clang_target_link_libraries(clangTidyBugproneModule
117117
clangASTMatchers
118118
clangBasic
119119
clangLex
120+
clangSema
120121
clangTooling
121122
clangTransformer
122123
)

clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "clang/Basic/Diagnostic.h"
2121
#include "clang/Basic/SourceLocation.h"
2222
#include "clang/Lex/Lexer.h"
23+
#include "clang/Sema/HeuristicResolver.h"
2324
#include "llvm/ADT/STLExtras.h"
2425
#include "llvm/ADT/SmallVector.h"
2526
#include "llvm/Support/Casting.h"
@@ -125,8 +126,8 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
125126
DeclarationName Name =
126127
Context.DeclarationNames.getIdentifier(&Context.Idents.get("clear"));
127128

128-
auto Candidates = MemberCall->getRecordDecl()->lookupDependentName(
129-
Name, [](const NamedDecl *ND) {
129+
auto Candidates = HeuristicResolver(Context).lookupDependentName(
130+
MemberCall->getRecordDecl(), Name, [](const NamedDecl *ND) {
130131
return isa<CXXMethodDecl>(ND) &&
131132
llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
132133
0 &&
@@ -174,8 +175,8 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
174175
DeclarationName Name =
175176
Context.DeclarationNames.getIdentifier(&Context.Idents.get("clear"));
176177

177-
auto Candidates =
178-
ArgRecordDecl->lookupDependentName(Name, [](const NamedDecl *ND) {
178+
auto Candidates = HeuristicResolver(Context).lookupDependentName(
179+
ArgRecordDecl, Name, [](const NamedDecl *ND) {
179180
return isa<CXXMethodDecl>(ND) &&
180181
llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
181182
0 &&

clang/include/clang/Sema/HeuristicResolver.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ class HeuristicResolver {
6969
QualType
7070
resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) const;
7171

72+
// Perform an imprecise lookup of a dependent name in `RD`.
73+
// This function does not follow strict semantic rules and should be used
74+
// only when lookup rules can be relaxed, e.g. indexing.
75+
std::vector<const NamedDecl *>
76+
lookupDependentName(CXXRecordDecl *RD, DeclarationName Name,
77+
llvm::function_ref<bool(const NamedDecl *ND)> Filter);
78+
7279
// Given the type T of a dependent expression that appears of the LHS of a
7380
// "->", heuristically find a corresponding pointee type in whose scope we
7481
// could look up the name appearing on the RHS.

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class HeuristicResolverImpl {
4444
const DependentTemplateSpecializationType *DTST);
4545
QualType resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS);
4646
QualType getPointeeType(QualType T);
47+
std::vector<const NamedDecl *>
48+
lookupDependentName(CXXRecordDecl *RD, DeclarationName Name,
49+
llvm::function_ref<bool(const NamedDecl *ND)> Filter);
4750

4851
private:
4952
ASTContext &Ctx;
@@ -83,16 +86,6 @@ class HeuristicResolverImpl {
8386
// during simplification, and the operation fails if no pointer type is found.
8487
QualType simplifyType(QualType Type, const Expr *E, bool UnwrapPointer);
8588

86-
// This is a reimplementation of CXXRecordDecl::lookupDependentName()
87-
// so that the implementation can call into other HeuristicResolver helpers.
88-
// FIXME: Once HeuristicResolver is upstreamed to the clang libraries
89-
// (https://github.com/clangd/clangd/discussions/1662),
90-
// CXXRecordDecl::lookupDepenedentName() can be removed, and its call sites
91-
// can be modified to benefit from the more comprehensive heuristics offered
92-
// by HeuristicResolver instead.
93-
std::vector<const NamedDecl *>
94-
lookupDependentName(CXXRecordDecl *RD, DeclarationName Name,
95-
llvm::function_ref<bool(const NamedDecl *ND)> Filter);
9689
bool findOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier,
9790
CXXBasePath &Path,
9891
DeclarationName Name);
@@ -539,6 +532,11 @@ QualType HeuristicResolver::resolveNestedNameSpecifierToType(
539532
const NestedNameSpecifier *NNS) const {
540533
return HeuristicResolverImpl(Ctx).resolveNestedNameSpecifierToType(NNS);
541534
}
535+
std::vector<const NamedDecl *> HeuristicResolver::lookupDependentName(
536+
CXXRecordDecl *RD, DeclarationName Name,
537+
llvm::function_ref<bool(const NamedDecl *ND)> Filter) {
538+
return HeuristicResolverImpl(Ctx).lookupDependentName(RD, Name, Filter);
539+
}
542540
const QualType HeuristicResolver::getPointeeType(QualType T) const {
543541
return HeuristicResolverImpl(Ctx).getPointeeType(T);
544542
}

clang/test/CodeGen/memtag-globals-asm.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
// CHECK-A: .memtag global_int
5252
// CHECK-A: .globl global_int
5353
// CHECK-A: .p2align 4, 0x0
54+
// CHECK-A: .zero 16
5455
// CHECK-A: .size global_int, 16
5556
int global_int;
5657
// CHECK-B: .memtag _ZL9local_int
@@ -66,25 +67,29 @@ static char local_buffer[16];
6667
// CHECK-D: .p2align 4, 0x0
6768
// CHECK-D: _ZL22local_buffer_local_end:
6869
// CHECK-D: .xword _ZL12local_buffer+16
70+
// CHECK-D: .zero 8
6971
// CHECK-D: .size _ZL22local_buffer_local_end, 16
7072
static char* local_buffer_local_end = &local_buffer[16];
7173
// CHECK-E: .memtag local_buffer_global_end
7274
// CHECK-E: .globl local_buffer_global_end
7375
// CHECK-E .p2align 4, 0x0
7476
// CHECK-E: local_buffer_global_end:
7577
// CHECK-E: .xword _ZL12local_buffer+16
78+
// CHECK-E: .zero 8
7679
// CHECK-E: .size local_buffer_global_end, 16
7780
char* local_buffer_global_end = &local_buffer[16];
7881

7982
// CHECK-F: .memtag global_buffer
8083
// CHECK-F: .globl global_buffer
8184
// CHECK-F: .p2align 4, 0x0
85+
// CHECK-F: .zero 16
8286
// CHECK-F: .size global_buffer, 16
8387
char global_buffer[16];
8488
// CHECK-G: .memtag _ZL23global_buffer_local_end
8589
// CHECK-G: .p2align 4, 0x0
8690
// CHECK-G: _ZL23global_buffer_local_end:
8791
// CHECK-G: .xword global_buffer+16
92+
// CHECK-G: .zero 8
8893
// CHECK-G: .size _ZL23global_buffer_local_end, 16
8994
static char* global_buffer_local_end = &global_buffer[16];
9095
// CHECK-H: .memtag global_buffer_global_end
@@ -104,6 +109,7 @@ class MyClass {
104109
// CHECK-I: .memtag _ZN7MyClass12my_class_intE
105110
// CHECK-I: .globl _ZN7MyClass12my_class_intE
106111
// CHECK-I: .p2align 4, 0x0
112+
// CHECK-I: .zero 16
107113
// CHECK-I: .size _ZN7MyClass12my_class_intE, 16
108114
int MyClass::my_class_int;
109115
// CHECK-NOT: .memtag _ZN7MyClass18my_class_const_intE
@@ -112,23 +118,27 @@ const int MyClass::my_class_const_int = 1;
112118
// CHECK-J: .memtag global_my_class
113119
// CHECK-J: .globl global_my_class
114120
// CHECK-J: .p2align 4, 0x0
121+
// CHECK-J: .zero 8
115122
// CHECK-J: .size global_my_class, 16
116123
MyClass global_my_class;
117124
// CHECK-K: .memtag _ZL14local_my_class
118125
// CHECK-K: .p2align 4, 0x0
126+
// CHECK-K: .zero 8
119127
// CHECK-K: .size _ZL14local_my_class, 16
120128
static MyClass local_my_class;
121129

122130
// CHECK-NOT: .memtag _ZL18local_const_string
123131
static const char local_const_string[] = "this is a local string";
124132
// CHECK-L: .memtag _ZL12local_string
125133
// CHECK-L: .p2align 4, 0x0
134+
// CHECK-L: .zero 9
126135
// CHECK-L: .size _ZL12local_string, 32
127136
static char local_string[] = "this is a local string";
128137

129138
// CHECK-M: .memtag global_atomic_int
130139
// CHECK-M: .globl global_atomic_int
131140
// CHECK-M: .p2align 4, 0x0
141+
// CHECK-M: .zero 16
132142
// CHECK-M: .size global_atomic_int, 16
133143
_Atomic(int) global_atomic_int;
134144
// CHECK-N: .memtag _ZL16local_atomic_int
@@ -144,6 +154,7 @@ union MyUnion {
144154
// CHECK-O: .memtag global_union
145155
// CHECK-O: .globl global_union
146156
// CHECK-O: .p2align 4, 0x0
157+
// CHECK-O: .zero 16
147158
// CHECK-O: .size global_union, 16
148159
MyUnion global_union;
149160
// CHECK-P: .memtag _ZL11local_union

clang/test/Driver/print-supported-extensions-riscv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
// CHECK-NEXT: xqcics 0.2 'Xqcics' (Qualcomm uC Conditional Select Extension)
201201
// CHECK-NEXT: xqcicsr 0.2 'Xqcicsr' (Qualcomm uC CSR Extension)
202202
// CHECK-NEXT: xqciint 0.2 'Xqciint' (Qualcomm uC Interrupts Extension)
203+
// CHECK-NEXT: xqcilia 0.2 'Xqcilia' (Qualcomm uC Large Immediate Arithmetic Extension)
203204
// CHECK-NEXT: xqcilo 0.2 'Xqcilo' (Qualcomm uC Large Offset Load Store Extension)
204205
// CHECK-NEXT: xqcilsm 0.2 'Xqcilsm' (Qualcomm uC Load Store Multiple Extension)
205206
// CHECK-NEXT: xqcisls 0.2 'Xqcisls' (Qualcomm uC Scaled Load Store Extension)

clang/test/SemaHLSL/BuiltIns/and-errors.hlsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %clang_cc1 -finclude-default-header -triple \
2-
// RUN: dxil-pc-shadermodel6.3-library %s \
3-
// RUN: -emit-llvm -O1 -verify
2+
// RUN: dxil-pc-shadermodel6.3-library %s -O1 -verify
43

54
bool test_too_few_arg(bool a) {
65
return __builtin_hlsl_and(a);

flang/docs/Extensions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,14 @@ print *, [(j,j=1,10)]
815815
integer overflow never occurs in address calculations and increment of
816816
do-variable unless the option `-fwrapv` is enabled.
817817

818+
* Two new ieee_round_type values were added in f18 beyond the four values
819+
defined in f03 and f08: ieee_away and ieee_other. Contemporary hardware
820+
typically does not have support for these rounding modes;
821+
ieee_support_rounding calls for these values return false.
822+
ieee_set_rounding_mode calls that attempt to set the rounding mode to one
823+
of these values in violation of the restriction in f23 clause 17.11.42 set
824+
the mode to ieee_nearest.
825+
818826
## De Facto Standard Features
819827

820828
* `EXTENDS_TYPE_OF()` returns `.TRUE.` if both of its arguments have the

flang/include/flang/Optimizer/Builder/FIRBuilder.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
385385
mlir::FunctionType ty,
386386
mlir::SymbolTable *);
387387

388+
/// Returns a named function for a Fortran runtime API, creating
389+
/// it, if it does not exist in the module yet.
390+
/// If \p isIO is set to true, then the function corresponds
391+
/// to one of Fortran runtime IO APIs.
392+
mlir::func::FuncOp createRuntimeFunction(mlir::Location loc,
393+
llvm::StringRef name,
394+
mlir::FunctionType ty,
395+
bool isIO = false);
396+
388397
/// Cast the input value to IndexType.
389398
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val) {
390399
return createConvert(loc, getIndexType(), val);

flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "flang/Optimizer/Builder/FIRBuilder.h"
2222
#include "flang/Optimizer/Dialect/FIRDialect.h"
2323
#include "flang/Optimizer/Dialect/FIRType.h"
24+
#include "flang/Runtime/io-api-consts.h"
2425
#include "flang/Runtime/reduce.h"
2526
#include "flang/Support/Fortran.h"
2627
#include "mlir/IR/BuiltinTypes.h"
@@ -586,6 +587,33 @@ constexpr TypeBuilderFunc getModel<void>() {
586587
};
587588
}
588589

590+
// Define additional runtime type models specific to IO.
591+
template <>
592+
constexpr TypeBuilderFunc getModel<Fortran::runtime::io::IoStatementState *>() {
593+
return getModel<char *>();
594+
}
595+
template <>
596+
constexpr TypeBuilderFunc getModel<Fortran::runtime::io::Iostat>() {
597+
return [](mlir::MLIRContext *context) -> mlir::Type {
598+
return mlir::IntegerType::get(context,
599+
8 * sizeof(Fortran::runtime::io::Iostat));
600+
};
601+
}
602+
template <>
603+
constexpr TypeBuilderFunc
604+
getModel<const Fortran::runtime::io::NamelistGroup &>() {
605+
return [](mlir::MLIRContext *context) -> mlir::Type {
606+
return fir::ReferenceType::get(mlir::TupleType::get(context));
607+
};
608+
}
609+
template <>
610+
constexpr TypeBuilderFunc
611+
getModel<const Fortran::runtime::io::NonTbpDefinedIoTable *>() {
612+
return [](mlir::MLIRContext *context) -> mlir::Type {
613+
return fir::ReferenceType::get(mlir::TupleType::get(context));
614+
};
615+
}
616+
589617
REDUCTION_REF_OPERATION_MODEL(std::int8_t)
590618
REDUCTION_VALUE_OPERATION_MODEL(std::int8_t)
591619
REDUCTION_REF_OPERATION_MODEL(std::int16_t)
@@ -778,16 +806,22 @@ struct RuntimeTableEntry<RuntimeTableKey<KT>, RuntimeIdentifier<Cs...>> {
778806
/// argument is intended to be of the form: <mkRTKey(runtime function name)>.
779807
template <typename RuntimeEntry>
780808
static mlir::func::FuncOp getRuntimeFunc(mlir::Location loc,
781-
fir::FirOpBuilder &builder) {
809+
fir::FirOpBuilder &builder,
810+
bool isIO = false) {
782811
using namespace Fortran::runtime;
783812
auto name = RuntimeEntry::name;
784813
auto func = builder.getNamedFunction(name);
785814
if (func)
786815
return func;
787816
auto funTy = RuntimeEntry::getTypeModel()(builder.getContext());
788-
func = builder.createFunction(loc, name, funTy);
789-
func->setAttr(FIROpsDialect::getFirRuntimeAttrName(), builder.getUnitAttr());
790-
return func;
817+
return builder.createRuntimeFunction(loc, name, funTy, isIO);
818+
}
819+
820+
/// Get (or generate) the MLIR FuncOp for a given IO runtime function.
821+
template <typename E>
822+
static mlir::func::FuncOp getIORuntimeFunc(mlir::Location loc,
823+
fir::FirOpBuilder &builder) {
824+
return getRuntimeFunc<E>(loc, builder, /*isIO=*/true);
791825
}
792826

793827
namespace helper {

0 commit comments

Comments
 (0)