Skip to content

Commit 8b2ac55

Browse files
authored
Merge branch 'main' into users/el-ev/cleanup-c-fn-noproto
2 parents dbe66e5 + 9c4c242 commit 8b2ac55

File tree

66 files changed

+2323
-1749
lines changed

Some content is hidden

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

66 files changed

+2323
-1749
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ describes how to get involved, raise issues and submit patches.
99

1010
## Getting in touch
1111

12-
Join the [LLVM Discourse forums](https://discourse.llvm.org/), [Discord
13-
chat](https://discord.gg/xS7Z362), or #llvm IRC channel on
14-
[OFTC](https://oftc.net/).
12+
Join the [LLVM Discourse forums](https://discourse.llvm.org/) or [Discord
13+
chat](https://discord.gg/xS7Z362).
1514

1615
The LLVM project has adopted a [code of conduct](https://llvm.org/docs/CodeOfConduct.html) for
1716
participants to all modes of communication within the project.

bolt/Maintainers.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ what goes in or not.
55

66
The list is sorted by surname and formatted to allow easy grepping and
77
beautification by scripts. The fields are: name (N), email (E), web-address
8-
(W), PGP key ID and fingerprint (P), description (D), snail-mail address
9-
(S) and (I) IRC handle. Each entry should contain at least the (N), (E) and
10-
(D) fields.
8+
(W), PGP key ID and fingerprint (P), and description (D). Each entry should
9+
contain at least the (N), (E) and (D) fields.
1110

1211
N: Maksim Panchenko, Rafael Auler
1312

clang-tools-extra/Maintainers.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ assistance.
1515
Lead Maintainer
1616
---------------
1717
| Aaron Ballman
18-
| [email protected] (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
18+
| [email protected] (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord)
1919

2020

2121
clang-tidy
@@ -33,7 +33,7 @@ clang-tidy
3333
clang-query
3434
-----------
3535
| Aaron Ballman
36-
| [email protected] (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
36+
| [email protected] (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord)
3737

3838

3939
clang-doc

clang/Maintainers.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ assistance.
2020
Lead Maintainer
2121
---------------
2222
| Aaron Ballman
23-
| aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
23+
| aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord)
2424
2525

2626
Contained Components
@@ -31,7 +31,7 @@ Clang that are typically contained to one area of the compiler.
3131
AST matchers
3232
~~~~~~~~~~~~
3333
| Aaron Ballman
34-
| aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
34+
| aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord)
3535
3636

3737
AST Visitors
@@ -300,7 +300,7 @@ standard, when fixing standards bugs, or when implementing a new standard featur
300300
C conformance
301301
~~~~~~~~~~~~~
302302
| Aaron Ballman
303-
| aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
303+
| aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord)
304304
305305

306306
C++ conformance

clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ PUNCTUATOR(minus, '-')
7575
// RootElement Keywords:
7676
KEYWORD(RootSignature) // used only for diagnostic messaging
7777
KEYWORD(DescriptorTable)
78+
KEYWORD(RootConstants)
79+
80+
// RootConstants Keywords:
81+
KEYWORD(num32BitConstants)
7882

7983
// DescriptorTable Keywords:
8084
KEYWORD(CBV)

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class RootSignatureParser {
7171
// expected, or, there is a lexing error
7272

7373
/// Root Element parse methods:
74+
std::optional<llvm::hlsl::rootsig::RootConstants> parseRootConstants();
7475
std::optional<llvm::hlsl::rootsig::DescriptorTable> parseDescriptorTable();
7576
std::optional<llvm::hlsl::rootsig::DescriptorTableClause>
7677
parseDescriptorTableClause();

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ RootSignatureParser::RootSignatureParser(SmallVector<RootElement> &Elements,
2727
bool RootSignatureParser::parse() {
2828
// Iterate as many RootElements as possible
2929
do {
30+
if (tryConsumeExpectedToken(TokenKind::kw_RootConstants)) {
31+
auto Constants = parseRootConstants();
32+
if (!Constants.has_value())
33+
return true;
34+
Elements.push_back(*Constants);
35+
}
36+
3037
if (tryConsumeExpectedToken(TokenKind::kw_DescriptorTable)) {
3138
auto Table = parseDescriptorTable();
3239
if (!Table.has_value())
@@ -35,12 +42,27 @@ bool RootSignatureParser::parse() {
3542
}
3643
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
3744

38-
if (consumeExpectedToken(TokenKind::end_of_stream,
45+
return consumeExpectedToken(TokenKind::end_of_stream,
46+
diag::err_hlsl_unexpected_end_of_params,
47+
/*param of=*/TokenKind::kw_RootSignature);
48+
}
49+
50+
std::optional<RootConstants> RootSignatureParser::parseRootConstants() {
51+
assert(CurToken.TokKind == TokenKind::kw_RootConstants &&
52+
"Expects to only be invoked starting at given keyword");
53+
54+
if (consumeExpectedToken(TokenKind::pu_l_paren, diag::err_expected_after,
55+
CurToken.TokKind))
56+
return std::nullopt;
57+
58+
RootConstants Constants;
59+
60+
if (consumeExpectedToken(TokenKind::pu_r_paren,
3961
diag::err_hlsl_unexpected_end_of_params,
40-
/*param of=*/TokenKind::kw_RootSignature))
41-
return true;
62+
/*param of=*/TokenKind::kw_RootConstants))
63+
return std::nullopt;
4264

43-
return false;
65+
return Constants;
4466
}
4567

4668
std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {

clang/unittests/Lex/LexHLSLRootSignatureTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ TEST_F(LexHLSLRootSignatureTest, ValidLexAllTokensTest) {
128128
129129
RootSignature
130130
131-
DescriptorTable
131+
DescriptorTable RootConstants
132+
133+
num32BitConstants
132134
133135
CBV SRV UAV Sampler
134136
space visibility flags

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,32 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
252252
ASSERT_TRUE(Consumer->isSatisfied());
253253
}
254254

255+
TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
256+
const llvm::StringLiteral Source = R"cc(
257+
RootConstants()
258+
)cc";
259+
260+
TrivialModuleLoader ModLoader;
261+
auto PP = createPP(Source, ModLoader);
262+
auto TokLoc = SourceLocation();
263+
264+
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
265+
SmallVector<RootElement> Elements;
266+
hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
267+
268+
// Test no diagnostics produced
269+
Consumer->setNoDiag();
270+
271+
ASSERT_FALSE(Parser.parse());
272+
273+
ASSERT_EQ(Elements.size(), 1u);
274+
275+
RootElement Elem = Elements[0];
276+
ASSERT_TRUE(std::holds_alternative<RootConstants>(Elem));
277+
278+
ASSERT_TRUE(Consumer->isSatisfied());
279+
}
280+
255281
TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
256282
// This test will checks we can handling trailing commas ','
257283
const llvm::StringLiteral Source = R"cc(

clang/www/menu.html.incl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<a href="https://discourse.llvm.org/c/clang">Clang Forum</a>
3737
<a href="http://lists.llvm.org/mailman/listinfo/cfe-commits">cfe-commits List</a>
3838
<a href="https://github.com/llvm/llvm-project/issues">Bug Reports</a>
39-
<a href="irc://irc.oftc.net/llvm">IRC: irc.oftc.net#llvm</a>
39+
<a href="https://discord.gg/2kQU7PCuys">Discord</a>
4040
</div>
4141

4242
<div class="submenu">

flang-rt/CODE_OWNERS.TXT

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ what goes in or not.
55

66
The list is sorted by surname and formatted to allow easy grepping and
77
beautification by scripts. The fields are: name (N), email (E), web-address
8-
(W), PGP key ID and fingerprint (P), description (D), snail-mail address
9-
(S) and (I) IRC handle. Each entry should contain at least the (N), (E) and
10-
(D) fields.
8+
(W), PGP key ID and fingerprint (P), and description (D). Each entry should
9+
contain at least the (N), (E) and (D) fields.
1110

1211
N: Steve Scalpone
1312

flang/docs/OpenMPSupport.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Note : No distinction is made between the support in Parser/Semantics, MLIR, Low
4848
| distribute simd construct | P | dist_schedule and linear clauses are not supported |
4949
| distribute parallel loop construct | P | dist_schedule clause not supported |
5050
| distribute parallel loop simd construct | P | dist_schedule and linear clauses are not supported |
51-
| depend clause | P | depend clause with array sections are not supported |
51+
| depend clause | Y | |
5252
| declare reduction construct | N | |
5353
| atomic construct extensions | Y | |
5454
| cancel construct | Y | |

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

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "flang/Support/Fortran.h"
2727
#include "mlir/IR/BuiltinTypes.h"
2828
#include "mlir/IR/MLIRContext.h"
29+
#include "llvm/ADT/STLExtras.h"
2930
#include "llvm/ADT/SmallVector.h"
3031
#include <cstdint>
3132
#include <functional>
@@ -824,33 +825,23 @@ static mlir::func::FuncOp getIORuntimeFunc(mlir::Location loc,
824825
return getRuntimeFunc<E>(loc, builder, /*isIO=*/true);
825826
}
826827

827-
namespace helper {
828-
template <int N, typename A>
829-
void createArguments(llvm::SmallVectorImpl<mlir::Value> &result,
830-
fir::FirOpBuilder &builder, mlir::Location loc,
831-
mlir::FunctionType fTy, A arg) {
832-
result.emplace_back(
833-
builder.createConvertWithVolatileCast(loc, fTy.getInput(N), arg));
834-
}
835-
836-
template <int N, typename A, typename... As>
837-
void createArguments(llvm::SmallVectorImpl<mlir::Value> &result,
838-
fir::FirOpBuilder &builder, mlir::Location loc,
839-
mlir::FunctionType fTy, A arg, As... args) {
840-
result.emplace_back(
841-
builder.createConvertWithVolatileCast(loc, fTy.getInput(N), arg));
842-
createArguments<N + 1>(result, builder, loc, fTy, args...);
828+
inline llvm::SmallVector<mlir::Value>
829+
createArguments(fir::FirOpBuilder &builder, mlir::Location loc,
830+
mlir::FunctionType fTy, llvm::ArrayRef<mlir::Value> args) {
831+
return llvm::map_to_vector(llvm::zip_equal(fTy.getInputs(), args),
832+
[&](const auto &pair) -> mlir::Value {
833+
auto [type, argument] = pair;
834+
return builder.createConvertWithVolatileCast(
835+
loc, type, argument);
836+
});
843837
}
844-
} // namespace helper
845838

846839
/// Create a SmallVector of arguments for a runtime call.
847840
template <typename... As>
848841
llvm::SmallVector<mlir::Value>
849842
createArguments(fir::FirOpBuilder &builder, mlir::Location loc,
850843
mlir::FunctionType fTy, As... args) {
851-
llvm::SmallVector<mlir::Value> result;
852-
helper::createArguments<0>(result, builder, loc, fTy, args...);
853-
return result;
844+
return createArguments(builder, loc, fTy, {args...});
854845
}
855846

856847
} // namespace fir::runtime

flang/lib/Lower/Allocatable.cpp

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,10 @@ static void genRuntimeSetBounds(fir::FirOpBuilder &builder, mlir::Location loc,
138138
builder)
139139
: fir::runtime::getRuntimeFunc<mkRTKey(AllocatableSetBounds)>(
140140
loc, builder);
141-
llvm::SmallVector<mlir::Value> args{box.getAddr(), dimIndex, lowerBound,
142-
upperBound};
143-
llvm::SmallVector<mlir::Value> operands;
144-
for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs()))
145-
operands.emplace_back(builder.createConvert(loc, snd, fst));
146-
builder.create<fir::CallOp>(loc, callee, operands);
141+
const auto args = fir::runtime::createArguments(
142+
builder, loc, callee.getFunctionType(), box.getAddr(), dimIndex,
143+
lowerBound, upperBound);
144+
builder.create<fir::CallOp>(loc, callee, args);
147145
}
148146

149147
/// Generate runtime call to set the lengths of a character allocatable or
@@ -162,9 +160,7 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
162160
if (inputTypes.size() != 5)
163161
fir::emitFatalError(
164162
loc, "AllocatableInitCharacter runtime interface not as expected");
165-
llvm::SmallVector<mlir::Value> args;
166-
args.push_back(builder.createConvert(loc, inputTypes[0], box.getAddr()));
167-
args.push_back(builder.createConvert(loc, inputTypes[1], len));
163+
llvm::SmallVector<mlir::Value> args = {box.getAddr(), len};
168164
if (kind == 0)
169165
kind = mlir::cast<fir::CharacterType>(box.getEleTy()).getFKind();
170166
args.push_back(builder.createIntegerConstant(loc, inputTypes[2], kind));
@@ -173,7 +169,9 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
173169
// TODO: coarrays
174170
int corank = 0;
175171
args.push_back(builder.createIntegerConstant(loc, inputTypes[4], corank));
176-
builder.create<fir::CallOp>(loc, callee, args);
172+
const auto convertedArgs = fir::runtime::createArguments(
173+
builder, loc, callee.getFunctionType(), args);
174+
builder.create<fir::CallOp>(loc, callee, convertedArgs);
177175
}
178176

179177
/// Generate a sequence of runtime calls to allocate memory.
@@ -194,10 +192,9 @@ static mlir::Value genRuntimeAllocate(fir::FirOpBuilder &builder,
194192
args.push_back(errorManager.errMsgAddr);
195193
args.push_back(errorManager.sourceFile);
196194
args.push_back(errorManager.sourceLine);
197-
llvm::SmallVector<mlir::Value> operands;
198-
for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs()))
199-
operands.emplace_back(builder.createConvert(loc, snd, fst));
200-
return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
195+
const auto convertedArgs = fir::runtime::createArguments(
196+
builder, loc, callee.getFunctionType(), args);
197+
return builder.create<fir::CallOp>(loc, callee, convertedArgs).getResult(0);
201198
}
202199

203200
/// Generate a sequence of runtime calls to allocate memory and assign with the
@@ -213,14 +210,11 @@ static mlir::Value genRuntimeAllocateSource(fir::FirOpBuilder &builder,
213210
loc, builder)
214211
: fir::runtime::getRuntimeFunc<mkRTKey(AllocatableAllocateSource)>(
215212
loc, builder);
216-
llvm::SmallVector<mlir::Value> args{
217-
box.getAddr(), fir::getBase(source),
218-
errorManager.hasStat, errorManager.errMsgAddr,
219-
errorManager.sourceFile, errorManager.sourceLine};
220-
llvm::SmallVector<mlir::Value> operands;
221-
for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs()))
222-
operands.emplace_back(builder.createConvert(loc, snd, fst));
223-
return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
213+
const auto args = fir::runtime::createArguments(
214+
builder, loc, callee.getFunctionType(), box.getAddr(),
215+
fir::getBase(source), errorManager.hasStat, errorManager.errMsgAddr,
216+
errorManager.sourceFile, errorManager.sourceLine);
217+
return builder.create<fir::CallOp>(loc, callee, args).getResult(0);
224218
}
225219

226220
/// Generate runtime call to apply mold to the descriptor.
@@ -234,14 +228,12 @@ static void genRuntimeAllocateApplyMold(fir::FirOpBuilder &builder,
234228
builder)
235229
: fir::runtime::getRuntimeFunc<mkRTKey(AllocatableApplyMold)>(
236230
loc, builder);
237-
llvm::SmallVector<mlir::Value> args{
231+
const auto args = fir::runtime::createArguments(
232+
builder, loc, callee.getFunctionType(),
238233
fir::factory::getMutableIRBox(builder, loc, box), fir::getBase(mold),
239234
builder.createIntegerConstant(
240-
loc, callee.getFunctionType().getInputs()[2], rank)};
241-
llvm::SmallVector<mlir::Value> operands;
242-
for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs()))
243-
operands.emplace_back(builder.createConvert(loc, snd, fst));
244-
builder.create<fir::CallOp>(loc, callee, operands);
235+
loc, callee.getFunctionType().getInputs()[2], rank));
236+
builder.create<fir::CallOp>(loc, callee, args);
245237
}
246238

247239
/// Generate a runtime call to deallocate memory.
@@ -669,15 +661,13 @@ class AllocateStmtHelper {
669661

670662
llvm::ArrayRef<mlir::Type> inputTypes =
671663
callee.getFunctionType().getInputs();
672-
llvm::SmallVector<mlir::Value> args;
673-
args.push_back(builder.createConvert(loc, inputTypes[0], box.getAddr()));
674-
args.push_back(builder.createConvert(loc, inputTypes[1], typeDescAddr));
675664
mlir::Value rankValue =
676665
builder.createIntegerConstant(loc, inputTypes[2], rank);
677666
mlir::Value corankValue =
678667
builder.createIntegerConstant(loc, inputTypes[3], corank);
679-
args.push_back(rankValue);
680-
args.push_back(corankValue);
668+
const auto args = fir::runtime::createArguments(
669+
builder, loc, callee.getFunctionType(), box.getAddr(), typeDescAddr,
670+
rankValue, corankValue);
681671
builder.create<fir::CallOp>(loc, callee, args);
682672
}
683673

@@ -696,8 +686,6 @@ class AllocateStmtHelper {
696686

697687
llvm::ArrayRef<mlir::Type> inputTypes =
698688
callee.getFunctionType().getInputs();
699-
llvm::SmallVector<mlir::Value> args;
700-
args.push_back(builder.createConvert(loc, inputTypes[0], box.getAddr()));
701689
mlir::Value categoryValue = builder.createIntegerConstant(
702690
loc, inputTypes[1], static_cast<int32_t>(category));
703691
mlir::Value kindValue =
@@ -706,10 +694,9 @@ class AllocateStmtHelper {
706694
builder.createIntegerConstant(loc, inputTypes[3], rank);
707695
mlir::Value corankValue =
708696
builder.createIntegerConstant(loc, inputTypes[4], corank);
709-
args.push_back(categoryValue);
710-
args.push_back(kindValue);
711-
args.push_back(rankValue);
712-
args.push_back(corankValue);
697+
const auto args = fir::runtime::createArguments(
698+
builder, loc, callee.getFunctionType(), box.getAddr(), categoryValue,
699+
kindValue, rankValue, corankValue);
713700
builder.create<fir::CallOp>(loc, callee, args);
714701
}
715702

0 commit comments

Comments
 (0)