summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/TransformInternals.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-17 18:03:54 +0000
committerChris Lattner <sabre@nondot.org>2003-10-17 18:03:54 +0000
commit1facf89eafb82226278693ca6eee4819d3dfc86f (patch)
treef29ff9bc4ad2d6c8d3f91c38670a9ac7e7d58a7e /llvm/lib/Transforms/TransformInternals.cpp
parentb9c70bb65398b5bf2df58ad7855234665064b656 (diff)
downloadbcm5719-llvm-1facf89eafb82226278693ca6eee4819d3dfc86f.tar.gz
bcm5719-llvm-1facf89eafb82226278693ca6eee4819d3dfc86f.zip
Do not crash on empty structures
llvm-svn: 9195
Diffstat (limited to 'llvm/lib/Transforms/TransformInternals.cpp')
-rw-r--r--llvm/lib/Transforms/TransformInternals.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/TransformInternals.cpp b/llvm/lib/Transforms/TransformInternals.cpp
index f726e829aa6..820dd3878e0 100644
--- a/llvm/lib/Transforms/TransformInternals.cpp
+++ b/llvm/lib/Transforms/TransformInternals.cpp
@@ -53,6 +53,11 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
uint64_t ThisOffset;
const Type *NextType;
if (const StructType *STy = dyn_cast<StructType>(Ty)) {
+ if (STy->getElementTypes().empty()) {
+ Offset = 0;
+ return STy;
+ }
+
ThisOffset = Offset;
NextType = getStructOffsetStep(STy, ThisOffset, Indices, TD);
} else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
OpenPOWER on IntegriCloud