mirror of
https://github.com/intel/llvm.git
synced 2026-02-08 17:28:30 +08:00
when emitting pointer load from an lvalue or storing to an lvalue,
do an explicit bitcast to whatever ConvertType produces. This will go with the next patch. llvm-svn: 134860
This commit is contained in:
@@ -756,6 +756,10 @@ llvm::Value *CodeGenFunction::EmitFromMemory(llvm::Value *Value, QualType Ty) {
|
||||
return Builder.CreateTrunc(Value, Builder.getInt1Ty(), "tobool");
|
||||
}
|
||||
|
||||
// If this is a pointer r-value, make sure that it has the right scalar type.
|
||||
if (isa<llvm::PointerType>(Value->getType()))
|
||||
return Builder.CreateBitCast(Value, ConvertType(Ty));
|
||||
|
||||
return Value;
|
||||
}
|
||||
|
||||
@@ -764,6 +768,14 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr,
|
||||
QualType Ty,
|
||||
llvm::MDNode *TBAAInfo) {
|
||||
Value = EmitToMemory(Value, Ty);
|
||||
|
||||
if (isa<llvm::PointerType>(Value->getType())) {
|
||||
llvm::Type *EltTy =
|
||||
cast<llvm::PointerType>(Addr->getType())->getElementType();
|
||||
if (EltTy != Value->getType())
|
||||
Value = Builder.CreateBitCast(Value, EltTy);
|
||||
}
|
||||
|
||||
llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile);
|
||||
if (Alignment)
|
||||
Store->setAlignment(Alignment);
|
||||
|
||||
Reference in New Issue
Block a user