[llvm] r223818 - [FastISel][AArch64] Fix a missing nullptr check in 'computeAddress'.

Juergen Ributzka juergen at apple.com
Tue Dec 9 11:44:38 PST 2014


Author: ributzka
Date: Tue Dec  9 13:44:38 2014
New Revision: 223818

URL: http://llvm.org/viewvc/llvm-project?rev=223818&view=rev
Log:
[FastISel][AArch64] Fix a missing nullptr check in 'computeAddress'.

The load/store value type is currently not available when lowering the memcpy
intrinsic. Add the missing nullptr check to support this in 'computeAddress'.

Fixes rdar://problem/19178947.

Added:
    llvm/trunk/test/CodeGen/AArch64/fast-isel-memcpy.ll
Modified:
    llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp

Modified: llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp?rev=223818&r1=223817&r2=223818&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp Tue Dec  9 13:44:38 2014
@@ -753,7 +753,7 @@ bool AArch64FastISel::computeAddress(con
     if (Addr.getOffsetReg())
       break;
 
-    if (DL.getTypeSizeInBits(Ty) != 8)
+    if (!Ty || DL.getTypeSizeInBits(Ty) != 8)
       break;
 
     const Value *LHS = U->getOperand(0);

Added: llvm/trunk/test/CodeGen/AArch64/fast-isel-memcpy.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/fast-isel-memcpy.ll?rev=223818&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/fast-isel-memcpy.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/fast-isel-memcpy.ll Tue Dec  9 13:44:38 2014
@@ -0,0 +1,15 @@
+; RUN: llc -mtriple=aarch64-apple-darwin -fast-isel -fast-isel-abort -verify-machineinstrs < %s | FileCheck %s
+
+; Test that we don't segfault.
+; CHECK-LABEL: test
+; CHECK:       ldr [[REG1:x[0-9]+]], [x1]
+; CHECK-NEXT:  and [[REG2:x[0-9]+]], x0, #0x7fffffffffffffff
+; CHECK-NEXT:  str [[REG1]], {{\[}}[[REG2]]{{\]}}
+define void @test(i64 %a, i8* %b) {
+  %1 = and i64 %a, 9223372036854775807
+  %2 = inttoptr i64 %1 to i8*
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %b, i64 8, i32 8, i1 false)
+  ret void
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1)





More information about the llvm-commits mailing list