Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e12e0d3
[BOLT] Fix thread-safety of MarkRAStates (#165368)
bgergely0 Oct 28, 2025
50b9077
Added RecursiveMemoryEffects to ExecuteRegionOp (#164390)
ddubov100 Oct 28, 2025
e80dc27
[MLIR] Fix test after ptrtoaddr change
nikic Oct 28, 2025
c4040f2
[TSan] Fix warning when compiling with -Wmissing-designated-field-ini…
DanBlackwell Oct 28, 2025
1d7d26c
[InstCombine] Support ptrtoaddr of gep fold
nikic Oct 28, 2025
4678f16
[clangd] Fix regression regarding new line handling for hover/signatu…
tcottin Oct 28, 2025
e588c7f
[X86] Attempt to fold trunc(srl(load(p),amt) -> load(p+amt/8) (#165266)
RKSimon Oct 28, 2025
44cb8c1
[lit] Fix to make "RUN: env PATH=..." work as intended (#165308)
bjope Oct 28, 2025
ec55aa4
[lldb][test] When an external stdlib is specified do not link to the …
da-viper Oct 28, 2025
cc22c9c
Revert "[nsan] More unit tests for `float128`. (#165248)" (#165391)
legrosbuffle Oct 28, 2025
a847134
[AbstractCallSite] Handle Indirect Calls Properly (#163003)
Camsyn Oct 28, 2025
f162488
[NFC][Clang] Regenerate CHECKs - CodeGen/AArch64/neon-across.c
paulwalker-arm Oct 28, 2025
29c830c
[test][DebugInfo] Fix location of test build artifacts (#165349)
rupprecht Oct 28, 2025
566c731
[UTC] Indent switch cases (#165212)
Camsyn Oct 28, 2025
d30bd27
[mlir][complex] Fix exp accuracy (#164952)
nurmukhametov Oct 28, 2025
e5bb946
Bug fixes for ISelLowering for HVX (#164416)
fhossein-quic Oct 28, 2025
0621fd0
[libcxx] Optimize `rng::generate_n` for segmented iterators (#165280)
c8ef Oct 28, 2025
531fd45
[PPC] Set minimum of largest number of comparisons to use bit test fo…
scui-ibm Oct 28, 2025
a4950c4
Add switch_case.test to profcheck-xfail.txt (#165407)
mtrofin Oct 28, 2025
bfb54e8
[AArch64][SME] Disable tail calls for callees that require saving ZT0…
MacDue Oct 28, 2025
2aea02d
[Fuzzer][Test-Only] Increase runs for reduce-inputs.test (#165402)
DanBlackwell Oct 28, 2025
3172970
[Fuzzer][Test-Only] Re-enable fuzzer-ubsan.test on Darwin (#165403)
DanBlackwell Oct 28, 2025
90ef613
merge main into amd-staging
z1-cciauto Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bolt/include/bolt/Passes/MarkRAStates.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
#define BOLT_PASSES_MARK_RA_STATES

#include "bolt/Passes/BinaryPasses.h"
#include <mutex>

namespace llvm {
namespace bolt {

class MarkRAStates : public BinaryFunctionPass {
// setIgnored() is not thread-safe, but the pass is running on functions in
// parallel.
std::mutex IgnoreMutex;

public:
explicit MarkRAStates() : BinaryFunctionPass(false) {}

Expand Down
5 changes: 4 additions & 1 deletion bolt/lib/Passes/MarkRAStates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
// Not all functions have .cfi_negate_ra_state in them. But if one does,
// we expect psign/pauth instructions to have the hasNegateRAState
// annotation.
BF.setIgnored();
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
<< BF.getPrintName()
<< ": ptr sign/auth inst without .cfi_negate_ra_state\n";
std::lock_guard<std::mutex> Lock(IgnoreMutex);
BF.setIgnored();
return false;
}
}
Expand All @@ -67,6 +68,7 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
<< BF.getPrintName()
<< ": ptr signing inst encountered in Signed RA state\n";
std::lock_guard<std::mutex> Lock(IgnoreMutex);
BF.setIgnored();
return false;
}
Expand All @@ -80,6 +82,7 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
<< BF.getPrintName()
<< ": ptr authenticating inst encountered in Unsigned RA "
"state\n";
std::lock_guard<std::mutex> Lock(IgnoreMutex);
BF.setIgnored();
return false;
}
Expand Down
190 changes: 115 additions & 75 deletions clang-tools-extra/clangd/support/Markup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,60 +475,101 @@ std::string Block::asPlainText() const {
return llvm::StringRef(OS.str()).trim().str();
}

void Paragraph::renderNewlinesMarkdown(llvm::raw_ostream &OS,
llvm::StringRef ParagraphText) const {
llvm::StringRef Line, Rest;

for (std::tie(Line, Rest) = ParagraphText.ltrim("\n").rtrim().split('\n');
!(Line.empty() && Rest.empty());
std::tie(Line, Rest) = Rest.split('\n')) {

if (Line.empty()) {
// Blank lines are preserved in markdown.
OS << '\n';
continue;
}

OS << Line;

if (!Rest.empty() && isHardLineBreakAfter(Line, Rest, /*IsMarkdown=*/true))
// In markdown, 2 spaces before a line break forces a line break.
OS << " ";
OS << '\n';
}
}

void Paragraph::renderEscapedMarkdown(llvm::raw_ostream &OS) const {
bool NeedsSpace = false;
bool HasChunks = false;
std::string ParagraphText;
ParagraphText.reserve(EstimatedStringSize);
llvm::raw_string_ostream ParagraphTextOS(ParagraphText);
for (auto &C : Chunks) {
if (C.SpaceBefore || NeedsSpace)
OS << " ";
ParagraphTextOS << " ";
switch (C.Kind) {
case ChunkKind::PlainText:
OS << renderText(C.Contents, !HasChunks, /*EscapeMarkdown=*/true);
ParagraphTextOS << renderText(C.Contents, !HasChunks,
/*EscapeMarkdown=*/true);
break;
case ChunkKind::InlineCode:
OS << renderInlineBlock(C.Contents);
ParagraphTextOS << renderInlineBlock(C.Contents);
break;
case ChunkKind::Bold:
OS << renderText("**" + C.Contents + "**", !HasChunks,
/*EscapeMarkdown=*/true);
ParagraphTextOS << renderText("**" + C.Contents + "**", !HasChunks,
/*EscapeMarkdown=*/true);
break;
case ChunkKind::Emphasized:
OS << renderText("*" + C.Contents + "*", !HasChunks,
/*EscapeMarkdown=*/true);
ParagraphTextOS << renderText("*" + C.Contents + "*", !HasChunks,
/*EscapeMarkdown=*/true);
break;
}
HasChunks = true;
NeedsSpace = C.SpaceAfter;
}

renderNewlinesMarkdown(OS, ParagraphText);

// A paragraph in markdown is separated by a blank line.
OS << "\n\n";
}

void Paragraph::renderMarkdown(llvm::raw_ostream &OS) const {
bool NeedsSpace = false;
bool HasChunks = false;
std::string ParagraphText;
ParagraphText.reserve(EstimatedStringSize);
llvm::raw_string_ostream ParagraphTextOS(ParagraphText);
for (auto &C : Chunks) {
if (C.SpaceBefore || NeedsSpace)
OS << " ";
ParagraphTextOS << " ";
switch (C.Kind) {
case ChunkKind::PlainText:
OS << renderText(C.Contents, !HasChunks, /*EscapeMarkdown=*/false);
ParagraphTextOS << renderText(C.Contents, !HasChunks,
/*EscapeMarkdown=*/false);
break;
case ChunkKind::InlineCode:
OS << renderInlineBlock(C.Contents);
ParagraphTextOS << renderInlineBlock(C.Contents);
break;
case ChunkKind::Bold:
OS << "**" << renderText(C.Contents, !HasChunks, /*EscapeMarkdown=*/false)
<< "**";
ParagraphTextOS << "**"
<< renderText(C.Contents, !HasChunks,
/*EscapeMarkdown=*/false)
<< "**";
break;
case ChunkKind::Emphasized:
OS << "*" << renderText(C.Contents, !HasChunks, /*EscapeMarkdown=*/false)
<< "*";
ParagraphTextOS << "*"
<< renderText(C.Contents, !HasChunks,
/*EscapeMarkdown=*/false)
<< "*";
break;
}
HasChunks = true;
NeedsSpace = C.SpaceAfter;
}

renderNewlinesMarkdown(OS, ParagraphText);

// A paragraph in markdown is separated by a blank line.
OS << "\n\n";
}
Expand All @@ -537,8 +578,6 @@ std::unique_ptr<Block> Paragraph::clone() const {
return std::make_unique<Paragraph>(*this);
}

/// Choose a marker to delimit `Text` from a prioritized list of options.
/// This is more readable than escaping for plain-text.
llvm::StringRef Paragraph::chooseMarker(llvm::ArrayRef<llvm::StringRef> Options,
llvm::StringRef Text) const {
// Prefer a delimiter whose characters don't appear in the text.
Expand All @@ -548,23 +587,36 @@ llvm::StringRef Paragraph::chooseMarker(llvm::ArrayRef<llvm::StringRef> Options,
return Options.front();
}

bool Paragraph::punctuationIndicatesLineBreak(llvm::StringRef Line) const {
bool Paragraph::punctuationIndicatesLineBreak(llvm::StringRef Line,
bool IsMarkdown) const {
constexpr llvm::StringLiteral Punctuation = R"txt(.:,;!?)txt";

if (!IsMarkdown && Line.ends_with(" "))
return true;

Line = Line.rtrim();
return !Line.empty() && Punctuation.contains(Line.back());
}

bool Paragraph::isHardLineBreakIndicator(llvm::StringRef Rest) const {
bool Paragraph::isHardLineBreakIndicator(llvm::StringRef Rest,
bool IsMarkdown) const {
// Plaintext indicators:
// '-'/'*' md list, '@'/'\' documentation command, '>' md blockquote,
// '#' headings, '`' code blocks, two spaces (markdown force newline)
constexpr llvm::StringLiteral LinebreakIndicators = R"txt(-*@\>#`)txt";
// '#' headings, '`' code blocks
constexpr llvm::StringLiteral LinebreakIndicatorsPlainText =
R"txt(-*@\>#`)txt";
// Markdown indicators:
// Only '@' and '\' documentation commands/escaped markdown syntax.
constexpr llvm::StringLiteral LinebreakIndicatorsMarkdown = R"txt(@\)txt";

Rest = Rest.ltrim(" \t");
if (Rest.empty())
return false;

if (LinebreakIndicators.contains(Rest.front()))
if (IsMarkdown)
return LinebreakIndicatorsMarkdown.contains(Rest.front());

if (LinebreakIndicatorsPlainText.contains(Rest.front()))
return true;

if (llvm::isDigit(Rest.front())) {
Expand All @@ -575,64 +627,18 @@ bool Paragraph::isHardLineBreakIndicator(llvm::StringRef Rest) const {
return false;
}

bool Paragraph::isHardLineBreakAfter(llvm::StringRef Line,
llvm::StringRef Rest) const {
// In Markdown, 2 spaces before a line break forces a line break.
// Add a line break for plaintext in this case too.
bool Paragraph::isHardLineBreakAfter(llvm::StringRef Line, llvm::StringRef Rest,
bool IsMarkdown) const {
// Should we also consider whether Line is short?
return Line.ends_with(" ") || punctuationIndicatesLineBreak(Line) ||
isHardLineBreakIndicator(Rest);
return punctuationIndicatesLineBreak(Line, IsMarkdown) ||
isHardLineBreakIndicator(Rest, IsMarkdown);
}

void Paragraph::renderPlainText(llvm::raw_ostream &OS) const {
bool NeedsSpace = false;
std::string ConcatenatedText;
ConcatenatedText.reserve(EstimatedStringSize);

llvm::raw_string_ostream ConcatenatedOS(ConcatenatedText);

for (auto &C : Chunks) {

if (C.Kind == ChunkKind::PlainText) {
if (C.SpaceBefore || NeedsSpace)
ConcatenatedOS << ' ';

ConcatenatedOS << C.Contents;
NeedsSpace = llvm::isSpace(C.Contents.back()) || C.SpaceAfter;
continue;
}

if (C.SpaceBefore || NeedsSpace)
ConcatenatedOS << ' ';
llvm::StringRef Marker = "";
if (C.Preserve && C.Kind == ChunkKind::InlineCode)
Marker = chooseMarker({"`", "'", "\""}, C.Contents);
else if (C.Kind == ChunkKind::Bold)
Marker = "**";
else if (C.Kind == ChunkKind::Emphasized)
Marker = "*";
ConcatenatedOS << Marker << C.Contents << Marker;
NeedsSpace = C.SpaceAfter;
}

// We go through the contents line by line to handle the newlines
// and required spacing correctly.
//
// Newlines are added if:
// - the line ends with 2 spaces and a newline follows
// - the line ends with punctuation that indicates a line break (.:,;!?)
// - the next line starts with a hard line break indicator (-@>#`, or a digit
// followed by '.' or ')'), ignoring leading whitespace.
//
// Otherwise, newlines in the input are replaced with a single space.
//
// Multiple spaces are collapsed into a single space.
//
// Lines containing only whitespace are ignored.
void Paragraph::renderNewlinesPlaintext(llvm::raw_ostream &OS,
llvm::StringRef ParagraphText) const {
llvm::StringRef Line, Rest;

for (std::tie(Line, Rest) =
llvm::StringRef(ConcatenatedText).trim().split('\n');
for (std::tie(Line, Rest) = ParagraphText.trim().split('\n');
!(Line.empty() && Rest.empty());
std::tie(Line, Rest) = Rest.split('\n')) {

Expand All @@ -653,14 +659,48 @@ void Paragraph::renderPlainText(llvm::raw_ostream &OS) const {

OS << canonicalizeSpaces(Line);

if (isHardLineBreakAfter(Line, Rest))
if (isHardLineBreakAfter(Line, Rest, /*IsMarkdown=*/false))
OS << '\n';
else if (!Rest.empty())
// Since we removed any trailing whitespace from the input using trim(),
// we know that the next line contains non-whitespace characters.
// Therefore, we can add a space without worrying about trailing spaces.
OS << ' ';
}
}

void Paragraph::renderPlainText(llvm::raw_ostream &OS) const {
bool NeedsSpace = false;
std::string ParagraphText;
ParagraphText.reserve(EstimatedStringSize);

llvm::raw_string_ostream ParagraphTextOS(ParagraphText);

for (auto &C : Chunks) {

if (C.Kind == ChunkKind::PlainText) {
if (C.SpaceBefore || NeedsSpace)
ParagraphTextOS << ' ';

ParagraphTextOS << C.Contents;
NeedsSpace = llvm::isSpace(C.Contents.back()) || C.SpaceAfter;
continue;
}

if (C.SpaceBefore || NeedsSpace)
ParagraphTextOS << ' ';
llvm::StringRef Marker = "";
if (C.Preserve && C.Kind == ChunkKind::InlineCode)
Marker = chooseMarker({"`", "'", "\""}, C.Contents);
else if (C.Kind == ChunkKind::Bold)
Marker = "**";
else if (C.Kind == ChunkKind::Emphasized)
Marker = "*";
ParagraphTextOS << Marker << C.Contents << Marker;
NeedsSpace = C.SpaceAfter;
}

renderNewlinesPlaintext(OS, ParagraphText);

// Paragraphs are separated by a blank line.
OS << "\n\n";
Expand Down
Loading