[clang][opaque pointers] Fix up a bunch of "getType()->getElementType()"
In contexts where we know an LLVM type is a pointer, there's generally some simpler way to get the pointee type.
This commit is contained in:
parent
3e5d671c19
commit
83fa811e5b
|
@ -1233,7 +1233,7 @@ static llvm::Value *CreateCoercedLoad(Address Src, llvm::Type *Ty,
|
||||||
|
|
||||||
if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy)) {
|
if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy)) {
|
||||||
Src = EnterStructPointerForCoercedAccess(Src, SrcSTy, DstSize, CGF);
|
Src = EnterStructPointerForCoercedAccess(Src, SrcSTy, DstSize, CGF);
|
||||||
SrcTy = Src.getType()->getElementType();
|
SrcTy = Src.getElementType();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t SrcSize = CGF.CGM.getDataLayout().getTypeAllocSize(SrcTy);
|
uint64_t SrcSize = CGF.CGM.getDataLayout().getTypeAllocSize(SrcTy);
|
||||||
|
@ -1299,7 +1299,7 @@ static void CreateCoercedStore(llvm::Value *Src,
|
||||||
bool DstIsVolatile,
|
bool DstIsVolatile,
|
||||||
CodeGenFunction &CGF) {
|
CodeGenFunction &CGF) {
|
||||||
llvm::Type *SrcTy = Src->getType();
|
llvm::Type *SrcTy = Src->getType();
|
||||||
llvm::Type *DstTy = Dst.getType()->getElementType();
|
llvm::Type *DstTy = Dst.getElementType();
|
||||||
if (SrcTy == DstTy) {
|
if (SrcTy == DstTy) {
|
||||||
CGF.Builder.CreateStore(Src, Dst, DstIsVolatile);
|
CGF.Builder.CreateStore(Src, Dst, DstIsVolatile);
|
||||||
return;
|
return;
|
||||||
|
@ -1309,7 +1309,7 @@ static void CreateCoercedStore(llvm::Value *Src,
|
||||||
|
|
||||||
if (llvm::StructType *DstSTy = dyn_cast<llvm::StructType>(DstTy)) {
|
if (llvm::StructType *DstSTy = dyn_cast<llvm::StructType>(DstTy)) {
|
||||||
Dst = EnterStructPointerForCoercedAccess(Dst, DstSTy, SrcSize, CGF);
|
Dst = EnterStructPointerForCoercedAccess(Dst, DstSTy, SrcSize, CGF);
|
||||||
DstTy = Dst.getType()->getElementType();
|
DstTy = Dst.getElementType();
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::PointerType *SrcPtrTy = llvm::dyn_cast<llvm::PointerType>(SrcTy);
|
llvm::PointerType *SrcPtrTy = llvm::dyn_cast<llvm::PointerType>(SrcTy);
|
||||||
|
@ -4304,7 +4304,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
||||||
llvm::StructType *STy =
|
llvm::StructType *STy =
|
||||||
dyn_cast<llvm::StructType>(ArgInfo.getCoerceToType());
|
dyn_cast<llvm::StructType>(ArgInfo.getCoerceToType());
|
||||||
if (STy && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened()) {
|
if (STy && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened()) {
|
||||||
llvm::Type *SrcTy = Src.getType()->getElementType();
|
llvm::Type *SrcTy = Src.getElementType();
|
||||||
uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(SrcTy);
|
uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(SrcTy);
|
||||||
uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(STy);
|
uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(STy);
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
|
||||||
// the global to match the initializer. (We have to do this
|
// the global to match the initializer. (We have to do this
|
||||||
// because some types, like unions, can't be completely represented
|
// because some types, like unions, can't be completely represented
|
||||||
// in the LLVM type system.)
|
// in the LLVM type system.)
|
||||||
if (GV->getType()->getElementType() != Init->getType()) {
|
if (GV->getValueType() != Init->getType()) {
|
||||||
llvm::GlobalVariable *OldGV = GV;
|
llvm::GlobalVariable *OldGV = GV;
|
||||||
|
|
||||||
GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),
|
GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),
|
||||||
|
|
|
@ -3634,7 +3634,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
|
||||||
// Check for a forward reference.
|
// Check for a forward reference.
|
||||||
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
|
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
|
||||||
if (GV) {
|
if (GV) {
|
||||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||||
"Forward metaclass reference has incorrect type.");
|
"Forward metaclass reference has incorrect type.");
|
||||||
values.finishAndSetAsInitializer(GV);
|
values.finishAndSetAsInitializer(GV);
|
||||||
GV->setSection(Section);
|
GV->setSection(Section);
|
||||||
|
@ -3697,7 +3697,7 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
|
||||||
// Check for a forward reference.
|
// Check for a forward reference.
|
||||||
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
|
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
|
||||||
if (GV) {
|
if (GV) {
|
||||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||||
"Forward metaclass reference has incorrect type.");
|
"Forward metaclass reference has incorrect type.");
|
||||||
values.finishAndSetAsInitializer(GV);
|
values.finishAndSetAsInitializer(GV);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3728,7 +3728,7 @@ llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) {
|
||||||
llvm::GlobalValue::PrivateLinkage, nullptr,
|
llvm::GlobalValue::PrivateLinkage, nullptr,
|
||||||
Name);
|
Name);
|
||||||
|
|
||||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||||
"Forward metaclass reference has incorrect type.");
|
"Forward metaclass reference has incorrect type.");
|
||||||
return GV;
|
return GV;
|
||||||
}
|
}
|
||||||
|
@ -3742,7 +3742,7 @@ llvm::Value *CGObjCMac::EmitSuperClassRef(const ObjCInterfaceDecl *ID) {
|
||||||
llvm::GlobalValue::PrivateLinkage, nullptr,
|
llvm::GlobalValue::PrivateLinkage, nullptr,
|
||||||
Name);
|
Name);
|
||||||
|
|
||||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||||
"Forward class metadata reference has incorrect type.");
|
"Forward class metadata reference has incorrect type.");
|
||||||
return GV;
|
return GV;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3176,7 +3176,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isa<llvm::Function>(Entry) || isa<llvm::GlobalAlias>(Entry)) &&
|
if ((isa<llvm::Function>(Entry) || isa<llvm::GlobalAlias>(Entry)) &&
|
||||||
(Entry->getType()->getElementType() == Ty)) {
|
(Entry->getValueType() == Ty)) {
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3225,7 +3225,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Constant *BC = llvm::ConstantExpr::getBitCast(
|
llvm::Constant *BC = llvm::ConstantExpr::getBitCast(
|
||||||
F, Entry->getType()->getElementType()->getPointerTo());
|
F, Entry->getValueType()->getPointerTo());
|
||||||
addGlobalValReplacement(Entry, BC);
|
addGlobalValReplacement(Entry, BC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3284,7 +3284,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
|
||||||
|
|
||||||
// Make sure the result is of the requested type.
|
// Make sure the result is of the requested type.
|
||||||
if (!IsIncompleteFunction) {
|
if (!IsIncompleteFunction) {
|
||||||
assert(F->getType()->getElementType() == Ty);
|
assert(F->getFunctionType() == Ty);
|
||||||
return F;
|
return F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3575,7 +3575,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
|
||||||
llvm::Constant *Init = emitter.tryEmitForInitializer(*InitDecl);
|
llvm::Constant *Init = emitter.tryEmitForInitializer(*InitDecl);
|
||||||
if (Init) {
|
if (Init) {
|
||||||
auto *InitType = Init->getType();
|
auto *InitType = Init->getType();
|
||||||
if (GV->getType()->getElementType() != InitType) {
|
if (GV->getValueType() != InitType) {
|
||||||
// The type of the initializer does not match the definition.
|
// The type of the initializer does not match the definition.
|
||||||
// This happens when an initializer has a different type from
|
// This happens when an initializer has a different type from
|
||||||
// the type of the global (because of padding at the end of a
|
// the type of the global (because of padding at the end of a
|
||||||
|
@ -3648,7 +3648,7 @@ llvm::GlobalVariable *CodeGenModule::CreateOrReplaceCXXRuntimeVariable(
|
||||||
|
|
||||||
if (GV) {
|
if (GV) {
|
||||||
// Check if the variable has the right type.
|
// Check if the variable has the right type.
|
||||||
if (GV->getType()->getElementType() == Ty)
|
if (GV->getValueType() == Ty)
|
||||||
return GV;
|
return GV;
|
||||||
|
|
||||||
// Because C++ name mangling, the only way we can end up with an already
|
// Because C++ name mangling, the only way we can end up with an already
|
||||||
|
@ -3992,7 +3992,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
|
||||||
// "extern int x[];") and then a definition of a different type (e.g.
|
// "extern int x[];") and then a definition of a different type (e.g.
|
||||||
// "int x[10];"). This also happens when an initializer has a different type
|
// "int x[10];"). This also happens when an initializer has a different type
|
||||||
// from the type of the global (this happens with unions).
|
// from the type of the global (this happens with unions).
|
||||||
if (!GV || GV->getType()->getElementType() != InitType ||
|
if (!GV || GV->getValueType() != InitType ||
|
||||||
GV->getType()->getAddressSpace() !=
|
GV->getType()->getAddressSpace() !=
|
||||||
getContext().getTargetAddressSpace(GetGlobalVarAddressSpace(D))) {
|
getContext().getTargetAddressSpace(GetGlobalVarAddressSpace(D))) {
|
||||||
|
|
||||||
|
@ -4472,7 +4472,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
|
||||||
llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
|
llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
|
||||||
|
|
||||||
// Get or create the prototype for the function.
|
// Get or create the prototype for the function.
|
||||||
if (!GV || (GV->getType()->getElementType() != Ty))
|
if (!GV || (GV->getValueType() != Ty))
|
||||||
GV = cast<llvm::GlobalValue>(GetAddrOfFunction(GD, Ty, /*ForVTable=*/false,
|
GV = cast<llvm::GlobalValue>(GetAddrOfFunction(GD, Ty, /*ForVTable=*/false,
|
||||||
/*DontDefer=*/true,
|
/*DontDefer=*/true,
|
||||||
ForDefinition));
|
ForDefinition));
|
||||||
|
|
Loading…
Reference in New Issue