Skip to content

Commit 71e4da7

Browse files
committed
Merge branch 'upstream' into x86-bw-permv3-depth
2 parents aacbcc3 + 44dc572 commit 71e4da7

File tree

215 files changed

+6572
-3136
lines changed

Some content is hidden

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

215 files changed

+6572
-3136
lines changed

.github/workflows/release-binaries.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ jobs:
138138
arches=arm64
139139
else
140140
arches=x86_64
141+
# Disable Flang builds on macOS x86_64. The FortranLower library takes
142+
# 2-3 hours to build on macOS, much slower than on Linux.
143+
# The long build time causes the release build to time out on x86_64,
144+
# so we need to disable flang there.
145+
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS='clang;lld;lldb;clang-tools-extra;bolt;polly;mlir'"
141146
fi
142147
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
143148
fi

bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void InstrumentationRuntimeLibrary::link(
219219
}
220220
outs() << "BOLT-INFO: output linked against instrumentation runtime "
221221
"library, lib entry point is 0x"
222-
<< Twine::utohexstr(RuntimeFiniAddress) << "\n";
222+
<< Twine::utohexstr(RuntimeStartAddress) << "\n";
223223
outs() << "BOLT-INFO: clear procedure is 0x"
224224
<< Twine::utohexstr(
225225
Linker.lookupSymbol("__bolt_instr_clear_counters").value_or(0))

clang/cmake/caches/Release.cmake

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
4848

4949
set(STAGE1_PROJECTS "clang")
5050

51-
# Building Flang on Windows requires compiler-rt, so we need to build it in
52-
# stage1. compiler-rt is also required for building the Flang tests on
53-
# macOS.
54-
set(STAGE1_RUNTIMES "compiler-rt")
51+
# Build all runtimes so we can statically link them into the stage2 compiler.
52+
set(STAGE1_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind")
5553

5654
if (LLVM_RELEASE_ENABLE_PGO)
5755
list(APPEND STAGE1_PROJECTS "lld")
@@ -90,9 +88,20 @@ else()
9088
set(CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING "")
9189
endif()
9290

91+
if (LLVM_RELEASE_ENABLE_LTO)
92+
# Enable LTO for the runtimes. We need to configure stage1 clang to default
93+
# to using lld as the linker because the stage1 toolchain will be used to
94+
# build and link the runtimes.
95+
# FIXME: We can't use LLVM_ENABLE_LTO=Thin here, because it causes the CMake
96+
# step for the libcxx build to fail. CMAKE_INTERPROCEDURAL_OPTIMIZATION does
97+
# enable ThinLTO, though.
98+
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DLLVM_ENABLE_LLD=ON" CACHE STRING "")
99+
endif()
100+
93101
# Stage 1 Common Config
94102
set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "")
95103
set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
104+
set(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY ON CACHE STRING "")
96105

97106
# stage2-instrumented and Final Stage Config:
98107
# Options that need to be set in both the instrumented stage (if we are doing
@@ -102,6 +111,16 @@ set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}"
102111
if (LLVM_RELEASE_ENABLE_LTO)
103112
set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
104113
endif()
114+
set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
115+
set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
116+
set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
117+
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
118+
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
119+
endif()
120+
121+
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
122+
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
123+
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
105124

106125
# Final Stage Config (stage2)
107126
set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ clang-format
266266
libclang
267267
--------
268268

269+
- Fixed a buffer overflow in ``CXString`` implementation. The fix may result in
270+
increased memory allocation.
271+
269272
Code Completion
270273
---------------
271274

clang/include/clang/Basic/BuiltinsNVPTX.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ class SM<string version, list<SMFeatures> newer_list> : SMFeatures {
2121
!strconcat(f, "|", newer.Features));
2222
}
2323

24+
let Features = "sm_120a" in def SM_120a : SMFeatures;
25+
let Features = "sm_101a" in def SM_101a : SMFeatures;
2426
let Features = "sm_100a" in def SM_100a : SMFeatures;
25-
26-
def SM_100 : SM<"100", [SM_100a]>;
27-
2827
let Features = "sm_90a" in def SM_90a : SMFeatures;
2928

29+
def SM_120 : SM<"120", [SM_120a]>;
30+
def SM_101 : SM<"101", [SM_101a, SM_120]>;
31+
def SM_100 : SM<"100", [SM_100a, SM_101]>;
3032
def SM_90 : SM<"90", [SM_90a, SM_100]>;
3133
def SM_89 : SM<"89", [SM_90]>;
3234
def SM_87 : SM<"87", [SM_89]>;

clang/include/clang/Basic/Cuda.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ enum class OffloadArch {
8282
SM_90a,
8383
SM_100,
8484
SM_100a,
85+
SM_101,
86+
SM_101a,
87+
SM_120,
88+
SM_120a,
8589
GFX600,
8690
GFX601,
8791
GFX602,

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

Lines changed: 229 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
///
1212
//===----------------------------------------------------------------------===//
1313

14-
#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIROPS
15-
#define LLVM_CLANG_CIR_DIALECT_IR_CIROPS
14+
#ifndef CLANG_CIR_DIALECT_IR_CIROPS_TD
15+
#define CLANG_CIR_DIALECT_IR_CIROPS_TD
1616

1717
include "clang/CIR/Dialect/IR/CIRDialect.td"
1818
include "clang/CIR/Dialect/IR/CIRTypes.td"
@@ -115,6 +115,165 @@ def ConstantOp : CIR_Op<"const",
115115
let hasFolder = 1;
116116
}
117117

118+
//===----------------------------------------------------------------------===//
119+
// ReturnOp
120+
//===----------------------------------------------------------------------===//
121+
122+
def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp"]>,
123+
Terminator]> {
124+
let summary = "Return from function";
125+
let description = [{
126+
The "return" operation represents a return operation within a function.
127+
The operation takes an optional operand and produces no results.
128+
The operand type must match the signature of the function that contains
129+
the operation.
130+
131+
```mlir
132+
func @foo() -> i32 {
133+
...
134+
cir.return %0 : i32
135+
}
136+
```
137+
}];
138+
139+
// The return operation takes an optional input operand to return. This
140+
// value must match the return type of the enclosing function.
141+
let arguments = (ins Variadic<CIR_AnyType>:$input);
142+
143+
// The return operation only emits the input in the format if it is present.
144+
let assemblyFormat = "($input^ `:` type($input))? attr-dict ";
145+
146+
// Allow building a ReturnOp with no return operand.
147+
let builders = [
148+
OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]>
149+
];
150+
151+
// Provide extra utility definitions on the c++ operation class definition.
152+
let extraClassDeclaration = [{
153+
bool hasOperand() { return getNumOperands() != 0; }
154+
}];
155+
156+
let hasVerifier = 1;
157+
}
158+
159+
//===----------------------------------------------------------------------===//
160+
// YieldOp
161+
//===----------------------------------------------------------------------===//
162+
163+
def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator,
164+
ParentOneOf<["ScopeOp"]>]> {
165+
let summary = "Represents the default branching behaviour of a region";
166+
let description = [{
167+
The `cir.yield` operation terminates regions on different CIR operations,
168+
and it is used to represent the default branching behaviour of a region.
169+
Said branching behaviour is determinted by the parent operation. For
170+
example, a yield in a `switch-case` region implies a fallthrough, while
171+
a yield in a `cir.if` region implies a branch to the exit block, and so
172+
on.
173+
174+
In some cases, it might yield an SSA value and the semantics of how the
175+
values are yielded is defined by the parent operation. For example, a
176+
`cir.ternary` operation yields a value from one of its regions.
177+
178+
As a general rule, `cir.yield` must be explicitly used whenever a region has
179+
more than one block and no terminator, or within `cir.switch` regions not
180+
`cir.return` terminated.
181+
182+
Examples:
183+
```mlir
184+
cir.if %4 {
185+
...
186+
cir.yield
187+
}
188+
189+
cir.switch (%5) [
190+
case (equal, 3) {
191+
...
192+
cir.yield
193+
}, ...
194+
]
195+
196+
cir.scope {
197+
...
198+
cir.yield
199+
}
200+
201+
%x = cir.scope {
202+
...
203+
cir.yield %val
204+
}
205+
206+
%y = cir.ternary {
207+
...
208+
cir.yield %val : i32
209+
} : i32
210+
```
211+
}];
212+
213+
let arguments = (ins Variadic<CIR_AnyType>:$args);
214+
let assemblyFormat = "($args^ `:` type($args))? attr-dict";
215+
let builders = [
216+
OpBuilder<(ins), [{ /* nothing to do */ }]>,
217+
];
218+
}
219+
220+
//===----------------------------------------------------------------------===//
221+
// ScopeOp
222+
//===----------------------------------------------------------------------===//
223+
224+
def ScopeOp : CIR_Op<"scope", [
225+
DeclareOpInterfaceMethods<RegionBranchOpInterface>,
226+
RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]> {
227+
let summary = "Represents a C/C++ scope";
228+
let description = [{
229+
`cir.scope` contains one region and defines a strict "scope" for all new
230+
values produced within its blocks.
231+
232+
The region can contain an arbitrary number of blocks but usually defaults
233+
to one and can optionally return a value (useful for representing values
234+
coming out of C++ full-expressions) via `cir.yield`:
235+
236+
237+
```mlir
238+
%rvalue = cir.scope {
239+
...
240+
cir.yield %value
241+
}
242+
```
243+
244+
The blocks can be terminated by `cir.yield`, `cir.return` or `cir.throw`.
245+
If `cir.scope` yields no value, the `cir.yield` can be left out, and
246+
will be inserted implicitly.
247+
}];
248+
249+
let results = (outs Optional<CIR_AnyType>:$results);
250+
let regions = (region AnyRegion:$scopeRegion);
251+
252+
let hasVerifier = 1;
253+
let skipDefaultBuilders = 1;
254+
let assemblyFormat = [{
255+
custom<OmittedTerminatorRegion>($scopeRegion) (`:` type($results)^)? attr-dict
256+
}];
257+
258+
let extraClassDeclaration = [{
259+
/// Determine whether the scope is empty, meaning it contains a single block
260+
/// terminated by a cir.yield.
261+
bool isEmpty() {
262+
auto &entry = getRegion().front();
263+
return getRegion().hasOneBlock() &&
264+
llvm::isa<YieldOp>(entry.front());
265+
}
266+
}];
267+
268+
let builders = [
269+
// Scopes for yielding values.
270+
OpBuilder<(ins
271+
"llvm::function_ref<void(mlir::OpBuilder &, mlir::Type &, mlir::Location)>":$scopeBuilder)>,
272+
// Scopes without yielding values.
273+
OpBuilder<(ins "llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>":$scopeBuilder)>
274+
];
275+
}
276+
118277
//===----------------------------------------------------------------------===//
119278
// GlobalOp
120279
//===----------------------------------------------------------------------===//
@@ -158,25 +317,86 @@ def GlobalOp : CIR_Op<"global"> {
158317
// FuncOp
159318
//===----------------------------------------------------------------------===//
160319

161-
// TODO(CIR): For starters, cir.func has only name, nothing else. The other
162-
// properties of a function will be added over time as more of ClangIR is
163-
// upstreamed.
320+
// TODO(CIR): FuncOp is still a tiny shell of what it will become. Many more
321+
// properties and attributes will be added as upstreaming continues.
164322

165-
def FuncOp : CIR_Op<"func"> {
323+
def FuncOp : CIR_Op<"func", [
324+
AutomaticAllocationScope, CallableOpInterface, FunctionOpInterface,
325+
IsolatedFromAbove
326+
]> {
166327
let summary = "Declare or define a function";
167328
let description = [{
168329
The `cir.func` operation defines a function, similar to the `mlir::FuncOp`
169330
built-in.
170331
}];
171332

172-
let arguments = (ins SymbolNameAttr:$sym_name);
333+
let arguments = (ins SymbolNameAttr:$sym_name,
334+
TypeAttrOf<CIR_FuncType>:$function_type,
335+
OptionalAttr<DictArrayAttr>:$arg_attrs,
336+
OptionalAttr<DictArrayAttr>:$res_attrs);
337+
338+
let regions = (region AnyRegion:$body);
173339

174340
let skipDefaultBuilders = 1;
175341

176-
let builders = [OpBuilder<(ins "llvm::StringRef":$sym_name)>];
342+
let builders = [OpBuilder<(ins "llvm::StringRef":$sym_name,
343+
"FuncType":$type)>];
344+
345+
let extraClassDeclaration = [{
346+
/// Returns the region on the current operation that is callable. This may
347+
/// return null in the case of an external callable object, e.g. an external
348+
/// function.
349+
::mlir::Region *getCallableRegion();
350+
351+
/// Returns the results types that the callable region produces when
352+
/// executed.
353+
llvm::ArrayRef<mlir::Type> getCallableResults() {
354+
return getFunctionType().getReturnTypes();
355+
}
356+
357+
/// Returns the argument types of this function.
358+
llvm::ArrayRef<mlir::Type> getArgumentTypes() {
359+
return getFunctionType().getInputs();
360+
}
361+
362+
/// Returns 0 or 1 result type of this function (0 in the case of a function
363+
/// returing void)
364+
llvm::ArrayRef<mlir::Type> getResultTypes() {
365+
return getFunctionType().getReturnTypes();
366+
}
367+
368+
/// Hook for OpTrait::FunctionOpInterfaceTrait, called after verifying that
369+
/// the 'type' attribute is present and checks if it holds a function type.
370+
/// Ensures getType, getNumFuncArguments, and getNumFuncResults can be
371+
/// called safely.
372+
llvm::LogicalResult verifyType();
373+
374+
//===------------------------------------------------------------------===//
375+
// SymbolOpInterface Methods
376+
//===------------------------------------------------------------------===//
377+
378+
bool isDeclaration();
379+
}];
177380

178381
let hasCustomAssemblyFormat = 1;
179382
let hasVerifier = 1;
180383
}
181384

182-
#endif // LLVM_CLANG_CIR_DIALECT_IR_CIROPS
385+
//===----------------------------------------------------------------------===//
386+
// TrapOp
387+
//===----------------------------------------------------------------------===//
388+
389+
def TrapOp : CIR_Op<"trap", [Terminator]> {
390+
let summary = "Exit the program abnormally";
391+
let description = [{
392+
The cir.trap operation causes the program to exit abnormally. The
393+
implementations may implement this operation with different mechanisms. For
394+
example, an implementation may implement this operation by calling abort,
395+
while another implementation may implement this operation by executing an
396+
illegal instruction.
397+
}];
398+
399+
let assemblyFormat = "attr-dict";
400+
}
401+
402+
#endif // CLANG_CIR_DIALECT_IR_CIROPS_TD

0 commit comments

Comments
 (0)