Skip to content

Commit dba0979

Browse files
authored
Merge branch 'main' into makslevental/upstream-smt
2 parents 644cccc + 02fde3a commit dba0979

File tree

49 files changed

+2828
-8188
lines changed

Some content is hidden

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

49 files changed

+2828
-8188
lines changed

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,19 @@ void CGHLSLRuntime::addHLSLBufferLayoutType(const RecordType *StructType,
282282

283283
void CGHLSLRuntime::finishCodeGen() {
284284
auto &TargetOpts = CGM.getTarget().getTargetOpts();
285+
auto &LangOpts = CGM.getLangOpts();
285286
llvm::Module &M = CGM.getModule();
286287
Triple T(M.getTargetTriple());
287288
if (T.getArch() == Triple::ArchType::dxil)
288289
addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
289290

291+
// NativeHalfType corresponds to the -fnative-half-type clang option which is
292+
// aliased by clang-dxc's -enable-16bit-types option. This option is used to
293+
// set the UseNativeLowPrecision DXIL module flag in the DirectX backend
294+
if (LangOpts.NativeHalfType)
295+
M.setModuleFlag(llvm::Module::ModFlagBehavior::Error, "dx.nativelowprec",
296+
1);
297+
290298
generateGlobalCtorDtorCalls();
291299
}
292300

clang/lib/Format/Format.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ class ObjCHeaderStyleGuesser : public TokenAnalyzer {
30783078
for (const FormatToken *FormatTok = Line->First; FormatTok;
30793079
FormatTok = FormatTok->Next) {
30803080
if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
3081-
(FormatTok->Tok.getObjCKeywordID() != tok::objc_not_keyword ||
3081+
(FormatTok->isNot(tok::objc_not_keyword) ||
30823082
FormatTok->isOneOf(tok::numeric_constant, tok::l_square,
30833083
tok::l_brace))) ||
30843084
(FormatTok->Tok.isAnyIdentifier() &&

clang/lib/Format/FormatToken.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ struct FormatToken {
621621
bool MacroParent = false;
622622

623623
bool is(tok::TokenKind Kind) const { return Tok.is(Kind); }
624+
bool is(tok::ObjCKeywordKind Kind) const {
625+
return Tok.getObjCKeywordID() == Kind;
626+
}
624627
bool is(TokenType TT) const { return getType() == TT; }
625628
bool is(const IdentifierInfo *II) const {
626629
return II && II == Tok.getIdentifierInfo();
@@ -678,10 +681,6 @@ struct FormatToken {
678681
return isOneOf(tok::kw___attribute, tok::kw___declspec, TT_AttributeMacro);
679682
}
680683

681-
bool isObjCAtKeyword(tok::ObjCKeywordKind Kind) const {
682-
return Tok.isObjCAtKeyword(Kind);
683-
}
684-
685684
bool isAccessSpecifierKeyword() const {
686685
return isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private);
687686
}
@@ -707,11 +706,8 @@ struct FormatToken {
707706
[[nodiscard]] bool isTypeOrIdentifier(const LangOptions &LangOpts) const;
708707

709708
bool isObjCAccessSpecifier() const {
710-
return is(tok::at) && Next &&
711-
(Next->isObjCAtKeyword(tok::objc_public) ||
712-
Next->isObjCAtKeyword(tok::objc_protected) ||
713-
Next->isObjCAtKeyword(tok::objc_package) ||
714-
Next->isObjCAtKeyword(tok::objc_private));
709+
return Next && Next->isOneOf(tok::objc_public, tok::objc_protected,
710+
tok::objc_package, tok::objc_private);
715711
}
716712

717713
/// Returns whether \p Tok is ([{ or an opening < of a template or in

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ class AnnotatingParser {
330330
if (!Style.isVerilog()) {
331331
if (FormatToken *MaybeSel = OpeningParen.Previous) {
332332
// @selector( starts a selector.
333-
if (MaybeSel->isObjCAtKeyword(tok::objc_selector) &&
334-
MaybeSel->Previous && MaybeSel->Previous->is(tok::at)) {
333+
if (MaybeSel->is(tok::objc_selector) && MaybeSel->Previous &&
334+
MaybeSel->Previous->is(tok::at)) {
335335
StartsObjCMethodExpr = true;
336336
}
337337
}
@@ -4505,7 +4505,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
45054505
if (Left.is(Keywords.kw_assert) && Style.Language == FormatStyle::LK_Java)
45064506
return true;
45074507
if (Style.ObjCSpaceAfterProperty && Line.Type == LT_ObjCProperty &&
4508-
Left.Tok.getObjCKeywordID() == tok::objc_property) {
4508+
Left.is(tok::objc_property)) {
45094509
return true;
45104510
}
45114511
if (Right.is(tok::hashhash))
@@ -4899,7 +4899,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
48994899
}
49004900
return false;
49014901
}
4902-
if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword)
4902+
if (Left.is(tok::at) && Right.isNot(tok::objc_not_keyword))
49034903
return false;
49044904
if (Right.is(TT_UnaryOperator)) {
49054905
return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
@@ -5472,7 +5472,12 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
54725472
// handled.
54735473
if (Left.is(tok::amp) && Right.is(tok::r_square))
54745474
return Style.SpacesInSquareBrackets;
5475-
return Style.SpaceAfterLogicalNot && Left.is(tok::exclaim);
5475+
if (Left.isNot(tok::exclaim))
5476+
return false;
5477+
if (Left.TokenText == "!")
5478+
return Style.SpaceAfterLogicalNot;
5479+
assert(Left.TokenText == "not");
5480+
return Right.isOneOf(tok::coloncolon, TT_UnaryOperator);
54765481
}
54775482

54785483
// If the next token is a binary operator or a selector name, we have
@@ -6220,9 +6225,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
62206225
if (Right.is(TT_TemplateCloser))
62216226
return Style.BreakBeforeTemplateCloser;
62226227

6223-
if (Left.is(tok::at))
6224-
return false;
6225-
if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
6228+
if (Left.isOneOf(tok::at, tok::objc_interface))
62266229
return false;
62276230
if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation))
62286231
return Right.isNot(tok::l_paren);

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,10 @@ class LineJoiner {
468468
switch (PreviousLine->First->Tok.getKind()) {
469469
case tok::at:
470470
// Don't merge block with left brace wrapped after ObjC special blocks.
471-
if (PreviousLine->First->Next) {
472-
tok::ObjCKeywordKind kwId =
473-
PreviousLine->First->Next->Tok.getObjCKeywordID();
474-
if (kwId == tok::objc_autoreleasepool ||
475-
kwId == tok::objc_synchronized) {
476-
return 0;
477-
}
471+
if (PreviousLine->First->Next &&
472+
PreviousLine->First->Next->isOneOf(tok::objc_autoreleasepool,
473+
tok::objc_synchronized)) {
474+
return 0;
478475
}
479476
break;
480477

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,12 +1719,13 @@ void UnwrappedLineParser::parseStructuralElement(
17191719
nextToken();
17201720
parseBracedList();
17211721
break;
1722-
} else if (Style.Language == FormatStyle::LK_Java &&
1723-
FormatTok->is(Keywords.kw_interface)) {
1722+
}
1723+
if (Style.Language == FormatStyle::LK_Java &&
1724+
FormatTok->is(Keywords.kw_interface)) {
17241725
nextToken();
17251726
break;
17261727
}
1727-
switch (FormatTok->Tok.getObjCKeywordID()) {
1728+
switch (bool IsAutoRelease = false; FormatTok->Tok.getObjCKeywordID()) {
17281729
case tok::objc_public:
17291730
case tok::objc_protected:
17301731
case tok::objc_package:
@@ -1745,19 +1746,11 @@ void UnwrappedLineParser::parseStructuralElement(
17451746
addUnwrappedLine();
17461747
return;
17471748
case tok::objc_autoreleasepool:
1748-
nextToken();
1749-
if (FormatTok->is(tok::l_brace)) {
1750-
if (Style.BraceWrapping.AfterControlStatement ==
1751-
FormatStyle::BWACS_Always) {
1752-
addUnwrappedLine();
1753-
}
1754-
parseBlock();
1755-
}
1756-
addUnwrappedLine();
1757-
return;
1749+
IsAutoRelease = true;
1750+
[[fallthrough]];
17581751
case tok::objc_synchronized:
17591752
nextToken();
1760-
if (FormatTok->is(tok::l_paren)) {
1753+
if (!IsAutoRelease && FormatTok->is(tok::l_paren)) {
17611754
// Skip synchronization object
17621755
parseParens();
17631756
}
@@ -3086,11 +3079,10 @@ void UnwrappedLineParser::parseTryCatch() {
30863079
if (FormatTok->is(tok::at))
30873080
nextToken();
30883081
if (!(FormatTok->isOneOf(tok::kw_catch, Keywords.kw___except,
3089-
tok::kw___finally) ||
3082+
tok::kw___finally, tok::objc_catch,
3083+
tok::objc_finally) ||
30903084
((Style.Language == FormatStyle::LK_Java || Style.isJavaScript()) &&
3091-
FormatTok->is(Keywords.kw_finally)) ||
3092-
(FormatTok->isObjCAtKeyword(tok::objc_catch) ||
3093-
FormatTok->isObjCAtKeyword(tok::objc_finally)))) {
3085+
FormatTok->is(Keywords.kw_finally)))) {
30943086
break;
30953087
}
30963088
nextToken();
@@ -4162,17 +4154,15 @@ void UnwrappedLineParser::parseObjCProtocolList() {
41624154
do {
41634155
nextToken();
41644156
// Early exit in case someone forgot a close angle.
4165-
if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
4166-
FormatTok->isObjCAtKeyword(tok::objc_end)) {
4157+
if (FormatTok->isOneOf(tok::semi, tok::l_brace, tok::objc_end))
41674158
return;
4168-
}
41694159
} while (!eof() && FormatTok->isNot(tok::greater));
41704160
nextToken(); // Skip '>'.
41714161
}
41724162

41734163
void UnwrappedLineParser::parseObjCUntilAtEnd() {
41744164
do {
4175-
if (FormatTok->isObjCAtKeyword(tok::objc_end)) {
4165+
if (FormatTok->is(tok::objc_end)) {
41764166
nextToken();
41774167
addUnwrappedLine();
41784168
break;
@@ -4195,8 +4185,7 @@ void UnwrappedLineParser::parseObjCUntilAtEnd() {
41954185
}
41964186

41974187
void UnwrappedLineParser::parseObjCInterfaceOrImplementation() {
4198-
assert(FormatTok->Tok.getObjCKeywordID() == tok::objc_interface ||
4199-
FormatTok->Tok.getObjCKeywordID() == tok::objc_implementation);
4188+
assert(FormatTok->isOneOf(tok::objc_interface, tok::objc_implementation));
42004189
nextToken();
42014190
nextToken(); // interface name
42024191

@@ -4244,10 +4233,8 @@ void UnwrappedLineParser::parseObjCLightweightGenerics() {
42444233
do {
42454234
nextToken();
42464235
// Early exit in case someone forgot a close angle.
4247-
if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
4248-
FormatTok->isObjCAtKeyword(tok::objc_end)) {
4236+
if (FormatTok->isOneOf(tok::semi, tok::l_brace, tok::objc_end))
42494237
break;
4250-
}
42514238
if (FormatTok->is(tok::less)) {
42524239
++NumOpenAngles;
42534240
} else if (FormatTok->is(tok::greater)) {
@@ -4261,7 +4248,7 @@ void UnwrappedLineParser::parseObjCLightweightGenerics() {
42614248
// Returns true for the declaration/definition form of @protocol,
42624249
// false for the expression form.
42634250
bool UnwrappedLineParser::parseObjCProtocol() {
4264-
assert(FormatTok->Tok.getObjCKeywordID() == tok::objc_protocol);
4251+
assert(FormatTok->is(tok::objc_protocol));
42654252
nextToken();
42664253

42674254
if (FormatTok->is(tok::l_paren)) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_dxc -enable-16bit-types -T lib_6_3 -HV 202x -Vd -Xclang -emit-llvm %s | FileCheck %s --check-prefix=FLAG
2+
// RUN: %clang_dxc -T lib_6_3 -HV 202x -Vd -Xclang -emit-llvm %s | FileCheck %s --check-prefix=NOFLAG
3+
4+
// FLAG-DAG: ![[NLP:.*]] = !{i32 1, !"dx.nativelowprec", i32 1}
5+
// FLAG-DAG: !llvm.module.flags = !{{{.*}}![[NLP]]{{.*}}}
6+
7+
// NOFLAG-NOT: dx.nativelowprec

clang/unittests/Format/FormatTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25393,16 +25393,17 @@ TEST_F(FormatTest, AlternativeOperators) {
2539325393
verifyFormat("%:define ABC abc"); // #define ABC abc
2539425394
verifyFormat("%:%:"); // ##
2539525395

25396+
verifyFormat("return not ::f();");
25397+
verifyFormat("return not *foo;");
25398+
2539625399
verifyFormat("a = v(not;);\n"
25397-
"b = v(not+);\n"
2539825400
"c = v(not x);\n"
2539925401
"d = v(not 1);\n"
2540025402
"e = v(not 123.f);");
2540125403

2540225404
verifyNoChange("#define ASSEMBLER_INSTRUCTION_LIST(V) \\\n"
2540325405
" V(and) \\\n"
2540425406
" V(not) \\\n"
25405-
" V(not!) \\\n"
2540625407
" V(other)",
2540725408
getLLVMStyleWithColumns(40));
2540825409
}

flang-rt/lib/cuda/allocator.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "flang/Runtime/CUDA/allocator.h"
1010
#include "flang-rt/runtime/allocator-registry.h"
1111
#include "flang-rt/runtime/derived.h"
12+
#include "flang-rt/runtime/descriptor.h"
1213
#include "flang-rt/runtime/environment.h"
1314
#include "flang-rt/runtime/stat.h"
1415
#include "flang-rt/runtime/terminator.h"
@@ -43,14 +44,18 @@ void *CUFAllocPinned(
4344

4445
void CUFFreePinned(void *p) { CUDA_REPORT_IF_ERROR(cudaFreeHost(p)); }
4546

46-
void *CUFAllocDevice(
47-
std::size_t sizeInBytes, [[maybe_unused]] std::int64_t asyncId) {
47+
void *CUFAllocDevice(std::size_t sizeInBytes, std::int64_t asyncId) {
4848
void *p;
4949
if (Fortran::runtime::executionEnvironment.cudaDeviceIsManaged) {
5050
CUDA_REPORT_IF_ERROR(
5151
cudaMallocManaged((void **)&p, sizeInBytes, cudaMemAttachGlobal));
5252
} else {
53-
CUDA_REPORT_IF_ERROR(cudaMalloc(&p, sizeInBytes));
53+
if (asyncId == kNoAsyncId) {
54+
CUDA_REPORT_IF_ERROR(cudaMalloc(&p, sizeInBytes));
55+
} else {
56+
CUDA_REPORT_IF_ERROR(
57+
cudaMallocAsync(&p, sizeInBytes, (cudaStream_t)asyncId));
58+
}
5459
}
5560
return p;
5661
}

llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ class CombinerHelper {
261261
void applyCombineShuffleConcat(MachineInstr &MI,
262262
SmallVector<Register> &Ops) const;
263263

264+
/// Replace \p MI with a build_vector.
265+
bool matchCombineShuffleToBuildVector(MachineInstr &MI) const;
266+
void applyCombineShuffleToBuildVector(MachineInstr &MI) const;
267+
264268
/// Try to combine G_SHUFFLE_VECTOR into G_CONCAT_VECTORS.
265269
/// Returns true if MI changed.
266270
///

0 commit comments

Comments
 (0)