Skip to content

Commit 788e6f7

Browse files
authored
Merge branch 'main' into clang-omp-allocate-npe-fix
2 parents f2397d1 + 04320c0 commit 788e6f7

File tree

307 files changed

+6191
-1857
lines changed

Some content is hidden

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

307 files changed

+6191
-1857
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,8 @@ class MCPlusBuilder {
22162216
}
22172217

22182218
/// Print each annotation attached to \p Inst.
2219-
void printAnnotations(const MCInst &Inst, raw_ostream &OS) const;
2219+
void printAnnotations(const MCInst &Inst, raw_ostream &OS,
2220+
bool PrintMemData = false) const;
22202221

22212222
/// Remove annotation with a given \p Index.
22222223
///

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ void BinaryContext::printInstruction(raw_ostream &OS, const MCInst &Instruction,
20442044
if (MCSymbol *Label = MIB->getInstLabel(Instruction))
20452045
OS << " # Label: " << *Label;
20462046

2047-
MIB->printAnnotations(Instruction, OS);
2047+
MIB->printAnnotations(Instruction, OS, PrintMemData || opts::PrintMemData);
20482048

20492049
if (opts::PrintDebugInfo)
20502050
printDebugInfo(OS, Instruction, Function, DwCtx.get());

bolt/lib/Core/MCPlusBuilder.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ void MCPlusBuilder::stripAnnotations(MCInst &Inst, bool KeepTC) const {
378378
setTailCall(Inst);
379379
}
380380

381-
void MCPlusBuilder::printAnnotations(const MCInst &Inst,
382-
raw_ostream &OS) const {
381+
void MCPlusBuilder::printAnnotations(const MCInst &Inst, raw_ostream &OS,
382+
bool PrintMemData) const {
383383
std::optional<unsigned> FirstAnnotationOp = getFirstAnnotationOpIndex(Inst);
384384
if (!FirstAnnotationOp)
385385
return;
@@ -390,7 +390,11 @@ void MCPlusBuilder::printAnnotations(const MCInst &Inst,
390390
const int64_t Value = extractAnnotationValue(Imm);
391391
const auto *Annotation = reinterpret_cast<const MCAnnotation *>(Value);
392392
if (Index >= MCAnnotation::kGeneric) {
393-
OS << " # " << AnnotationNames[Index - MCAnnotation::kGeneric] << ": ";
393+
std::string AnnotationName =
394+
AnnotationNames[Index - MCAnnotation::kGeneric];
395+
if (!PrintMemData && AnnotationName == "MemoryAccessProfile")
396+
continue;
397+
OS << " # " << AnnotationName << ": ";
394398
Annotation->print(OS);
395399
}
396400
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Check that --print-mem-data option works properly in llvm-bolt
2+
3+
# RUN: split-file %s %t
4+
# RUN: %clang %cflags -fPIC -pie %t/main.s -o %t.exe -nostdlib -Wl,-q
5+
# RUN: llvm-bolt %t.exe -o %t.bolt --print-mem-data=true --print-cfg \
6+
# RUN: --data %t/fdata | FileCheck %s -check-prefix=CHECK-PRINT
7+
# RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg \
8+
# RUN: --data %t/fdata | FileCheck %s -check-prefix=CHECK-DEFAULT
9+
10+
# CHECK-PRINT: ldr w2, [x1], #0x4 # MemoryAccessProfile: 7 total counts :
11+
# CHECK-PRINT-NEXT: { 0x123: 1 },
12+
# CHECK-PRINT-NEXT: { 0x456: 2 },
13+
# CHECK-PRINT-NEXT: { 0xabc: 4 }
14+
# CHECK-DEFAULT-NOT: MemoryAccessProfile
15+
16+
#--- main.s
17+
.text
18+
.align 4
19+
.global main
20+
.type main, %function
21+
main:
22+
sub sp, sp, #48
23+
add x1, sp, 8
24+
add x3, sp, 48
25+
mov w0, 0
26+
.L2:
27+
ldr w2, [x1], 4
28+
add w0, w0, w2
29+
cmp x1, x3
30+
bne .L2
31+
add sp, sp, 48
32+
ret
33+
.size main, .-main
34+
35+
# The three memory access data generated by the load at
36+
# offset 0x10 in the main.
37+
#--- fdata
38+
4 main 10 4 otherSym 123 1
39+
4 main 10 4 otherSym 456 2
40+
4 main 10 4 otherSym abc 4

clang/cmake/modules/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ include(FindPrefixFromConfig)
88
# the usual CMake convention seems to be ${Project}Targets.cmake.
99
set(CLANG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/clang" CACHE STRING
1010
"Path for CMake subdirectory for Clang (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/clang')")
11-
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
12-
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang")
1311

1412
# Keep this in sync with llvm/cmake/CMakeLists.txt!
1513
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
1614
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
1715
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
18-
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
19-
set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
16+
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_builddir "${LLVM_LIBRARY_DIR}")
17+
set(llvm_cmake_builddir "${llvm_builddir}/cmake/llvm")
18+
set(clang_cmake_builddir "${llvm_builddir}/cmake/clang")
2019

2120
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
2221
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,6 +5079,113 @@ the configuration (without a prefix: ``Auto``).
50795079

50805080
For example: TESTSUITE
50815081

5082+
.. _NumericLiteralCase:
5083+
5084+
**NumericLiteralCase** (``NumericLiteralCaseStyle``) :versionbadge:`clang-format 22` :ref:`<NumericLiteralCase>`
5085+
Capitalization style for numeric literals.
5086+
5087+
Nested configuration flags:
5088+
5089+
Separate control for each numeric literal component.
5090+
5091+
For example, the config below will leave exponent letters alone, reformat
5092+
hexadecimal digits in lowercase, reformat numeric literal prefixes in
5093+
uppercase, and reformat suffixes in lowercase.
5094+
5095+
.. code-block:: c++
5096+
5097+
NumericLiteralCase:
5098+
ExponentLetter: Leave
5099+
HexDigit: Lower
5100+
Prefix: Upper
5101+
Suffix: Lower
5102+
5103+
* ``NumericLiteralComponentStyle ExponentLetter``
5104+
Format floating point exponent separator letter case.
5105+
5106+
.. code-block:: c++
5107+
5108+
float a = 6.02e23 + 1.0E10; // Leave
5109+
float a = 6.02E23 + 1.0E10; // Upper
5110+
float a = 6.02e23 + 1.0e10; // Lower
5111+
5112+
Possible values:
5113+
5114+
* ``NLCS_Leave`` (in configuration: ``Leave``)
5115+
Leave this component of the literal as is.
5116+
5117+
* ``NLCS_Upper`` (in configuration: ``Upper``)
5118+
Format this component with uppercase characters.
5119+
5120+
* ``NLCS_Lower`` (in configuration: ``Lower``)
5121+
Format this component with lowercase characters.
5122+
5123+
5124+
* ``NumericLiteralComponentStyle HexDigit``
5125+
Format hexadecimal digit case.
5126+
5127+
.. code-block:: c++
5128+
5129+
a = 0xaBcDeF; // Leave
5130+
a = 0xABCDEF; // Upper
5131+
a = 0xabcdef; // Lower
5132+
5133+
Possible values:
5134+
5135+
* ``NLCS_Leave`` (in configuration: ``Leave``)
5136+
Leave this component of the literal as is.
5137+
5138+
* ``NLCS_Upper`` (in configuration: ``Upper``)
5139+
Format this component with uppercase characters.
5140+
5141+
* ``NLCS_Lower`` (in configuration: ``Lower``)
5142+
Format this component with lowercase characters.
5143+
5144+
5145+
* ``NumericLiteralComponentStyle Prefix``
5146+
Format integer prefix case.
5147+
5148+
.. code-block:: c++
5149+
5150+
a = 0XF0 | 0b1; // Leave
5151+
a = 0XF0 | 0B1; // Upper
5152+
a = 0xF0 | 0b1; // Lower
5153+
5154+
Possible values:
5155+
5156+
* ``NLCS_Leave`` (in configuration: ``Leave``)
5157+
Leave this component of the literal as is.
5158+
5159+
* ``NLCS_Upper`` (in configuration: ``Upper``)
5160+
Format this component with uppercase characters.
5161+
5162+
* ``NLCS_Lower`` (in configuration: ``Lower``)
5163+
Format this component with lowercase characters.
5164+
5165+
5166+
* ``NumericLiteralComponentStyle Suffix``
5167+
Format suffix case. This option excludes case-sensitive reserved
5168+
suffixes, such as ``min`` in C++.
5169+
5170+
.. code-block:: c++
5171+
5172+
a = 1uLL; // Leave
5173+
a = 1ULL; // Upper
5174+
a = 1ull; // Lower
5175+
5176+
Possible values:
5177+
5178+
* ``NLCS_Leave`` (in configuration: ``Leave``)
5179+
Leave this component of the literal as is.
5180+
5181+
* ``NLCS_Upper`` (in configuration: ``Upper``)
5182+
Format this component with uppercase characters.
5183+
5184+
* ``NLCS_Lower`` (in configuration: ``Lower``)
5185+
Format this component with lowercase characters.
5186+
5187+
5188+
50825189
.. _ObjCBinPackProtocolList:
50835190

50845191
**ObjCBinPackProtocolList** (``BinPackStyle``) :versionbadge:`clang-format 7` :ref:`<ObjCBinPackProtocolList>`

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ AST Matchers
468468
clang-format
469469
------------
470470
- Add ``SpaceInEmptyBraces`` option and set it to ``Always`` for WebKit style.
471+
- Add ``NumericLiteralCase`` option for enforcing character case in numeric
472+
literals.
471473

472474
libclang
473475
--------

clang/include/clang/Basic/arm_sme.td

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,10 @@ let SMETargetGuard = "sme2p1" in {
156156
////////////////////////////////////////////////////////////////////////////////
157157
// SME - Counting elements in a streaming vector
158158

159-
multiclass ZACount<string n_suffix> {
160-
def NAME : SInst<"sv" # n_suffix, "nv", "", MergeNone,
161-
"aarch64_sme_" # n_suffix,
162-
[IsOverloadNone, IsStreamingCompatible]>;
163-
}
164-
165-
defm SVCNTSB : ZACount<"cntsb">;
166-
defm SVCNTSH : ZACount<"cntsh">;
167-
defm SVCNTSW : ZACount<"cntsw">;
168-
defm SVCNTSD : ZACount<"cntsd">;
159+
def SVCNTSB : SInst<"svcntsb", "nv", "", MergeNone, "", [IsOverloadNone, IsStreamingCompatible]>;
160+
def SVCNTSH : SInst<"svcntsh", "nv", "", MergeNone, "", [IsOverloadNone, IsStreamingCompatible]>;
161+
def SVCNTSW : SInst<"svcntsw", "nv", "", MergeNone, "", [IsOverloadNone, IsStreamingCompatible]>;
162+
def SVCNTSD : SInst<"svcntsd", "nv", "", MergeNone, "aarch64_sme_cntsd", [IsOverloadNone, IsStreamingCompatible]>;
169163

170164
////////////////////////////////////////////////////////////////////////////////
171165
// SME - ADDHA/ADDVA

clang/include/clang/Format/Format.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,73 @@ struct FormatStyle {
35583558
/// \version 9
35593559
std::vector<std::string> NamespaceMacros;
35603560

3561+
/// Control over each component in a numeric literal.
3562+
enum NumericLiteralComponentStyle : int8_t {
3563+
/// Leave this component of the literal as is.
3564+
NLCS_Leave,
3565+
/// Format this component with uppercase characters.
3566+
NLCS_Upper,
3567+
/// Format this component with lowercase characters.
3568+
NLCS_Lower,
3569+
};
3570+
3571+
/// Separate control for each numeric literal component.
3572+
///
3573+
/// For example, the config below will leave exponent letters alone, reformat
3574+
/// hexadecimal digits in lowercase, reformat numeric literal prefixes in
3575+
/// uppercase, and reformat suffixes in lowercase.
3576+
/// \code
3577+
/// NumericLiteralCase:
3578+
/// ExponentLetter: Leave
3579+
/// HexDigit: Lower
3580+
/// Prefix: Upper
3581+
/// Suffix: Lower
3582+
/// \endcode
3583+
struct NumericLiteralCaseStyle {
3584+
/// Format floating point exponent separator letter case.
3585+
/// \code
3586+
/// float a = 6.02e23 + 1.0E10; // Leave
3587+
/// float a = 6.02E23 + 1.0E10; // Upper
3588+
/// float a = 6.02e23 + 1.0e10; // Lower
3589+
/// \endcode
3590+
NumericLiteralComponentStyle ExponentLetter;
3591+
/// Format hexadecimal digit case.
3592+
/// \code
3593+
/// a = 0xaBcDeF; // Leave
3594+
/// a = 0xABCDEF; // Upper
3595+
/// a = 0xabcdef; // Lower
3596+
/// \endcode
3597+
NumericLiteralComponentStyle HexDigit;
3598+
/// Format integer prefix case.
3599+
/// \code
3600+
/// a = 0XF0 | 0b1; // Leave
3601+
/// a = 0XF0 | 0B1; // Upper
3602+
/// a = 0xF0 | 0b1; // Lower
3603+
/// \endcode
3604+
NumericLiteralComponentStyle Prefix;
3605+
/// Format suffix case. This option excludes case-sensitive reserved
3606+
/// suffixes, such as ``min`` in C++.
3607+
/// \code
3608+
/// a = 1uLL; // Leave
3609+
/// a = 1ULL; // Upper
3610+
/// a = 1ull; // Lower
3611+
/// \endcode
3612+
NumericLiteralComponentStyle Suffix;
3613+
3614+
bool operator==(const NumericLiteralCaseStyle &R) const {
3615+
return ExponentLetter == R.ExponentLetter && HexDigit == R.HexDigit &&
3616+
Prefix == R.Prefix && Suffix == R.Suffix;
3617+
}
3618+
3619+
bool operator!=(const NumericLiteralCaseStyle &R) const {
3620+
return !(*this == R);
3621+
}
3622+
};
3623+
3624+
/// Capitalization style for numeric literals.
3625+
/// \version 22
3626+
NumericLiteralCaseStyle NumericLiteralCase;
3627+
35613628
/// Controls bin-packing Objective-C protocol conformance list
35623629
/// items into as few lines as possible when they go over ``ColumnLimit``.
35633630
///
@@ -5469,6 +5536,7 @@ struct FormatStyle {
54695536
MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep &&
54705537
NamespaceIndentation == R.NamespaceIndentation &&
54715538
NamespaceMacros == R.NamespaceMacros &&
5539+
NumericLiteralCase == R.NumericLiteralCase &&
54725540
ObjCBinPackProtocolList == R.ObjCBinPackProtocolList &&
54735541
ObjCBlockIndentWidth == R.ObjCBlockIndentWidth &&
54745542
ObjCBreakBeforeNestedBlockParam ==

clang/lib/AST/ASTImporter.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,15 +1745,13 @@ ExpectedType ASTNodeImporter::VisitTagType(const TagType *T) {
17451745
if (!ToDeclOrErr)
17461746
return ToDeclOrErr.takeError();
17471747

1748-
if (DeclForType->isUsed()) {
1749-
// If there is a definition of the 'OriginalDecl', it should be imported to
1750-
// have all information for the type in the "To" AST. (In some cases no
1751-
// other reference may exist to the definition decl and it would not be
1752-
// imported otherwise.)
1753-
Expected<TagDecl *> ToDefDeclOrErr = import(DeclForType->getDefinition());
1754-
if (!ToDefDeclOrErr)
1755-
return ToDefDeclOrErr.takeError();
1756-
}
1748+
// If there is a definition of the 'OriginalDecl', it should be imported to
1749+
// have all information for the type in the "To" AST. (In some cases no
1750+
// other reference may exist to the definition decl and it would not be
1751+
// imported otherwise.)
1752+
Expected<TagDecl *> ToDefDeclOrErr = import(DeclForType->getDefinition());
1753+
if (!ToDefDeclOrErr)
1754+
return ToDefDeclOrErr.takeError();
17571755

17581756
if (T->isCanonicalUnqualified())
17591757
return Importer.getToContext().getCanonicalTagType(*ToDeclOrErr);

0 commit comments

Comments
 (0)