efriedma created this revision. efriedma added reviewers: rsmith, ahatanak, rjmccall. Herald added a subscriber: jfb. efriedma requested review of this revision. Herald added a project: clang.
I wouldn't recommend writing code like the testcase; a function parameter isn't atomic, so using an atomic type doesn't really make sense. But it's valid, so clang shouldn't crash on it. The code was assuming hasAggregateEvaluationKind(Ty) implies Ty is a RecordType, which isn't true. Looking at the code, I think the only other possibility for a parameter is an atomic type, though. Atomic types are always trivially destructible, I think. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D102015 Files: clang/lib/CodeGen/CGDecl.cpp clang/test/CodeGen/big-atomic-ops.c Index: clang/test/CodeGen/big-atomic-ops.c =================================================================== --- clang/test/CodeGen/big-atomic-ops.c +++ clang/test/CodeGen/big-atomic-ops.c @@ -311,4 +311,9 @@ // CHECK: } } +// Check this doesn't crash +// CHECK: @test_atomic_array_param( +void test_atomic_array_param(_Atomic(struct foo) a) { +} + #endif Index: clang/lib/CodeGen/CGDecl.cpp =================================================================== --- clang/lib/CodeGen/CGDecl.cpp +++ clang/lib/CodeGen/CGDecl.cpp @@ -2474,6 +2474,7 @@ // Don't push a cleanup in a thunk for a method that will also emit a // cleanup. if (hasAggregateEvaluationKind(Ty) && !CurFuncIsThunk && + !Ty->isAtomicType() && Ty->castAs<RecordType>()->getDecl()->isParamDestroyedInCallee()) { if (QualType::DestructionKind DtorKind = D.needsDestruction(getContext())) {
Index: clang/test/CodeGen/big-atomic-ops.c =================================================================== --- clang/test/CodeGen/big-atomic-ops.c +++ clang/test/CodeGen/big-atomic-ops.c @@ -311,4 +311,9 @@ // CHECK: } } +// Check this doesn't crash +// CHECK: @test_atomic_array_param( +void test_atomic_array_param(_Atomic(struct foo) a) { +} + #endif Index: clang/lib/CodeGen/CGDecl.cpp =================================================================== --- clang/lib/CodeGen/CGDecl.cpp +++ clang/lib/CodeGen/CGDecl.cpp @@ -2474,6 +2474,7 @@ // Don't push a cleanup in a thunk for a method that will also emit a // cleanup. if (hasAggregateEvaluationKind(Ty) && !CurFuncIsThunk && + !Ty->isAtomicType() && Ty->castAs<RecordType>()->getDecl()->isParamDestroyedInCallee()) { if (QualType::DestructionKind DtorKind = D.needsDestruction(getContext())) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits