[llvm-commits] [llvm] r43893 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll

Andrew Lenharth alenhar2 at cs.uiuc.edu
Thu Nov 8 09:39:28 PST 2007


Author: alenhar2
Date: Thu Nov  8 11:39:28 2007
New Revision: 43893

URL: http://llvm.org/viewvc/llvm-project?rev=43893&view=rev
Log:
Fix PR1780

Added:
    llvm/trunk/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=43893&r1=43892&r2=43893&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Nov  8 11:39:28 2007
@@ -7582,7 +7582,7 @@
                                            unsigned PrefAlign = 0) {
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
     unsigned Align = GV->getAlignment();
-    if (Align == 0 && TD) 
+    if (Align == 0 && TD && !isa<OpaqueType>(GV->getType()->getElementType())) 
       Align = TD->getPrefTypeAlignment(GV->getType()->getElementType());
 
     // If there is a large requested alignment and we can, bump up the alignment

Added: llvm/trunk/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll?rev=43893&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll Thu Nov  8 11:39:28 2007
@@ -0,0 +1,19 @@
+; RUN: llvm-as < %s | opt -instcombine -disable-output
+; PR1780
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
+target triple = "i686-pc-linux-gnu"
+
+%opaque_t = type opaque
+
+ at g = external global %opaque_t
+
+define i32 @foo() {
+entry:
+        %x = load i8* bitcast (%opaque_t* @g to i8*)
+        %y = load i32* bitcast (%opaque_t* @g to i32*)
+	%z = zext i8 %x to i32
+	%r = add i32 %y, %z
+        ret i32 %r
+}
+





More information about the llvm-commits mailing list