From 418da21866b7d5105839823610a3681ad00fc649 Mon Sep 17 00:00:00 2001 From: xlauko Date: Tue, 25 Nov 2025 22:12:47 +0100 Subject: [PATCH] XXX --- .../include/clang/CIR/Dialect/IR/CIRAttrs.td | 4 --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 1 + clang/lib/CIR/CodeGen/CIRGenCall.cpp | 34 +++++++++++-------- clang/lib/CIR/CodeGen/CIRGenFunction.cpp | 6 +--- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 18 ++++++++-- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 8 ++++- .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 4 +++ .../Lowering/DirectToLLVM/LowerToLLVMIR.cpp | 2 -- clang/test/CIR/CodeGen/OpenCL/nothrow.cl | 6 ++-- clang/test/CIR/CodeGen/call-extra-attrs.cpp | 4 +-- .../test/CIR/CodeGen/conditional-cleanup.cpp | 1 - clang/test/CIR/CodeGen/coro-task.cpp | 18 +++++----- clang/test/CIR/CodeGen/default-methods.cpp | 4 +-- clang/test/CIR/CodeGen/dynamic-cast.mlir | 6 ++-- clang/test/CIR/CodeGen/function-attrs.cpp | 12 +++---- clang/test/CIR/CodeGen/hello.c | 2 +- clang/test/CIR/CodeGen/lambda.cpp | 10 +++--- .../CIR/CodeGen/null-arithmatic-expression.c | 2 +- clang/test/CIR/CodeGen/optnone.cpp | 2 +- clang/test/CIR/CodeGen/temporaries.cpp | 14 ++++---- clang/test/CIR/IR/call.cir | 9 +++-- clang/test/CIR/IR/func-dsolocal-parser.cir | 4 +-- clang/test/CIR/IR/invalid.cir | 4 +-- clang/test/CIR/IR/tbaa-parse.cir | 4 +-- clang/test/CIR/Lowering/brcond.cir | 5 +-- clang/test/CIR/Lowering/syncscope.cir | 4 +-- 26 files changed, 101 insertions(+), 87 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 249d31487684..4d3e00c3f927 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -1192,10 +1192,6 @@ def CIR_OptNoneAttr : CIR_UnitAttr<"OptNone", "optnone"> { let storageType = [{ OptNoneAttr }]; } -def CIR_NoThrowAttr : CIR_UnitAttr<"NoThrow", "nothrow"> { - let storageType = [{ NoThrowAttr }]; -} - def CIR_ConvergentAttr : CIR_UnitAttr<"Convergent", "convergent"> { let storageType = [{ ConvergentAttr }]; } diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 0c117bd6d636..6223fe7d2125 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -4105,6 +4105,7 @@ def FuncOp : CIR_Op<"func", [ UnitAttr:$lambda, UnitAttr:$no_proto, UnitAttr:$dso_local, + UnitAttr:$nothrow, DefaultValuedAttr< CIR_GlobalLinkageKind, "GlobalLinkageKind::ExternalLinkage" >:$linkage, diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp index 49e3bb41f0cc..d1701c63809e 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp @@ -162,8 +162,7 @@ static void AddAttributesFromFunctionProtoType(CIRGenBuilderTy &builder, if (!isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) && FPT->isNothrow()) { - auto nu = cir::NoThrowAttr::get(builder.getContext()); - FuncAttrs.set(nu.getMnemonic(), nu); + FuncAttrs.set("nothrow", builder.getUnitAttr()); } } @@ -221,8 +220,8 @@ void CIRGenModule::constructAttributeList( if (TargetDecl) { if (TargetDecl->hasAttr()) { - auto nu = cir::NoThrowAttr::get(&getMLIRContext()); - funcAttrs.set(nu.getMnemonic(), nu); + auto nu = mlir::UnitAttr::get(&getMLIRContext()); + funcAttrs.set("nothrow", nu); } if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) { @@ -324,7 +323,7 @@ emitCallLikeOp(CIRGenFunction &CGF, mlir::Location callLoc, cir::FuncOp directFuncOp, SmallVectorImpl &CIRCallArgs, bool isInvoke, cir::CallingConv callingConv, cir::SideEffect sideEffect, - cir::ExtraFuncAttributesAttr extraFnAttrs) { + cir::ExtraFuncAttributesAttr extraFnAttrs, bool cannotThrow) { auto &builder = CGF.getBuilder(); auto getOrCreateSurroundingTryOp = [&]() { // In OG, we build the landing pad for this scope. In CIR, we emit a @@ -383,6 +382,8 @@ emitCallLikeOp(CIRGenFunction &CGF, mlir::Location callLoc, callLoc, directFuncOp, CIRCallArgs, callingConv, sideEffect); } callOpWithExceptions->setAttr("extra_attrs", extraFnAttrs); + if (cannotThrow) + callOpWithExceptions->setAttr("nothrow", builder.getUnitAttr()); CGF.mayThrow = true; CGF.callWithExceptionCtx = callOpWithExceptions; @@ -398,15 +399,20 @@ emitCallLikeOp(CIRGenFunction &CGF, mlir::Location callLoc, } assert(builder.getInsertionBlock() && "expected valid basic block"); + cir::CIRCallOpInterface callOp; if (indirectFuncTy) { // TODO(cir): Set calling convention for indirect calls. assert(callingConv == cir::CallingConv::C && "NYI"); - return builder.createIndirectCallOp( + callOp = builder.createIndirectCallOp( callLoc, indirectFuncVal, indirectFuncTy, CIRCallArgs, cir::CallingConv::C, sideEffect, extraFnAttrs); + } else { + callOp = builder.createCallOp(callLoc, directFuncOp, CIRCallArgs, callingConv, + sideEffect, extraFnAttrs); } - return builder.createCallOp(callLoc, directFuncOp, CIRCallArgs, callingConv, - sideEffect, extraFnAttrs); + if (cannotThrow) + callOp->setAttr("nothrow", builder.getUnitAttr()); + return callOp; } static RValue getRValueThroughMemory(mlir::Location loc, @@ -601,12 +607,10 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &CallInfo, CannotThrow = true; } else { // Otherwise, nounwind call sites will never throw. - auto noThrowAttr = cir::NoThrowAttr::get(&getMLIRContext()); - CannotThrow = Attrs.getNamed(noThrowAttr.getMnemonic()).has_value(); + CannotThrow = Attrs.getNamed("nothrow").has_value(); if (auto fptr = dyn_cast(CalleePtr)) - if (fptr.getExtraAttrs().getElements().contains( - noThrowAttr.getMnemonic())) + if (fptr.getNothrow()) CannotThrow = true; } bool isInvoke = CannotThrow ? false : isInvokeDest(); @@ -650,7 +654,7 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &CallInfo, cir::CIRCallOpInterface callLikeOp = emitCallLikeOp( *this, callLoc, indirectFuncTy, indirectFuncVal, directFuncOp, - CIRCallArgs, isInvoke, callingConv, sideEffect, extraFnAttrs); + CIRCallArgs, isInvoke, callingConv, sideEffect, extraFnAttrs, CannotThrow); if (E) callLikeOp->setAttr("ast", @@ -1462,8 +1466,8 @@ static void getTrivialDefaultFunctionAttributes( llvm_unreachable("NYI"); if (langOpts.OpenCL || ((langOpts.CUDA || langOpts.HIP) && langOpts.CUDAIsDevice)) { - auto noThrow = cir::NoThrowAttr::get(CGM.getBuilder().getContext()); - funcAttrs.set(noThrow.getMnemonic(), noThrow); + auto noThrow = mlir::UnitAttr::get(CGM.getBuilder().getContext()); + funcAttrs.set("nothrow", noThrow); } } diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index 808fe95af5b2..d5625f9b39e2 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -683,11 +683,7 @@ static void tryMarkNoThrow(CIRGenFunction &cgf, cir::FuncOp fn) { if (isInterposable(fn) || cgf.mayThrow) return; - mlir::NamedAttrList extraAttrs{fn.getExtraAttrs().getElements().getValue()}; - auto noThrowAttr = cir::NoThrowAttr::get(&cgf.getMLIRContext()); - extraAttrs.set(noThrowAttr.getMnemonic(), noThrowAttr); - fn.setExtraAttrsAttr(cir::ExtraFuncAttributesAttr::get( - extraAttrs.getDictionary(&cgf.getMLIRContext()))); + fn.setNothrow(true); } cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn, diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index a45e6820cbf9..fc6b717ae09b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -2873,8 +2873,7 @@ void CIRGenModule::setCIRFunctionAttributesForDefinition(const Decl *decl, llvm_unreachable("NYI"); if (!hasUnwindExceptions(getLangOpts())) { - auto attr = cir::NoThrowAttr::get(&getMLIRContext()); - attrs.set(attr.getMnemonic(), attr); + f.setNothrow(true); } assert(!MissingFeatures::stackProtector()); @@ -3052,6 +3051,21 @@ void CIRGenModule::setCIRFunctionAttributes(GlobalDecl gd, func.setExtraAttrsAttr( cir::ExtraFuncAttributesAttr::get(pal.getDictionary(&getMLIRContext()))); + // Set nothrow as a direct attribute if the function declaration has it or + // if the function type is nothrow. + const Decl *TargetDecl = gd.getDecl(); + if (TargetDecl && TargetDecl->hasAttr()) { + func.setNothrow(true); + } else if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) { + if (const FunctionProtoType *FPT = + Fn->getType()->getAs()) { + if (!isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) && + FPT->isNothrow()) { + func.setNothrow(true); + } + } + } + // TODO(cir): Check X86_VectorCall incompatibility with WinARM64EC func.setCallingConv(callingConv); diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 4a4d098e8663..5aaf6af1313e 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -2641,6 +2641,7 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, OperationState &state) { auto noProtoNameAttr = getNoProtoAttrName(state.name); auto visibilityNameAttr = getGlobalVisibilityAttrName(state.name); auto dsoLocalNameAttr = getDsoLocalAttrName(state.name); + auto nothrowNameAttr = getNothrowAttrName(state.name); auto annotationsNameAttr = getAnnotationsAttrName(state.name); auto cxxSpecialMemberAttr = getCxxSpecialMemberAttrName(state.name); if (::mlir::succeeded(parser.parseOptionalKeyword(builtinNameAttr.strref()))) @@ -2676,6 +2677,8 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, OperationState &state) { if (parser.parseOptionalKeyword(dsoLocalNameAttr).succeeded()) state.addAttribute(dsoLocalNameAttr, parser.getBuilder().getUnitAttr()); + if (parser.parseOptionalKeyword(nothrowNameAttr).succeeded()) + state.addAttribute(nothrowNameAttr, parser.getBuilder().getUnitAttr()); StringAttr nameAttr; llvm::SmallVector arguments; @@ -2907,6 +2910,9 @@ void cir::FuncOp::print(OpAsmPrinter &p) { if (getDsoLocal()) p << " dso_local"; + if (getNothrow()) + p << " nothrow"; + // Print function name, signature, and control. p << ' '; p.printSymbolName(getSymName()); @@ -2932,7 +2938,7 @@ void cir::FuncOp::print(OpAsmPrinter &p) { p, *this, // These are all omitted since they are custom printed already. {getAliaseeAttrName(), getBuiltinAttrName(), getCoroutineAttrName(), - getDsoLocalAttrName(), getExtraAttrsAttrName(), + getDsoLocalAttrName(), getNothrowAttrName(), getExtraAttrsAttrName(), getFunctionTypeAttrName(), getGlobalCtorPriorityAttrName(), getGlobalDtorPriorityAttrName(), getLambdaAttrName(), getLinkageAttrName(), getCallingConvAttrName(), getNoProtoAttrName(), diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index d2efc8075119..8352871b40eb 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -2493,6 +2493,10 @@ mlir::LogicalResult CIRToLLVMFuncOpLowering::matchAndRewrite( llvmFnTy, linkage, isDsoLocal, cconv, mlir::SymbolRefAttr(), attributes); + if (op.getNothrow()) { + fn.setNoUnwind(true); + } + // Lower CIR attributes for arguments. for (unsigned index = 0; index < fnType.getNumInputs(); index++) { mlir::DictionaryAttr cirAttrs = op.getArgAttrDict(index); diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp index 520cc2109743..f8ee3ca0ea7f 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp @@ -112,8 +112,6 @@ class CIRDialectLLVMIRTranslationInterface llvm_unreachable("Unknown inline kind"); } else if (mlir::dyn_cast(attr.getValue())) { llvmFunc->addFnAttr(llvm::Attribute::OptimizeNone); - } else if (mlir::dyn_cast(attr.getValue())) { - llvmFunc->addFnAttr(llvm::Attribute::NoUnwind); } else if (mlir::dyn_cast(attr.getValue())) { llvmFunc->addFnAttr(llvm::Attribute::Convergent); } else if (mlir::isa(attr.getValue())) { diff --git a/clang/test/CIR/CodeGen/OpenCL/nothrow.cl b/clang/test/CIR/CodeGen/OpenCL/nothrow.cl index a45cf51ef649..22b1f7d7e7e5 100644 --- a/clang/test/CIR/CodeGen/OpenCL/nothrow.cl +++ b/clang/test/CIR/CodeGen/OpenCL/nothrow.cl @@ -5,18 +5,16 @@ // CIR-LABEL: #fn_attr = // CIR: cl.kernel = #cir.cl.kernel -// CIR: nothrow = #cir.nothrow // CIR-LABEL: #fn_attr1 = // CIR-NOT: cl.kernel = #cir.cl.kernel -// CIR: nothrow = #cir.nothrow kernel void ker() {}; -// CIR: cir.func @ker{{.*}} extra(#fn_attr) { +// CIR: cir.func nothrow @ker{{.*}} extra(#fn_attr) { // LLVM: define{{.*}}@ker(){{.*}} #0 void foo() {}; -// CIR: cir.func @foo{{.*}} extra(#fn_attr1) { +// CIR: cir.func nothrow @foo{{.*}} extra(#fn_attr1) { // LLVM: define{{.*}}@foo(){{.*}} #1 // LLVM-LABEL: attributes #0 diff --git a/clang/test/CIR/CodeGen/call-extra-attrs.cpp b/clang/test/CIR/CodeGen/call-extra-attrs.cpp index a9b21d144f3f..5f764c00a897 100644 --- a/clang/test/CIR/CodeGen/call-extra-attrs.cpp +++ b/clang/test/CIR/CodeGen/call-extra-attrs.cpp @@ -18,12 +18,10 @@ int s2(int a, int b) { return s1(a, b); } -// CIR: #fn_attr = #cir, nothrow = #cir.nothrow, optnone = #cir.optnone})> -// CIR: #fn_attr1 = #cir +// CIR: #fn_attr = #cir, optnone = #cir.optnone})> // CIR: cir.func {{.*}} @_Z2s0ii(%{{.*}}, %{{.*}}) -> {{.*}} extra(#fn_attr) // CIR: cir.func {{.*}} @_Z2s1ii(%{{.*}}, %{{.*}}) -> {{.*}} extra(#fn_attr) -// CIR: cir.call @_Z2s0ii(%{{.*}}, %{{.*}}) : ({{.*}}, {{.*}}) -> {{.*}} extra(#fn_attr1) // CIR: cir.func {{.*}} @_Z2s2ii(%{{.*}}, %{{.*}}) -> {{.*}} extra(#fn_attr) // CHECK-NOT: cir.call @_Z2s1ii(%{{.*}}, %{{.*}}) : ({{.*}}, {{.*}}) -> {{.*}} extra(#fn_attr{{.*}}) diff --git a/clang/test/CIR/CodeGen/conditional-cleanup.cpp b/clang/test/CIR/CodeGen/conditional-cleanup.cpp index 2fbf882acade..e4798358dd7f 100644 --- a/clang/test/CIR/CodeGen/conditional-cleanup.cpp +++ b/clang/test/CIR/CodeGen/conditional-cleanup.cpp @@ -81,7 +81,6 @@ namespace test7 { // CIR: } // CIR_EH-DAG: #[[$ATTR_0:.+]] = #cir.bool : !cir.bool -// CIR_EH-DAG: #[[$ATTR_1:.+]] = #cir // CIR_EH-DAG: #[[$ATTR_2:.+]] = #cir, optnone = #cir.optnone})> // CIR_EH-DAG: #[[$ATTR_3:.+]] = #cir.bool : !cir.bool diff --git a/clang/test/CIR/CodeGen/coro-task.cpp b/clang/test/CIR/CodeGen/coro-task.cpp index 7b422e4f867d..975f9b1b0d3d 100644 --- a/clang/test/CIR/CodeGen/coro-task.cpp +++ b/clang/test/CIR/CodeGen/coro-task.cpp @@ -139,7 +139,7 @@ co_invoke_fn co_invoke; // CHECK: cir.func builtin private @__builtin_coro_id(!u32i, !cir.ptr, !cir.ptr, !cir.ptr) -> !u32i // CHECK: cir.func builtin private @__builtin_coro_alloc(!u32i) -> !cir.bool -// CHECK: cir.func builtin private @__builtin_coro_size() -> !u64i +// CHECK: cir.func builtin private nothrow @__builtin_coro_size() -> !u64i // CHECK: cir.func builtin private @__builtin_coro_begin(!u32i, !cir.ptr) -> !cir.ptr using VoidTask = folly::coro::Task; @@ -148,7 +148,7 @@ VoidTask silly_task() { co_await std::suspend_always(); } -// CHECK: cir.func coroutine dso_local @_Z10silly_taskv() -> ![[VoidTask]] extra{{.*}}{ +// CHECK: cir.func coroutine dso_local nothrow @_Z10silly_taskv() -> ![[VoidTask]] // Allocate promise. @@ -274,7 +274,7 @@ folly::coro::Task byRef(const std::string& s) { } // FIXME: this could be less redundant than two allocas + reloads -// CHECK: cir.func coroutine dso_local @_Z5byRefRKSt6string(%arg0: !cir.ptr {{.*}} ![[IntTask]] extra{{.*}}{ +// CHECK: cir.func coroutine {{.*}} @_Z5byRefRKSt6string(%arg0: !cir.ptr {{.*}} ![[IntTask]] // CHECK: %[[#AllocaParam:]] = cir.alloca !cir.ptr, {{.*}} ["s", init, const] // CHECK: %[[#AllocaFnUse:]] = cir.alloca !cir.ptr, {{.*}} ["s", init, const] @@ -291,7 +291,7 @@ folly::coro::Task silly_coro() { // Make sure we properly handle OnFallthrough coro body sub stmt and // check there are not multiple co_returns emitted. -// CHECK: cir.func coroutine dso_local @_Z10silly_corov() {{.*}} ![[VoidTask]] extra{{.*}}{ +// CHECK: cir.func coroutine {{.*}} @_Z10silly_corov() {{.*}} ![[VoidTask]] // CHECK: cir.await(init, ready : { // CHECK: cir.call @_ZN5folly4coro4TaskIvE12promise_type11return_voidEv // CHECK-NOT: cir.call @_ZN5folly4coro4TaskIvE12promise_type11return_voidEv @@ -303,7 +303,7 @@ folly::coro::Task go1() { co_return co_await task; } -// CHECK: cir.func coroutine dso_local @_Z3go1v() {{.*}} ![[IntTask]] extra{{.*}}{ +// CHECK: cir.func coroutine {{.*}} @_Z3go1v() {{.*}} ![[IntTask]] // CHECK: %[[#IntTaskAddr:]] = cir.alloca ![[IntTask]], !cir.ptr, ["task", init] // CHECK: cir.await(init, ready : { @@ -338,8 +338,8 @@ folly::coro::Task go1_lambda() { co_return co_await task; } -// CHECK: cir.func coroutine lambda internal private dso_local @_ZZ10go1_lambdavENK3$_0clEv{{.*}} ![[IntTask]] extra{{.*}}{ -// CHECK: cir.func coroutine dso_local @_Z10go1_lambdav() {{.*}} ![[IntTask]] extra{{.*}}{ +// CHECK: cir.func coroutine lambda {{.*}} @_ZZ10go1_lambdavENK3$_0clEv{{.*}} ![[IntTask]] +// CHECK: cir.func coroutine {{.*}} @_Z10go1_lambdav() {{.*}} ![[IntTask]] folly::coro::Task go4() { auto* fn = +[](int const& i) -> folly::coro::Task { co_return i; }; @@ -347,7 +347,7 @@ folly::coro::Task go4() { co_return co_await std::move(task); } -// CHECK: cir.func coroutine dso_local @_Z3go4v() {{.*}} ![[IntTask]] extra{{.*}}{ +// CHECK: cir.func coroutine {{.*}} @_Z3go4v() {{.*}} ![[IntTask]] // CHECK: cir.await(init, ready : { // CHECK: }, suspend : { @@ -387,7 +387,7 @@ folly::coro::Task yield1() { co_yield t; } -// CHECK: cir.func coroutine dso_local @_Z6yield1v() -> !rec_folly3A3Acoro3A3ATask3Cvoid3E +// CHECK: cir.func coroutine {{.*}} @_Z6yield1v() -> !rec_folly3A3Acoro3A3ATask3Cvoid3E // CHECK: cir.await(init, ready : { // CHECK: }, suspend : { diff --git a/clang/test/CIR/CodeGen/default-methods.cpp b/clang/test/CIR/CodeGen/default-methods.cpp index b2cec52a456d..8f187b365ec1 100644 --- a/clang/test/CIR/CodeGen/default-methods.cpp +++ b/clang/test/CIR/CodeGen/default-methods.cpp @@ -10,8 +10,8 @@ struct S { } t; }; -// CIR-LABEL: cir.func linkonce_odr @_ZN1S1TaSERKS0_({{.*}} { -// CIR-LABEL: cir.func linkonce_odr @_ZN1SaSERKS_( +// CIR-LABEL: cir.func linkonce_odr nothrow @_ZN1S1TaSERKS0_({{.*}} { +// CIR-LABEL: cir.func linkonce_odr nothrow @_ZN1SaSERKS_( // CIR: cir.call @_ZN1S1TaSERKS0_( // CIR-LABEL: cir.func {{.*}} @_Z1fR1SS0_( // CIR: cir.call @_ZN1SaSERKS_( diff --git a/clang/test/CIR/CodeGen/dynamic-cast.mlir b/clang/test/CIR/CodeGen/dynamic-cast.mlir index 83193bc1a4bd..d86df12b69d2 100644 --- a/clang/test/CIR/CodeGen/dynamic-cast.mlir +++ b/clang/test/CIR/CodeGen/dynamic-cast.mlir @@ -21,7 +21,7 @@ module @"/Users/henrichlauko/src/clangir/clang/test/CIR/CodeGen/dynamic-cast.cpp cir.global constant external @_ZTI7Derived = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2 : i32]> : !cir.ptr, #cir.global_view<@_ZTS7Derived> : !cir.ptr, #cir.global_view<@_ZTI4Base> : !cir.ptr}> : !rec_anon_struct {alignment = 8 : i64} loc(#loc28) cir.func private @__dynamic_cast(!cir.ptr, !cir.ptr, !cir.ptr, !s64i) -> !cir.ptr loc(#loc) cir.func private @__cxa_bad_cast() loc(#loc) - cir.func dso_local @_Z8ptr_castP4Base(%arg0: !cir.ptr loc(fused[#loc5, #loc6])) -> !cir.ptr {inline = #cir.inline, nothrow = #cir.nothrow, optnone = #cir.optnone} { + cir.func dso_local nothrow @_Z8ptr_castP4Base(%arg0: !cir.ptr loc(fused[#loc5, #loc6])) -> !cir.ptr {inline = #cir.inline, optnone = #cir.optnone} { %0 = cir.alloca !cir.ptr, !cir.ptr>, ["b", init] {alignment = 8 : i64} loc(#loc30) %1 = cir.alloca !cir.ptr, !cir.ptr>, ["__retval"] {alignment = 8 : i64} loc(#loc4) cir.store %arg0, %0 : !cir.ptr, !cir.ptr> loc(#loc7) @@ -43,7 +43,7 @@ module @"/Users/henrichlauko/src/clangir/clang/test/CIR/CodeGen/dynamic-cast.cpp %5 = cir.load %1 : !cir.ptr>, !cir.ptr loc(#loc31) cir.return %5 : !cir.ptr loc(#loc31) } loc(#loc29) - cir.func dso_local @_Z8ref_castR4Base(%arg0: !cir.ptr loc(fused[#loc12, #loc13])) -> !cir.ptr {inline = #cir.inline, nothrow = #cir.nothrow, optnone = #cir.optnone} { + cir.func {{.*}} @_Z8ref_castR4Base(%arg0: !cir.ptr loc(fused[#loc12, #loc13])) -> !cir.ptr {inline = #cir.inline, optnone = #cir.optnone} { %0 = cir.alloca !cir.ptr, !cir.ptr>, ["b", init, const] {alignment = 8 : i64} loc(#loc33) %1 = cir.alloca !cir.ptr, !cir.ptr>, ["__retval"] {alignment = 8 : i64} loc(#loc11) cir.store %arg0, %0 : !cir.ptr, !cir.ptr> loc(#loc14) @@ -64,7 +64,7 @@ module @"/Users/henrichlauko/src/clangir/clang/test/CIR/CodeGen/dynamic-cast.cpp %11 = cir.load %1 : !cir.ptr>, !cir.ptr loc(#loc35) cir.return %11 : !cir.ptr loc(#loc35) } loc(#loc32) - cir.func dso_local @_Z20ptr_cast_to_completeP4Base(%arg0: !cir.ptr loc(fused[#loc21, #loc22])) -> !cir.ptr {inline = #cir.inline, nothrow = #cir.nothrow, optnone = #cir.optnone} { + cir.func {{.*}} @_Z20ptr_cast_to_completeP4Base(%arg0: !cir.ptr loc(fused[#loc21, #loc22])) -> !cir.ptr {inline = #cir.inline, optnone = #cir.optnone} { %0 = cir.alloca !cir.ptr, !cir.ptr>, ["ptr", init] {alignment = 8 : i64} loc(#loc37) %1 = cir.alloca !cir.ptr, !cir.ptr>, ["__retval"] {alignment = 8 : i64} loc(#loc20) cir.store %arg0, %0 : !cir.ptr, !cir.ptr> loc(#loc23) diff --git a/clang/test/CIR/CodeGen/function-attrs.cpp b/clang/test/CIR/CodeGen/function-attrs.cpp index 0114f34ff86e..9a6d4c6c0585 100644 --- a/clang/test/CIR/CodeGen/function-attrs.cpp +++ b/clang/test/CIR/CodeGen/function-attrs.cpp @@ -24,13 +24,13 @@ int s3(int a, int b) { return x; } -// CIR: #fn_attr = #cir, nothrow = #cir.nothrow})> -// CIR: #fn_attr1 = #cir, nothrow = #cir.nothrow})> -// CIR: #fn_attr2 = #cir, nothrow = #cir.nothrow})> +// CIR: #fn_attr = #cir})> +// CIR: #fn_attr1 = #cir})> +// CIR: #fn_attr2 = #cir})> -// CIR: cir.func linkonce_odr @_Z2s0ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr) -// CIR: cir.func {{.*}} @_Z2s1ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr1) -// CIR: cir.func {{.*}} @_Z2s2ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr2) +// CIR: cir.func linkonce_odr nothrow @_Z2s0ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr) +// CIR: cir.func {{.*}} nothrow @_Z2s1ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr1) +// CIR: cir.func {{.*}} nothrow @_Z2s2ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr2) // CIR: cir.func {{.*}} @_Z2s3ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} { // LLVM: define dso_local i32 @_Z2s1ii(i32 %0, i32 %1) {{.*}} #[[#ATTR1:]] diff --git a/clang/test/CIR/CodeGen/hello.c b/clang/test/CIR/CodeGen/hello.c index 251e333f86ec..37e338d95180 100644 --- a/clang/test/CIR/CodeGen/hello.c +++ b/clang/test/CIR/CodeGen/hello.c @@ -7,7 +7,7 @@ int main (void) { return 0; } -// CHECK: cir.func private @printf(!cir.ptr, ...) -> !s32i +// CHECK: cir.func {{.*}} @printf(!cir.ptr, ...) -> !s32i // CHECK: cir.global "private" constant cir_private dso_local @".str" = #cir.const_array<"Hello, world!\0A\00" : !cir.array> : !cir.array {alignment = 1 : i64} // CHECK: cir.func {{.*}} @main() -> !s32i // CHECK: %0 = cir.alloca !s32i, !cir.ptr, ["__retval"] {alignment = 4 : i64} diff --git a/clang/test/CIR/CodeGen/lambda.cpp b/clang/test/CIR/CodeGen/lambda.cpp index 134e6bcb6e7a..c4aaf34a923a 100644 --- a/clang/test/CIR/CodeGen/lambda.cpp +++ b/clang/test/CIR/CodeGen/lambda.cpp @@ -15,7 +15,7 @@ void fn() { // CHECK-DAG: !rec_anon2E8 = !cir.record}> // CHECK-DAG: module -// CHECK: cir.func lambda internal private dso_local @_ZZ2fnvENK3$_0clEv{{.*}}) extra +// CHECK: cir.func lambda internal private dso_local nothrow @_ZZ2fnvENK3$_0clEv{{.*}}) // CHECK: cir.func {{.*}} @_Z2fnv() // CHECK-NEXT: %0 = cir.alloca !rec_anon2E0, !cir.ptr, ["a"] @@ -41,7 +41,7 @@ void l0() { a(); } -// CHECK: cir.func lambda internal private dso_local @_ZZ2l0vENK3$_0clEv({{.*}}) extra +// CHECK: cir.func lambda internal private dso_local nothrow @_ZZ2l0vENK3$_0clEv({{.*}}) // CHECK: %0 = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] {alignment = 8 : i64} // CHECK: cir.store{{.*}} %arg0, %0 : !cir.ptr, !cir.ptr> @@ -197,13 +197,13 @@ int g3() { } // lambda operator() -// CHECK: cir.func lambda internal private dso_local @_ZZ2g3vENK3$_0clERKi{{.*}}!s32i extra +// CHECK: cir.func lambda internal private dso_local nothrow @_ZZ2g3vENK3$_0clERKi{{.*}} // lambda __invoke() -// CHECK: cir.func internal private dso_local @_ZZ2g3vEN3$_08__invokeERKi +// CHECK: cir.func internal private dso_local nothrow @_ZZ2g3vEN3$_08__invokeERKi // lambda operator int (*)(int const&)() -// CHECK: cir.func internal private dso_local @_ZZ2g3vENK3$_0cvPFiRKiEEv +// CHECK: cir.func internal private dso_local nothrow @_ZZ2g3vENK3$_0cvPFiRKiEEv // CHECK-LABEL: @_Z2g3v() // CHECK: %0 = cir.alloca !s32i, !cir.ptr, ["__retval"] {alignment = 4 : i64} diff --git a/clang/test/CIR/CodeGen/null-arithmatic-expression.c b/clang/test/CIR/CodeGen/null-arithmatic-expression.c index d3d45aed410e..d994dc92ccf3 100644 --- a/clang/test/CIR/CodeGen/null-arithmatic-expression.c +++ b/clang/test/CIR/CodeGen/null-arithmatic-expression.c @@ -6,7 +6,7 @@ char *foo() { return (char*)NULL + 1; } -// CHECK: cir.func no_proto dso_local @foo() +// CHECK: cir.func {{.*}} @foo() // CHECK: [[CONST_1:%[0-9]+]] = cir.const #cir.int<1> : !s32i // CHECK: {{.*}} = cir.cast int_to_ptr [[CONST_1]] : !s32i // CHECK: cir.return diff --git a/clang/test/CIR/CodeGen/optnone.cpp b/clang/test/CIR/CodeGen/optnone.cpp index 64b4cd3b166b..00b01b9fb152 100644 --- a/clang/test/CIR/CodeGen/optnone.cpp +++ b/clang/test/CIR/CodeGen/optnone.cpp @@ -17,7 +17,7 @@ int s0(int a, int b) { return x; } -// CIR-O0: #fn_attr = #cir, nothrow = #cir.nothrow, optnone = #cir.optnone})> +// CIR-O0: #fn_attr = #cir, optnone = #cir.optnone})> // CIR-O0: cir.func {{.*}} @_Z2s0ii(%arg0:{{.*}}, %arg1:{{.*}} -> {{.*}} extra(#fn_attr) // CIR-O2-NOT: #fn_attr ={{.*}} optnone diff --git a/clang/test/CIR/CodeGen/temporaries.cpp b/clang/test/CIR/CodeGen/temporaries.cpp index 64ab5634899f..6642880151e4 100644 --- a/clang/test/CIR/CodeGen/temporaries.cpp +++ b/clang/test/CIR/CodeGen/temporaries.cpp @@ -14,18 +14,18 @@ void f() { !E(); } -// CIR: cir.func private @_ZN1EC1Ev(!cir.ptr) special_member<#cir.cxx_ctor> extra(#fn_attr) -// CIR-NEXT: cir.func private @_ZN1EntEv(!cir.ptr) -> !rec_E -// CIR-NEXT: cir.func private @_ZN1ED1Ev(!cir.ptr) special_member<#cir.cxx_dtor> extra(#fn_attr) -// CIR-NEXT: cir.func {{.*}} @_Z1fv() extra(#fn_attr1) { +// CIR: cir.func {{.*}} @_ZN1EC1Ev(!cir.ptr) special_member<#cir.cxx_ctor> +// CIR-NEXT: cir.func {{.*}} @_ZN1EntEv(!cir.ptr) -> !rec_E +// CIR-NEXT: cir.func {{.*}} @_ZN1ED1Ev(!cir.ptr) special_member<#cir.cxx_dtor> +// CIR-NEXT: cir.func {{.*}} @_Z1fv() // CIR-NEXT: cir.scope { // CIR-NEXT: %[[ONE:[0-9]+]] = cir.alloca !rec_E, !cir.ptr, ["agg.tmp.ensured"] {alignment = 1 : i64} // CIR-NEXT: %[[TWO:[0-9]+]] = cir.alloca !rec_E, !cir.ptr, ["ref.tmp0"] {alignment = 1 : i64} -// CIR-NEXT: cir.call @_ZN1EC1Ev(%1) : (!cir.ptr) -> () extra(#fn_attr) +// CIR-NEXT: cir.call @_ZN1EC1Ev(%1) : (!cir.ptr) -> () // CIR-NEXT: %[[THREE:[0-9]+]] = cir.call @_ZN1EntEv(%[[TWO]]) : (!cir.ptr) -> !rec_E // CIR-NEXT: cir.store{{.*}} %[[THREE]], %[[ONE]] : !rec_E, !cir.ptr -// CIR-NEXT: cir.call @_ZN1ED1Ev(%[[ONE]]) : (!cir.ptr) -> () extra(#fn_attr) -// CIR-NEXT: cir.call @_ZN1ED1Ev(%[[TWO]]) : (!cir.ptr) -> () extra(#fn_attr) +// CIR-NEXT: cir.call @_ZN1ED1Ev(%[[ONE]]) : (!cir.ptr) -> () +// CIR-NEXT: cir.call @_ZN1ED1Ev(%[[TWO]]) : (!cir.ptr) -> () // CIR-NEXT: } // CIR-NEXT: cir.return // CIR-NEXT: } diff --git a/clang/test/CIR/IR/call.cir b/clang/test/CIR/IR/call.cir index be86fe461577..e267ac145036 100644 --- a/clang/test/CIR/IR/call.cir +++ b/clang/test/CIR/IR/call.cir @@ -4,7 +4,6 @@ !fnptr = !cir.ptr !s32i>> #fn_attr = #cir, optnone = #cir.optnone})> -#fn_attr1 = #cir module { // Excerpt of std::array::operator[](unsigned long) @@ -18,11 +17,11 @@ module { %r = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i // CHECK: %0 = cir.call %arg0(%arg1) : (!cir.ptr !s32i>>, !s32i) -> !s32i // Check parse->pretty-print round-trip on extra() attribute - %7 = cir.call @_ZNSt5arrayIiLm8192EEixEm(%a) : (!s32i) -> !s32i extra(#fn_attr1) -// CHECK: %1 = cir.call @_ZNSt5arrayIiLm8192EEixEm(%arg1) : (!s32i) -> !s32i extra(#fn_attr1) + %7 = cir.call @_ZNSt5arrayIiLm8192EEixEm(%a) : (!s32i) -> !s32i +// CHECK: %1 = cir.call @_ZNSt5arrayIiLm8192EEixEm(%arg1) : (!s32i) -> !s32i // Frankenstein's example from clang/test/CIR/Lowering/call-op-call-conv.cir - %3 = cir.try_call @my_add(%r, %7) ^continue, ^landing_pad : (!s32i, !s32i) -> !s32i cc(spir_function) extra(#fn_attr1) -// CHECK: %2 = cir.try_call @my_add(%0, %1) ^bb1, ^bb2 : (!s32i, !s32i) -> !s32i cc(spir_function) extra(#fn_attr1) + %3 = cir.try_call @my_add(%r, %7) ^continue, ^landing_pad : (!s32i, !s32i) -> !s32i cc(spir_function) +// CHECK: %2 = cir.try_call @my_add(%0, %1) ^bb1, ^bb2 : (!s32i, !s32i) -> !s32i cc(spir_function) ^continue: cir.br ^landing_pad ^landing_pad: diff --git a/clang/test/CIR/IR/func-dsolocal-parser.cir b/clang/test/CIR/IR/func-dsolocal-parser.cir index 409974fb8ec0..08e083acb22f 100644 --- a/clang/test/CIR/IR/func-dsolocal-parser.cir +++ b/clang/test/CIR/IR/func-dsolocal-parser.cir @@ -1,9 +1,9 @@ // RUN: cir-opt %s --verify-roundtrip | FileCheck %s !s32i = !cir.int -#fn_attr = #cir, nothrow = #cir.nothrow, optnone = #cir.optnone})> +#fn_attr = #cir, optnone = #cir.optnone})> module { - cir.func dso_local @foo(%arg0: !s32i ) extra(#fn_attr) { + cir.func dso_local nothrow @foo(%arg0: !s32i ) extra(#fn_attr) { %0 = cir.alloca !s32i, !cir.ptr, ["i", init] {alignment = 4 : i64} cir.store %arg0, %0 : !s32i, !cir.ptr cir.return diff --git a/clang/test/CIR/IR/invalid.cir b/clang/test/CIR/IR/invalid.cir index 70846ac264cd..80d38728733c 100644 --- a/clang/test/CIR/IR/invalid.cir +++ b/clang/test/CIR/IR/invalid.cir @@ -1626,7 +1626,7 @@ cir.func @invalidConditionTerminator (%arg0 : !cir.bool) -> !cir.void { !s16i = !cir.int !s32i = !cir.int -#fn_attr = #cir})> +#fn_attr = #cir})> !rec_S = !cir.record #tbaa_scalar = #cir.tbaa_scalar // expected-error @below {{invalid kind of attribute specified}} @@ -1634,7 +1634,7 @@ cir.func @invalidConditionTerminator (%arg0 : !cir.bool) -> !cir.void { #tbaa_struct = #cir.tbaa_struct}> #tbaa_tag = #cir.tbaa_tag cir.global external dso_local @glob = #cir.zero : !rec_S {alignment = 2 : i64} -cir.func dso_local @main() -> !s32i extra(#fn_attr) { +cir.func dso_local nothrow @main() -> !s32i extra(#fn_attr) { %0 = cir.alloca !s32i, !cir.ptr, ["__retval"] {alignment = 4 : i64} %1 = cir.const #cir.int<0> : !s32i %2 = cir.cast integral %1 : !s32i -> !s16i diff --git a/clang/test/CIR/IR/tbaa-parse.cir b/clang/test/CIR/IR/tbaa-parse.cir index 723c31537704..63e53f8fd75d 100644 --- a/clang/test/CIR/IR/tbaa-parse.cir +++ b/clang/test/CIR/IR/tbaa-parse.cir @@ -2,7 +2,7 @@ !s16i = !cir.int !s32i = !cir.int -#fn_attr = #cir})> +#fn_attr = #cir})> !rec_S = !cir.record // CHECK: #tbaa_scalar = #cir.tbaa_scalar // CHECK: #tbaa_struct = #cir.tbaa_struct}> @@ -11,7 +11,7 @@ #tbaa_struct = #cir.tbaa_struct}> #tbaa_tag = #cir.tbaa_tag cir.global external dso_local @glob = #cir.zero : !rec_S {alignment = 2 : i64} -cir.func dso_local @main() -> !s32i extra(#fn_attr) { +cir.func dso_local nothrow @main() -> !s32i extra(#fn_attr) { %0 = cir.alloca !s32i, !cir.ptr, ["__retval"] {alignment = 4 : i64} %1 = cir.const #cir.int<0> : !s32i %2 = cir.cast integral %1 : !s32i -> !s16i diff --git a/clang/test/CIR/Lowering/brcond.cir b/clang/test/CIR/Lowering/brcond.cir index 41722a54af49..f516626d029b 100644 --- a/clang/test/CIR/Lowering/brcond.cir +++ b/clang/test/CIR/Lowering/brcond.cir @@ -2,8 +2,9 @@ // RUN: cir-translate %s -cir-to-llvmir --disable-cc-lowering | FileCheck %s -check-prefix=LLVM !s32i = !cir.int -#fn_attr = #cir, nothrow = #cir.nothrow, optnone = #cir.optnone})> -module { cir.func no_proto @test() -> !cir.bool extra(#fn_attr) { +#fn_attr = #cir, optnone = #cir.optnone})> +module { + cir.func no_proto nothrow @test() -> !cir.bool extra(#fn_attr) { %0 = cir.const #cir.int<0> : !s32i %1 = cir.cast int_to_bool %0 : !s32i -> !cir.bool cir.br ^bb1 diff --git a/clang/test/CIR/Lowering/syncscope.cir b/clang/test/CIR/Lowering/syncscope.cir index 49ef200a1a3a..4686b0b8d037 100644 --- a/clang/test/CIR/Lowering/syncscope.cir +++ b/clang/test/CIR/Lowering/syncscope.cir @@ -1,14 +1,14 @@ // RUN: cir-translate %s -cir-to-llvmir --disable-cc-lowering -o - | FileCheck %s -check-prefix=LLVM !s32i = !cir.int -#fn_attr = #cir, nothrow = #cir.nothrow, optnone = #cir.optnone})> +#fn_attr = #cir, optnone = #cir.optnone})> module { cir.func @test(%ptr: !cir.ptr, %expected: !s32i, %desired: !s32i) -> !cir.bool extra(#fn_attr) { %old, %cmp = cir.atomic.cmp_xchg(%ptr : !cir.ptr, %expected : !s32i, %desired : !s32i, success = acquire, failure = acquire) syncscope(single_thread) align(4) : (!s32i, !cir.bool) cir.return %cmp: !cir.bool } - cir.func @load(%ptr: !cir.ptr) -> !s32i extra(#fn_attr) { + cir.func nothrow @load(%ptr: !cir.ptr) -> !s32i extra(#fn_attr) { %val = cir.load syncscope(single_thread) atomic(relaxed) %ptr : !cir.ptr, !s32i cir.return %val : !s32i }