summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-05-01 03:07:18 +0000
committerReid Kleckner <reid@kleckner.net>2014-05-01 03:07:18 +0000
commit380c0cfb644a51fb7bdecea32d83da5111dde0ab (patch)
treea58e248ddb5bcd5e1dcc5d938b5c4b73f68411c7 /lib/CodeGen/CGCall.cpp
parentfc666be85c1653c29ba0c4a4799c8d6bdc9fe456 (diff)
downloadclang-380c0cfb644a51fb7bdecea32d83da5111dde0ab.tar.gz
clang-380c0cfb644a51fb7bdecea32d83da5111dde0ab.tar.bz2
clang-380c0cfb644a51fb7bdecea32d83da5111dde0ab.tar.xz
MS ABI x64: Don't destroy arguments twice on x64
We were destroying them in the callee, and then again in the caller. We should use an EH-only cleanup and disable it at the point of the call for win64, even though we don't use inalloca. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r--lib/CodeGen/CGCall.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index e82b6defa6..4428b96316 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -2286,16 +2286,23 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
// In the Microsoft C++ ABI, aggregate arguments are destructed by the callee.
// However, we still have to push an EH-only cleanup in case we unwind before
// we make it to the call.
- if (HasAggregateEvalKind && args.isUsingInAlloca()) {
- assert(getTarget().getTriple().getArch() == llvm::Triple::x86);
- AggValueSlot Slot = createPlaceholderSlot(*this, type);
+ if (HasAggregateEvalKind &&
+ CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
+ // If we're using inalloca, use the argument memory. Otherwise, use a
+ // temporary. Either way, the aggregate is destroyed externally in the
+ // callee.
+ AggValueSlot Slot;
+ if (args.isUsingInAlloca())
+ Slot = createPlaceholderSlot(*this, type);
+ else
+ Slot = CreateAggTemp(type, "agg.tmp");
Slot.setExternallyDestructed();
EmitAggExpr(E, Slot);
RValue RV = Slot.asRValue();
args.add(RV, type);
const CXXRecordDecl *RD = type->getAsCXXRecordDecl();
- if (RD->hasNonTrivialDestructor()) {
+ if (RD && RD->hasNonTrivialDestructor()) {
// Create a no-op GEP between the placeholder and the cleanup so we can
// RAUW it successfully. It also serves as a marker of the first
// instruction where the cleanup is active.