https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/136361
LowerGlobalDtors: Use use_empty instead of getNumUses == 0 (#136337) [flang] Improve runtime SAME_TYPE_AS() (#135670) The present implementation of the intrinsic function SAME_TYPE_AS() yields false positive .TRUE. results for distinct derived types that happen to have the same name. Replace with an implementation that can now depend on derived type information records being the same type if and only if they are at the same location, or are PDT instantiations of the same uninstantiated derived type. And ensure that the derived type information includes references from instantiated PDTs to their original types. (The derived type information format supports these references already, but they were not being set, perhaps because the current faulty SAME_TYPE_AS implementation didn't need them, and nothing else does.) Fixes https://github.com/llvm/llvm-project/issues/135580. [flang] Compile the output of -fdebug-unparse-with-modules (#135696) The output of a compilation with the -fdebug-unparse-with-modules option comprises its normal unparsed output along with the regenerated contents of any modules that were required from module files. This is handy for producing stand-alone test cases. The modules' contents are generated by the same code that writes module files, so they can contain some USE associations to private entities in other modules that are necessary to complete local declarations, usually initializers. Such USE associations to private entities are not flagged as fatal errors when modules are read from module files, but they currently are caught when the output produced by this option is being read back in to the compiler. Handle this case by softening the error to a warning when one module uses a private entity from another with an alias containing the non-conforming '$' character. (I could have omitted the message altogether, but there are other valid warnings that will occur due to undefined function result variables; further, I didn't want to provide a general hole around the protection of private names.) [flang] Fix fixed-form continuations of !$ OpenMP conditional lines (#135852) I broke fixed-form line continuation (without !$) for OpenMP !$ conditional compilation lines. Fix it. [flang] Improve OpenACC SELF clause parser (#135883) The current parser can fail on "self(x * 2)" by recognizing just "x" as a one-element list of object names and then failing at a higher level because it never reached the right parenthesis. Add lookahead checks and error recovery. Fixes https://github.com/llvm/llvm-project/issues/135810. [flang][runtime] Better handling for integer input into null address (#135987) The original descriptor-only path for I/O checks for null data addresses and crashes with a readable message, but there's no such check on the new fast path for formatted integer input, and so a READ into (say) a deallocated allocatable will crash with a segfault. Put a null data address check on the new fast path. [flang][CUDA] Add error & warning for device argument first dimension… (#136058) … discontiguity For dummy assumed-shape/-rank device arrays, test the associated actual argument for stride-1 contiguity, and report an error when the actual argument is known to not be stride-1 contiguous and nonempty, or a warning when when the actual argument is not known to be empty or stride-1 contiguous. [flang] Don't perform macro replacement on exponents (#136176) See new test. I inadvertently broke this behavior with a recent fix for another problem, because the effects of the overloaded TokenSequence::Put() member function on token merging were confusing. Rename and document the various overloads. [flang][OpenACC] Fix crash due to truncated scope source range (#136206) A combined construct needs to ensure that the source range of their initial statement is part of the source range of their scope. Fixes https://github.com/llvm/llvm-project/issues/136076. [flang] Tweak integer output under width-free I/G editing (#136316) A recent patch fixed Fujitsu test case 0561_0168 by emitting a leading space for "bare" (no width 'w') I and G output editing of integer values. This fix has broken another Fujitsu test case (0561_0168), since the leading space should not be produced at the first column of the output record. Adjust. [CIR] Upstream support for typedef and type aliases (#136335) Nothing is actually needed in ClangIR to support typedef and type aliases, but the Decl kinds need to be explicitly ignored in the emitDecl handlers to avoid hitting the default NYI errors. This change does that and adds tests. [CIR] Infer MLIR context in type builders when possible >From 6efc75121afe96586658393eb935713417fae000 Mon Sep 17 00:00:00 2001 From: xlauko <xla...@mail.muni.cz> Date: Fri, 18 Apr 2025 21:59:30 +0200 Subject: [PATCH] [CIR] Infer MLIR context in type builders when possible --- clang/include/clang/CIR/Dialect/IR/CIRTypes.td | 8 ++++++++ clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp | 3 +-- clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp | 3 +-- clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 3 +-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index b028bc7db4e59..a552b6081f5dc 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -294,6 +294,14 @@ def CIR_ArrayType : CIR_Type<"Array", "array", let parameters = (ins "mlir::Type":$eltType, "uint64_t":$size); + let builders = [ + TypeBuilderWithInferredContext<(ins + "mlir::Type":$eltType, "uint64_t":$size + ), [{ + return $_get(eltType.getContext(), eltType, size); + }]>, + ]; + let assemblyFormat = [{ `<` $eltType `x` $size `>` }]; diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp index 50fa029851f33..0caa8961ed0a6 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp @@ -206,8 +206,7 @@ emitArrayConstant(CIRGenModule &cgm, mlir::Type desiredType, eles.push_back(element); return cir::ConstArrayAttr::get( - cir::ArrayType::get(builder.getContext(), commonElementType, - arrayBound), + cir::ArrayType::get(commonElementType, arrayBound), mlir::ArrayAttr::get(builder.getContext(), eles)); } diff --git a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp index 5e209b5b92503..83aba256cd48e 100644 --- a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp @@ -102,8 +102,7 @@ struct CIRRecordLowering final { mlir::Type type = getCharType(); return numberOfChars == CharUnits::One() ? type - : cir::ArrayType::get(type.getContext(), type, - numberOfChars.getQuantity()); + : cir::ArrayType::get(type, numberOfChars.getQuantity()); } mlir::Type getStorageType(const FieldDecl *fieldDecl) { diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp index 7bd86cf0c7bcd..c286aef360b01 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp @@ -395,8 +395,7 @@ mlir::Type CIRGenTypes::convertType(QualType type) { case Type::ConstantArray: { const ConstantArrayType *arrTy = cast<ConstantArrayType>(ty); mlir::Type elemTy = convertTypeForMem(arrTy->getElementType()); - resultType = cir::ArrayType::get(builder.getContext(), elemTy, - arrTy->getSize().getZExtValue()); + resultType = cir::ArrayType::get(elemTy, arrTy->getSize().getZExtValue()); break; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits