[clang] [CIR] Add support for __builtin_alloca (PR #157116)

2025-09-09 Thread Morris Hafner via cfe-commits
@@ -149,6 +149,57 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, emitVAEnd(emitVAListRef(e->getArg(0)).getPointer()); return {}; + case Builtin::BIalloca: + case Builtin::BI_alloca: + case Builtin::BI__builtin_alloca_uninitializ

[clang] [CIR] Fix LLVM lowering crashes after #155244 (PR #157471)

2025-09-08 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/157471 This patch replaces all uses of `replaceAllUseWith` with `replaceOp`. This fixes a number of regressions post #155244. >From 9cc2c129d4f1cc805901897c6a11be50fe971675 Mon Sep 17 00:00:00 2001 From: Morris Hafner Da

[clang] [CIR] Fix LLVM lowering crashes after #155244 (PR #157471)

2025-09-08 Thread Morris Hafner via cfe-commits
mmha wrote: My understanding is that we are not supposed to erase an op that was replaced anymore. `eraseOp` calls `replaceOp` internally which lead to the double replacement assertion failure. I also think in our case it doesn't really matter whether we use `replaceOp` and `replaceAllUseWith

[clang] [CIR] Add support for __builtin_alloca (PR #157116)

2025-09-08 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/157116 >From 4121aecbda6be80161eb8fe22c351fadd5bbe62a Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 5 Sep 2025 16:27:28 +0200 Subject: [PATCH 1/2] [CIR] Add support for __builtin_alloca This patch adds support f

[clang] [CIR] Add support for __builtin_alloca (PR #157116)

2025-09-08 Thread Morris Hafner via cfe-commits
@@ -258,3 +258,13 @@ void trap2() { // LLVM: {{.+}}: // LLVM-NEXT:call void @_Z2f1v() // LLVM: } + +void *test_alloca(unsigned long n) { + return __builtin_alloca(n); +} + +// CIR-LABEL: @_Z11test_allocam( +// CIR: %{{.+}} = cir.alloca !u8i, !cir.ptr, %

[clang] [CIR] Add support for __builtin_alloca (PR #157116)

2025-09-08 Thread Morris Hafner via cfe-commits
@@ -1053,9 +1053,12 @@ mlir::LogicalResult CIRToLLVMBaseClassAddrOpLowering::matchAndRewrite( mlir::LogicalResult CIRToLLVMAllocaOpLowering::matchAndRewrite( cir::AllocaOp op, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const { - assert(!cir::Missing

[clang] [CIR] Fix assertion order in 'Address' (PR #157477)

2025-09-08 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/157477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Fix LLVM lowering crashes after #155244 (PR #157471)

2025-09-08 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/157471 >From b3a93e27c9d04b3a8dbe7bf99e541a9975a6f97a Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Mon, 8 Sep 2025 16:12:45 +0200 Subject: [PATCH] [CIR] Fix LLVM lowering crashes after #155244 This patch replaces al

[clang] [CIR] Add support for delegating constructor initialization (PR #156757)

2025-09-07 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM. Can you add a couple more test cases? ```c++ struct WithBraceInit { int i{}; WithBraceInit() = default; WithBraceInit(int); }; WithBraceInit:WithBraceInit(int) : WithBraceInit() {} int main() { // Destinations are zeroed stati

[clang] [CIR] Add support for __builtin_alloca (PR #157116)

2025-09-07 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/157116 This patch adds support for the alloca builtin and extends AllocaOp with a dynamic size argument. >From 6080e710fcf5c2b8527a1c6ea1057891e5820bbf Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 5 Sep 2025 1

[clang] [CIR] Add support for delegating constructors with VTT args (PR #156970)

2025-09-04 Thread Morris Hafner via cfe-commits
@@ -70,3 +70,266 @@ DelegatingWithZeroing::DelegatingWithZeroing(int) : DelegatingWithZeroing() {} // OGCG: store i32 %[[I_ARG]], ptr %[[I_ADDR]] // OGCG: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]] // OGCG: call void @llvm.memset.p0.i64(ptr align 4 %[[THIS]], i8 0, i64

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-04 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/155663 >From ce55bc0b9ef72e399ea012eda451299fc5a2b636 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 2 Sep 2025 19:11:42 +0200 Subject: [PATCH 1/6] [CIR] Add constant record ILE support This patch adds basic supp

[clang] [CIR] Add support for delegating constructor initialization (PR #156757)

2025-09-04 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/156757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Finish record layout for classes with virtual bases (PR #156770)

2025-09-04 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. https://github.com/llvm/llvm-project/pull/156770 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-03 Thread Morris Hafner via cfe-commits
@@ -21,20 +20,526 @@ #include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/B

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-03 Thread Morris Hafner via cfe-commits
@@ -903,8 +1440,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &value, return ConstantLValueEmitter(*this, value, destType).tryEmit(); case APValue::Struct: case APValue::Union: -cgm.errorNYI("ConstExprEmitter::tryEmitPrivate struct or union");

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-03 Thread Morris Hafner via cfe-commits
@@ -21,20 +20,526 @@ #include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/B

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-03 Thread Morris Hafner via cfe-commits
@@ -21,20 +20,526 @@ #include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/B

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-03 Thread Morris Hafner via cfe-commits
@@ -30,7 +30,8 @@ llvm::Align CIRDataLayout::getAlignment(mlir::Type ty, bool useABIAlign) const { return llvm::Align(1); // Get the layout annotation... which is lazily created on demand. -llvm_unreachable("getAlignment()) for record type is not implemented");

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-03 Thread Morris Hafner via cfe-commits
@@ -21,20 +20,526 @@ #include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/B

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-09-03 Thread Morris Hafner via cfe-commits
@@ -21,20 +20,526 @@ #include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/B

[clang] [CIR][NFC] Fix build issue after AST modification (PR #156493)

2025-09-03 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM, Thanks! For the record, this was caused by #152870. https://github.com/llvm/llvm-project/pull/156493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm

[clang] [CIR] Add handling for volatile loads and stores (PR #156124)

2025-09-02 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/156124 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add handling for volatile loads and stores (PR #156124)

2025-09-02 Thread Morris Hafner via cfe-commits
mmha wrote: Can you add a test that calls a `volatile` qualified member function (assuming that works already)? https://github.com/llvm/llvm-project/pull/156124 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] [CIR] Add value initialization for scalar types (PR #156036)

2025-08-29 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/156036 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add value initialization for scalar types (PR #156036)

2025-08-29 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/156036 None >From a79c57ee6cedd19ea15565fe7e7ca9872d416f2c Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 29 Aug 2025 16:45:44 +0200 Subject: [PATCH] [CIR] Add value initialization for scalar types --- clang/li

[clang] [OpenACC] 'reduction' init lowering for +, |, ^, || (PR #155924)

2025-08-29 Thread Morris Hafner via cfe-commits
@@ -3,9 +3,32 @@ // CHECK: acc.reduction.recipe @reduction_lor__ZTSA5_f : !cir.ptr> reduction_operator init { // CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr>{{.*}}) -// CHECK-NEXT: cir.alloca !cir.array, !cir.ptr>, ["openacc.reduction.init"] -// TODO OpenACC: Expecting an initia

[clang] [CIR] Add value initialization for scalar types (PR #156036)

2025-08-29 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/156036 >From a79c57ee6cedd19ea15565fe7e7ca9872d416f2c Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 29 Aug 2025 16:45:44 +0200 Subject: [PATCH 1/3] [CIR] Add value initialization for scalar types --- clang/lib/

[clang] [CIR] Add value initialization for scalar types (PR #156036)

2025-08-29 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/156036 >From a79c57ee6cedd19ea15565fe7e7ca9872d416f2c Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 29 Aug 2025 16:45:44 +0200 Subject: [PATCH 1/2] [CIR] Add value initialization for scalar types --- clang/lib/

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-08-29 Thread Morris Hafner via cfe-commits
@@ -21,20 +20,526 @@ #include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/B

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-08-28 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/155663 >From c2ba9037496f23e22e43b2f4a2bfcddb3aaad535 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Wed, 27 Aug 2025 19:36:34 +0200 Subject: [PATCH 1/4] [CIR] Add constant record ILE support This patch adds basic sup

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-08-28 Thread Morris Hafner via cfe-commits
@@ -130,6 +132,44 @@ void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset( computeGlobalViewIndicesFromFlatOffset(offset, subType, layout, indices); } +static mlir::Type getAttributeType(mlir::Attribute attr) { + return mlir::cast(attr).getType(); +} + +cir::Record

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-08-28 Thread Morris Hafner via cfe-commits
@@ -21,20 +20,571 @@ #include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/B

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-08-28 Thread Morris Hafner via cfe-commits
@@ -130,6 +132,44 @@ void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset( computeGlobalViewIndicesFromFlatOffset(offset, subType, layout, indices); } +static mlir::Type getAttributeType(mlir::Attribute attr) { + return mlir::cast(attr).getType(); +} + +cir::Record

[clang] [CIR] Add constant record ILE support (PR #155663)

2025-08-27 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/155663 >From c2ba9037496f23e22e43b2f4a2bfcddb3aaad535 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Wed, 27 Aug 2025 19:36:34 +0200 Subject: [PATCH 1/2] [CIR] Add constant record ILE support This patch adds basic sup

[clang] [CIR] Upstream GotoSolver pass (PR #154596)

2025-08-21 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/154596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream GotoSolver pass (PR #154596)

2025-08-21 Thread Morris Hafner via cfe-commits
@@ -0,0 +1,52 @@ +#include "PassDetail.h" +#include "clang/CIR/Dialect/IR/CIRDialect.h" +#include "clang/CIR/Dialect/Passes.h" +#include "llvm/Support/TimeProfiler.h" +#include + +using namespace mlir; +using namespace cir; + +namespace { + +struct GotoSolverPass : public GotoSol

[clang] [CIR] Upstream GotoSolver pass (PR #154596)

2025-08-21 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM, just one nit https://github.com/llvm/llvm-project/pull/154596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add CIR vtable attribute (PR #154415)

2025-08-21 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. https://github.com/llvm/llvm-project/pull/154415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-21 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/154060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add CIR vtable attribute (PR #154415)

2025-08-20 Thread Morris Hafner via cfe-commits
mmha wrote: Is this also meant to cover VTTs? https://github.com/llvm/llvm-project/pull/154415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add support for string literal lvalues in ConstantLValueEmitter (PR #154514)

2025-08-20 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/154514 Reopening #154360 because the target branch was deleted first. >From 3b8951482dc4a4a779bb914706d6d85e75c83743 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 19 Aug 2025 17:13:51 +0200 Subject: [PATCH] [CIR

[clang] [CIR] Add constant attribute to GlobalOp (PR #154359)

2025-08-20 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/154359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Implement__builtin_va_arg (PR #153834)

2025-08-20 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/153834 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add support for base classes in type conversion safety check (PR #154385)

2025-08-20 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/154385 >From df7866a4b60570fd2aa834656a2fbc62729b4277 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 19 Aug 2025 18:58:29 +0200 Subject: [PATCH] [CIR] Add support for derived classes in type info conversion safet

[clang] [CIR] Add support for base classes in type conversion safety check (PR #154385)

2025-08-20 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/154385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add support for derived classes in type info conversion safety … (PR #154385)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/154385 …check This patch enables the record layout computation of types that are dervied more than once. >From 0a0e87c263c56d4fce307e6325cb07a080d7ef94 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 19 Aug 2025

[clang] [CIR] Add constant attribute to GlobalOp (PR #154359)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/154359 >From 50399d0569e01a5a00878afc5d52c27a52e54d4a Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 19 Aug 2025 16:58:44 +0200 Subject: [PATCH 1/2] [CIR] Add constant attribute to GlobalOp This patch adds the co

[clang] [CIR] Add constant attribute to GlobalOp (PR #154359)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/154359 This patch adds the constant attribute to cir.global, the appropriate lowering to LLVM constant and updates the tests. >From 50399d0569e01a5a00878afc5d52c27a52e54d4a Mon Sep 17 00:00:00 2001 From: Morris Hafner Da

[clang] [CIR][NFC] Fix regression by #153819 (PR #154346)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. Thanks for fixing this! This also ran fine on my Arch + clang 20 machine which is why I didn't catch it. https://github.com/llvm/llvm-project/pull/154346 ___ cfe-commits mailing list cfe-commits@list

[clang] [CIR] Implement__builtin_va_arg (PR #153834)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153834 >From d1245a1d3c0ac2d904049b3a6a9937f75da49eea Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 19 Aug 2025 12:23:12 +0200 Subject: [PATCH 1/2] [CIR] Implement__builtin_va_arg Part of #153286. Depends on #15

[clang] [CIR] Implement__builtin_va_arg (PR #153834)

2025-08-19 Thread Morris Hafner via cfe-commits
@@ -382,3 +382,13 @@ void CIRGenFunction::emitVAStartEnd(mlir::Value argValue, bool isStart) { else cir::VAEndOp::create(builder, argValue.getLoc(), argValue); } + +// FIXME(cir): This completely abstracts away the ABI with a generic CIR Op. We +// need to decide how to

[clang] [CIR] Implement__builtin_va_arg (PR #153834)

2025-08-19 Thread Morris Hafner via cfe-commits
@@ -382,3 +382,13 @@ void CIRGenFunction::emitVAStartEnd(mlir::Value argValue, bool isStart) { else cir::VAEndOp::create(builder, argValue.getLoc(), argValue); } + +// FIXME(cir): This completely abstracts away the ABI with a generic CIR Op. We mmha wrot

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/153677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From 2e799c0cd75e6e79735f591e1d72015047b414dc Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH 1/8] [CIR] Implement Statement Expressions This patch adds support f

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/153819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
https://github.com/mmha commented: Thanks for working on this! I mostly have style related comments. https://github.com/llvm/llvm-project/pull/154060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s mmha wrote: Can you compare CIR, classic codegen and the new LLVM coden in this test? See `clang/test/CIR/CodeGen/call.c` for an example. https://g

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -553,6 +591,35 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, SourceLocation loc) { return RValue::get(nullptr); } +static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd) { + assert(!cir::MissingFeatures::weakRefReference()); + return cgm.g

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -553,6 +591,35 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, SourceLocation loc) { return RValue::get(nullptr); } +static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd) { + assert(!cir::MissingFeatures::weakRefReference()); + return cgm.g

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/154060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -73,21 +73,59 @@ Address CIRGenFunction::emitPointerWithAlignment(const Expr *expr, // Casts: if (auto const *ce = dyn_cast(expr)) { -if (isa(ce)) { - cgm.errorNYI(expr->getSourceRange(), - "emitPointerWithAlignment: explicit cast"); - r

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -553,6 +591,35 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, SourceLocation loc) { return RValue::get(nullptr); } +static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd) { + assert(!cir::MissingFeatures::weakRefReference()); + return cgm.g

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -73,21 +73,59 @@ Address CIRGenFunction::emitPointerWithAlignment(const Expr *expr, // Casts: if (auto const *ce = dyn_cast(expr)) { -if (isa(ce)) { - cgm.errorNYI(expr->getSourceRange(), - "emitPointerWithAlignment: explicit cast"); - r

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -609,6 +676,16 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr *e) { return emitLValue(bd->getBinding()); } + if (const auto *FD = dyn_cast(nd)) { +LValue LV = emitFunctionDeclLValue(*this, e, FD); mmha wrote: ```suggestion if (

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -73,21 +73,59 @@ Address CIRGenFunction::emitPointerWithAlignment(const Expr *expr, // Casts: if (auto const *ce = dyn_cast(expr)) { -if (isa(ce)) { - cgm.errorNYI(expr->getSourceRange(), - "emitPointerWithAlignment: explicit cast"); - r

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -553,6 +591,35 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, SourceLocation loc) { return RValue::get(nullptr); } +static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd) { + assert(!cir::MissingFeatures::weakRefReference()); + return cgm.g

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -553,6 +591,35 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, SourceLocation loc) { return RValue::get(nullptr); } +static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd) { + assert(!cir::MissingFeatures::weakRefReference()); + return cgm.g

[clang] [CIR] Handle FunctionToPointerDecay casts (#153657) (PR #154060)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -73,21 +73,59 @@ Address CIRGenFunction::emitPointerWithAlignment(const Expr *expr, // Casts: if (auto const *ce = dyn_cast(expr)) { -if (isa(ce)) { - cgm.errorNYI(expr->getSourceRange(), - "emitPointerWithAlignment: explicit cast"); - r

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-18 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From 19733bc353bb40f86a931219f10837d525b8f144 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH 1/8] [CIR] Implement Statement Expressions This patch adds support f

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -1178,11 +1178,11 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf, ->getBaseElementTypeUnsafe() ->getAs()) { // Get the destructor for the reference temporary. -auto *classDecl =

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-18 Thread Morris Hafner via cfe-commits
mmha wrote: I changed the op definition to keep the count in CIR. So I'm asking for a small re-review :) It leads to somewhat worse LLVM IR because of a dead load but I don't think there's much we can do here. https://github.com/llvm/llvm-project/pull/153819 __

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-18 Thread Morris Hafner via cfe-commits
@@ -3415,4 +3415,81 @@ def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> { }]; } +//===--===// +// Variadic Operations +//===--=

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-18 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153819 >From dae7b978b994f5d160fae784fcd32bb3734f3208 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 15 Aug 2025 17:18:19 +0200 Subject: [PATCH 1/2] [CIR] Upstream __builtin_va_start and __builtin_va_end --- cla

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-17 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From d68b52a0af50bb4d18df40e81c54c32bd700e702 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH 1/7] [CIR] Implement Statement Expressions This patch adds support f

[clang] [CIR] Implement __builtin_return_address and __builtin_frame_address (PR #153698)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/153698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-15 Thread Morris Hafner via cfe-commits
@@ -561,7 +558,6 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn, emitImplicitAssignmentOperatorBody(args); } else if (body) { if (mlir::failed(emitFunctionBody(body))) { -fn.erase(); mmha wrote: This c

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-15 Thread Morris Hafner via cfe-commits
@@ -1178,11 +1178,11 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf, ->getBaseElementTypeUnsafe() ->getAs()) { // Get the destructor for the reference temporary. -auto *classDecl =

[clang] [CIR] Implement__builtin_va_arg (PR #153834)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/153834 Part of https://github.com/llvm/llvm-project/issues/153286. Depends on https://github.com/llvm/llvm-project/pull/153819. This patch adds support for __builtin_va_arg by adding the cir.va.arg operator. Unlike the in

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/153819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/153819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-15 Thread Morris Hafner via cfe-commits
@@ -3415,4 +3415,81 @@ def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> { }]; } +//===--===// +// Variadic Operations +//===--=

[clang] [CIR] Upstream __builtin_va_start and __builtin_va_end (PR #153819)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/153819 None >From dae7b978b994f5d160fae784fcd32bb3734f3208 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 15 Aug 2025 17:18:19 +0200 Subject: [PATCH] [CIR] Upstream __builtin_va_start and __builtin_va_end --- c

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/153677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-15 Thread Morris Hafner via cfe-commits
@@ -0,0 +1,166 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir mmha wrote: `stmtexpr-init.c` is not useful because we lack record init list exprs. I added a few C++ tests but I noticed that we don't call destructors for

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From d68b52a0af50bb4d18df40e81c54c32bd700e702 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH 1/5] [CIR] Implement Statement Expressions This patch adds support f

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-15 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From d68b52a0af50bb4d18df40e81c54c32bd700e702 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH 1/3] [CIR] Implement Statement Expressions This patch adds support f

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From d68b52a0af50bb4d18df40e81c54c32bd700e702 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH 1/3] [CIR] Implement Statement Expressions This patch adds support f

[clang] [CIR] Implement __builtin_return_address and __builtin_frame_address (PR #153698)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153698 >From 1de984292efcc907405812ccb02f348e0a36e0af Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 15 Aug 2025 00:05:14 +0200 Subject: [PATCH 1/3] [CIR] Implement __builtin_return_address and __builtin_frame_ad

[clang] [CIR] Implement __builtin_return_address and __builtin_frame_address (PR #153698)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153698 >From 1de984292efcc907405812ccb02f348e0a36e0af Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 15 Aug 2025 00:05:14 +0200 Subject: [PATCH 1/2] [CIR] Implement __builtin_return_address and __builtin_frame_ad

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From d68b52a0af50bb4d18df40e81c54c32bd700e702 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH 1/2] [CIR] Implement Statement Expressions This patch adds support f

[clang] [CIR] Implement __builtin_return_address and __builtin_frame_address (PR #153698)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/153698 This adds ReturnAddrOp and FrameAddrOp that represent __builtin_return_address and __builtin_frame_address and the respective lowering to LLVM parts. >From 1de984292efcc907405812ccb02f348e0a36e0af Mon Sep 17 00:00:

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From 4c0aea8b8a1dd05eab7c4e0befbf3610e6123ffc Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH] [CIR] Implement Statement Expressions This patch adds support for s

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/153677 >From 34b219ffb5412599ea7548cc7579bff454343b95 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 14 Aug 2025 22:44:35 +0200 Subject: [PATCH] [CIR] Implement Statement Expressions This patch adds support for s

[clang] [CIR][NFC] Add Symbol Table to CIRGenFunction (PR #153625)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/153625 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Implement Statement Expressions (PR #153677)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/153677 Depends on #153625 This patch adds support for statement expressions. It also changes emitCompoundStmt and emitCompoundStmtWithoutScope to accept an Address that the optional result is written to. This allows the

[clang] [CIR] Add `InlineAsmOp` (PR #153362)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/153362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add `InlineAsmOp` (PR #153362)

2025-08-14 Thread Morris Hafner via cfe-commits
@@ -2406,6 +2406,212 @@ OpFoldResult RotateOp::fold(FoldAdaptor adaptor) { return IntAttr::get(input.getContext(), input.getType(), resultValue); } +//===--===// +// InlineAsmOp +//===---

[clang] [CIR] Add `InlineAsmOp` (PR #153362)

2025-08-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/153362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Introduce more cleanup infrastructure (PR #152589)

2025-08-11 Thread Morris Hafner via cfe-commits
@@ -70,45 +70,89 @@ void EHScopeStack::deallocate(size_t size) { } void *EHScopeStack::pushCleanup(CleanupKind kind, size_t size) { - char *buffer = allocate(size); + char *buffer = allocate(EHCleanupScope::getSizeForCleanupSize(size)); - // When the full implementation i

  1   2   3   4   >