Excellent :) On Mon, Jan 8, 2018 at 8:39 AM Adrian Prantl <apra...@apple.com> wrote:
> > On Jan 8, 2018, at 8:14 AM, David Blaikie <dblai...@gmail.com> wrote: > > Great - are you tracking/planning to implement this for trivial_abi once > it's in? (was mentioned in the code review, but not sure if it's on your > plate/plan or not (no worries if it isn't, just keeping these things in > mind)) > > > Yes, this was in fact my primary motivation for the feature. Since the > code is asking the ABI object, it looks like this might work out of the box > with the trivial_abi attribute, but I will definitely at least add a > testcase once it's in. > > -- adrian > > > On Thu, Jan 4, 2018 at 5:14 PM Adrian Prantl via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: adrian >> Date: Thu Jan 4 17:13:52 2018 >> New Revision: 321845 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=321845&view=rev >> Log: >> Debug Info: Support DW_AT_calling_convention on composite types. >> This implements the DWARF 5 feature described at >> http://www.dwarfstd.org/ShowIssue.php?issue=141215.1 >> >> This allows a consumer to understand whether a composite data type is >> trivially copyable and thus should be passed by value instead of by >> reference. The canonical example is being able to distinguish the >> following two types: >> >> // S is not trivially copyable because of the explicit destructor. >> struct S { >> ~S() {} >> }; >> >> // T is a POD type. >> struct T { >> ~T() = default; >> }; >> >> <rdar://problem/36034993> >> Differential Revision: https://reviews.llvm.org/D41039 >> >> Added: >> cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp >> Modified: >> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp >> >> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff >> >> ============================================================================== >> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan 4 17:13:52 2018 >> @@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea >> >> SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU); >> >> + // Explicitly record the calling convention for C++ records. >> + auto Flags = llvm::DINode::FlagZero; >> + if (auto CXXRD = dyn_cast<CXXRecordDecl>(RD)) { >> + if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect) >> + Flags |= llvm::DINode::FlagTypePassByReference; >> + else >> + Flags |= llvm::DINode::FlagTypePassByValue; >> + } >> + >> llvm::DICompositeType *RealDecl = >> DBuilder.createReplaceableCompositeType( >> getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, >> Align, >> - llvm::DINode::FlagZero, FullName); >> + Flags, FullName); >> >> // Elements of composite types usually have back to the type, creating >> // uniquing cycles. Distinct nodes are more efficient. >> >> Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto >> >> ============================================================================== >> --- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added) >> +++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan 4 >> 17:13:52 2018 >> @@ -0,0 +1,48 @@ >> +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple >> %itanium_abi_triple %s -o - | FileCheck %s >> + >> +// Not trivially copyable because of the explicit destructor. >> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags: >> DIFlagTypePassByReference >> +struct RefDtor { >> + int i; >> + ~RefDtor() {} >> +} refDtor; >> + >> +// Not trivially copyable because of the explicit copy constructor. >> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags: >> DIFlagTypePassByReference >> +struct RefCopy { >> + int i; >> + RefCopy() = default; >> + RefCopy(RefCopy &Copy) {} >> +} refCopy; >> + >> +// Not trivially copyable because of the explicit move constructor. >> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags: >> DIFlagTypePassByReference >> +struct RefMove { >> + int i; >> + RefMove() = default; >> + RefMove(RefMove &&Move) {} >> +} refMove; >> + >> +// POD-like type even though it defines a destructor. >> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags: >> DIFlagTypePassByValue >> +struct Podlike { >> + int i; >> + Podlike() = default; >> + Podlike(Podlike &&Move) = default; >> + ~Podlike() = default; >> +} podlike; >> + >> + >> +// This is a POD type. >> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Pod",{{.*}}flags: >> DIFlagTypePassByValue >> +struct Pod { >> + int i; >> +} pod; >> + >> +// This is definitely not a POD type. >> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Complex",{{.*}}flags: >> DIFlagTypePassByReference >> +struct Complex { >> + Complex() {} >> + Complex(Complex &Copy) : i(Copy.i) {}; >> + int i; >> +} complex; >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits