diff options
| author | Anders Carlsson <andersca@mac.com> | 2009-05-19 19:36:19 +0000 | 
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2009-05-19 19:36:19 +0000 | 
| commit | 29a1be34b7ed87ae65a93a1cb560890b5004a413 (patch) | |
| tree | 79638d029906b4671c68b2121eaaf241de53fa3a | |
| parent | d33a090efa0e2bc0ef1fd6987de96d8578784c4b (diff) | |
| download | bcm5719-llvm-29a1be34b7ed87ae65a93a1cb560890b5004a413.tar.gz bcm5719-llvm-29a1be34b7ed87ae65a93a1cb560890b5004a413.zip | |
Only do the bitcast in EmitStoreOfScalar if the type is a boolean.
llvm-svn: 72125
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 27 | 
1 files changed, 12 insertions, 15 deletions
| diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 24d885cec54..f7c3fd09769 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -200,8 +200,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(llvm::Value *Addr, bool Volatile,                                                 QualType Ty) {    llvm::Value *V = Builder.CreateLoad(Addr, Volatile, "tmp"); -  // Bool can have different representation in memory than in -  // registers. +  // Bool can have different representation in memory than in registers.    if (Ty->isBooleanType())      if (V->getType() != llvm::Type::Int1Ty)        V = Builder.CreateTrunc(V, llvm::Type::Int1Ty, "tobool"); @@ -211,20 +210,18 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(llvm::Value *Addr, bool Volatile,  void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr,                                          bool Volatile, QualType Ty) { -  // Handle stores of types which have different representations in memory and -  // as LLVM values. - -  // FIXME: We shouldn't be this loose, we should only do this conversion when -  // we have a type we know has a different memory representation (e.g., bool). - -  const llvm::Type *SrcTy = Value->getType(); -  const llvm::PointerType *DstPtr = cast<llvm::PointerType>(Addr->getType()); -  if (DstPtr->getElementType() != SrcTy) { -    const llvm::Type *MemTy =  -      llvm::PointerType::get(SrcTy, DstPtr->getAddressSpace()); -    Addr = Builder.CreateBitCast(Addr, MemTy, "storetmp"); +   +  if (Ty->isBooleanType()) { +    // Bool can have different representation in memory than in registers. +    const llvm::Type *SrcTy = Value->getType(); +    const llvm::PointerType *DstPtr = cast<llvm::PointerType>(Addr->getType()); +    if (DstPtr->getElementType() != SrcTy) { +      const llvm::Type *MemTy =  +        llvm::PointerType::get(SrcTy, DstPtr->getAddressSpace()); +      Addr = Builder.CreateBitCast(Addr, MemTy, "storetmp"); +    }    } - +      Builder.CreateStore(Value, Addr, Volatile);    } | 

