Skip to content

Commit 32a06a8

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:61da6366d043792d7db280ce9edd2db62516e0e8 into amd-gfx:cac0b75adbc1
Local branch amd-gfx cac0b75 Merged main:398162ddbcf741c49e86bef2ef4aaa3fd0213916 into amd-gfx:f8acc62d410f Remote branch main 61da636 [flang] Initial debug info support for local variables. (llvm#90905)
2 parents cac0b75 + 61da636 commit 32a06a8

File tree

79 files changed

+1805
-1529
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

+1805
-1529
lines changed

.github/workflows/libclang-abi-tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ jobs:
3333
ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
3434
ABI_LIBS: ${{ steps.vars.outputs.ABI_LIBS }}
3535
BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
36-
BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }}
3736
LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
3837
LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
3938
LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
@@ -51,9 +50,9 @@ jobs:
5150
id: vars
5251
run: |
5352
remote_repo='https://github.com/llvm/llvm-project'
54-
if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 ] || [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
53+
if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
5554
major_version=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))
56-
baseline_ref="llvmorg-$major_version.0.0"
55+
baseline_ref="llvmorg-$major_version.1.0"
5756
5857
# If there is a minor release, we want to use that as the base line.
5958
minor_ref=$(git ls-remote --refs -t "$remote_repo" llvmorg-"$major_version".[1-9].[0-9] | tail -n1 | grep -o 'llvmorg-.\+' || true)
@@ -75,7 +74,7 @@ jobs:
7574
else
7675
{
7776
echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}"
78-
echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.0.0"
77+
echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.1.0"
7978
echo "ABI_HEADERS=."
8079
echo "ABI_LIBS=libclang.so libclang-cpp.so"
8180
} >> "$GITHUB_OUTPUT"

bolt/lib/Rewrite/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(LLVM_LINK_COMPONENTS
2+
Core
23
DebugInfoDWARF
34
DWP
45
JITLink

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ void SuspiciousEnumUsageCheck::check(const MatchFinder::MatchResult &Result) {
171171
// Skip when one of the parameters is an empty enum. The
172172
// hasDisjointValueRange function could not decide the values properly in
173173
// case of an empty enum.
174-
if (EnumDec->enumerator_begin() == EnumDec->enumerator_end() ||
175-
OtherEnumDec->enumerator_begin() == OtherEnumDec->enumerator_end())
174+
if (EnumDec->enumerators().empty() || OtherEnumDec->enumerators().empty())
176175
return;
177176

178177
if (!hasDisjointValueRange(EnumDec, OtherEnumDec))

clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ static std::string createReplacementText(const LambdaExpr *Lambda) {
6767
AppendName("this");
6868
}
6969
}
70-
if (!Replacement.empty() &&
71-
Lambda->explicit_capture_begin() != Lambda->explicit_capture_end()) {
70+
if (!Replacement.empty() && !Lambda->explicit_captures().empty()) {
7271
// Add back separator if we are adding explicit capture variables.
7372
Stream << ", ";
7473
}

clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ void UnusedParametersCheck::check(const MatchFinder::MatchResult &Result) {
192192

193193
// In non-strict mode ignore function definitions with empty bodies
194194
// (constructor initializer counts for non-empty body).
195-
if (StrictMode ||
196-
(Function->getBody()->child_begin() !=
197-
Function->getBody()->child_end()) ||
195+
if (StrictMode || !Function->getBody()->children().empty() ||
198196
(isa<CXXConstructorDecl>(Function) &&
199197
cast<CXXConstructorDecl>(Function)->getNumCtorInitializers() > 0))
200198
warnOnUnusedParameter(Result, Function, I);

clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ generateReplacements(const MatchFinder::MatchResult &Match,
129129
continue;
130130
}
131131

132+
// if the nested call is not the same as the top call
133+
if (InnerCall->getDirectCallee()->getQualifiedNameAsString() !=
134+
TopCall->getDirectCallee()->getQualifiedNameAsString())
135+
continue;
136+
132137
const FindArgsResult InnerResult = findArgs(InnerCall);
133138

134139
// if the nested call doesn't have arguments skip it
135140
if (!InnerResult.First || !InnerResult.Last)
136141
continue;
137142

138-
// if the nested call is not the same as the top call
139-
if (InnerCall->getDirectCallee()->getQualifiedNameAsString() !=
140-
TopCall->getDirectCallee()->getQualifiedNameAsString())
141-
continue;
142-
143143
// if the nested call doesn't have the same compare function
144144
if ((Result.Compare || InnerResult.Compare) &&
145145
!utils::areStatementsIdentical(Result.Compare, InnerResult.Compare,

clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ findInsertionForConstraint(const FunctionDecl *Function, ASTContext &Context) {
254254
return utils::lexer::findPreviousTokenKind(Init->getSourceLocation(),
255255
SM, LangOpts, tok::colon);
256256
}
257-
if (Constructor->init_begin() != Constructor->init_end())
257+
if (!Constructor->inits().empty())
258258
return std::nullopt;
259259
}
260260
if (Function->isDeleted()) {

clang-tools-extra/test/clang-tidy/checkers/modernize/min-max-use-initializer-list.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,27 @@ B maxTT2 = std::max(B(), std::max(B(), B()));
300300
B maxTT3 = std::max(B(), std::max(B(), B()), [](const B &lhs, const B &rhs) { return lhs.a[0] < rhs.a[0]; });
301301
// CHECK-FIXES: B maxTT3 = std::max(B(), std::max(B(), B()), [](const B &lhs, const B &rhs) { return lhs.a[0] < rhs.a[0]; });
302302

303+
struct GH91982 {
304+
int fun0Args();
305+
int fun1Arg(int a);
306+
int fun2Args(int a, int b);
307+
int fun3Args(int a, int b, int c);
308+
int fun4Args(int a, int b, int c, int d);
309+
310+
int foo() {
311+
return std::max(
312+
fun0Args(),
313+
std::max(fun1Arg(0),
314+
std::max(fun2Args(0, 1),
315+
std::max(fun3Args(0, 1, 2), fun4Args(0, 1, 2, 3)))));
316+
// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: do not use nested 'std::max' calls, use an initializer list instead [modernize-min-max-use-initializer-list]
317+
// CHECK-FIXES: return std::max(
318+
// CHECK-FIXES-NEXT: {fun0Args(),
319+
// CHECK-FIXES-NEXT: fun1Arg(0),
320+
// CHECK-FIXES-NEXT: fun2Args(0, 1),
321+
// CHECK-FIXES-NEXT: fun3Args(0, 1, 2), fun4Args(0, 1, 2, 3)});
322+
}
323+
};
303324

304325
} // namespace
305326

clang/lib/CodeGen/CGCoroutine.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ static LValueOrRValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Co
278278

279279
llvm::Function *AwaitSuspendIntrinsic = CGF.CGM.getIntrinsic(AwaitSuspendIID);
280280

281-
const auto AwaitSuspendCanThrow = StmtCanThrow(S.getSuspendExpr());
281+
// SuspendHandle might throw since it also resumes the returned handle.
282+
const bool AwaitSuspendCanThrow =
283+
SuspendReturnType ==
284+
CoroutineSuspendExpr::SuspendReturnType::SuspendHandle ||
285+
StmtCanThrow(S.getSuspendExpr());
282286

283287
llvm::CallBase *SuspendRet = nullptr;
284288
// FIXME: add call attributes?
@@ -307,10 +311,7 @@ static LValueOrRValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Co
307311
break;
308312
}
309313
case CoroutineSuspendExpr::SuspendReturnType::SuspendHandle: {
310-
assert(SuspendRet->getType()->isPointerTy());
311-
312-
auto ResumeIntrinsic = CGF.CGM.getIntrinsic(llvm::Intrinsic::coro_resume);
313-
Builder.CreateCall(ResumeIntrinsic, SuspendRet);
314+
assert(SuspendRet->getType()->isVoidTy());
314315
break;
315316
}
316317
}

clang/lib/CodeGen/Targets/Sparc.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit) const {
263263

264264
CoerceBuilder CB(getVMContext(), getDataLayout());
265265
CB.addStruct(0, StrTy);
266-
CB.pad(llvm::alignTo(CB.DL.getTypeSizeInBits(StrTy), 64));
266+
// All structs, even empty ones, should take up a register argument slot,
267+
// so pin the minimum struct size to one bit.
268+
CB.pad(llvm::alignTo(
269+
std::max(CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(), 1UL), 64));
267270

268271
// Try to use the original type for coercion.
269272
llvm::Type *CoerceTy = CB.isUsableType(StrTy) ? StrTy : CB.getType();

clang/test/CodeGen/sparcv9-abi.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,47 @@ char f_int_4(char x) { return x; }
2121
// CHECK-LABEL: define{{.*}} fp128 @f_ld(fp128 noundef %x)
2222
long double f_ld(long double x) { return x; }
2323

24+
// Zero-sized structs reserves an argument register slot if passed directly.
25+
struct empty {};
26+
struct emptyarr { struct empty a[10]; };
27+
28+
// CHECK-LABEL: define{{.*}} i64 @f_empty(i64 %x.coerce)
29+
struct empty f_empty(struct empty x) { return x; }
30+
31+
// CHECK-LABEL: define{{.*}} i64 @f_emptyarr(i64 %x.coerce)
32+
struct empty f_emptyarr(struct emptyarr x) { return x.a[0]; }
33+
34+
// CHECK-LABEL: define{{.*}} i64 @f_emptyvar(i32 noundef zeroext %count, ...)
35+
long f_emptyvar(unsigned count, ...) {
36+
long ret;
37+
va_list args;
38+
va_start(args, count);
39+
40+
// CHECK: %[[CUR:[^ ]+]] = load ptr, ptr %args
41+
// CHECK-DAG: %[[NXT:[^ ]+]] = getelementptr inbounds i8, ptr %[[CUR]], i64 8
42+
// CHECK-DAG: store ptr %[[NXT]], ptr %args
43+
va_arg(args, struct empty);
44+
45+
// CHECK: %[[CUR:[^ ]+]] = load ptr, ptr %args
46+
// CHECK-DAG: %[[NXT:[^ ]+]] = getelementptr inbounds i8, ptr %[[CUR]], i64 8
47+
// CHECK-DAG: store ptr %[[NXT]], ptr %args
48+
// CHECK-DAG: load i64, ptr %[[CUR]]
49+
ret = va_arg(args, long);
50+
va_end(args);
51+
return ret;
52+
}
53+
54+
// If the zero-sized struct is contained in a non-zero-sized struct,
55+
// though, it doesn't reserve any registers.
56+
struct emptymixed { struct empty a; long b; };
57+
struct emptyflex { unsigned count; struct empty data[10]; };
58+
59+
// CHECK-LABEL: define{{.*}} i64 @f_emptymixed(i64 %x.coerce)
60+
long f_emptymixed(struct emptymixed x) { return x.b; }
61+
62+
// CHECK-LABEL: define{{.*}} i64 @f_emptyflex(i64 %x.coerce, i64 noundef %y)
63+
long f_emptyflex(struct emptyflex x, long y) { return y; }
64+
2465
// Small structs are passed in registers.
2566
struct small {
2667
int *a, *b;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 -triple sparcv9-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2+
3+
class Empty {
4+
};
5+
6+
class Long : public Empty {
7+
public:
8+
long l;
9+
};
10+
11+
// CHECK: define{{.*}} i64 @_Z4foo15Empty(i64 %e.coerce)
12+
Empty foo1(Empty e) {
13+
return e;
14+
}
15+
16+
// CHECK: define{{.*}} %class.Long @_Z4foo24Long(i64 %l.coerce)
17+
Long foo2(Long l) {
18+
return l;
19+
}
20+
21+
// CHECK: define{{.*}} i64 @_Z4foo34Long(i64 %l.coerce)
22+
long foo3(Long l) {
23+
return l.l;
24+
}

clang/test/CodeGenCoroutines/coro-await.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ extern "C" void TestTailcall() {
370370
// ---------------------------
371371
// Call coro.await.suspend
372372
// ---------------------------
373-
// CHECK-NEXT: %[[RESUMED:.+]] = call ptr @llvm.coro.await.suspend.handle(ptr %[[AWAITABLE]], ptr %[[FRAME]], ptr @TestTailcall.__await_suspend_wrapper__await)
374-
// CHECK-NEXT: call void @llvm.coro.resume(ptr %[[RESUMED]])
373+
// Note: The call must not be nounwind since the resumed function could throw.
374+
// CHECK-NEXT: call void @llvm.coro.await.suspend.handle(ptr %[[AWAITABLE]], ptr %[[FRAME]], ptr @TestTailcall.__await_suspend_wrapper__await){{$}}
375375
// CHECK-NEXT: %[[OUTCOME:.+]] = call i8 @llvm.coro.suspend(token %[[SUSPEND_ID]], i1 false)
376376
// CHECK-NEXT: switch i8 %[[OUTCOME]], label %[[RET_BB:.+]] [
377377
// CHECK-NEXT: i8 0, label %[[READY_BB]]

clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

clang/test/CodeGenCoroutines/coro-symmetric-transfer-02.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ Task bar() {
8989
// CHECK: br i1 %{{.+}}, label %[[CASE1_AWAIT_READY:.+]], label %[[CASE1_AWAIT_SUSPEND:.+]]
9090
// CHECK: [[CASE1_AWAIT_SUSPEND]]:
9191
// CHECK-NEXT: %{{.+}} = call token @llvm.coro.save(ptr null)
92-
// CHECK-NEXT: %[[HANDLE1_PTR:.+]] = call ptr @llvm.coro.await.suspend.handle
93-
// CHECK-NEXT: call void @llvm.coro.resume(ptr %[[HANDLE1_PTR]])
92+
// CHECK-NEXT: call void @llvm.coro.await.suspend.handle
9493
// CHECK-NEXT: %{{.+}} = call i8 @llvm.coro.suspend
9594
// CHECK-NEXT: switch i8 %{{.+}}, label %coro.ret [
9695
// CHECK-NEXT: i8 0, label %[[CASE1_AWAIT_READY]]
@@ -104,8 +103,7 @@ Task bar() {
104103
// CHECK: br i1 %{{.+}}, label %[[CASE2_AWAIT_READY:.+]], label %[[CASE2_AWAIT_SUSPEND:.+]]
105104
// CHECK: [[CASE2_AWAIT_SUSPEND]]:
106105
// CHECK-NEXT: %{{.+}} = call token @llvm.coro.save(ptr null)
107-
// CHECK-NEXT: %[[HANDLE2_PTR:.+]] = call ptr @llvm.coro.await.suspend.handle
108-
// CHECK-NEXT: call void @llvm.coro.resume(ptr %[[HANDLE2_PTR]])
106+
// CHECK-NEXT: call void @llvm.coro.await.suspend.handle
109107
// CHECK-NEXT: %{{.+}} = call i8 @llvm.coro.suspend
110108
// CHECK-NEXT: switch i8 %{{.+}}, label %coro.ret [
111109
// CHECK-NEXT: i8 0, label %[[CASE2_AWAIT_READY]]

flang/lib/Optimizer/CodeGen/CGOps.h renamed to flang/include/flang/Optimizer/CodeGen/CGOps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef OPTIMIZER_CODEGEN_CGOPS_H
1414
#define OPTIMIZER_CODEGEN_CGOPS_H
1515

16+
#include "flang/Optimizer/Dialect/FIRAttr.h"
1617
#include "flang/Optimizer/Dialect/FIRType.h"
1718
#include "mlir/Dialect/Func/IR/FuncOps.h"
1819

flang/include/flang/Optimizer/CodeGen/CGOps.td

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
include "mlir/IR/SymbolInterfaces.td"
1818
include "flang/Optimizer/Dialect/FIRTypes.td"
19+
include "flang/Optimizer/Dialect/FIRAttr.td"
20+
include "mlir/IR/BuiltinAttributes.td"
1921

2022
def fircg_Dialect : Dialect {
2123
let name = "fircg";
@@ -202,4 +204,36 @@ def fircg_XArrayCoorOp : fircg_Op<"ext_array_coor", [AttrSizedOperandSegments]>
202204
}];
203205
}
204206

207+
// Extended Declare operation.
208+
def fircg_XDeclareOp : fircg_Op<"ext_declare", [AttrSizedOperandSegments]> {
209+
let summary = "for internal conversion only";
210+
211+
let description = [{
212+
Prior to lowering to LLVM IR dialect, a DeclareOp will
213+
be converted to an extended DeclareOp.
214+
}];
215+
216+
let arguments = (ins
217+
AnyRefOrBox:$memref,
218+
Variadic<AnyIntegerType>:$shape,
219+
Variadic<AnyIntegerType>:$shift,
220+
Variadic<AnyIntegerType>:$typeparams,
221+
Optional<fir_DummyScopeType>:$dummy_scope,
222+
Builtin_StringAttr:$uniq_name
223+
);
224+
let results = (outs AnyRefOrBox);
225+
226+
let assemblyFormat = [{
227+
$memref (`(` $shape^ `)`)? (`origin` $shift^)? (`typeparams` $typeparams^)?
228+
(`dummy_scope` $dummy_scope^)?
229+
attr-dict `:` functional-type(operands, results)
230+
}];
231+
232+
let extraClassDeclaration = [{
233+
// Shape is optional, but if it exists, it will be at offset 1.
234+
unsigned shapeOffset() { return 1; }
235+
unsigned shiftOffset() { return shapeOffset() + getShape().size(); }
236+
}];
237+
}
238+
205239
#endif

flang/include/flang/Optimizer/CodeGen/CGPasses.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def CodeGenRewrite : Pass<"cg-rewrite", "mlir::ModuleOp"> {
4747
let dependentDialects = [
4848
"fir::FIROpsDialect", "fir::FIRCodeGenDialect"
4949
];
50+
let options = [
51+
Option<"preserveDeclare", "preserve-declare", "bool", /*default=*/"false",
52+
"Preserve DeclareOp during pre codegen re-write.">
53+
];
5054
let statistics = [
5155
Statistic<"numDCE", "num-dce'd", "Number of operations eliminated">
5256
];

0 commit comments

Comments
 (0)