Skip to content

Commit ad07f49

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#4045)
2 parents dca057f + cea3c6a commit ad07f49

File tree

136 files changed

+3853
-1303
lines changed

Some content is hidden

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

136 files changed

+3853
-1303
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "llvm/MC/MCSymbol.h"
3434
#include "llvm/Support/CommandLine.h"
3535
#include "llvm/Support/Error.h"
36+
#include "llvm/Support/FileSystem.h"
3637
#include "llvm/Support/Regex.h"
3738
#include <algorithm>
3839
#include <functional>
@@ -1632,19 +1633,29 @@ void BinaryContext::preprocessDWODebugInfo() {
16321633
DwarfUnit->getUnitDIE().find(
16331634
{dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
16341635
"");
1635-
SmallString<16> AbsolutePath;
1636+
SmallString<16> AbsolutePath(DWOName);
1637+
std::string DWOCompDir = DwarfUnit->getCompilationDir();
16361638
if (!opts::CompDirOverride.empty()) {
1637-
sys::path::append(AbsolutePath, opts::CompDirOverride);
1638-
sys::path::append(AbsolutePath, DWOName);
1639+
DWOCompDir = opts::CompDirOverride;
1640+
} else if (!sys::fs::exists(DWOCompDir) && sys::fs::exists(DWOName)) {
1641+
DWOCompDir = ".";
1642+
this->outs()
1643+
<< "BOLT-WARNING: Debug Fission: Debug Compilation Directory of "
1644+
<< DWOName
1645+
<< " does not exist. Relative path will be used to process .dwo "
1646+
"files.\n";
16391647
}
1648+
// Prevent failures when DWOName is already an absolute path.
1649+
sys::fs::make_absolute(DWOCompDir, AbsolutePath);
16401650
DWARFUnit *DWOCU =
16411651
DwarfUnit->getNonSkeletonUnitDIE(false, AbsolutePath).getDwarfUnit();
16421652
if (!DWOCU->isDWOUnit()) {
16431653
this->outs()
16441654
<< "BOLT-WARNING: Debug Fission: DWO debug information for "
16451655
<< DWOName
16461656
<< " was not retrieved and won't be updated. Please check "
1647-
"relative path.\n";
1657+
"relative path or use '--comp-dir-override' to specify the base "
1658+
"location.\n";
16481659
continue;
16491660
}
16501661
DWOCUs[*DWOId] = DWOCU;

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,15 +1846,16 @@ void DWARFRewriter::writeDWOFiles(
18461846
}
18471847

18481848
std::string CompDir = CU.getCompilationDir();
1849+
SmallString<16> AbsolutePath(DWOName);
18491850

18501851
if (!opts::DwarfOutputPath.empty())
18511852
CompDir = opts::DwarfOutputPath.c_str();
18521853
else if (!opts::CompDirOverride.empty())
18531854
CompDir = opts::CompDirOverride;
1854-
1855-
SmallString<16> AbsolutePath;
1856-
sys::path::append(AbsolutePath, CompDir);
1857-
sys::path::append(AbsolutePath, DWOName);
1855+
else if (!sys::fs::exists(CompDir))
1856+
CompDir = ".";
1857+
// Prevent failures when DWOName is already an absolute path.
1858+
sys::fs::make_absolute(CompDir, AbsolutePath);
18581859

18591860
std::error_code EC;
18601861
std::unique_ptr<ToolOutputFile> TempOut =

bolt/test/dwo-name-retrieving.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Test DWO retrieval via relative path with a missing CompDir.
2+
## Also, verify no crash for an absolute DWOName path.
3+
4+
## The case where DWOName is a relative path, and debug compilation directory does not exist.
5+
# RUN: rm -rf %t && mkdir -p %t && cd %t
6+
# RUN: %clang %cflags -g -gsplit-dwarf -fdebug-compilation-dir=/path/does/not/exist %p/Inputs/hello.c -o main.exe
7+
# RUN: llvm-bolt %t/main.exe -o %t/main.exe.bolt -update-debug-sections 2>&1 | FileCheck %s -check-prefix=DWO-NAME-REL
8+
9+
# DWO-NAME-REL: BOLT-WARNING: Debug Fission: Debug Compilation Directory of main.exe-hello.dwo does not exist.
10+
# DWO-NAME-REL-NOT: Debug Fission: DWO debug information for
11+
12+
## The case where DWOName is a absolute path, and a dwp file is provided.
13+
# RUN: %clang %cflags -g -gsplit-dwarf %p/Inputs/hello.c -o %t/main.exe
14+
# RUN: llvm-dwp -e %t/main.exe -o %t/main.exe.dwp
15+
# RUN: llvm-bolt %t/main.exe -o %t/main.exe.bolt -update-debug-sections -dwp=%t/main.exe.dwp 2>&1 | FileCheck %s -check-prefix=DWO-NAME-ABS
16+
17+
# DWO-NAME-ABS-NOT: BOLT-WARNING: Debug Fission: Debug Compilation Directory of {{.*}}/main.exe-hello.dwo does not exist.
18+
# DWO-NAME-ABS-NOT: Debug Fission: DWO debug information for
19+
# DWO-NAME-ABS-NOT: Assertion `FD >= 0 && "File not yet open!"' failed.

clang/docs/APINotes.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ declaration kind), all of which are optional:
229229
- Name: vector
230230
SwiftConformsTo: Cxx.CxxSequence
231231

232+
:SwiftSafety:
233+
234+
Import a declaration as ``@safe`` or ``@unsafe`` to Swift.
235+
236+
::
237+
238+
Tags:
239+
- Name: UnsafeType
240+
SwiftSafety: unsafe
241+
- Name: span
242+
Methods:
243+
- Name: size
244+
SwiftSafety: safe
245+
232246
:Availability, AvailabilityMsg:
233247

234248
A value of "nonswift" is equivalent to ``NS_SWIFT_UNAVAILABLE``. A value of

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ implementation.
576576
| | | | Flang parser: https://github.com/llvm/llvm-project/pull/153807 |
577577
| | | | Flang sema: https://github.com/llvm/llvm-project/pull/154779 |
578578
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
579-
| variable-category on default clause | :part:`In Progress` | :none:`unclaimed` | |
579+
| variable-category on default clause | :good:`done` | :none:`unclaimed` | |
580580
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
581581
| Changes to omp_target_is_accessible | :part:`In Progress` | :part:`In Progress` | |
582582
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ Bug Fixes in This Version
562562
- Builtin elementwise operators now accept vector arguments that have different
563563
qualifiers on their elements. For example, vector of 4 ``const float`` values
564564
and vector of 4 ``float`` values. (#GH155405)
565+
- Fixed inconsistent shadow warnings for lambda capture of structured bindings.
566+
Previously, ``[val = val]`` (regular parameter) produced no warnings with ``-Wshadow``
567+
while ``[a = a]`` (where ``a`` is from ``auto [a, b] = std::make_pair(1, 2)``)
568+
incorrectly produced warnings. Both cases now consistently show no warnings with
569+
``-Wshadow`` and show uncaptured-local warnings with ``-Wshadow-all``. (#GH68605)
565570
- Fixed a failed assertion with a negative limit parameter value inside of
566571
``__has_embed``. (#GH157842)
567572

@@ -773,6 +778,7 @@ OpenMP Support
773778
- Allow array length to be omitted in array section subscript expression.
774779
- Fixed non-contiguous strided update in the ``omp target update`` directive with the ``from`` clause.
775780
- Properly handle array section/assumed-size array privatization in C/C++.
781+
- Added support for ``variable-category`` modifier in ``default clause``.
776782

777783
Improvements
778784
^^^^^^^^^^^^

clang/include/clang/APINotes/Types.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ enum class SwiftNewTypeKind {
4646
Enum,
4747
};
4848

49+
enum class SwiftSafetyKind { Unspecified, Safe, Unsafe, None };
50+
4951
/// Describes API notes data for any entity.
5052
///
5153
/// This is used as the base of all API notes.
@@ -71,13 +73,19 @@ class CommonEntityInfo {
7173
LLVM_PREFERRED_TYPE(bool)
7274
unsigned SwiftPrivate : 1;
7375

76+
LLVM_PREFERRED_TYPE(bool)
77+
unsigned SwiftSafetyAudited : 1;
78+
79+
LLVM_PREFERRED_TYPE(SwiftSafetyKind)
80+
unsigned SwiftSafety : 2;
81+
7482
public:
7583
/// Swift name of this entity.
7684
std::string SwiftName;
7785

7886
CommonEntityInfo()
7987
: Unavailable(0), UnavailableInSwift(0), SwiftPrivateSpecified(0),
80-
SwiftPrivate(0) {}
88+
SwiftPrivate(0), SwiftSafetyAudited(0), SwiftSafety(0) {}
8189

8290
std::optional<bool> isSwiftPrivate() const {
8391
return SwiftPrivateSpecified ? std::optional<bool>(SwiftPrivate)
@@ -89,6 +97,17 @@ class CommonEntityInfo {
8997
SwiftPrivate = Private.value_or(0);
9098
}
9199

100+
std::optional<SwiftSafetyKind> getSwiftSafety() const {
101+
return SwiftSafetyAudited ? std::optional<SwiftSafetyKind>(
102+
static_cast<SwiftSafetyKind>(SwiftSafety))
103+
: std::nullopt;
104+
}
105+
106+
void setSwiftSafety(SwiftSafetyKind Safety) {
107+
SwiftSafetyAudited = 1;
108+
SwiftSafety = static_cast<unsigned>(Safety);
109+
}
110+
92111
friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &);
93112

94113
CommonEntityInfo &operator|=(const CommonEntityInfo &RHS) {
@@ -108,6 +127,9 @@ class CommonEntityInfo {
108127
if (!SwiftPrivateSpecified)
109128
setSwiftPrivate(RHS.isSwiftPrivate());
110129

130+
if (!SwiftSafetyAudited && RHS.SwiftSafetyAudited)
131+
setSwiftSafety(*RHS.getSwiftSafety());
132+
111133
if (SwiftName.empty())
112134
SwiftName = RHS.SwiftName;
113135

@@ -123,7 +145,9 @@ inline bool operator==(const CommonEntityInfo &LHS,
123145
LHS.Unavailable == RHS.Unavailable &&
124146
LHS.UnavailableInSwift == RHS.UnavailableInSwift &&
125147
LHS.SwiftPrivateSpecified == RHS.SwiftPrivateSpecified &&
126-
LHS.SwiftPrivate == RHS.SwiftPrivate && LHS.SwiftName == RHS.SwiftName;
148+
LHS.SwiftPrivate == RHS.SwiftPrivate &&
149+
LHS.SwiftSafetyAudited == RHS.SwiftSafetyAudited &&
150+
LHS.SwiftSafety == RHS.SwiftSafety && LHS.SwiftName == RHS.SwiftName;
127151
}
128152

129153
inline bool operator!=(const CommonEntityInfo &LHS,

clang/include/clang/AST/OpenMPClause.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,12 @@ class OMPDefaultClause : public OMPClause {
12691269
/// Start location of the kind in source code.
12701270
SourceLocation KindKwLoc;
12711271

1272+
/// Variable-Category to indicate where Kind is applied
1273+
OpenMPDefaultClauseVariableCategory VC = OMPC_DEFAULT_VC_all;
1274+
1275+
/// Start location of Variable-Category
1276+
SourceLocation VCLoc;
1277+
12721278
/// Set kind of the clauses.
12731279
///
12741280
/// \param K Argument of clause.
@@ -1279,6 +1285,15 @@ class OMPDefaultClause : public OMPClause {
12791285
/// \param KLoc Argument location.
12801286
void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
12811287

1288+
/// Set Variable Category used with the Kind Clause (Default Modifier)
1289+
void setDefaultVariableCategory(OpenMPDefaultClauseVariableCategory VC) {
1290+
this->VC = VC;
1291+
}
1292+
1293+
void setDefaultVariableCategoryLocation(SourceLocation VCLoc) {
1294+
this->VCLoc = VCLoc;
1295+
}
1296+
12821297
public:
12831298
/// Build 'default' clause with argument \a A ('none' or 'shared').
12841299
///
@@ -1288,10 +1303,11 @@ class OMPDefaultClause : public OMPClause {
12881303
/// \param LParenLoc Location of '('.
12891304
/// \param EndLoc Ending location of the clause.
12901305
OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc,
1306+
OpenMPDefaultClauseVariableCategory VC, SourceLocation VCLoc,
12911307
SourceLocation StartLoc, SourceLocation LParenLoc,
12921308
SourceLocation EndLoc)
12931309
: OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc),
1294-
LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1310+
LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), VC(VC), VCLoc(VCLoc) {}
12951311

12961312
/// Build an empty clause.
12971313
OMPDefaultClause()
@@ -1310,6 +1326,10 @@ class OMPDefaultClause : public OMPClause {
13101326
/// Returns location of clause kind.
13111327
SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
13121328

1329+
OpenMPDefaultClauseVariableCategory getDefaultVC() const { return VC; }
1330+
1331+
SourceLocation getDefaultVCLoc() const { return VCLoc; }
1332+
13131333
child_range children() {
13141334
return child_range(child_iterator(), child_iterator());
13151335
}

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ let Features = "ssse3", Attributes = [NoThrow, Const, RequiredVectorWidth<128>]
312312

313313
let Features = "sse4.1", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
314314
def insertps128 : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant char)">;
315-
def pblendw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>, _Constant int)">;
316-
def blendpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant int)">;
317-
def blendps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant int)">;
318315
def packusdw128 : X86Builtin<"_Vector<8, short>(_Vector<4, int>, _Vector<4, int>)">;
319316
def roundps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Constant int)">;
320317
def roundss : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant int)">;
@@ -333,6 +330,9 @@ let Features = "sse4.1", Attributes = [NoThrow, Const, RequiredVectorWidth<128>]
333330
}
334331

335332
let Features = "sse4.1", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
333+
def pblendw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>, _Constant int)">;
334+
def blendpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant int)">;
335+
def blendps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant int)">;
336336
def blendvpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Vector<2, double>)">;
337337
def blendvps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Vector<4, float>)">;
338338
def pblendvb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Vector<16, char>)">;
@@ -469,8 +469,6 @@ let Features = "avx", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in
469469
def vpermilvarps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, int>)">;
470470
def vpermilvarpd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, long long int>)">;
471471
def vpermilvarps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, int>)">;
472-
def blendpd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Constant int)">;
473-
def blendps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant int)">;
474472
def shufpd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Constant int)">;
475473
def shufps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant int)">;
476474
def dpps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant char)">;
@@ -495,6 +493,8 @@ let Features = "avx", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in
495493
}
496494

497495
let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
496+
def blendpd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Constant int)">;
497+
def blendps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant int)">;
498498
def blendvpd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Vector<4, double>)">;
499499
def blendvps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Vector<8, float>)">;
500500
}
@@ -575,7 +575,6 @@ let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] i
575575
def packuswb256 : X86Builtin<"_Vector<32, char>(_Vector<16, short>, _Vector<16, short>)">;
576576
def packusdw256 : X86Builtin<"_Vector<16, short>(_Vector<8, int>, _Vector<8, int>)">;
577577
def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Constant int)">;
578-
def pblendw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>, _Constant int)">;
579578
def phaddw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
580579
def phaddd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
581580
def phaddsw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
@@ -604,8 +603,6 @@ let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] i
604603
def psrlw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<8, short>)">;
605604
def psrld256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<4, int>)">;
606605
def psrlq256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<2, long long int>)">;
607-
def pblendd128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>, _Constant int)">;
608-
def pblendd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>, _Constant int)">;
609606
def permvarsi256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
610607
def permdf256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Constant int)">;
611608
def permvarsf256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, int>)">;
@@ -619,6 +616,10 @@ let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWi
619616
def pavgb256 : X86Builtin<"_Vector<32, unsigned char>(_Vector<32, unsigned char>, _Vector<32, unsigned char>)">;
620617
def pavgw256 : X86Builtin<"_Vector<16, unsigned short>(_Vector<16, unsigned short>, _Vector<16, unsigned short>)">;
621618

619+
def pblendd128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>, _Constant int)">;
620+
def pblendd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>, _Constant int)">;
621+
def pblendw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>, _Constant int)">;
622+
622623
def pblendvb256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Vector<32, char>)">;
623624

624625
def pmuldq256 : X86Builtin<"_Vector<4, long long int>(_Vector<8, int>, _Vector<8, int>)">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11710,6 +11710,8 @@ def note_omp_default_dsa_none : Note<
1171011710
"explicit data sharing attribute requested here">;
1171111711
def note_omp_defaultmap_attr_none : Note<
1171211712
"explicit data sharing attribute, data mapping attribute, or is_device_ptr clause requested here">;
11713+
def err_omp_default_vc : Error<
11714+
"wrong variable category specified with modifier %0 in the default clause">;
1171311715
def err_omp_wrong_dsa : Error<
1171411716
"%0 variable cannot be %1">;
1171511717
def err_omp_variably_modified_type_not_supported : Error<

0 commit comments

Comments
 (0)