Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d667528
[gn build] Port 2354dce21ab1 (#213803)
nico Aug 4, 2026
3cdc913
[gn build] Port f84bacf82a15 (#213804)
nico Aug 4, 2026
1d3ea0f
[ADT] Fix - gcc warning: buf may be used uninitialized [-Werror=maybe…
arun-thmn Aug 4, 2026
275c9ef
[Offload] Add `--kernel <name>` command to `llvm-gpu-loader` (#213738)
jhuber6 Aug 4, 2026
38146e8
[flang][cuda] Only register module variables defined in the current t…
wangzpgi Aug 4, 2026
04a123b
[OpenMP][Clang] Enable `ATTACH`-style maps for mappers. (#210213)
abhinavgaba Aug 4, 2026
eb50d87
[lit] Run builtin cat / diff in-process instead of spawning (#208024)
prasoon054 Aug 4, 2026
8f82ba2
Revert "clang: Use TargetID parsing from AMDGPUTargetParser" (#213824)
Kewen12 Aug 4, 2026
ff6d537
[RISCV] Pick correct lround libcall for fp128 (#213220)
ReVe1uv Aug 4, 2026
ac19ad6
[AMDGPU] Support partial and empty WWM pools for SGPR spills (#213491)
shiltian Aug 4, 2026
8145c05
[clang][bytecode] Add DeclOrExpr (#213686)
tbaederr Aug 4, 2026
f7eefa8
[NFC] Pre-commit a test case for a SimplifyCFG issue (#204957)
shiltian Aug 4, 2026
513a02e
[Offload] Save jit image (#212384)
jandrovins Aug 4, 2026
ed3d4a7
[lldb/Interpreter] Remove Interpreter's layering dependency on API (#…
medismailben Aug 4, 2026
1e9c8ce
[mlir][xegpu] Lower 1D vector transfers to scattered load/store (#213…
Jianhui-Li Aug 4, 2026
f914343
[SimplifyCFG] Do not thread branches into uncontrolled convergent reg…
shiltian Aug 4, 2026
73817e6
[WebAssembly] Add funclet bundle to thread local wrapper calls (#213826)
aheejin Aug 4, 2026
ecd6a18
[mlir][xegpu] Support batched matmul in VectorToXeGPU ContractionL…
Jianhui-Li Aug 4, 2026
8b18aa0
[RISCV] Reduce spill/reload pairs when Xqcilo extension is enabled (#…
quic-garvgupt Aug 4, 2026
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: 3 additions & 2 deletions clang/docs/OpenMPSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ implementation.
| device | support close modifier on map clause | {good}`done` | [D55719][D55719],[D55892][D55892] |
| device | teams construct on the host device | {good}`done` | r371553 |
| device | support non-contiguous array sections for target update | {good}`done` | [PR144635][PR144635] |
| device | pointer attachment | {part}`being repaired` | @abhinavgaba ([PR153683][PR153683]) |
| device | pointer attachment | {part}`being repaired` | @abhinavgaba ([PR153683][PR153683], [PR210213][PR210213]) |
| atomic | hints for the atomic construct | {good}`done` | [D51233][D51233] |
| base language | C11 support | {good}`done` | |
| base language | C++11/14/17 support | {good}`done` | |
Expand Down Expand Up @@ -386,7 +386,7 @@ implementation.
| dyn_groupprivate clause | {part}`partial` | {part}`In Progress` | C/C++: Host device support missing |
| loop flatten transformation | {none}`unclaimed` | {none}`unclaimed` | |
| loop grid/tile modifiers for sizes clause | {none}`unclaimed` | {none}`unclaimed` | |
| attach map-type modifier | {part}`In Progress` | {none}`unclaimed` | C/C++: @abhinavgaba; RT: @abhinavgaba ([PR149036][PR149036], [PR158370][PR158370]) |
| attach map-type modifier | {part}`In Progress` | {none}`unclaimed` | C/C++: @abhinavgaba; RT: @abhinavgaba ([PR149036][PR149036], [PR158370][PR158370], [PR210213][PR210213]) |
| need_device_ptr modifier for adjust_args clause | {part}`partial` | {none}`unclaimed` | Clang Parsing/Sema: [PR168905][PR168905] [PR169558][PR169558] |
| fallback modifier for use_device_ptr clause | {good}`done` | {none}`unclaimed` | Clang: @abhinavgaba ([PR170578][PR170578], [PR173931][PR173931]) RT: @abhinavgaba ([PR169603][PR169603]) |
| dims modifier for num_teams, thread_limit, and num_threads clauses | {part}`partial` | {part}`In Progress` | C/C++: @kevinsala ([PR206412]); Fortran: @skc7, @kparzysz, @mjklemm |
Expand Down Expand Up @@ -562,5 +562,6 @@ considered for standardization. Please post on the
[PR194168]: https://github.com/llvm/llvm-project/pull/194168
[PR195829]: https://github.com/llvm/llvm-project/pull/195829
[PR196431]: https://github.com/llvm/llvm-project/pull/196431
[PR210213]: https://github.com/llvm/llvm-project/pull/210213

[discourse forums (runtimes - openmp category)]: https://discourse.llvm.org/c/runtimes/openmp/35
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ features cannot lower the translation-unit ABI level;
`thread_limit` clauses for OpenMP 6.1 or later.
- Map-type-modifying modifiers applied to a list item with a user-defined mapper
are now propagated onto the maps the mapper expands to.
- Mapping of expressions with base-pointers through a user-defined mapper (e.g.
`map(s.p[0:n])`) now conforms to OpenMP's conditional pointer-attachment,
matching the behavior of such maps outside a mapper.

### SYCL Support

Expand Down
44 changes: 34 additions & 10 deletions clang/include/clang/Basic/TargetID.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,53 @@
#ifndef LLVM_CLANG_BASIC_TARGETID_H
#define LLVM_CLANG_BASIC_TARGETID_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/TargetParser/Triple.h"
#include <optional>
#include <string>
#include <utility>
#include <set>

namespace clang {

/// Get all feature strings that can be used in target ID for \p Processor.
/// Target ID is a processor name with optional feature strings
/// postfixed by a plus or minus sign delimited by colons, e.g.
/// gfx908:xnack+:sramecc-. Each processor have a limited
/// number of predefined features when showing up in a target ID.
llvm::SmallVector<llvm::StringRef, 4>
getAllPossibleTargetIDFeatures(const llvm::Triple &T,
llvm::StringRef Processor);

/// Get processor name from target ID.
/// Returns canonical processor name or empty if the processor name is invalid.
llvm::StringRef getProcessorFromTargetID(const llvm::Triple &T,
llvm::StringRef OffloadArch);

/// A device triple paired with a target ID (processor and feature modifiers)
/// for that triple, e.g. {amdgcn-amd-amdhsa, "gfx906:xnack+"}.
using TargetIDEntry = std::pair<const llvm::Triple &, llvm::StringRef>;
/// Parse a target ID to get processor and feature map.
/// Returns canonicalized processor name or std::nullopt if the target ID is
/// invalid. Returns target ID features in \p FeatureMap if it is not null
/// pointer. This function assumes \p OffloadArch is a valid target ID.
/// If the target ID contains feature+, map it to true.
/// If the target ID contains feature-, map it to false.
/// If the target ID does not contain a feature (default), do not map it.
std::optional<llvm::StringRef> parseTargetID(const llvm::Triple &T,
llvm::StringRef OffloadArch,
llvm::StringMap<bool> *FeatureMap);

/// Returns canonical target ID, assuming \p Processor is canonical and all
/// entries in \p Features are valid.
std::string getCanonicalTargetID(llvm::StringRef Processor,
const llvm::StringMap<bool> &Features);

/// Get the conflicted pair of target IDs for a compilation or a bundled code
/// object. Two entries conflict when they resolve to the same processor but
/// disagree on whether a feature (xnack/sramecc) is explicitly specified. If
/// there is no conflict, returns std::nullopt.
/// object, assuming \p TargetIDs are canonicalized. If there is no conflicts,
/// returns std::nullopt.
std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictTargetIDCombination(llvm::ArrayRef<TargetIDEntry> Entries);
getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs);

/// Check whether the provided target ID is compatible with the requested
/// target ID.
bool isCompatibleTargetID(llvm::StringRef Provided, llvm::StringRef Requested);

/// Sanitize a target ID string for use in a file name.
/// Replaces invalid characters (like ':') with safe characters (like '@').
Expand Down
20 changes: 10 additions & 10 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,7 @@ bool Compiler<Emitter>::visitCallArgs(ArrayRef<const Expr *> Args,
return false;
} else {

DeclTy Source = Arg;
DeclOrExpr Source = Arg;
if (FuncDecl) {
// Try to use the parameter declaration instead of the argument
// expression as a source.
Expand Down Expand Up @@ -5313,37 +5313,37 @@ bool Compiler<Emitter>::emitConst(const APSInt &Value, const Expr *E) {
}

template <class Emitter>
unsigned Compiler<Emitter>::allocateLocalPrimitive(DeclTy &&Src, PrimType Ty,
bool IsConst,
unsigned Compiler<Emitter>::allocateLocalPrimitive(DeclOrExpr &&Src,
PrimType Ty, bool IsConst,
bool IsVolatile,
ScopeKind SC) {
// FIXME: There are cases where Src.is<Expr*>() is wrong, e.g.
// FIXME: There are cases where Src.isExpr() is wrong, e.g.
// (int){12} in C. Consider using Expr::isTemporaryObject() instead
// or isa<MaterializeTemporaryExpr>().
Descriptor *D = P.createDescriptor(Src, Ty, nullptr, Descriptor::InlineDescMD,
IsConst, isa<const Expr *>(Src),
IsConst, Src.isExpr(),
/*IsMutable=*/false, IsVolatile);
D->IsConstexprUnknown = this->VariablesAreConstexprUnknown;
Scope::Local Local = this->createLocal(D);
if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>()))
if (auto *VD = Src.asValueDecl())
Locals.insert({VD, Local});
VarScope->addForScopeKind(Local, SC);
return Local.Offset;
}

template <class Emitter>
UnsignedOrNone Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
UnsignedOrNone Compiler<Emitter>::allocateLocal(DeclOrExpr &&Src, QualType Ty,
ScopeKind SC) {
const ValueDecl *Key = nullptr;
const Expr *Init = nullptr;
bool IsTemporary = false;
if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
if (auto *VD = Src.asValueDecl()) {
Key = VD;

if (const auto *VarD = dyn_cast<VarDecl>(VD))
Init = VarD->getInit();
}
if (auto *E = Src.dyn_cast<const Expr *>()) {
if (const auto *E = Src.asExpr()) {
IsTemporary = true;
if (Ty.isNull())
Ty = E->getType();
Expand Down Expand Up @@ -8704,7 +8704,7 @@ bool Compiler<Emitter>::emitDestructionPop(const Descriptor *Desc,
/// Create a dummy pointer for the given decl (or expr) and
/// push a pointer to it on the stack.
template <class Emitter>
bool Compiler<Emitter>::emitDummyPtr(const DeclTy &D, const Expr *E, bool CU) {
bool Compiler<Emitter>::emitDummyPtr(DeclOrExpr D, const Expr *E, bool CU) {
assert(!DiscardResult && "Should've been checked before");
unsigned DummyID = P.getOrCreateDummy(D, CU);

Expand Down
7 changes: 4 additions & 3 deletions clang/lib/AST/ByteCode/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define LLVM_CLANG_AST_INTERP_BYTECODEEXPRGEN_H

#include "ByteCodeEmitter.h"
#include "DeclOrExpr.h"
#include "EvalEmitter.h"
#include "Pointer.h"
#include "PrimType.h"
Expand Down Expand Up @@ -339,12 +340,12 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
bool Activate, bool IsOperatorCall);

/// Creates a local primitive value.
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,
unsigned allocateLocalPrimitive(DeclOrExpr &&Decl, PrimType Ty, bool IsConst,
bool IsVolatile = false,
ScopeKind SC = ScopeKind::Block);

/// Allocates a space storing a local given its type.
UnsignedOrNone allocateLocal(DeclTy &&Decl, QualType Ty = QualType(),
UnsignedOrNone allocateLocal(DeclOrExpr &&Decl, QualType Ty = QualType(),
ScopeKind = ScopeKind::Block);
UnsignedOrNone allocateTemporary(const Expr *E);

Expand Down Expand Up @@ -427,7 +428,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
const BinaryOperator *E);
bool emitRecordDestructionPop(const Record *R, SourceInfo Loc);
bool emitDestructionPop(const Descriptor *Desc, SourceInfo Loc);
bool emitDummyPtr(const DeclTy &D, const Expr *E, bool CU = false);
bool emitDummyPtr(DeclOrExpr D, const Expr *E, bool CU = false);
bool emitFloat(const APFloat &F, SourceInfo Info);
unsigned collectBaseOffset(const QualType BaseType,
const QualType DerivedType);
Expand Down
65 changes: 65 additions & 0 deletions clang/lib/AST/ByteCode/DeclOrExpr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//===------------------------- DeclOrExpr.h ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_AST_INTERP_DECLOREXPR_H
#define LLVM_CLANG_AST_INTERP_DECLOREXPR_H

#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/TypeBase.h"
#include "llvm/ADT/PointerUnion.h"

namespace clang {
namespace interp {

struct DeclOrExpr {
llvm::PointerUnion<const Decl *, const Expr *> V;

DeclOrExpr() : V(nullptr) {}
DeclOrExpr(std::nullptr_t) : V(nullptr) {}
DeclOrExpr(const Decl *VD) : V(VD) {}
DeclOrExpr(const Expr *E) : V(E) {}

bool isExpr() const { return isa_and_nonnull<const Expr *>(V); }
bool isDecl() const { return isa_and_nonnull<const Decl *>(V); }
bool isValueDecl() const { return isa_and_nonnull<ValueDecl>(asDecl()); }

const Expr *asExpr() const { return V.dyn_cast<const Expr *>(); }
const Decl *asDecl() const { return V.dyn_cast<const Decl *>(); }
const ValueDecl *asValueDecl() const {
return dyn_cast_if_present<ValueDecl>(asDecl());
}
const VarDecl *asVarDecl() const {
return dyn_cast_if_present<VarDecl>(asDecl());
}

const void *getOpaqueValue() const { return V.getOpaqueValue(); }

bool operator==(DeclOrExpr O) const { return O.V == V; }
bool operator!=(DeclOrExpr O) const { return O.V != V; }
explicit operator bool() const { return !V.isNull(); }

QualType getType() const {
if (const auto *VD = asValueDecl())
return VD->getType();
return asExpr()->getType();
}
};
static_assert(sizeof(DeclOrExpr) == sizeof(void *));

inline DeclOrExpr getSwappedBytes(DeclOrExpr F) { return F; }

inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, DeclOrExpr D) {
OS << D.getOpaqueValue();
return OS;
}

} // namespace interp
} // namespace clang

#endif
22 changes: 11 additions & 11 deletions clang/lib/AST/ByteCode/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static BlockDtorFn getDtorArrayPrim(PrimType Type) {
}

/// Primitives.
Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type,
Descriptor::Descriptor(DeclOrExpr D, const Type *SourceTy, PrimType Type,
MetadataSize MD, bool IsConst, bool IsTemporary,
bool IsMutable, bool IsVolatile)
: Source(D), SourceType(SourceTy), ElemSize(primSize(Type)), Size(ElemSize),
Expand All @@ -293,7 +293,7 @@ Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type,
}

/// Primitive arrays.
Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type,
Descriptor::Descriptor(DeclOrExpr D, const Type *SourceTy, PrimType Type,
MetadataSize MD, size_t NumElems, bool IsConst,
bool IsTemporary, bool IsMutable, bool IsVolatile)
: Source(D), SourceType(SourceTy), ElemSize(primSize(Type)),
Expand All @@ -307,7 +307,7 @@ Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type,
}

/// Primitive unknown-size arrays.
Descriptor::Descriptor(const DeclTy &D, PrimType Type, MetadataSize MD,
Descriptor::Descriptor(DeclOrExpr D, PrimType Type, MetadataSize MD,
bool IsTemporary, bool IsConst, UnknownSize)
: Source(D), ElemSize(primSize(Type)), Size(UnknownSizeMark),
MDSize(MD.value_or(0)),
Expand All @@ -319,7 +319,7 @@ Descriptor::Descriptor(const DeclTy &D, PrimType Type, MetadataSize MD,
}

/// Arrays of composite elements.
Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy,
Descriptor::Descriptor(DeclOrExpr D, const Type *SourceTy,
const Descriptor *Elem, MetadataSize MD,
unsigned NumElems, bool IsConst, bool IsTemporary,
bool IsMutable)
Expand All @@ -334,7 +334,7 @@ Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy,
}

/// Unknown-size arrays of composite elements.
Descriptor::Descriptor(const DeclTy &D, const Descriptor *Elem, MetadataSize MD,
Descriptor::Descriptor(DeclOrExpr D, const Descriptor *Elem, MetadataSize MD,
bool IsTemporary, UnknownSize)
: Source(D), ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),
Size(UnknownSizeMark), MDSize(MD.value_or(0)),
Expand All @@ -345,7 +345,7 @@ Descriptor::Descriptor(const DeclTy &D, const Descriptor *Elem, MetadataSize MD,
}

/// Composite records.
Descriptor::Descriptor(const DeclTy &D, const Record *R, MetadataSize MD,
Descriptor::Descriptor(DeclOrExpr D, const Record *R, MetadataSize MD,
bool IsConst, bool IsTemporary, bool IsMutable,
bool IsVolatile)
: Source(D), ElemSize(std::max<size_t>(alignof(void *), R->getFullSize())),
Expand All @@ -357,7 +357,7 @@ Descriptor::Descriptor(const DeclTy &D, const Record *R, MetadataSize MD,
}

/// Dummy.
Descriptor::Descriptor(const DeclTy &D, MetadataSize MD)
Descriptor::Descriptor(DeclOrExpr D, MetadataSize MD)
: Source(D), ElemSize(1), Size(1), MDSize(MD.value_or(0)),
AllocSize(MDSize), ElemRecord(nullptr), IsConst(true), IsMutable(false),
IsTemporary(false) {
Expand Down Expand Up @@ -470,17 +470,17 @@ QualType Descriptor::getDataType(const ASTContext &Ctx) const {
}

SourceLocation Descriptor::getLocation() const {
if (auto *D = dyn_cast<const Decl *>(Source))
if (auto *D = Source.asDecl())
return D->getLocation();
if (auto *E = dyn_cast<const Expr *>(Source))
if (auto *E = Source.asExpr())
return E->getExprLoc();
llvm_unreachable("Invalid descriptor type");
}

SourceInfo Descriptor::getLoc() const {
if (const auto *D = dyn_cast<const Decl *>(Source))
if (const auto *D = Source.asDecl())
return SourceInfo(D);
if (const auto *E = dyn_cast<const Expr *>(Source))
if (const auto *E = Source.asExpr())
return SourceInfo(E);
llvm_unreachable("Invalid descriptor type");
}
Expand Down
Loading
Loading