Fix crash when looking up the addrspace of GEPs with vector types
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 2 Sep 2014 18:47:54 +0000 (18:47 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 2 Sep 2014 18:47:54 +0000 (18:47 +0000)
Patch by Björn Steinbrink

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216930 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Operator.h
test/Transforms/MergeFunc/vector-GEP-crash.ll [new file with mode: 0644]

index 888cabffe378b7aa143523f04c919324ee9269fd..762f4a75c315948e3897df7c7ed751012f6101a2 100644 (file)
@@ -402,7 +402,7 @@ public:
   /// getPointerAddressSpace - Method to return the address space of the
   /// pointer operand.
   unsigned getPointerAddressSpace() const {
-    return cast<PointerType>(getPointerOperandType())->getAddressSpace();
+    return getPointerOperandType()->getPointerAddressSpace();
   }
 
   unsigned getNumIndices() const {  // Note: always non-negative
diff --git a/test/Transforms/MergeFunc/vector-GEP-crash.ll b/test/Transforms/MergeFunc/vector-GEP-crash.ll
new file mode 100644 (file)
index 0000000..a1eefa0
--- /dev/null
@@ -0,0 +1,12 @@
+; RUN: opt -mergefunc -disable-output < %s
+; This used to cause a crash when compairing the GEPs
+
+define void @foo(<2 x i64*>) {
+  %tmp = getelementptr <2 x i64*> %0, <2 x i64> <i64 0, i64 0>
+  ret void
+}
+
+define void @bar(<2 x i64*>) {
+  %tmp = getelementptr <2 x i64*> %0, <2 x i64> <i64 0, i64 0>
+  ret void
+}