forked from OSchip/llvm-project
Reapply r95393, without the change to CGExpr. I was wrong in assuming that the
element type always matched the converted LLVM type for ExprType. llvm-svn: 95596
This commit is contained in:
parent
99777dd78f
commit
3d33fab7fc
|
@ -703,25 +703,19 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
|
||||||
CanQualType CTy = getContext().getCanonicalType(Ty);
|
CanQualType CTy = getContext().getCanonicalType(Ty);
|
||||||
|
|
||||||
llvm::Value *DeclPtr;
|
llvm::Value *DeclPtr;
|
||||||
if (!Ty->isConstantSizeType()) {
|
// If this is an aggregate or variable sized value, reuse the input pointer.
|
||||||
// Variable sized values always are passed by-reference.
|
if (!Ty->isConstantSizeType() ||
|
||||||
|
CodeGenFunction::hasAggregateLLVMType(Ty)) {
|
||||||
DeclPtr = Arg;
|
DeclPtr = Arg;
|
||||||
} else {
|
} else {
|
||||||
// A fixed sized single-value variable becomes an alloca in the entry block.
|
// Otherwise, create a temporary to hold the value.
|
||||||
const llvm::Type *LTy = ConvertTypeForMem(Ty);
|
DeclPtr = CreateTempAlloca(ConvertTypeForMem(Ty));
|
||||||
if (LTy->isSingleValueType()) {
|
DeclPtr->setName(D.getName() + ".addr");
|
||||||
// TODO: Alignment
|
|
||||||
DeclPtr = CreateTempAlloca(LTy);
|
|
||||||
DeclPtr->setName(D.getNameAsString() + llvm::StringRef(".addr"));
|
|
||||||
|
|
||||||
// Store the initial value into the alloca.
|
// Store the initial value into the alloca.
|
||||||
EmitStoreOfScalar(Arg, DeclPtr, CTy.isVolatileQualified(), Ty);
|
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];
|
llvm::Value *&DMEntry = LocalDeclMap[&D];
|
||||||
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
|
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
|
||||||
|
|
|
@ -553,6 +553,8 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
|
||||||
cast<llvm::PointerType>(Ptr->getType())->getElementType();
|
cast<llvm::PointerType>(Ptr->getType())->getElementType();
|
||||||
|
|
||||||
// Simple scalar l-value.
|
// Simple scalar l-value.
|
||||||
|
//
|
||||||
|
// FIXME: We shouldn't have to use isSingleValueType here.
|
||||||
if (EltTy->isSingleValueType())
|
if (EltTy->isSingleValueType())
|
||||||
return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(),
|
return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(),
|
||||||
ExprType));
|
ExprType));
|
||||||
|
|
|
@ -861,14 +861,13 @@ llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S,
|
||||||
std::string &ConstraintStr) {
|
std::string &ConstraintStr) {
|
||||||
llvm::Value *Arg;
|
llvm::Value *Arg;
|
||||||
if (Info.allowsRegister() || !Info.allowsMemory()) {
|
if (Info.allowsRegister() || !Info.allowsMemory()) {
|
||||||
const llvm::Type *Ty = ConvertType(InputExpr->getType());
|
if (!CodeGenFunction::hasAggregateLLVMType(InputExpr->getType())) {
|
||||||
|
|
||||||
if (Ty->isSingleValueType()) {
|
|
||||||
Arg = EmitScalarExpr(InputExpr);
|
Arg = EmitScalarExpr(InputExpr);
|
||||||
} else {
|
} else {
|
||||||
InputExpr = InputExpr->IgnoreParenNoopCasts(getContext());
|
InputExpr = InputExpr->IgnoreParenNoopCasts(getContext());
|
||||||
LValue Dest = EmitLValue(InputExpr);
|
LValue Dest = EmitLValue(InputExpr);
|
||||||
|
|
||||||
|
const llvm::Type *Ty = ConvertType(InputExpr->getType());
|
||||||
uint64_t Size = CGM.getTargetData().getTypeSizeInBits(Ty);
|
uint64_t Size = CGM.getTargetData().getTypeSizeInBits(Ty);
|
||||||
if (Size <= 64 && llvm::isPowerOf2_64(Size)) {
|
if (Size <= 64 && llvm::isPowerOf2_64(Size)) {
|
||||||
Ty = llvm::IntegerType::get(VMContext, Size);
|
Ty = llvm::IntegerType::get(VMContext, Size);
|
||||||
|
|
Loading…
Reference in New Issue