1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[MemCpyOpt] Fix handling of readnone byval arguments

If the call is readnone, then there may not be any MemoryAccess
associated with the call. Bail out in that case.

This fixes the issue reported at
https://reviews.llvm.org/D94376#2578312.
This commit is contained in:
Nikita Popov 2021-02-22 18:46:55 +01:00
parent 659da52985
commit a86f098589
2 changed files with 20 additions and 0 deletions

View File

@ -1541,6 +1541,8 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
MemCpyInst *MDep = nullptr;
if (EnableMemorySSA) {
MemoryUseOrDef *CallAccess = MSSA->getMemoryAccess(&CB);
if (!CallAccess)
return false;
MemoryAccess *Clobber = MSSA->getWalker()->getClobberingMemoryAccess(
CallAccess->getDefiningAccess(), Loc);
if (auto *MD = dyn_cast<MemoryDef>(Clobber))

View File

@ -0,0 +1,18 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -memcpyopt -S -enable-memcpyopt-memoryssa=0 | FileCheck %s
; RUN: opt < %s -memcpyopt -S -enable-memcpyopt-memoryssa=1 -verify-memoryssa | FileCheck %s
%struct = type { i16 }
declare i16 @g(%struct*) readnone
define void @f() {
; CHECK-LABEL: @f(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CALL:%.*]] = call i16 @g(%struct* byval(%struct) align 1 undef)
; CHECK-NEXT: ret void
;
entry:
%call = call i16 @g(%struct* byval(%struct) align 1 undef)
ret void
}