Skip to content

Commit 544233f

Browse files
authored
merge main into amd-staging (llvm#1613)
2 parents 97bab12 + bd441cb commit 544233f

File tree

110 files changed

+8141
-5908
lines changed

Some content is hidden

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

110 files changed

+8141
-5908
lines changed

clang-tools-extra/clang-doc/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
33
BitstreamReader
44
FrontendOpenMP
55
)
6+
add_subdirectory(support)
67

78
add_clang_library(clangDoc STATIC
89
BitcodeReader.cpp
@@ -23,6 +24,7 @@ add_clang_library(clangDoc STATIC
2324

2425
clang_target_link_libraries(clangDoc
2526
PRIVATE
27+
clangDocSupport
2628
clangAnalysis
2729
clangAST
2830
clangASTMatchers
@@ -34,4 +36,9 @@ clang_target_link_libraries(clangDoc
3436
clangToolingCore
3537
)
3638

39+
target_link_libraries(clangDoc
40+
PRIVATE
41+
clangDocSupport
42+
)
43+
3744
add_subdirectory(tool)

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "Generators.h"
1010
#include "Representation.h"
11+
#include "support/File.h"
1112
#include "clang/Basic/Version.h"
1213
#include "llvm/ADT/StringExtras.h"
1314
#include "llvm/ADT/StringRef.h"
@@ -251,47 +252,6 @@ static void appendVector(std::vector<Derived> &&New,
251252
std::move(New.begin(), New.end(), std::back_inserter(Original));
252253
}
253254

254-
// Compute the relative path from an Origin directory to a Destination directory
255-
static SmallString<128> computeRelativePath(StringRef Destination,
256-
StringRef Origin) {
257-
// If Origin is empty, the relative path to the Destination is its complete
258-
// path.
259-
if (Origin.empty())
260-
return Destination;
261-
262-
// The relative path is an empty path if both directories are the same.
263-
if (Destination == Origin)
264-
return {};
265-
266-
// These iterators iterate through each of their parent directories
267-
llvm::sys::path::const_iterator FileI = llvm::sys::path::begin(Destination);
268-
llvm::sys::path::const_iterator FileE = llvm::sys::path::end(Destination);
269-
llvm::sys::path::const_iterator DirI = llvm::sys::path::begin(Origin);
270-
llvm::sys::path::const_iterator DirE = llvm::sys::path::end(Origin);
271-
// Advance both iterators until the paths differ. Example:
272-
// Destination = A/B/C/D
273-
// Origin = A/B/E/F
274-
// FileI will point to C and DirI to E. The directories behind them is the
275-
// directory they share (A/B).
276-
while (FileI != FileE && DirI != DirE && *FileI == *DirI) {
277-
++FileI;
278-
++DirI;
279-
}
280-
SmallString<128> Result; // This will hold the resulting path.
281-
// Result has to go up one directory for each of the remaining directories in
282-
// Origin
283-
while (DirI != DirE) {
284-
llvm::sys::path::append(Result, "..");
285-
++DirI;
286-
}
287-
// Result has to append each of the remaining directories in Destination
288-
while (FileI != FileE) {
289-
llvm::sys::path::append(Result, *FileI);
290-
++FileI;
291-
}
292-
return Result;
293-
}
294-
295255
// HTML generation
296256

297257
static std::vector<std::unique_ptr<TagNode>>
@@ -1138,23 +1098,6 @@ static llvm::Error genIndex(const ClangDocContext &CDCtx) {
11381098
return llvm::Error::success();
11391099
}
11401100

1141-
static llvm::Error copyFile(StringRef FilePath, StringRef OutDirectory) {
1142-
llvm::SmallString<128> PathWrite;
1143-
llvm::sys::path::native(OutDirectory, PathWrite);
1144-
llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
1145-
llvm::SmallString<128> PathRead;
1146-
llvm::sys::path::native(FilePath, PathRead);
1147-
std::error_code OK;
1148-
std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
1149-
if (FileErr != OK) {
1150-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
1151-
"error creating file " +
1152-
llvm::sys::path::filename(FilePath) +
1153-
": " + FileErr.message() + "\n");
1154-
}
1155-
return llvm::Error::success();
1156-
}
1157-
11581101
llvm::Error HTMLGenerator::createResources(ClangDocContext &CDCtx) {
11591102
auto Err = serializeIndex(CDCtx);
11601103
if (Err)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# clang-doc/support contains support libraries that do not depend
2+
# on clang either programmatically or conceptually.
3+
set(LLVM_LINK_COMPONENTS
4+
Support
5+
)
6+
7+
add_clang_library(clangDocSupport STATIC
8+
File.cpp
9+
)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#include "File.h"
9+
#include "llvm/Support/FileSystem.h"
10+
#include "llvm/Support/Path.h"
11+
12+
namespace clang {
13+
namespace doc {
14+
15+
llvm::Error copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory) {
16+
llvm::SmallString<128> PathWrite;
17+
llvm::sys::path::native(OutDirectory, PathWrite);
18+
llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
19+
llvm::SmallString<128> PathRead;
20+
llvm::sys::path::native(FilePath, PathRead);
21+
std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
22+
if (FileErr) {
23+
return llvm::createStringError(llvm::inconvertibleErrorCode(),
24+
"error creating file " +
25+
llvm::sys::path::filename(FilePath) +
26+
": " + FileErr.message() + "\n");
27+
}
28+
return llvm::Error::success();
29+
}
30+
31+
llvm::SmallString<128> computeRelativePath(llvm::StringRef Destination,
32+
llvm::StringRef Origin) {
33+
// If Origin is empty, the relative path to the Destination is its complete
34+
// path.
35+
if (Origin.empty())
36+
return Destination;
37+
38+
// The relative path is an empty path if both directories are the same.
39+
if (Destination == Origin)
40+
return {};
41+
42+
// These iterators iterate through each of their parent directories
43+
llvm::sys::path::const_iterator FileI = llvm::sys::path::begin(Destination);
44+
llvm::sys::path::const_iterator FileE = llvm::sys::path::end(Destination);
45+
llvm::sys::path::const_iterator DirI = llvm::sys::path::begin(Origin);
46+
llvm::sys::path::const_iterator DirE = llvm::sys::path::end(Origin);
47+
// Advance both iterators until the paths differ. Example:
48+
// Destination = A/B/C/D
49+
// Origin = A/B/E/F
50+
// FileI will point to C and DirI to E. The directories behind them is the
51+
// directory they share (A/B).
52+
while (FileI != FileE && DirI != DirE && *FileI == *DirI) {
53+
++FileI;
54+
++DirI;
55+
}
56+
llvm::SmallString<128> Result; // This will hold the resulting path.
57+
// Result has to go up one directory for each of the remaining directories in
58+
// Origin
59+
while (DirI != DirE) {
60+
llvm::sys::path::append(Result, "..");
61+
++DirI;
62+
}
63+
// Result has to append each of the remaining directories in Destination
64+
while (FileI != FileE) {
65+
llvm::sys::path::append(Result, *FileI);
66+
++FileI;
67+
}
68+
return Result;
69+
}
70+
71+
} // namespace doc
72+
} // namespace clang
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_FILE_H
9+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_FILE_H
10+
11+
#include "llvm/ADT/StringExtras.h"
12+
#include "llvm/Support/Error.h"
13+
14+
namespace clang {
15+
namespace doc {
16+
17+
llvm::Error copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory);
18+
19+
llvm::SmallString<128> computeRelativePath(llvm::StringRef Destination,
20+
llvm::StringRef Origin);
21+
22+
} // namespace doc
23+
} // namespace clang
24+
25+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_FILE_H

clang/docs/ReleaseNotes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ C23 Feature Support
162162
- Fixed a bug where you could not cast a null pointer constant to type
163163
``nullptr_t``. Fixes #GH133644.
164164

165+
C11 Feature Support
166+
^^^^^^^^^^^^^^^^^^^
167+
- Implemented `WG14 N1285 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1285.htm>`_
168+
which introduces the notion of objects with a temporary lifetime. When an
169+
expression resulting in an rvalue with structure or union type and that type
170+
contains a member of array type, the expression result is an automatic storage
171+
duration object with temporary lifetime which begins when the expression is
172+
evaluated and ends at the evaluation of the containing full expression. This
173+
functionality is also implemented for earlier C language modes because the
174+
C99 semantics will never be implemented (it would require dynamic allocations
175+
of memory which leaks, which users would not appreciate).
176+
165177
Non-comprehensive list of changes in this release
166178
-------------------------------------------------
167179

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
201201
return create<cir::PtrStrideOp>(loc, base.getType(), base, stride);
202202
}
203203

204+
//===--------------------------------------------------------------------===//
205+
// Call operators
206+
//===--------------------------------------------------------------------===//
207+
208+
cir::CallOp createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee) {
209+
auto op = create<cir::CallOp>(loc, callee);
210+
return op;
211+
}
212+
213+
cir::CallOp createCallOp(mlir::Location loc, cir::FuncOp callee) {
214+
return createCallOp(loc, mlir::SymbolRefAttr::get(callee));
215+
}
216+
204217
//===--------------------------------------------------------------------===//
205218
// Cast/Conversion Operators
206219
//===--------------------------------------------------------------------===//

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,48 @@ def FuncOp : CIR_Op<"func", [
13421342
let hasVerifier = 1;
13431343
}
13441344

1345+
//===----------------------------------------------------------------------===//
1346+
// CallOp
1347+
//===----------------------------------------------------------------------===//
1348+
1349+
class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []>
1350+
: Op<CIR_Dialect, mnemonic,
1351+
!listconcat(extra_traits,
1352+
[DeclareOpInterfaceMethods<CIRCallOpInterface>,
1353+
DeclareOpInterfaceMethods<SymbolUserOpInterface>])> {
1354+
let hasCustomAssemblyFormat = 1;
1355+
let skipDefaultBuilders = 1;
1356+
let hasVerifier = 0;
1357+
1358+
// TODO(cir): for now cir.call is just a tiny shell of what it will become.
1359+
// More attributes, arguments, and properties will be added in the future as
1360+
// the upstreaming process moves on. The verifiers is also missing for now,
1361+
// will add in the future.
1362+
1363+
dag commonArgs = (ins FlatSymbolRefAttr:$callee);
1364+
}
1365+
1366+
def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> {
1367+
let summary = "call a function";
1368+
let description = [{
1369+
The `cir.call` operation represents a direct call to a function that is
1370+
within the same symbol scope as the call. The callee is encoded as a symbol
1371+
reference attribute named `callee`.
1372+
1373+
Example:
1374+
1375+
```mlir
1376+
%0 = cir.call @foo()
1377+
```
1378+
}];
1379+
1380+
let arguments = commonArgs;
1381+
1382+
let builders = [OpBuilder<(ins "mlir::SymbolRefAttr":$callee), [{
1383+
$_state.addAttribute("callee", callee);
1384+
}]>];
1385+
}
1386+
13451387
//===----------------------------------------------------------------------===//
13461388
// UnreachableOp
13471389
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/Interfaces/CIROpInterfaces.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@
1515

1616
include "mlir/IR/OpBase.td"
1717
include "mlir/IR/SymbolInterfaces.td"
18+
include "mlir/Interfaces/CallInterfaces.td"
1819

1920
let cppNamespace = "::cir" in {
21+
// The CIRCallOpInterface must be used instead of CallOpInterface when looking
22+
// at arguments and other bits of CallOp. This creates a level of abstraction
23+
// that's useful for handling indirect calls and other details.
24+
def CIRCallOpInterface : OpInterface<"CIRCallOpInterface", []> {
25+
// Currently we don't have any methods defined in CIRCallOpInterface. We'll
26+
// add more methods as the upstreaming proceeds.
27+
}
28+
2029
def CIRGlobalValueInterface
2130
: OpInterface<"CIRGlobalValueInterface", [Symbol]> {
2231

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ struct MissingFeatures {
7272
static bool opFuncLinkage() { return false; }
7373
static bool opFuncVisibility() { return false; }
7474

75+
// CallOp handling
76+
static bool opCallBuiltinFunc() { return false; }
77+
static bool opCallPseudoDtor() { return false; }
78+
static bool opCallArgs() { return false; }
79+
static bool opCallReturn() { return false; }
80+
static bool opCallArgEvaluationOrder() { return false; }
81+
static bool opCallCallConv() { return false; }
82+
static bool opCallSideEffect() { return false; }
83+
static bool opCallChainCall() { return false; }
84+
static bool opCallNoPrototypeFunc() { return false; }
85+
static bool opCallMustTail() { return false; }
86+
static bool opCallIndirect() { return false; }
87+
static bool opCallVirtual() { return false; }
88+
static bool opCallInAlloca() { return false; }
89+
static bool opCallAttrs() { return false; }
90+
static bool opCallSurroundingTry() { return false; }
91+
static bool opCallASTAttr() { return false; }
92+
7593
// ScopeOp handling
7694
static bool opScopeCleanupRegion() { return false; }
7795

@@ -90,7 +108,10 @@ struct MissingFeatures {
90108
static bool lowerModeOptLevel() { return false; }
91109
static bool opTBAA() { return false; }
92110
static bool objCLifetime() { return false; }
111+
static bool objCBlocks() { return false; }
93112
static bool emitNullabilityCheck() { return false; }
113+
static bool emitLValueAlignmentAssumption() { return false; }
114+
static bool emitLifetimeMarkers() { return false; }
94115
static bool astVarDeclInterface() { return false; }
95116
static bool stackSaveOp() { return false; }
96117
static bool aggValueSlot() { return false; }
@@ -113,6 +134,8 @@ struct MissingFeatures {
113134
static bool incrementProfileCounter() { return false; }
114135
static bool insertBuiltinUnpredictable() { return false; }
115136
static bool objCGC() { return false; }
137+
static bool weakRefReference() { return false; }
138+
static bool hip() { return false; }
116139

117140
// Missing types
118141
static bool dataMemberType() { return false; }
@@ -132,6 +155,7 @@ struct MissingFeatures {
132155
static bool complexImagOp() { return false; }
133156
static bool complexRealOp() { return false; }
134157
static bool ifOp() { return false; }
158+
static bool invokeOp() { return false; }
135159
static bool labelOp() { return false; }
136160
static bool ptrDiffOp() { return false; }
137161
static bool ptrStrideOp() { return false; }

0 commit comments

Comments
 (0)