Better check
authorAndrew Lenharth <andrewl@lenharth.org>
Thu, 8 Nov 2007 18:45:15 +0000 (18:45 +0000)
committerAndrew Lenharth <andrewl@lenharth.org>
Thu, 8 Nov 2007 18:45:15 +0000 (18:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43897 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp
test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll

index c8d03be2c008cbe0e045212c4873eb1169aab997..efcd8e32972ed4fd11f29d02c76009cb1711928b 100644 (file)
@@ -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
index 61e67ad10c9d25940c2c46fd8b11998d03ce25b6..f3caf079763884329d1445c9878fc2da83cf9767 100644 (file)
@@ -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