Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
c2ba81c
[lldb][nfc] Fix comment about UINT32_MAX in UnwindAssemblyInstruction…
felipepiovezan Nov 17, 2025
74c9168
[lldb][nfc] Avoid duplicate calls to GetInstructionCondition in Unwin…
felipepiovezan Nov 17, 2025
fdbb888
[analyzer] StdVariantChecker: fix crashes and incorrect retrieval of …
guillem-bartrina-sonarsource Nov 17, 2025
7e730da
[VPlan] Add printRecipe, prepare printing metadata in ::print (NFC) (…
fhahn Nov 17, 2025
82ba3f5
[clang][DebugInfo] Clear retained nodes list of vararg trunk's DISubp…
dzhidzhoev Nov 17, 2025
3ee54a6
[DTLTO] [LLVM] Initial DTLTO cache implementation (#156433)
romanova-ekaterina Nov 17, 2025
c2ddaaa
[NFC][analyzer] Add missing documentation for `decodeValueOfObjCType`…
zeyi2 Nov 17, 2025
515924f
[X86] bittest-big-integer.ll - add BLSR style pattern test (#168356)
RKSimon Nov 17, 2025
6b464e4
[clang][SourceManager] Use `getFileLoc` when computing `getPresumedLo…
SergejSalnikov Nov 17, 2025
e3cfb17
Update Clang Maintainers (#168271)
steakhal Nov 17, 2025
ae2fec0
[mlir][bazel] Fix build after #167848. (#168366)
bchetioui Nov 17, 2025
e468ea3
[mlir][amdgpu] Fix documentation and verifiers (#167369)
amd-eochoalo Nov 17, 2025
ef023ca
Reland [VPlan] Expand WidenInt inductions with nuw/nsw (#168354)
artagnon Nov 17, 2025
fd1bdfd
Revert "[clang][SourceManager] Use `getFileLoc` when computing `getPr…
AaronBallman Nov 17, 2025
e70e9ec
[flang][OpenMP] Store Block in OpenMPLoopConstruct, add access functi…
kparzysz Nov 17, 2025
29e7b4f
[flang][NFC] Strip trailing whitespace from tests (5 of N)
tarunprabhu Nov 17, 2025
b6fd3c6
[X86] Enable APX and AVX10.2 on NVL (#168061)
mikolaj-pirog Nov 17, 2025
6eab083
[mlir][emitc] Refactor brackets in expressions (#168267)
aniragil Nov 17, 2025
9fe0a70
[llvm][RISCV] Support splat and vp_splat for zvfbfa codegen (#167920)
4vtomat Nov 17, 2025
53e3f8e
[XRay] Prefix setting XRAY_OPTIONS with env
boomanaiden154 Nov 17, 2025
e95c5c8
[libc++] Refactor basic_string::__recommend (#162631)
philnik777 Nov 17, 2025
c7a9be8
[XRay] Rewrite tests to not use subshells
boomanaiden154 Nov 17, 2025
e9743e2
[clang] Support constrained fp elementwise builtins (#166905)
ficol Nov 17, 2025
47c1aa4
[X86] Add constexpr support for addsub intrinsics (#167512)
ahmednoursphinx Nov 17, 2025
17cbb48
[MLIR] Apply clang-tidy fixes for readability-identifier-naming in Pa…
joker-eph Aug 21, 2025
38811be
[Flang] [OpenMP] Add support for spaces in between the name (#168311)
Thirumalai-Shaktivel Nov 17, 2025
d65be16
[AArch64][GlobalISel] Add combine for build_vector(unmerge, unmerge, …
HolyMolyCowMan Nov 17, 2025
ff7896e
[MLIR] Add verification that symbol operations must not have results …
timnoack Nov 17, 2025
498a01d
[Option] Use llvm::is_contained (NFC) (#168295)
kazutakahirata Nov 17, 2025
99bf41c
[TargetParser] Use range-based for loops (#168296)
kazutakahirata Nov 17, 2025
bf21156
[IPO] Remove a redundant cast (NFC) (#168297)
kazutakahirata Nov 17, 2025
dcf8cd9
[ADT] Consolidate the grow() logic in DenseMapBase (NFC) (#168316)
kazutakahirata Nov 17, 2025
3c54972
[ADT] Remove DenseMap::init (NFC) (#168322)
kazutakahirata Nov 17, 2025
e69d2bf
[OpenMP][omptest] Fix missing source extention
Meinersbur Nov 17, 2025
a9633aa
[libc++] Fix __hash_table::erase(iterator, iterator) to update the bu…
philnik777 Nov 17, 2025
7659cd4
[VectorUtils] Use PatternMatch in findScalarElement (NFC) (#168389)
artagnon Nov 17, 2025
4dd2796
[AMDGPU][GlobalISel] Add RegBankLegalize support for G_FMUL (#167847)
vangthao95 Nov 17, 2025
d163988
[MLIR][NVVM][NFC] Re-order mem_scope and shared_space attrs (#168348)
durga4github Nov 17, 2025
83fc85c
Remove shadowing "size" field from classes that inherit from Syntheti…
Sterling-Augustine Nov 17, 2025
35ae515
[MLIR][NVVM][Docs] Explain memory spaces (#168059)
grypp Nov 17, 2025
c66f1fd
[MC] Use MCRegister::id() to avoid implicit casts. NFC (#168233)
topperc Nov 17, 2025
39e7712
[LLVM-Tablegen] Pretty Printing Arguments in LLVM Intrinsics (#162629)
DharuniRAcharya Nov 17, 2025
6f5c8fe
[MLIR][SparseTensor] Dense Outer Loop Ordering Strategy (#160168)
gmalasan Nov 17, 2025
0c84643
[CIR] Upstream handling for BaseToDerived casts (#167769)
andykaylor Nov 17, 2025
72b02c7
[AMDGPU] Fix layering violations in AMDGPUMCExpr.cpp. NFC (#168242)
topperc Nov 17, 2025
fb2b138
[CIR] Handle __asm labels on function declarations (#168149)
andykaylor Nov 17, 2025
8c674f0
[OpenMP][Flang] Change the OmpDefaultMapperName suffix (#168399)
TIFitis Nov 17, 2025
2b22e9b
[SPIRV] Use a worklist in the post-legalizer (#165027)
s-perron Nov 17, 2025
be6296e
[RISCV] Fold Zba-expanded (mul (shr exact X, C1), C2) (#168019)
pfusik Nov 17, 2025
a9a4515
[lld][MachO] Read cstring order for non deduped sections (#161879)
ellishg Nov 17, 2025
eb879ac
[CI] Make premerge upload/write comments (#166609)
boomanaiden154 Nov 17, 2025
a770d2b
Add 'exact' flag to arith.shrui/shrsi/divsi/divui operations (#165923)
jfurtek Nov 17, 2025
9349a10
Fix side effects for LLVM integer operations (udiv, sdiv) incorrectly…
jfurtek Nov 17, 2025
a7579fd
[PowerPC][AIX] Remove flag for no semantic interposition (#168109)
lei137 Nov 17, 2025
72059be
[compiler-rt][Profile] Mark Darwin test work with internal shell
boomanaiden154 Nov 17, 2025
05bd742
[CIR] Upstream the initial BlockAddressOp implementation (#168151)
Andres-Salamanca Nov 17, 2025
1425d75
[X86] Delete Profile Guided Prefetch Passes (#167317)
boomanaiden154 Nov 17, 2025
472e4ab
[MLGO] Fully Remove MLRegalloc Experimental Features (#168252)
boomanaiden154 Nov 17, 2025
4be0ab6
[flang][OpenMP] Undeprecate accidentally deprecated TARGET LOOP (#167…
kparzysz Nov 17, 2025
c4be17a
[compiler-rt] [libFuzzer] Fix merge-posix.test file size test (#168137)
ndrewh Nov 17, 2025
cc304e5
[TableGen] Strip directories from filename prefixes. (#168355)
kosarev Nov 17, 2025
aa4de7b
[bazel] Add support for multiple tblgen outputs (#168158)
keith Nov 17, 2025
6360bbb
[AIX] Raise soft memory limits to hard limits (#167928)
daltenty Nov 17, 2025
bb9df2e
[lldb] Ensure FILE* access mode is correctly specified when creating …
ashgti Nov 17, 2025
aba3269
[.gitignore] Ignore .claude and .gemini in subdirectories (#167029)
JDevlieghere Nov 17, 2025
adeedad
[bazel] Port 900c517919794ff0ea83c6b15ffe03707a164800 (#168423)
keith Nov 17, 2025
18b5e2a
[lldb] Push down the SWIG module to avoid an import cycle (#166265)
JDevlieghere Nov 17, 2025
7672a5c
[scudo] Fix wrong return type. (#168157)
cferris1000 Nov 17, 2025
cd5d5b3
[mlir][XeGPU] Use DistributeLayoutAttr instead of LayoutAttr for load…
dchigarev Nov 17, 2025
bafb3f6
[LV] Add test with existing noalias metadata and runtime checks.
fhahn Nov 17, 2025
af6af8e
[bazel] Port 0a58e49c44ae7cca39b3eb219efed9f0581b8b0f (#168424)
keith Nov 17, 2025
c555522
[lldb-dap] Migrating 'evaluate' to structured types. (#167720)
ashgti Nov 17, 2025
c1c22cd
[ASan][HIP] Add ASan declarations and macros. (#167522)
ampandey-1995 Nov 17, 2025
69b4190
[AArch64] Optimize extending loads of small vectors (#163064)
guy-david Nov 17, 2025
21e0b56
[AArch64][GlobalISel] Add basic GISel test coverage for lround and ll…
davemgreen Nov 17, 2025
320c18a
[SystemZ] TableGen-erate node descriptions (#168113)
s-barannikov Nov 17, 2025
b32c434
[libc][Github] Perform baremetal libc builds (#167583)
Prabhuk Nov 17, 2025
557a6b8
[lldb][NFC] use llvm::erase_if to remove non matching types (#168279)
da-viper Nov 17, 2025
bac8d01
[bazel][libc] Fixes #165219 (#168429)
pranavk Nov 17, 2025
3fb3742
[bazel] Fix #168113 (#168434)
pranavk Nov 17, 2025
4bec74a
[mlir][bazel] Fix #168066 (#168435)
pranavk Nov 17, 2025
b00588f
Fix bazel dep caused by f5b73760 (#168436)
lialan Nov 17, 2025
321b9d1
[VPlan] Replace VPIRMetadata::addMetadata with setMetadata. (NFC)
fhahn Nov 17, 2025
54c2c7c
[LLDB] Fix test compilation errors under asan (NFC) (#168408)
adrian-prantl Nov 17, 2025
24c524d
[libc++] Enable compiler-rt when performing a bootstrapping build (#1…
ldionne Nov 17, 2025
aae2b89
[libc++] Replace a few .compile.fail.cpp tests by proper clang-verify…
ldionne Nov 17, 2025
7693f12
[mlir][bazel] Fix #167957 (#168441)
pranavk Nov 17, 2025
0d8c294
Fixed typo in llvm-otool (#168395)
boredhuman Nov 17, 2025
ed617bd
[bazel][buildifier] reformat changes in #168434 (#168443)
pranavk Nov 17, 2025
3cba379
[VPlan] Populate and use VPIRMetadata from VPInstructions (NFC) (#167…
fhahn Nov 17, 2025
92c8c87
[libc] Implement wcstod and wcstold. (#168020)
vonosmas Nov 17, 2025
3f60d22
[-Wunsafe-buffer-usage] Fold the expression "cond ? E1 : E2" when che…
ziqingluo-90 Nov 17, 2025
909c9aa
[mlir][amdgpu] Add lowerings for ScaledExtPacked816 (#168123)
amd-eochoalo Nov 17, 2025
7d0a208
[AArch64] Treat COPY between cross-register banks as expensive (#167661)
guy-david Nov 17, 2025
6245a4f
Add support for the .base64 directive (#165549)
kenballus Nov 17, 2025
88b3969
[lldb-dap] Address a unit test race condition during initialization. …
ashgti Nov 17, 2025
e89e359
[libc]Github] Fix typo on build_type param (#168453)
Prabhuk Nov 17, 2025
f0f5332
[mlir][acc] Add ACCImplicitRoutine pass for implicit `acc routine` (#…
razvanlupusoru Nov 17, 2025
43dacd0
[PowerPC] TableGen-erate SDNode descriptions (#168108)
s-barannikov Nov 17, 2025
5cf5eb7
[MemProf] Fixup edges for largest N cold contexts (#167599)
teresajohnson Nov 17, 2025
7a14ef0
[scudo] Skip test if mlock fails. (#168448)
cferris1000 Nov 17, 2025
3bec613
[lldb] Add helper to create mock objects for dwarf expression tests (…
dmpots Nov 17, 2025
b48f293
Fix build breakage (MLIR LLVM dialect requires MLIRInferIntRangeInter…
jfurtek Nov 17, 2025
da61dd2
[libc] Move mbtowc, mbstowcs and inverse functions to stdlib.h (#168455)
vonosmas Nov 17, 2025
865c92b
llvm: Export `ilist_node_base` template specialization (#168094)
Steelskin Nov 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .ci/premerge_advisor_explain.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_comment(
) -> dict[str, str]:
repo = github.Github(github_token).get_repo("llvm/llvm-project")
pr = repo.get_issue(pr_number).as_pull_request()
body = COMMENT_TAG.format(platform=platform.system()) + "\n" + body
comment = {"body": body}
comment_id = get_comment_id(platform.system(), pr)
if comment_id:
Expand Down Expand Up @@ -128,7 +129,7 @@ def main(
),
)
]
with open("comment", "w") as comment_file_handle:
with open("comments", "w") as comment_file_handle:
json.dump(comments, comment_file_handle)
else:
print(advisor_response.reason)
Expand Down
83 changes: 67 additions & 16 deletions .github/workflows/libc-fullbuild-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@ jobs:
cpp_compiler: clang++-22
target: x86_64-unknown-uefi-llvm
include_scudo: OFF
- os: ubuntu-24.04
build_type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv6m-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build_type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv7m-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build_type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv7em-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build_type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv8m.main-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build_type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: armv8.1m.main-none-eabi
include_scudo: OFF
- os: ubuntu-24.04
build_type: MinSizeRel
c_compiler: clang-22
cpp_compiler: clang++-22
target: riscv32-unknown-elf
include_scudo: OFF
# TODO: add back gcc build when it is fixed
# - c_compiler: gcc
# cpp_compiler: g++
Expand Down Expand Up @@ -93,28 +129,39 @@ jobs:
run: |
export RUNTIMES="libc"

export CMAKE_FLAGS="
-G Ninja
-S ${{ github.workspace }}/runtimes
-B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_ASM_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_C_COMPILER_LAUNCHER=sccache
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}"

if [[ ${{ matrix.include_scudo}} == "ON" ]]; then
export RUNTIMES="$RUNTIMES;compiler-rt"
export CMAKE_FLAGS="
export CMAKE_FLAGS="$CMAKE_FLAGS
-DLLVM_LIBC_INCLUDE_SCUDO=ON
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF"
fi

cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }} \
-DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
-DLLVM_LIBC_FULL_BUILD=ON \
-G Ninja \
-S ${{ github.workspace }}/runtimes \
$CMAKE_FLAGS
case "${{ matrix.target }}" in
*-none-eabi|riscv32-unknown-elf)
cmake $CMAKE_FLAGS \
-C ${{ github.workspace }}/libc/cmake/caches/${{ matrix.target }}.cmake
;;
*)
cmake -DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
-DLLVM_LIBC_FULL_BUILD=ON \
$CMAKE_FLAGS
;;
esac

- name: Build
run: >
Expand All @@ -124,8 +171,12 @@ jobs:
--target install

- name: Test
# Skip UEFI tests until we have testing set up.
if: ${{ ! endsWith(matrix.target, '-uefi-llvm') }}
# Skip UEFI and baremetal tests until we have testing set up.
if: ${{
!endsWith(matrix.target, '-uefi-llvm') &&
!endsWith(matrix.target, '-none-eabi') &&
matrix.target != 'riscv32-unknown-elf'
}}
run: >
cmake
--build ${{ steps.strings.outputs.build-output-dir }}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/premerge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ jobs:
path: artifacts/
retention-days: 5
include-hidden-files: 'true'
- name: Upload Comment
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ always() && !startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') }}
continue-on-error: true
with:
name: workflow-args
path: |
comments

premerge-checks-windows:
name: Build and Test Windows
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ autoconf/autom4te.cache
/cmake-build*
# Coding assistants' stuff
/CLAUDE.md
/.claude/
.claude/
/GEMINI.md
/.gemini/
.gemini/

#==============================================================================#
# Directories to ignore (do not add trailing '/'s, they skip symlinks).
Expand Down
1 change: 0 additions & 1 deletion clang/Maintainers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ Clang static analyzer
| Balázs Benics
| benicsbalazs\@gmail.com (email), steakhal (Phabricator), steakhal (GitHub)
| balazs.benics\@sonarsource.com (email), balazs-benics-sonarsource (GitHub)
Compiler options
~~~~~~~~~~~~~~~~
Expand Down
19 changes: 18 additions & 1 deletion clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ as error. Specifically on x86/x86-64 target if the pointer address space is
dereference is not defined as error. See `X86/X86-64 Language Extensions
<https://clang.llvm.org/docs/LanguageExtensions.html#memory-references-to-specified-segments>`__
for reference.

If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
to true (the default value), then this checker never reports dereference of
pointers with a specified address space. If the option is set to false, then
Expand Down Expand Up @@ -1664,6 +1664,23 @@ Warn on uses of the 'bzero' function.
bzero(ptr, n); // warn
}

.. _security-insecureAPI-decodeValueOfObjCType:

security.insecureAPI.decodeValueOfObjCType (C)
""""""""""""""""""""""""""""""""""""""""""""""
Warn on uses of the Objective-C method ``-decodeValueOfObjCType:at:``.

.. code-block:: objc

void test(NSCoder *decoder) {
unsigned int x;
[decoder decodeValueOfObjCType:"I" at:&x]; // warn
}

This diagnostic is emitted only on Apple platforms where the safer
``-decodeValueOfObjCType:at:size:`` alternative is available
(iOS 11+, macOS 10.13+, tvOS 11+, watchOS 4.0+).

.. _security-insecureAPI-getpw:

security.insecureAPI.getpw (C)
Expand Down
18 changes: 14 additions & 4 deletions clang/include/clang/Basic/BuiltinsX86.td
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
def cmpsd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant char)">;
}


let Features = "sse3" in {
let Features = "sse3",
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
foreach Op = ["addsub"] in {
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
Expand Down Expand Up @@ -121,8 +121,9 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
}

// AVX
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in {
foreach Op = ["addsub", "max", "min"] in {
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>],
Features = "avx" in {
foreach Op = ["max", "min"] in {
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
}
Expand Down Expand Up @@ -571,6 +572,15 @@ let Features = "avx",
def movmskps256 : X86Builtin<"int(_Vector<8, float>)">;
}

let Features = "avx",
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
def addsubpd256
: X86Builtin<
"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
def addsubps256
: X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
}

let Features = "avx", Attributes = [NoThrow] in {
def vzeroall : X86Builtin<"void()">;
def vzeroupper : X86Builtin<"void()">;
Expand Down
25 changes: 25 additions & 0 deletions clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -1026,4 +1026,29 @@ def CIR_UnwindAttr : CIR_UnitAttr<"Unwind", "unwind"> {
let storageType = [{ CatchUnwind }];
}

//===----------------------------------------------------------------------===//
// CIR_BlockAddrInfoAttr
//===----------------------------------------------------------------------===//

def CIR_BlockAddrInfoAttr : CIR_Attr<"BlockAddrInfo", "block_addr_info"> {
let summary = "Block Addres attribute";
let description = [{
This attribute is used to represent the address of a basic block
within a function. It combines the symbol reference to a function
with the name of a label inside that function.
}];
let parameters = (ins "mlir::FlatSymbolRefAttr":$func,
"mlir::StringAttr":$label);

let assemblyFormat = "`<` $func `,` $label `>`";
let builders = [
AttrBuilder<(ins "llvm::StringRef":$func_name,
"llvm::StringRef":$label_name
), [{
return $_get($_ctxt, mlir::FlatSymbolRefAttr::get($_ctxt, func_name),
mlir::StringAttr::get($_ctxt, label_name));
}]>
];
}

#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_TD
90 changes: 88 additions & 2 deletions clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -3386,6 +3386,10 @@ def CIR_BaseClassAddrOp : CIR_Op<"base_class_addr"> {
cannot be known by the operation, and that information affects how the
operation is lowered.

The validity of the relationship of derived and base cannot yet be verified.
If the target class is not a valid base class for the object, the behavior
is undefined.

Example:
```c++
struct Base { };
Expand All @@ -3399,8 +3403,6 @@ def CIR_BaseClassAddrOp : CIR_Op<"base_class_addr"> {
```
}];

// The validity of the relationship of derived and base cannot yet be
// verified, currently not worth adding a verifier.
let arguments = (ins
Arg<CIR_PointerType, "derived class pointer", [MemRead]>:$derived_addr,
IndexAttr:$offset, UnitAttr:$assume_not_null);
Expand All @@ -3414,6 +3416,56 @@ def CIR_BaseClassAddrOp : CIR_Op<"base_class_addr"> {
}];
}

//===----------------------------------------------------------------------===//
// DerivedClassAddrOp
//===----------------------------------------------------------------------===//

def CIR_DerivedClassAddrOp : CIR_Op<"derived_class_addr"> {
let summary = "Get the derived class address for a class/struct";
let description = [{
The `cir.derived_class_addr` operaration gets the address of a particular
derived class given a non-virtual base class pointer. The offset in bytes
of the base class must be passed in, similar to `cir.base_class_addr`, but
going into the other direction. This means lowering to a negative offset.

The operation contains a flag for whether or not the operand may be nullptr.
That depends on the context and cannot be known by the operation, and that
information affects how the operation is lowered.

The validity of the relationship of derived and base cannot yet be verified.
If the target class is not a valid derived class for the object, the
behavior is undefined.

Example:
```c++
class A {};
class B : public A {};

B *getAsB(A *a) {
return static_cast<B*>(a);
}
```

leads to
```mlir
%2 = cir.load %0 : !cir.ptr<!cir.ptr<!rec_A>>, !cir.ptr<!rec_A>
%3 = cir.base_class_addr %2 : !cir.ptr<!rec_B> [0] -> !cir.ptr<!rec_A>
```
}];

let arguments = (ins
Arg<CIR_PointerType, "base class pointer", [MemRead]>:$base_addr,
IndexAttr:$offset, UnitAttr:$assume_not_null);

let results = (outs Res<CIR_PointerType, "">:$derived_addr);

let assemblyFormat = [{
$base_addr `:` qualified(type($base_addr))
(`nonnull` $assume_not_null^)?
` ` `[` $offset `]` `->` qualified(type($derived_addr)) attr-dict
}];
}

//===----------------------------------------------------------------------===//
// ComplexCreateOp
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -4845,4 +4897,38 @@ def CIR_AtomicClearOp : CIR_Op<"atomic.clear"> {
}];
}

//===----------------------------------------------------------------------===//
// BlockAddressOp
//===----------------------------------------------------------------------===//

def CIR_BlockAddressOp : CIR_Op<"block_address", [Pure]> {
let summary = "Get the address of a cir.label within a function";
let description = [{
The `cir.blockaddress` operation takes a function name and a label and
produces a pointer value that represents the address of that cir.label
within the specified function.

This operation models GCC's "labels as values" extension (`&&label`), which
allows taking the address of a local label and using it as a computed
jump target (e.g., with `goto *addr;`).

Example:
```mlir
%1 = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>, ["ptr", init]
{alignment = 8 : i64}
%addr = cir.block_address <@c, "label1"> : !cir.ptr<!cir.void>
cir.store align(8) %addr, %1 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>
cir.br ^bb1
^bb1:
cir.label "label"
```
}];

let arguments = (ins CIR_BlockAddrInfoAttr:$block_addr_info);
let results = (outs CIR_VoidPtrType:$addr);
let assemblyFormat = [{
$block_addr_info `:` qualified(type($addr)) attr-dict
}];
}

#endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
Loading
Loading