diff options
author | Andrew Lenharth <andrewl@lenharth.org> | 2007-11-08 17:39:28 +0000 |
---|---|---|
committer | Andrew Lenharth <andrewl@lenharth.org> | 2007-11-08 17:39:28 +0000 |
commit | ab9338eb9f18a1303e271ed144f78c29a48ff011 (patch) | |
tree | 34a4fb94460ed88beae37fbb30db87e9f76c54a7 | |
parent | e0cb36b9fb1e1b0de9b46eafd8dc3802122b2e73 (diff) |
Fix PR1780
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43893 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 41485b203e..c8d03be2c0 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) + 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 diff --git a/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll b/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll new file mode 100644 index 0000000000..61e67ad10c --- /dev/null +++ b/test/Transforms/InstCombine/2007-11-07-OpaqueAlignCrash.ll @@ -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 + +@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 +} + |