summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CGCall.h
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-02-01 00:04:45 +0000
committerReid Kleckner <reid@kleckner.net>2014-02-01 00:04:45 +0000
commit279292b8f1a9855f5c57dbc8d7711fc1d99c055e (patch)
tree42dfa039cb5eeafd127b4ff45866a0edf00d0c51 /lib/CodeGen/CGCall.h
parente6a9903e83ef065d324145e1fce4ed7c238c6ec5 (diff)
[ms-cxxabi] Use inalloca on win32 when passing non-trivial C++ objects
When a non-trivial parameter is present, clang now gathers up all the parameters that lack inreg and puts them into a packed struct. MSVC always aligns each parameter to 4 bytes and no more, so this is a pretty simple struct to lay out. On win64, non-trivial records are passed indirectly. Prior to this change, clang was incorrectly using byval on win64. I'm able to self-host a working clang with this change and additional LLVM patches. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2636 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200597 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.h')
-rw-r--r--lib/CodeGen/CGCall.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/CodeGen/CGCall.h b/lib/CodeGen/CGCall.h
index 532cb59c62..c51f06fdcd 100644
--- a/lib/CodeGen/CGCall.h
+++ b/lib/CodeGen/CGCall.h
@@ -56,6 +56,8 @@ namespace CodeGen {
class CallArgList :
public SmallVector<CallArg, 16> {
public:
+ CallArgList() : StackBase(0), StackBaseMem(0) {}
+
struct Writeback {
/// The original argument. Note that the argument l-value
/// is potentially null.
@@ -113,6 +115,14 @@ namespace CodeGen {
return CleanupsToDeactivate;
}
+ void allocateArgumentMemory(CodeGenFunction &CGF);
+ llvm::Instruction *getStackBase() const { return StackBase; }
+ void freeArgumentMemory(CodeGenFunction &CGF) const;
+
+ /// \brief Returns if we're using an inalloca struct to pass arguments in
+ /// memory.
+ bool isUsingInAlloca() const { return StackBase; }
+
private:
SmallVector<Writeback, 1> Writebacks;
@@ -120,6 +130,17 @@ namespace CodeGen {
/// is used to cleanup objects that are owned by the callee once the call
/// occurs.
SmallVector<CallArgCleanup, 1> CleanupsToDeactivate;
+
+ /// The stacksave call. It dominates all of the argument evaluation.
+ llvm::CallInst *StackBase;
+
+ /// The alloca holding the stackbase. We need it to maintain SSA form.
+ llvm::AllocaInst *StackBaseMem;
+
+ /// The iterator pointing to the stack restore cleanup. We manually run and
+ /// deactivate this cleanup after the call in the unexceptional case because
+ /// it doesn't run in the normal order.
+ EHScopeStack::stable_iterator StackCleanup;
};
/// FunctionArgList - Type for representing both the decl and type