aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp2
-rw-r--r--test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll5
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index c8d03be..efcd8e3 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -7582,7 +7582,7 @@ static unsigned GetOrEnforceKnownAlignment(Value *V, TargetData *TD,
unsigned PrefAlign = 0) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
unsigned Align = GV->getAlignment();
- if (Align == 0 && TD && !isa<OpaqueType>(GV->getType()->getElementType()))
+ if (Align == 0 && TD && GV->getType()->getElementType()->isSized())
Align = TD->getPrefTypeAlignment(GV->getType()->getElementType());
// If there is a large requested alignment and we can, bump up the alignment
diff --git a/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll b/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll
index 61e67ad1..f3caf07 100644
--- a/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll
+++ b/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll
@@ -6,12 +6,15 @@ target triple = "i686-pc-linux-gnu"
%opaque_t = type opaque
+%op_ts = type {opaque, i32}
+
@g = external global %opaque_t
+@h = external global %op_ts
define i32 @foo() {
entry:
%x = load i8* bitcast (%opaque_t* @g to i8*)
- %y = load i32* bitcast (%opaque_t* @g to i32*)
+ %y = load i32* bitcast (%op_ts* @h to i32*)
%z = zext i8 %x to i32
%r = add i32 %y, %z
ret i32 %r