Skip to content

Commit ea051e2

Browse files
authored
Merge branch 'main' into bugfix
2 parents 36bfc12 + 03c356c commit ea051e2

Some content is hidden

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

50 files changed

+788
-187
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/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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ OpenMP Support
521521
- Allow array length to be omitted in array section subscript expression.
522522
- Fixed non-contiguous strided update in the ``omp target update`` directive with the ``from`` clause.
523523
- Properly handle array section/assumed-size array privatization in C/C++.
524+
- Added support for ``variable-category`` modifier in ``default clause``.
524525

525526
Improvements
526527
^^^^^^^^^^^^

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/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11714,6 +11714,8 @@ def note_omp_default_dsa_none : Note<
1171411714
"explicit data sharing attribute requested here">;
1171511715
def note_omp_defaultmap_attr_none : Note<
1171611716
"explicit data sharing attribute, data mapping attribute, or is_device_ptr clause requested here">;
11717+
def err_omp_default_vc : Error<
11718+
"wrong variable category specified with modifier %0 in the default clause">;
1171711719
def err_omp_wrong_dsa : Error<
1171811720
"%0 variable cannot be %1">;
1171911721
def err_omp_variably_modified_type_not_supported : Error<

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#ifndef OPENMP_DIST_SCHEDULE_KIND
3636
#define OPENMP_DIST_SCHEDULE_KIND(Name)
3737
#endif
38+
#ifndef OPENMP_DEFAULT_VARIABLE_CATEGORY
39+
#define OPENMP_DEFAULT_VARIABLE_CATEGORY(Name)
40+
#endif
3841
#ifndef OPENMP_DEFAULTMAP_KIND
3942
#define OPENMP_DEFAULTMAP_KIND(Name)
4043
#endif
@@ -112,6 +115,13 @@ OPENMP_SCHEDULE_MODIFIER(simd)
112115
OPENMP_DEVICE_MODIFIER(ancestor)
113116
OPENMP_DEVICE_MODIFIER(device_num)
114117

118+
// Variable-category attributes for 'default' clause.
119+
OPENMP_DEFAULT_VARIABLE_CATEGORY(aggregate)
120+
OPENMP_DEFAULT_VARIABLE_CATEGORY(all)
121+
OPENMP_DEFAULT_VARIABLE_CATEGORY(allocatable)
122+
OPENMP_DEFAULT_VARIABLE_CATEGORY(pointer)
123+
OPENMP_DEFAULT_VARIABLE_CATEGORY(scalar)
124+
115125
// Static attributes for 'defaultmap' clause.
116126
OPENMP_DEFAULTMAP_KIND(scalar)
117127
OPENMP_DEFAULTMAP_KIND(aggregate)
@@ -267,6 +277,7 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
267277
#undef OPENMP_MAP_MODIFIER_KIND
268278
#undef OPENMP_MOTION_MODIFIER_KIND
269279
#undef OPENMP_DIST_SCHEDULE_KIND
280+
#undef OPENMP_DEFAULT_VARIABLE_CATEGORY
270281
#undef OPENMP_DEFAULTMAP_KIND
271282
#undef OPENMP_DEFAULTMAP_MODIFIER
272283
#undef OPENMP_DOACROSS_MODIFIER

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ enum OpenMPDistScheduleClauseKind {
107107
OMPC_DIST_SCHEDULE_unknown
108108
};
109109

110+
/// OpenMP variable-category for 'default' clause.
111+
enum OpenMPDefaultClauseVariableCategory {
112+
#define OPENMP_DEFAULT_VARIABLE_CATEGORY(Name) OMPC_DEFAULT_VC_##Name,
113+
#include "clang/Basic/OpenMPKinds.def"
114+
OMPC_DEFAULT_VC_unknown
115+
};
116+
110117
/// OpenMP attributes for 'defaultmap' clause.
111118
enum OpenMPDefaultmapClauseKind {
112119
#define OPENMP_DEFAULTMAP_KIND(Name) \
@@ -257,6 +264,10 @@ struct OMPInteropInfo final {
257264
llvm::SmallVector<Expr *, 4> PreferTypes;
258265
};
259266

267+
OpenMPDefaultClauseVariableCategory
268+
getOpenMPDefaultVariableCategory(StringRef Str, const LangOptions &LangOpts);
269+
const char *getOpenMPDefaultVariableCategoryName(unsigned VC);
270+
260271
unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str,
261272
const LangOptions &LangOpts);
262273
const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,11 @@ class SemaOpenMP : public SemaBase {
951951
SourceLocation LParenLoc,
952952
SourceLocation EndLoc);
953953
/// Called on well-formed 'default' clause.
954-
OMPClause *ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind,
955-
SourceLocation KindLoc,
956-
SourceLocation StartLoc,
957-
SourceLocation LParenLoc,
958-
SourceLocation EndLoc);
954+
OMPClause *
955+
ActOnOpenMPDefaultClause(llvm::omp::DefaultKind M, SourceLocation MLoc,
956+
OpenMPDefaultClauseVariableCategory VCKind,
957+
SourceLocation VCKindLoc, SourceLocation StartLoc,
958+
SourceLocation LParenLoc, SourceLocation EndLoc);
959959
/// Called on well-formed 'proc_bind' clause.
960960
OMPClause *ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind,
961961
SourceLocation KindLoc,

0 commit comments

Comments
 (0)