Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
53a65ba
[VPlan] Don't look up recipe for IV step via RecipeBuilder. (NFC)
fhahn Nov 12, 2025
71763a5
[clang] Extract `CompilerInvocation::visitPaths()` (#167420)
jansvoboda11 Nov 12, 2025
b6bcfde
[VPlan] Get opcode & type from recipe in adjustRecipesForReduction (NFC)
fhahn Nov 12, 2025
bdf3f24
[mlir][NVVM] Add support for barrier0-reduction operation (#167036)
clementval Nov 12, 2025
2e489f7
CodeGen: Fix CodeView crashes with empty llvm.dbg.cu (#163286)
arsenm Nov 12, 2025
342bf57
[LifetimeSafety] Ignore parentheses when tracking expressions (#167245)
usx95 Nov 12, 2025
4b05581
[AMDGPU] Regenerate gfx1250 wmma MC test. NFC (#167773)
rampitec Nov 12, 2025
dbf77e4
[utils] revamp options controlling lit's output (#167192)
hnrklssn Nov 12, 2025
a01a921
[ARM] Prevent stack argument overwrite during tail calls (#166492)
dtellenbach Nov 12, 2025
18d4da2
Add the ability to exempt callees from the misc-coroutine-hostile-rai…
higher-performance Nov 12, 2025
8c0dadf
[libc] allow UnitTest suite to be compiled on darwin (#166062)
bojle Nov 12, 2025
500e6d8
[AMDGPU] Change encoding of gfx1250 ld_scale (#167777)
rampitec Nov 13, 2025
fa417d7
[libclc] Fix floating-point __clc_atomic_store/exchange cast mismatch…
wenju-he Nov 13, 2025
141c2bf
[ASan][Windows] Add new instruction sizes (#167734)
boomanaiden154 Nov 13, 2025
897cc3e
[lldb][NFC] Remove plugin headers from Module (#167789)
bulbazord Nov 13, 2025
45d5e7b
[lldb][NFC] Mark ValueObject library with NO_PLUGIN_DEPENDENCIES (#16…
bulbazord Nov 13, 2025
196c2ec
Allow this test to run on read-only file systems. (#167791)
Sterling-Augustine Nov 13, 2025
18f29a5
[ARM] Fix not saving FP when required to in frame-pointer=non-leaf. (…
aemerson Nov 13, 2025
8f90716
[CIR] Upstream `AddressSpace` conversions support (#161212)
RiverDave Nov 13, 2025
4b805e1
[X86] Remove Redundant memset Calls
boomanaiden154 Nov 13, 2025
6121826
[utils] remove flakiness in verbosity.py test case (#167801)
hnrklssn Nov 13, 2025
3cda32d
[clang] [Serialization] No transitive change for MacroID and Preproce…
ChuanqiXu9 Nov 13, 2025
0bba1e7
Reland yet again: [mlir] Add FP software implementation lowering pass…
makslevental Nov 13, 2025
769c1ef
[ASan] Fix forward 141c2b
boomanaiden154 Nov 13, 2025
acb798e
Revert "[X86] Remove Redundant memset Calls"
boomanaiden154 Nov 13, 2025
622d52d
clang: Only prevent hip driver test from running on windows (#167623)
arsenm Nov 13, 2025
329dec9
[MLIR] Add reduction interface with tester to mlir-reduce (#166096)
aidint Nov 13, 2025
c764ee6
[RISCV] Remove custom legalization of v2i16/v4i8 loads for P extensio…
topperc Nov 13, 2025
d4e9982
[AMDGPU] Document meaning of alignment of buffer fat pointers, intrin…
krzysz00 Nov 13, 2025
73e70e0
[mlir][linalg] Fix Linalg runtime verification test (#167814)
matthias-springer Nov 13, 2025
316ccf2
merge main into amd-staging
z1-cciauto Nov 13, 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
10 changes: 8 additions & 2 deletions clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ CoroutineHostileRAIICheck::CoroutineHostileRAIICheck(StringRef Name,
RAIITypesList(utils::options::parseStringList(
Options.get("RAIITypesList", "std::lock_guard;std::scoped_lock"))),
AllowedAwaitablesList(utils::options::parseStringList(
Options.get("AllowedAwaitablesList", ""))) {}
Options.get("AllowedAwaitablesList", ""))),
AllowedCallees(
utils::options::parseStringList(Options.get("AllowedCallees", ""))) {}

void CoroutineHostileRAIICheck::registerMatchers(MatchFinder *Finder) {
// A suspension happens with co_await or co_yield.
auto ScopedLockable = varDecl(hasType(hasCanonicalType(hasDeclaration(
hasAttr(attr::Kind::ScopedLockable)))))
.bind("scoped-lockable");
auto OtherRAII = varDecl(typeWithNameIn(RAIITypesList)).bind("raii");
auto AllowedSuspend = awaitable(typeWithNameIn(AllowedAwaitablesList));
auto AllowedSuspend = awaitable(
anyOf(typeWithNameIn(AllowedAwaitablesList),
callExpr(callee(functionDecl(hasAnyName(AllowedCallees))))));
Finder->addMatcher(
expr(anyOf(coawaitExpr(unless(AllowedSuspend)), coyieldExpr()),
forEachPrevStmt(
Expand Down Expand Up @@ -111,5 +115,7 @@ void CoroutineHostileRAIICheck::storeOptions(
utils::options::serializeStringList(RAIITypesList));
Options.store(Opts, "SafeAwaitableList",
utils::options::serializeStringList(AllowedAwaitablesList));
Options.store(Opts, "SafeCallees",
utils::options::serializeStringList(AllowedCallees));
}
} // namespace clang::tidy::misc
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class CoroutineHostileRAIICheck : public ClangTidyCheck {
// List of fully qualified awaitable types which are considered safe to
// co_await.
std::vector<StringRef> AllowedAwaitablesList;
// List of callees whose return values are considered safe to directly
// co_await.
std::vector<StringRef> AllowedCallees;
};

} // namespace clang::tidy::misc
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ Changes in existing checks
positives on return of non-const pointer and fix false positives on
pointer-to-member operator.

- Improved :doc:`misc-coroutine-hostile-raii
<clang-tidy/checks/misc/coroutine-hostile-raii>` check by adding the option
`AllowedCallees`, that allows exempting safely awaitable callees from the
check.

- Improved :doc:`misc-header-include-cycle
<clang-tidy/checks/misc/header-include-cycle>` check performance.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,23 @@ Options
Eg: `my::safe::awaitable;other::awaitable`
Default is an empty string.

.. option:: AllowedCallees

A semicolon-separated list of callee function names which can
be safely awaited while having hostile RAII objects in scope.
Example usage:

.. code-block:: c++

// Consider option AllowedCallees = "noop"
task noop() { co_return; }

task coro() {
// This persists across the co_await but is not flagged
// because the awaitable is considered safe to await on.
const std::lock_guard l(&mu_);
co_await noop();
}

Eg: `my::safe::await;other::await`
Default is an empty string.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// RUN: %check_clang_tidy -std=c++20 %s misc-coroutine-hostile-raii %t \
// RUN: -config="{CheckOptions: {\
// RUN: misc-coroutine-hostile-raii.RAIITypesList: 'my::Mutex; ::my::other::Mutex', \
// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 'safe::awaitable; ::transformable::awaitable' \
// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 'safe::awaitable; ::transformable::awaitable', \
// RUN: misc-coroutine-hostile-raii.AllowedCallees: 'safe::AwaitFunc; ::safe::Obj::AwaitMethod' \
// RUN: }}"

namespace std {
Expand Down Expand Up @@ -145,12 +146,18 @@ namespace safe {
void await_suspend(std::coroutine_handle<>) noexcept {}
void await_resume() noexcept {}
};
std::suspend_always AwaitFunc();
struct Obj {
std::suspend_always AwaitMethod();
};
} // namespace safe
ReturnObject RAIISafeSuspendTest() {
absl::Mutex a;
co_await safe::awaitable{};
using other = safe::awaitable;
co_await other{};
co_await safe::AwaitFunc();
co_await safe::Obj().AwaitMethod();
}

// ================================================================================
Expand Down
9 changes: 9 additions & 0 deletions clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCompare(ptr.getLoc(), cir::CmpOpKind::eq, ptr, nullPtr);
}

mlir::Value createAddrSpaceCast(mlir::Location loc, mlir::Value src,
mlir::Type newTy) {
return createCast(loc, cir::CastKind::address_space, src, newTy);
}

mlir::Value createAddrSpaceCast(mlir::Value src, mlir::Type newTy) {
return createAddrSpaceCast(src.getLoc(), src, newTy);
}

//===--------------------------------------------------------------------===//
// Binary Operators
//===--------------------------------------------------------------------===//
Expand Down
11 changes: 11 additions & 0 deletions clang/include/clang/CIR/Dialect/IR/CIRTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#ifndef CLANG_CIR_DIALECT_IR_CIRTYPES_H
#define CLANG_CIR_DIALECT_IR_CIRTYPES_H

#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Types.h"
#include "mlir/Interfaces/DataLayoutInterfaces.h"
#include "clang/Basic/AddressSpaces.h"
Expand All @@ -38,6 +40,15 @@ bool isValidFundamentalIntWidth(unsigned width);
/// void, or abstract types.
bool isSized(mlir::Type ty);

//===----------------------------------------------------------------------===//
// AddressSpace helpers
//===----------------------------------------------------------------------===//
cir::TargetAddressSpaceAttr toCIRTargetAddressSpace(mlir::MLIRContext &context,
clang::LangAS langAS);

bool isMatchingAddressSpace(cir::TargetAddressSpaceAttr cirAS,
clang::LangAS as);

} // namespace cir

//===----------------------------------------------------------------------===//
Expand Down
13 changes: 13 additions & 0 deletions clang/include/clang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ class CompilerInvocationBase {
}
/// @}

/// Visitation.
/// @{
/// Visits paths stored in the invocation. The callback may return true to
/// short-circuit the visitation, or return false to continue visiting.
void visitPaths(llvm::function_ref<bool(StringRef)> Callback) const;
/// @}

/// Command line generation.
/// @{
using StringAllocator = llvm::function_ref<const char *(const Twine &)>;
Expand Down Expand Up @@ -181,6 +188,12 @@ class CompilerInvocationBase {
/// This is a (less-efficient) wrapper over generateCC1CommandLine().
std::vector<std::string> getCC1CommandLine() const;

protected:
/// Visits paths stored in the invocation. This is generally unsafe to call
/// directly, and each sub-class need to ensure calling this doesn't violate
/// its invariants.
void visitPathsImpl(llvm::function_ref<bool(std::string &)> Predicate);

private:
/// Generate command line options from DiagnosticOptions.
static void GenerateDiagnosticArgs(const DiagnosticOptions &Opts,
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class FrontendInputFile {
/// Whether we're dealing with a 'system' input (vs. a 'user' input).
bool IsSystem = false;

friend class CompilerInvocationBase;

public:
FrontendInputFile() = default;
FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false)
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Serialization/ASTBitCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ struct UnsafeQualTypeDenseMapInfo {
};

/// An ID number that refers to a macro in an AST file.
using MacroID = uint32_t;
using MacroID = uint64_t;

/// A global ID number that refers to a macro in an AST file.
using GlobalMacroID = uint32_t;
using GlobalMacroID = uint64_t;

/// A local to a module ID number that refers to a macro in an
/// AST file.
using LocalMacroID = uint32_t;
using LocalMacroID = uint64_t;

/// The number of predefined macro IDs.
const unsigned int NUM_PREDEF_MACRO_IDS = 1;
Expand All @@ -179,7 +179,7 @@ using CXXCtorInitializersID = uint32_t;

/// An ID number that refers to an entity in the detailed
/// preprocessing record.
using PreprocessedEntityID = uint32_t;
using PreprocessedEntityID = uint64_t;

/// An ID number that refers to a submodule in a module file.
using SubmoduleID = uint32_t;
Expand Down
39 changes: 23 additions & 16 deletions clang/include/clang/Serialization/ASTReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,6 @@ class ASTReader
/// files.
llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;

using GlobalMacroMapType =
ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;

/// Mapping from global macro IDs to the module in which the
/// macro resides along with the offset that should be added to the
/// global macro ID to produce a local ID.
GlobalMacroMapType GlobalMacroMap;

/// A vector containing submodules that have already been loaded.
///
/// This vector is indexed by the Submodule ID (-1). NULL submodule entries
Expand Down Expand Up @@ -1655,18 +1647,16 @@ class ASTReader

/// Returns the first preprocessed entity ID that begins or ends after
/// \arg Loc.
serialization::PreprocessedEntityID
findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const;
unsigned findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const;

/// Find the next module that contains entities and return the ID
/// of the first entry.
///
/// \param SLocMapI points at a chunk of a module that contains no
/// preprocessed entities or the entities it contains are not the
/// ones we are looking for.
serialization::PreprocessedEntityID
findNextPreprocessedEntity(
GlobalSLocOffsetMapType::const_iterator SLocMapI) const;
unsigned findNextPreprocessedEntity(
GlobalSLocOffsetMapType::const_iterator SLocMapI) const;

/// Returns (ModuleFile, Local index) pair for \p GlobalIndex of a
/// preprocessed entity.
Expand Down Expand Up @@ -1748,6 +1738,14 @@ class ASTReader
std::pair<ModuleFile *, unsigned>
translateIdentifierIDToIndex(serialization::IdentifierID ID) const;

/// Translate an \param MacroID ID to the index of MacrosLoaded
/// array and the corresponding module file.
std::pair<ModuleFile *, unsigned>
translateMacroIDToIndex(serialization::MacroID ID) const;

unsigned translatePreprocessedEntityIDToIndex(
serialization::PreprocessedEntityID ID) const;

/// Translate an \param TypeID ID to the index of TypesLoaded
/// array and the corresponding module file.
std::pair<ModuleFile *, unsigned>
Expand Down Expand Up @@ -2163,6 +2161,14 @@ class ASTReader
LocalDeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M,
GlobalDeclID GlobalID);

/// Reads a macro ID from the given position in a record in the
/// given module.
///
/// \returns The declaration ID read from the record, adjusted to a global
/// Macro ID.
serialization::MacroID
ReadMacroID(ModuleFile &F, const RecordDataImpl &Record, unsigned &Idx);

/// Reads a declaration ID from the given position in a record in the
/// given module.
///
Expand Down Expand Up @@ -2388,7 +2394,8 @@ class ASTReader

/// Retrieve the global macro ID corresponding to the given local
/// ID within the given module file.
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID);
serialization::MacroID getGlobalMacroID(ModuleFile &M,
serialization::MacroID LocalID);

/// Read the source location entry with index ID.
bool ReadSLocEntry(int ID) override;
Expand Down Expand Up @@ -2572,8 +2579,8 @@ class ASTReader

/// Determine the global preprocessed entity ID that corresponds to
/// the given local ID within the given module.
serialization::PreprocessedEntityID
getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const;
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(
ModuleFile &M, serialization::PreprocessedEntityID LocalID) const;

/// Add a macro to deserialize its macro directive history.
///
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Serialization/ASTWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@ class ASTWriter : public ASTDeserializationListener,
void AddLookupOffsets(const LookupBlockOffsets &Offsets,
RecordDataImpl &Record);

/// Emit a reference to a macro.
void AddMacroRef(MacroInfo *MI, const IdentifierInfo *Name,
RecordDataImpl &Record);

/// Emit a reference to a declaration.
void AddDeclRef(const Decl *D, RecordDataImpl &Record);
// Emit a reference to a declaration if the declaration was emitted.
Expand Down
6 changes: 0 additions & 6 deletions clang/include/clang/Serialization/ModuleFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,6 @@ class ModuleFile {
/// Base macro ID for macros local to this module.
serialization::MacroID BaseMacroID = 0;

/// Remapping table for macro IDs in this module.
ContinuousRangeMap<uint32_t, int, 2> MacroRemap;

/// The offset of the start of the set of defined macros.
uint64_t MacroStartOffset = 0;

Expand All @@ -372,9 +369,6 @@ class ModuleFile {
/// this module.
serialization::PreprocessedEntityID BasePreprocessedEntityID = 0;

/// Remapping table for preprocessed entity IDs in this module.
ContinuousRangeMap<uint32_t, int, 2> PreprocessedEntityRemap;

const PPEntityOffset *PreprocessedEntityOffsets = nullptr;
unsigned NumPreprocessedEntities = 0;

Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Analysis/LifetimeSafety/Origins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Origin &OriginManager::addOrigin(OriginID ID, const clang::Expr &E) {

// TODO: Mark this method as const once we remove the call to getOrCreate.
OriginID OriginManager::get(const Expr &E) {
if (auto *ParenIgnored = E.IgnoreParens(); ParenIgnored != &E)
return get(*ParenIgnored);
auto It = ExprToOriginID.find(&E);
if (It != ExprToOriginID.end())
return It->second;
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/CIR/CodeGen/Address.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

#include "mlir/IR/Value.h"
#include "clang/AST/CharUnits.h"
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
#include "clang/CIR/Dialect/IR/CIRTypes.h"
#include "clang/CIR/MissingFeatures.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/Casting.h"

namespace clang::CIRGen {

Expand Down Expand Up @@ -114,6 +116,11 @@ class Address {
return elementType;
}

cir::TargetAddressSpaceAttr getAddressSpace() const {
auto ptrTy = mlir::dyn_cast<cir::PointerType>(getType());
return ptrTy.getAddrSpace();
}

clang::CharUnits getAlignment() const { return alignment; }

/// Get the operation which defines this address.
Expand Down
13 changes: 9 additions & 4 deletions clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//

#include "CIRGenCall.h"
#include "CIRGenConstantEmitter.h"
#include "CIRGenFunction.h"
#include "CIRGenModule.h"
#include "CIRGenValue.h"
Expand All @@ -22,6 +21,7 @@
#include "clang/AST/Expr.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/Basic/Builtins.h"
#include "clang/CIR/Dialect/IR/CIRTypes.h"
#include "clang/CIR/MissingFeatures.h"
#include "llvm/Support/ErrorHandling.h"

Expand Down Expand Up @@ -193,11 +193,16 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
// default (e.g. in C / C++ auto vars are in the generic address space). At
// the AST level this is handled within CreateTempAlloca et al., but for the
// builtin / dynamic alloca we have to handle it here.
assert(!cir::MissingFeatures::addressSpace());

if (!cir::isMatchingAddressSpace(
getCIRAllocaAddressSpace(),
e->getType()->getPointeeType().getAddressSpace())) {
cgm.errorNYI(e->getSourceRange(), "Non-default address space for alloca");
}

// Bitcast the alloca to the expected type.
return RValue::get(
builder.createBitcast(allocaAddr, builder.getVoidPtrTy()));
return RValue::get(builder.createBitcast(
allocaAddr, builder.getVoidPtrTy(getCIRAllocaAddressSpace())));
}

case Builtin::BIcos:
Expand Down
Loading