Skip to content

Commit bb5bcae

Browse files
authored
Merge branch 'main' into users/el-ev/04-20-_recommit_constraintelim_simplify_cmp_after_uadd.sat_usub.sat_135603_
2 parents bf9f398 + 349dc34 commit bb5bcae

File tree

260 files changed

+3024
-2958
lines changed

Some content is hidden

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

260 files changed

+3024
-2958
lines changed

bolt/docs/BinaryAnalysis.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,6 @@ The following are current known cases of false negatives:
180180
[prototype branch](
181181
https://github.com/llvm/llvm-project/compare/main...kbeyls:llvm-project:bolt-gadget-scanner-prototype).
182182

183-
BOLT cannot currently handle functions with `cfi_negate_ra_state` correctly,
184-
i.e. any binaries built with `-mbranch-protection=pac-ret`. The scanner is meant
185-
to be used on specifically such binaries, so this is a major limitation! Work is
186-
going on in PR [#120064](https://github.com/llvm/llvm-project/pull/120064) to
187-
fix this.
188-
189183
## How to add your own binary analysis
190184

191185
_TODO: this section needs to be written. Ideally, we should have a simple

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ extern cl::opt<bool> StrictMode;
6565
extern cl::opt<bool> UpdateDebugSections;
6666
extern cl::opt<unsigned> Verbosity;
6767

68+
extern bool BinaryAnalysisMode;
69+
extern bool HeatmapMode;
6870
extern bool processAllFunctions();
6971

7072
static cl::opt<bool> CheckEncoding(
@@ -2760,13 +2762,19 @@ struct CFISnapshot {
27602762
}
27612763
case MCCFIInstruction::OpAdjustCfaOffset:
27622764
case MCCFIInstruction::OpWindowSave:
2763-
case MCCFIInstruction::OpNegateRAState:
27642765
case MCCFIInstruction::OpNegateRAStateWithPC:
27652766
case MCCFIInstruction::OpLLVMDefAspaceCfa:
27662767
case MCCFIInstruction::OpLabel:
27672768
case MCCFIInstruction::OpValOffset:
27682769
llvm_unreachable("unsupported CFI opcode");
27692770
break;
2771+
case MCCFIInstruction::OpNegateRAState:
2772+
if (!(opts::BinaryAnalysisMode || opts::HeatmapMode)) {
2773+
llvm_unreachable("BOLT-ERROR: binaries using pac-ret hardening (e.g. "
2774+
"as produced by '-mbranch-protection=pac-ret') are "
2775+
"currently not supported by BOLT.");
2776+
}
2777+
break;
27702778
case MCCFIInstruction::OpRememberState:
27712779
case MCCFIInstruction::OpRestoreState:
27722780
case MCCFIInstruction::OpGnuArgsSize:
@@ -2900,13 +2908,19 @@ struct CFISnapshotDiff : public CFISnapshot {
29002908
return CFAReg == Instr.getRegister() && CFAOffset == Instr.getOffset();
29012909
case MCCFIInstruction::OpAdjustCfaOffset:
29022910
case MCCFIInstruction::OpWindowSave:
2903-
case MCCFIInstruction::OpNegateRAState:
29042911
case MCCFIInstruction::OpNegateRAStateWithPC:
29052912
case MCCFIInstruction::OpLLVMDefAspaceCfa:
29062913
case MCCFIInstruction::OpLabel:
29072914
case MCCFIInstruction::OpValOffset:
29082915
llvm_unreachable("unsupported CFI opcode");
29092916
return false;
2917+
case MCCFIInstruction::OpNegateRAState:
2918+
if (!(opts::BinaryAnalysisMode || opts::HeatmapMode)) {
2919+
llvm_unreachable("BOLT-ERROR: binaries using pac-ret hardening (e.g. "
2920+
"as produced by '-mbranch-protection=pac-ret') are "
2921+
"currently not supported by BOLT.");
2922+
}
2923+
break;
29102924
case MCCFIInstruction::OpRememberState:
29112925
case MCCFIInstruction::OpRestoreState:
29122926
case MCCFIInstruction::OpGnuArgsSize:
@@ -3051,13 +3065,19 @@ BinaryFunction::unwindCFIState(int32_t FromState, int32_t ToState,
30513065
break;
30523066
case MCCFIInstruction::OpAdjustCfaOffset:
30533067
case MCCFIInstruction::OpWindowSave:
3054-
case MCCFIInstruction::OpNegateRAState:
30553068
case MCCFIInstruction::OpNegateRAStateWithPC:
30563069
case MCCFIInstruction::OpLLVMDefAspaceCfa:
30573070
case MCCFIInstruction::OpLabel:
30583071
case MCCFIInstruction::OpValOffset:
30593072
llvm_unreachable("unsupported CFI opcode");
30603073
break;
3074+
case MCCFIInstruction::OpNegateRAState:
3075+
if (!(opts::BinaryAnalysisMode || opts::HeatmapMode)) {
3076+
llvm_unreachable("BOLT-ERROR: binaries using pac-ret hardening (e.g. "
3077+
"as produced by '-mbranch-protection=pac-ret') are "
3078+
"currently not supported by BOLT.");
3079+
}
3080+
break;
30613081
case MCCFIInstruction::OpGnuArgsSize:
30623082
// do not affect CFI state
30633083
break;

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,29 +5195,6 @@ the configuration (without a prefix: ``Auto``).
51955195
Add a space in front of an Objective-C protocol list, i.e. use
51965196
``Foo <Protocol>`` instead of ``Foo<Protocol>``.
51975197

5198-
.. _OneLineFormatOffRegex:
5199-
5200-
**OneLineFormatOffRegex** (``String``) :versionbadge:`clang-format 21` :ref:`<OneLineFormatOffRegex>`
5201-
A regular expression that describes markers for turning formatting off for
5202-
one line. If it matches a comment that is the only token of a line,
5203-
clang-format skips the comment and the next line. Otherwise, clang-format
5204-
skips lines containing a matched token.
5205-
5206-
.. code-block:: c++
5207-
5208-
// OneLineFormatOffRegex: ^(// NOLINT|logger$)
5209-
// results in the output below:
5210-
int a;
5211-
int b ; // NOLINT
5212-
int c;
5213-
// NOLINTNEXTLINE
5214-
int d ;
5215-
int e;
5216-
s = "// NOLINT";
5217-
logger() ;
5218-
logger2();
5219-
my_logger();
5220-
52215198
.. _PPIndentWidth:
52225199

52235200
**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13` :ref:`<PPIndentWidth>`

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,6 @@ clang-format
720720
top of the file.
721721
- Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
722722
``enum`` enumerator lists.
723-
- Add ``OneLineFormatOffRegex`` option for turning formatting off for one line.
724723

725724
libclang
726725
--------

clang/include/clang/Basic/LangOptions.def

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,17 @@ BENIGN_ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contracti
347347
COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating point")
348348
BENIGN_LANGOPT(RoundingMath, 1, false, "Do not assume default floating-point rounding behavior")
349349
BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Default, "FP Exception Behavior Mode type")
350+
351+
#if defined(__clang__)
352+
// FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600
353+
#pragma clang diagnostic push
354+
#pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion"
355+
#endif
350356
BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 3, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic")
357+
#if defined(__clang__)
358+
#pragma clang diagnostic pop
359+
#endif
360+
351361
ENUM_LANGOPT(Float16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for Float16 arithmetic")
352362
ENUM_LANGOPT(BFloat16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for BFloat16 arithmetic")
353363
LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

clang/include/clang/Format/Format.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,27 +3654,6 @@ struct FormatStyle {
36543654
/// \version 3.7
36553655
bool ObjCSpaceBeforeProtocolList;
36563656

3657-
/// A regular expression that describes markers for turning formatting off for
3658-
/// one line. If it matches a comment that is the only token of a line,
3659-
/// clang-format skips the comment and the next line. Otherwise, clang-format
3660-
/// skips lines containing a matched token.
3661-
/// \code
3662-
/// // OneLineFormatOffRegex: ^(// NOLINT|logger$)
3663-
/// // results in the output below:
3664-
/// int a;
3665-
/// int b ; // NOLINT
3666-
/// int c;
3667-
/// // NOLINTNEXTLINE
3668-
/// int d ;
3669-
/// int e;
3670-
/// s = "// NOLINT";
3671-
/// logger() ;
3672-
/// logger2();
3673-
/// my_logger();
3674-
/// \endcode
3675-
/// \version 21
3676-
std::string OneLineFormatOffRegex;
3677-
36783657
/// Different ways to try to fit all constructor initializers on a line.
36793658
enum PackConstructorInitializersStyle : int8_t {
36803659
/// Always put each constructor initializer on its own line.
@@ -5420,7 +5399,6 @@ struct FormatStyle {
54205399
ObjCPropertyAttributeOrder == R.ObjCPropertyAttributeOrder &&
54215400
ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&
54225401
ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
5423-
OneLineFormatOffRegex == R.OneLineFormatOffRegex &&
54245402
PackConstructorInitializers == R.PackConstructorInitializers &&
54255403
PenaltyBreakAssignment == R.PenaltyBreakAssignment &&
54265404
PenaltyBreakBeforeFirstCallParameter ==

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class FactEntry : public CapabilityExpr {
119119
/// Exclusive or shared.
120120
LockKind LKind : 8;
121121

122-
// How it was acquired.
122+
/// How it was acquired.
123123
SourceKind Source : 8;
124124

125125
/// Where it was acquired.
@@ -1011,8 +1011,8 @@ class ScopedLockableFactEntry : public FactEntry {
10111011
SourceLocation loc, ThreadSafetyHandler *Handler) const {
10121012
if (FSet.findLock(FactMan, Cp)) {
10131013
FSet.removeLock(FactMan, Cp);
1014-
FSet.addLock(FactMan, std::make_unique<LockableFactEntry>(
1015-
!Cp, LK_Exclusive, loc));
1014+
FSet.addLock(FactMan,
1015+
std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
10161016
} else if (Handler) {
10171017
SourceLocation PrevLoc;
10181018
if (const FactEntry *Neg = FSet.findLock(FactMan, !Cp))

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,22 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
962962
Debugify.setOrigDIVerifyBugsReportFilePath(
963963
CodeGenOpts.DIBugsReportFilePath);
964964
Debugify.registerCallbacks(PIC, MAM);
965+
966+
#if LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING
967+
// If we're using debug location coverage tracking, mark all the
968+
// instructions coming out of the frontend without a DebugLoc as being
969+
// compiler-generated, to prevent both those instructions and new
970+
// instructions that inherit their location from being treated as
971+
// incorrectly empty locations.
972+
for (Function &F : *TheModule) {
973+
if (!F.getSubprogram())
974+
continue;
975+
for (BasicBlock &BB : F)
976+
for (Instruction &I : BB)
977+
if (!I.getDebugLoc())
978+
I.setDebugLoc(DebugLoc::getCompilerGenerated());
979+
}
980+
#endif
965981
}
966982
// Attempt to load pass plugins and register their callbacks with PB.
967983
for (auto &PluginFN : CodeGenOpts.PassPlugins) {

clang/lib/Format/Format.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,6 @@ template <> struct MappingTraits<FormatStyle> {
11001100
IO.mapOptional("ObjCSpaceAfterProperty", Style.ObjCSpaceAfterProperty);
11011101
IO.mapOptional("ObjCSpaceBeforeProtocolList",
11021102
Style.ObjCSpaceBeforeProtocolList);
1103-
IO.mapOptional("OneLineFormatOffRegex", Style.OneLineFormatOffRegex);
11041103
IO.mapOptional("PackConstructorInitializers",
11051104
Style.PackConstructorInitializers);
11061105
IO.mapOptional("PenaltyBreakAssignment", Style.PenaltyBreakAssignment);

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,43 +83,8 @@ FormatTokenLexer::FormatTokenLexer(
8383
ArrayRef<FormatToken *> FormatTokenLexer::lex() {
8484
assert(Tokens.empty());
8585
assert(FirstInLineIndex == 0);
86-
const llvm::Regex FormatOffRegex(Style.OneLineFormatOffRegex);
87-
enum { FO_None, FO_CurrentLine, FO_NextLine } FormatOff = FO_None;
8886
do {
8987
Tokens.push_back(getNextToken());
90-
auto &Tok = *Tokens.back();
91-
const auto NewlinesBefore = Tok.NewlinesBefore;
92-
switch (FormatOff) {
93-
case FO_CurrentLine:
94-
if (NewlinesBefore == 0)
95-
Tok.Finalized = true;
96-
else
97-
FormatOff = FO_None;
98-
break;
99-
case FO_NextLine:
100-
if (NewlinesBefore > 1) {
101-
FormatOff = FO_None;
102-
} else {
103-
Tok.Finalized = true;
104-
FormatOff = FO_CurrentLine;
105-
}
106-
break;
107-
default:
108-
if (!FormattingDisabled && FormatOffRegex.match(Tok.TokenText)) {
109-
if (Tok.is(tok::comment) &&
110-
(NewlinesBefore > 0 || &Tok == Tokens.front())) {
111-
Tok.Finalized = true;
112-
FormatOff = FO_NextLine;
113-
} else {
114-
for (auto *Token : reverse(Tokens)) {
115-
Token->Finalized = true;
116-
if (Token->NewlinesBefore > 0)
117-
break;
118-
}
119-
FormatOff = FO_CurrentLine;
120-
}
121-
}
122-
}
12388
if (Style.isJavaScript()) {
12489
tryParseJSRegexLiteral();
12590
handleTemplateStrings();

0 commit comments

Comments
 (0)