From 772744826c9ebe6883673eb46f0c455f52e7583d Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Tue, 9 Dec 2014 19:44:38 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223818 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AArch64FastISel.cpp | 2 +- test/CodeGen/AArch64/fast-isel-memcpy.ll | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/AArch64/fast-isel-memcpy.ll diff --git a/lib/Target/AArch64/AArch64FastISel.cpp b/lib/Target/AArch64/AArch64FastISel.cpp index d942ace427b..3cad316c284 100644 --- a/lib/Target/AArch64/AArch64FastISel.cpp +++ b/lib/Target/AArch64/AArch64FastISel.cpp @@ -753,7 +753,7 @@ bool AArch64FastISel::computeAddress(const Value *Obj, Address &Addr, Type *Ty) if (Addr.getOffsetReg()) break; - if (DL.getTypeSizeInBits(Ty) != 8) + if (!Ty || DL.getTypeSizeInBits(Ty) != 8) break; const Value *LHS = U->getOperand(0); diff --git a/test/CodeGen/AArch64/fast-isel-memcpy.ll b/test/CodeGen/AArch64/fast-isel-memcpy.ll new file mode 100644 index 00000000000..9161dad249a --- /dev/null +++ b/test/CodeGen/AArch64/fast-isel-memcpy.ll @@ -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) -- 2.34.1