diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-05 21:10:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-05 21:10:36 +0000 |
commit | a5002106fbe5563aa59eba007416074d5b1ffecf (patch) | |
tree | 2d5f2f7c66a8ed20872b604b10572e71fdcbd342 /lib/CodeGen/CGDecl.cpp | |
parent | 4794081837ba088965a71652a46494ef4c6b2590 (diff) |
Revert r95393, which broke Clang's self-host.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index d18b87fb9a..e27c5e4e51 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -690,19 +690,25 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) { CanQualType CTy = getContext().getCanonicalType(Ty); llvm::Value *DeclPtr; - // If this is an aggregate or variable sized value, reuse the input pointer. - if (!Ty->isConstantSizeType() || - CodeGenFunction::hasAggregateLLVMType(Ty)) { + if (!Ty->isConstantSizeType()) { + // Variable sized values always are passed by-reference. DeclPtr = Arg; } else { - // Otherwise, create a temporary to hold the value. - DeclPtr = CreateTempAlloca(ConvertTypeForMem(Ty)); - DeclPtr->setName(D.getName() + ".addr"); - - // Store the initial value into the alloca. - EmitStoreOfScalar(Arg, DeclPtr, CTy.isVolatileQualified(), Ty); + // A fixed sized single-value variable becomes an alloca in the entry block. + const llvm::Type *LTy = ConvertTypeForMem(Ty); + if (LTy->isSingleValueType()) { + // TODO: Alignment + DeclPtr = CreateTempAlloca(LTy); + DeclPtr->setName(D.getNameAsString() + llvm::StringRef(".addr")); + + // Store the initial value into the alloca. + EmitStoreOfScalar(Arg, DeclPtr, CTy.isVolatileQualified(), Ty); + } else { + // Otherwise, if this is an aggregate, just use the input pointer. + DeclPtr = Arg; + } + Arg->setName(D.getNameAsString()); } - Arg->setName(D.getName()); llvm::Value *&DMEntry = LocalDeclMap[&D]; assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); |