Skip to content

Commit d35d1d2

Browse files
authored
merge main into amd-staging (#364)
2 parents 6ffda03 + 752e345 commit d35d1d2

File tree

52 files changed

+1451
-535
lines changed

Some content is hidden

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

52 files changed

+1451
-535
lines changed

.github/workflows/containers/github-action-ci-windows/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,45 @@ RUN powershell -Command \
9898
Add-Type -AssemblyName System.IO.Compression.FileSystem ; \
9999
[System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win.zip', $PWD) ;\
100100
rm actions-runner-win.zip
101+
102+
# Set the LLVM_VERSION environment variable
103+
ENV LLVM_VERSION=21.1.2
104+
105+
# Download and extract Clang compiler.
106+
# Create directories, download, extract, and clean up all in one layer
107+
RUN powershell -Command \
108+
# --- Setup directories --- \
109+
Write-Host "Creating directories..."; \
110+
New-Item -Path "C:\temp-download" -ItemType "Directory" -Force ; \
111+
New-Item -Path "C:\xz-utils" -ItemType "Directory" -Force ; \
112+
New-Item -Path "C:\clang" -ItemType "Directory" -Force ; \
113+
# --- 1. Download and extract xz --- \
114+
Set-Location C:\temp-download ; \
115+
Invoke-WebRequest -Uri "http://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1-windows.zip" -OutFile "xz.zip"; \
116+
(Get-FileHash -Path "C:\temp-download\xz.zip" -Algorithm MD5).Hash -eq 'c3c69fdce3e825cc0b76123b36b0bcc2' ; \
117+
Add-Type -AssemblyName "System.IO.Compression.FileSystem"; \
118+
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\temp-download\xz.zip', 'C:\xz-utils'); \
119+
# --- 2. Download and decompress Clang --- \
120+
Invoke-WebRequest -Uri "http://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -OutFile "clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" ; \
121+
(Get-FileHash -Path "C:\temp-download\clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -Algorithm MD5).Hash -eq '0ae1d3effd9ab9d323f7fa595777f0a2' ; \
122+
C:\xz-utils\bin_x86-64\xz.exe -d -qq clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz ; \
123+
# --- 3. Extract clang --- \
124+
C:\Windows\System32\tar.exe -xf clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar -C C:\clang ; \
125+
# --- 4. Clean up --- \
126+
Set-Location C:\ ; \
127+
Remove-Item C:\temp-download -Recurse -Force; \
128+
Remove-Item C:\xz-utils -Recurse -Force; \
129+
# -- 5. Shorten path to clang files & remove unnecessary files -- \
130+
Set-Location C:\clang ; \
131+
Rename-Item -Path "C:\clang\clang+llvm-21.1.2-x86_64-pc-windows-msvc" -NewName "C:\clang\clang-msvc" ; \
132+
Set-Location C:\clang\clang-msvc ; \
133+
Remove-Item -Path C:\clang\clang-msvc\libexec -Recurse -Force ; \
134+
Remove-Item -Path C:\clang\clang-msvc\share -Recurse -Force ; \
135+
Rename-Item -Path "C:\clang\clang-msvc\bin" -NewName "C:\clang\clang-msvc\bin-full" ; \
136+
New-Item -Path "C:\clang\clang-msvc\bin" -ItemType Directory -Force ; \
137+
Set-Location C:\clang\clang-msvc\bin ; \
138+
Copy-Item -Path C:\clang\clang-msvc\bin-full\*.dll -Destination C:\clang\clang-msvc\bin\. ; \
139+
Copy-Item -Path C:\clang\clang-msvc\bin-full\clang-cl.exe -Destination C:\clang\clang-msvc\bin\. ; \
140+
Copy-Item -Path C:\clang\clang-msvc\bin-full\lld-link.exe -Destination C:\clang\clang-msvc\bin\. ; \
141+
Set-Location C:\clang\clang-msvc ; \
142+
Remove-Item -Path C:\clang\clang-msvc\bin-full -Recurse -Force ;

clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,18 @@ static void transferNotOkStatusCall(const CallExpr *Expr,
516516
State.Env.assume(A.makeNot(OkVal.formula()));
517517
}
518518

519+
static void transferEmplaceCall(const CXXMemberCallExpr *Expr,
520+
const MatchFinder::MatchResult &,
521+
LatticeTransferState &State) {
522+
RecordStorageLocation *StatusOrLoc =
523+
getImplicitObjectLocation(*Expr, State.Env);
524+
if (StatusOrLoc == nullptr)
525+
return;
526+
527+
auto &OkVal = valForOk(locForStatus(*StatusOrLoc), State.Env);
528+
State.Env.assume(OkVal.formula());
529+
}
530+
519531
CFGMatchSwitch<LatticeTransferState>
520532
buildTransferMatchSwitch(ASTContext &Ctx,
521533
CFGMatchSwitchBuilder<LatticeTransferState> Builder) {
@@ -559,6 +571,8 @@ buildTransferMatchSwitch(ASTContext &Ctx,
559571
})
560572
.CaseOfCFGStmt<CallExpr>(isOkStatusCall(), transferOkStatusCall)
561573
.CaseOfCFGStmt<CallExpr>(isNotOkStatusCall(), transferNotOkStatusCall)
574+
.CaseOfCFGStmt<CXXMemberCallExpr>(isStatusOrMemberCallWithName("emplace"),
575+
transferEmplaceCall)
562576
.Build();
563577
}
564578

clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,6 +2928,53 @@ TEST_P(UncheckedStatusOrAccessModelTest, PointerEqualityCheck) {
29282928
)cc");
29292929
}
29302930

2931+
TEST_P(UncheckedStatusOrAccessModelTest, Emplace) {
2932+
ExpectDiagnosticsFor(R"cc(
2933+
#include "unchecked_statusor_access_test_defs.h"
2934+
2935+
struct Foo {
2936+
Foo(int);
2937+
};
2938+
2939+
void target(absl::StatusOr<Foo> sor, int value) {
2940+
sor.emplace(value);
2941+
sor.value();
2942+
}
2943+
)cc");
2944+
ExpectDiagnosticsFor(R"cc(
2945+
#include "unchecked_statusor_access_test_defs.h"
2946+
2947+
struct Foo {
2948+
Foo(std::initializer_list<int>, int);
2949+
};
2950+
2951+
void target(absl::StatusOr<Foo> sor, int value) {
2952+
sor.emplace({1, 2, 3}, value);
2953+
sor.value();
2954+
}
2955+
)cc");
2956+
ExpectDiagnosticsFor(R"cc(
2957+
#include "unchecked_statusor_access_test_defs.h"
2958+
2959+
void target() {
2960+
STATUSOR_INT sor;
2961+
bool sor_ok = sor.ok();
2962+
if (!sor_ok)
2963+
sor.emplace(42);
2964+
sor.value();
2965+
}
2966+
)cc");
2967+
ExpectDiagnosticsFor(R"cc(
2968+
#include "unchecked_statusor_access_test_defs.h"
2969+
2970+
void target(bool b) {
2971+
STATUSOR_INT sor;
2972+
if (b) sor.emplace(42);
2973+
if (b) sor.value();
2974+
}
2975+
)cc");
2976+
}
2977+
29312978
} // namespace
29322979

29332980
std::string

flang/examples/FeatureList/FeatureList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ struct NodeVisitor {
451451
READ_FEATURE(OmpBlockConstruct)
452452
READ_FEATURE(OmpClause)
453453
READ_FEATURE(OmpClauseList)
454+
READ_FEATURE(OmpCombinerExpression)
454455
READ_FEATURE(OmpDefaultClause)
455456
READ_FEATURE(OmpDefaultClause::DataSharingAttribute)
456457
READ_FEATURE(OmpDefaultmapClause)
@@ -496,7 +497,6 @@ struct NodeVisitor {
496497
READ_FEATURE(OmpProcBindClause::AffinityPolicy)
497498
READ_FEATURE(OmpReductionClause)
498499
READ_FEATURE(OmpInReductionClause)
499-
READ_FEATURE(OmpReductionCombiner)
500500
READ_FEATURE(OmpInitializerClause)
501501
READ_FEATURE(OmpReductionIdentifier)
502502
READ_FEATURE(OmpAllocateClause)

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ class ParseTreeDumper {
538538
NODE(parser, OmpClauseList)
539539
NODE(parser, OmpCloseModifier)
540540
NODE_ENUM(OmpCloseModifier, Value)
541+
NODE(parser, OmpCombinerExpression)
541542
NODE(parser, OmpContainsClause)
542543
NODE(parser, OmpContextSelectorSpecification)
543544
NODE(parser, OmpDeclareVariantDirective)
@@ -655,7 +656,6 @@ class ParseTreeDumper {
655656
NODE_ENUM(OmpProcBindClause, AffinityPolicy)
656657
NODE(parser, OmpReductionClause)
657658
NODE(OmpReductionClause, Modifier)
658-
NODE(parser, OmpReductionCombiner)
659659
NODE(parser, OmpReductionIdentifier)
660660
NODE(parser, OmpReductionModifier)
661661
NODE_ENUM(OmpReductionModifier, Value)
@@ -693,8 +693,8 @@ class ParseTreeDumper {
693693
NODE(parser, OmpTraitSetSelectorName)
694694
NODE_ENUM(OmpTraitSetSelectorName, Value)
695695
NODE(parser, OmpTransparentClause)
696+
NODE(parser, OmpTypeName)
696697
NODE(parser, OmpTypeNameList)
697-
NODE(parser, OmpTypeSpecifier)
698698
NODE(parser, OmpUnifiedAddressClause)
699699
NODE(parser, OmpUnifiedSharedMemoryClause)
700700
NODE(parser, OmpUpdateClause)

flang/include/flang/Parser/parse-tree.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,6 +3502,16 @@ struct OmpDirectiveName {
35023502
llvm::omp::Directive v{llvm::omp::Directive::OMPD_unknown};
35033503
};
35043504

3505+
// type-name list item
3506+
struct OmpTypeName {
3507+
UNION_CLASS_BOILERPLATE(OmpTypeName);
3508+
std::variant<TypeSpec, DeclarationTypeSpec> u;
3509+
};
3510+
3511+
struct OmpTypeNameList {
3512+
WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeName>);
3513+
};
3514+
35053515
// 2.1 Directives or clauses may accept a list or extended-list.
35063516
// A list item is a variable, array section or common block name (enclosed
35073517
// in slashes). An extended list item is a list item or a procedure Name.
@@ -3539,21 +3549,12 @@ struct OmpReductionIdentifier {
35393549
// combiner-expression -> // since 4.5
35403550
// assignment-statement |
35413551
// function-reference
3542-
struct OmpReductionCombiner {
3543-
UNION_CLASS_BOILERPLATE(OmpReductionCombiner);
3552+
struct OmpCombinerExpression {
3553+
UNION_CLASS_BOILERPLATE(OmpCombinerExpression);
35443554
std::variant<AssignmentStmt, FunctionReference> u;
35453555
};
35463556

35473557
inline namespace arguments {
3548-
struct OmpTypeSpecifier {
3549-
UNION_CLASS_BOILERPLATE(OmpTypeSpecifier);
3550-
std::variant<TypeSpec, DeclarationTypeSpec> u;
3551-
};
3552-
3553-
struct OmpTypeNameList {
3554-
WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeSpecifier>);
3555-
};
3556-
35573558
struct OmpLocator {
35583559
UNION_CLASS_BOILERPLATE(OmpLocator);
35593560
std::variant<OmpObject, FunctionReference> u;
@@ -3596,7 +3597,7 @@ struct OmpMapperSpecifier {
35963597
struct OmpReductionSpecifier {
35973598
TUPLE_CLASS_BOILERPLATE(OmpReductionSpecifier);
35983599
std::tuple<OmpReductionIdentifier, OmpTypeNameList,
3599-
std::optional<OmpReductionCombiner>>
3600+
std::optional<OmpCombinerExpression>>
36003601
t;
36013602
};
36023603

flang/include/flang/Semantics/openmp-utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <utility>
2929

3030
namespace Fortran::semantics {
31+
class Scope;
3132
class SemanticsContext;
3233
class Symbol;
3334

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3106,7 +3106,9 @@ IntrinsicLibrary::genAtomicCas(mlir::Type resultType,
31063106
.getResult(0);
31073107
auto cmpxchg = mlir::LLVM::AtomicCmpXchgOp::create(
31083108
builder, loc, address, arg1, arg2, successOrdering, failureOrdering);
3109-
return mlir::LLVM::ExtractValueOp::create(builder, loc, cmpxchg, 1);
3109+
mlir::Value boolResult =
3110+
mlir::LLVM::ExtractValueOp::create(builder, loc, cmpxchg, 1);
3111+
return builder.createConvert(loc, resultType, boolResult);
31103112
}
31113113

31123114
mlir::Value IntrinsicLibrary::genAtomicDec(mlir::Type resultType,

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,17 @@ struct OmpArgumentListParser {
367367
};
368368

369369
TYPE_PARSER( //
370-
construct<OmpTypeSpecifier>(Parser<DeclarationTypeSpec>{}) ||
371-
construct<OmpTypeSpecifier>(Parser<TypeSpec>{}))
370+
construct<OmpTypeName>(Parser<DeclarationTypeSpec>{}) ||
371+
construct<OmpTypeName>(Parser<TypeSpec>{}))
372372

373373
// 2.15.3.6 REDUCTION (reduction-identifier: variable-name-list)
374374
TYPE_PARSER(construct<OmpReductionIdentifier>(Parser<DefinedOperator>{}) ||
375375
construct<OmpReductionIdentifier>(Parser<ProcedureDesignator>{}))
376376

377377
TYPE_PARSER(construct<OmpReductionSpecifier>( //
378378
Parser<OmpReductionIdentifier>{},
379-
":"_tok >> nonemptyList(Parser<OmpTypeSpecifier>{}),
380-
maybe(":"_tok >> Parser<OmpReductionCombiner>{})))
379+
":"_tok >> nonemptyList(Parser<OmpTypeName>{}),
380+
maybe(":"_tok >> Parser<OmpCombinerExpression>{})))
381381

382382
// --- Parsers for context traits -------------------------------------
383383

@@ -1832,8 +1832,8 @@ TYPE_PARSER(sourced(construct<OpenMPDeclareMapperConstruct>(
18321832
IsDirective(llvm::omp::Directive::OMPD_declare_mapper)) >=
18331833
Parser<OmpDirectiveSpecification>{})))
18341834

1835-
TYPE_PARSER(construct<OmpReductionCombiner>(Parser<AssignmentStmt>{}) ||
1836-
construct<OmpReductionCombiner>(Parser<FunctionReference>{}))
1835+
TYPE_PARSER(construct<OmpCombinerExpression>(Parser<AssignmentStmt>{}) ||
1836+
construct<OmpCombinerExpression>(Parser<FunctionReference>{}))
18371837

18381838
TYPE_PARSER(sourced(construct<OpenMPCriticalConstruct>(
18391839
OmpBlockConstructParser{llvm::omp::Directive::OMPD_critical})))

flang/lib/Parser/unparse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,7 @@ class UnparseVisitor {
21112111
Walk(std::get<OmpReductionIdentifier>(x.t));
21122112
Put(":");
21132113
Walk(std::get<OmpTypeNameList>(x.t));
2114-
Walk(": ", std::get<std::optional<OmpReductionCombiner>>(x.t));
2114+
Walk(": ", std::get<std::optional<OmpCombinerExpression>>(x.t));
21152115
}
21162116
void Unparse(const llvm::omp::Directive &x) {
21172117
unsigned ompVersion{langOpts_.OpenMPVersion};
@@ -2519,7 +2519,7 @@ class UnparseVisitor {
25192519
Walk(x.u);
25202520
}
25212521
}
2522-
void Unparse(const OmpReductionCombiner &x) {
2522+
void Unparse(const OmpCombinerExpression &x) {
25232523
// Don't let the visitor go to the normal AssignmentStmt Unparse function,
25242524
// it adds an extra newline that we don't want.
25252525
if (const auto *assignment{std::get_if<AssignmentStmt>(&x.u)}) {

0 commit comments

Comments
 (0)