aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Linker
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-16 19:55:40 +0000
committerChris Lattner <sabre@nondot.org>2008-06-16 19:55:40 +0000
commit9ddf2c898f5227ca137aef7abc3051e16bd60025 (patch)
tree4daccfa71c67d2c64c06516d78edb8ab93007e11 /lib/Linker
parent849dcd928a58290447a710b856bdd487aac44d24 (diff)
downloadexternal_llvm-9ddf2c898f5227ca137aef7abc3051e16bd60025.zip
external_llvm-9ddf2c898f5227ca137aef7abc3051e16bd60025.tar.gz
external_llvm-9ddf2c898f5227ca137aef7abc3051e16bd60025.tar.bz2
simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp45
1 files changed, 21 insertions, 24 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 64c0032..43721e6 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -75,13 +75,6 @@ static bool ResolveTypes(const Type *DestTy, const Type *SrcTy) {
return false;
}
-static const FunctionType *getFT(const PATypeHolder &TH) {
- return cast<FunctionType>(TH.get());
-}
-static const StructType *getST(const PATypeHolder &TH) {
- return cast<StructType>(TH.get());
-}
-
// RecursiveResolveTypes - This is just like ResolveTypes, except that it
// recurses down into derived types, merging the used types if the parent types
// are compatible.
@@ -105,24 +98,25 @@ static bool RecursiveResolveTypesI(const PATypeHolder &DestTy,
default:
return true;
case Type::FunctionTyID: {
- if (cast<FunctionType>(DestTyT)->isVarArg() !=
- cast<FunctionType>(SrcTyT)->isVarArg() ||
- cast<FunctionType>(DestTyT)->getNumContainedTypes() !=
- cast<FunctionType>(SrcTyT)->getNumContainedTypes())
+ const FunctionType *DstFT = cast<FunctionType>(DestTyT);
+ const FunctionType *SrcFT = cast<FunctionType>(SrcTyT);
+ if (DstFT->isVarArg() != SrcFT->isVarArg() ||
+ DstFT->getNumContainedTypes() != SrcFT->getNumContainedTypes())
return true;
- for (unsigned i = 0, e = getFT(DestTy)->getNumContainedTypes(); i != e; ++i)
- if (RecursiveResolveTypesI(getFT(DestTy)->getContainedType(i),
- getFT(SrcTy)->getContainedType(i), Pointers))
+ for (unsigned i = 0, e = DstFT->getNumContainedTypes(); i != e; ++i)
+ if (RecursiveResolveTypesI(DstFT->getContainedType(i),
+ SrcFT->getContainedType(i), Pointers))
return true;
return false;
}
case Type::StructTyID: {
- if (getST(DestTy)->getNumContainedTypes() !=
- getST(SrcTy)->getNumContainedTypes())
+ const StructType *DstST = cast<StructType>(DestTyT);
+ const StructType *SrcST = cast<StructType>(SrcTyT);
+ if (DstST->getNumContainedTypes() != SrcST->getNumContainedTypes())
return true;
- for (unsigned i = 0, e = getST(DestTy)->getNumContainedTypes(); i != e; ++i)
- if (RecursiveResolveTypesI(getST(DestTy)->getContainedType(i),
- getST(SrcTy)->getContainedType(i), Pointers))
+ for (unsigned i = 0, e = DstST->getNumContainedTypes(); i != e; ++i)
+ if (RecursiveResolveTypesI(DstST->getContainedType(i),
+ SrcST->getContainedType(i), Pointers))
return true;
return false;
}
@@ -141,6 +135,12 @@ static bool RecursiveResolveTypesI(const PATypeHolder &DestTy,
Pointers);
}
case Type::PointerTyID: {
+ const PointerType *DstPT = cast<PointerType>(DestTy.get());
+ const PointerType *SrcPT = cast<PointerType>(SrcTy.get());
+
+ if (DstPT->getAddressSpace() != SrcPT->getAddressSpace())
+ return true;
+
// If this is a pointer type, check to see if we have already seen it. If
// so, we are in a recursive branch. Cut off the search now. We cannot use
// an associative container for this search, because the type pointers (keys
@@ -152,11 +152,8 @@ static bool RecursiveResolveTypesI(const PATypeHolder &DestTy,
// Otherwise, add the current pointers to the vector to stop recursion on
// this pair.
Pointers.push_back(std::make_pair(DestTyT, SrcTyT));
- bool Result =
- RecursiveResolveTypesI(cast<PointerType>(DestTy.get())->getElementType(),
- cast<PointerType>(SrcTy.get())->getElementType(),
- Pointers);
- return Result;
+ return RecursiveResolveTypesI(DstPT->getElementType(),
+ SrcPT->getElementType(), Pointers);
}
}
}