capturing-func.ll 709 B

12345678910111213141516171819202122
  1. ; RUN: opt < %s -basicaa -memcpyopt -S | FileCheck %s
  2. target datalayout = "e"
  3. declare void @foo(i8*)
  4. declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
  5. define void @test() {
  6. %ptr1 = alloca i8
  7. %ptr2 = alloca i8
  8. call void @foo(i8* %ptr2)
  9. call void @llvm.memcpy.p0i8.p0i8.i32(i8* %ptr1, i8* %ptr2, i32 1, i32 1, i1 false)
  10. call void @foo(i8* %ptr1)
  11. ret void
  12. ; Check that the transformation isn't applied if the called function can
  13. ; capture the pointer argument (i.e. the nocapture attribute isn't present)
  14. ; CHECK-LABEL: @test(
  15. ; CHECK: call void @foo(i8* %ptr2)
  16. ; CHECK-NEXT: call void @llvm.memcpy
  17. ; CHECK-NEXT: call void @foo(i8* %ptr1)
  18. }