Nikita Popov | 64c54c5 | 2020-10-01 22:42:14 +0200 | [diff] [blame^] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
Fangrui Song | f31811f | 2020-06-26 20:41:37 -0700 | [diff] [blame] | 2 | ; RUN: opt < %s -basic-aa -memcpyopt -S | FileCheck %s |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 3 | |
| 4 | target datalayout = "e" |
| 5 | |
| 6 | declare void @foo(i8*) |
| 7 | declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i1) nounwind |
| 8 | |
| 9 | define void @test() { |
Nikita Popov | 64c54c5 | 2020-10-01 22:42:14 +0200 | [diff] [blame^] | 10 | ; CHECK-LABEL: @test( |
| 11 | ; CHECK-NEXT: [[PTR1:%.*]] = alloca i8, align 1 |
| 12 | ; CHECK-NEXT: [[PTR2:%.*]] = alloca i8, align 1 |
| 13 | ; CHECK-NEXT: call void @foo(i8* [[PTR2]]) |
| 14 | ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* [[PTR1]], i8* [[PTR2]], i32 1, i1 false) |
| 15 | ; CHECK-NEXT: call void @foo(i8* [[PTR1]]) |
| 16 | ; CHECK-NEXT: ret void |
| 17 | ; |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 18 | %ptr1 = alloca i8 |
| 19 | %ptr2 = alloca i8 |
| 20 | call void @foo(i8* %ptr2) |
| 21 | call void @llvm.memcpy.p0i8.p0i8.i32(i8* %ptr1, i8* %ptr2, i32 1, i1 false) |
| 22 | call void @foo(i8* %ptr1) |
| 23 | ret void |
| 24 | |
| 25 | ; Check that the transformation isn't applied if the called function can |
| 26 | ; capture the pointer argument (i.e. the nocapture attribute isn't present) |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 27 | } |