readattrs.ll 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ; RUN: opt < %s -functionattrs -S | FileCheck %s
  2. @x = global i32 0
  3. declare void @test1_1(i8* %x1_1, i8* readonly %y1_1, ...)
  4. ; CHECK: define void @test1_2(i8* %x1_2, i8* readonly %y1_2, i8* %z1_2)
  5. define void @test1_2(i8* %x1_2, i8* %y1_2, i8* %z1_2) {
  6. call void (i8*, i8*, ...) @test1_1(i8* %x1_2, i8* %y1_2, i8* %z1_2)
  7. store i32 0, i32* @x
  8. ret void
  9. }
  10. ; CHECK: define i8* @test2(i8* readnone %p)
  11. define i8* @test2(i8* %p) {
  12. store i32 0, i32* @x
  13. ret i8* %p
  14. }
  15. ; CHECK: define i1 @test3(i8* readnone %p, i8* readnone %q)
  16. define i1 @test3(i8* %p, i8* %q) {
  17. %A = icmp ult i8* %p, %q
  18. ret i1 %A
  19. }
  20. declare void @test4_1(i8* nocapture) readonly
  21. ; CHECK: define void @test4_2(i8* nocapture readonly %p)
  22. define void @test4_2(i8* %p) {
  23. call void @test4_1(i8* %p)
  24. ret void
  25. }
  26. ; CHECK: define void @test5(i8** nocapture %p, i8* %q)
  27. ; Missed optz'n: we could make %q readnone, but don't break test6!
  28. define void @test5(i8** %p, i8* %q) {
  29. store i8* %q, i8** %p
  30. ret void
  31. }
  32. declare void @test6_1()
  33. ; CHECK: define void @test6_2(i8** nocapture %p, i8* %q)
  34. ; This is not a missed optz'n.
  35. define void @test6_2(i8** %p, i8* %q) {
  36. store i8* %q, i8** %p
  37. call void @test6_1()
  38. ret void
  39. }
  40. ; CHECK: define void @test7_1(i32* inalloca nocapture %a)
  41. ; inalloca parameters are always considered written
  42. define void @test7_1(i32* inalloca %a) {
  43. ret void
  44. }
  45. ; CHECK: define i32* @test8_1(i32* readnone %p)
  46. define i32* @test8_1(i32* %p) {
  47. entry:
  48. ret i32* %p
  49. }
  50. ; CHECK: define void @test8_2(i32* %p)
  51. define void @test8_2(i32* %p) {
  52. entry:
  53. %call = call i32* @test8_1(i32* %p)
  54. store i32 10, i32* %call, align 4
  55. ret void
  56. }