libcalls.ll 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ; RUN: opt -S -basicaa -dse < %s | FileCheck %s
  2. declare i8* @strcpy(i8* %dest, i8* %src) nounwind
  3. define void @test1(i8* %src) {
  4. ; CHECK-LABEL: @test1(
  5. %B = alloca [16 x i8]
  6. %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
  7. ; CHECK-NOT: @strcpy
  8. %call = call i8* @strcpy(i8* %dest, i8* %src)
  9. ; CHECK: ret void
  10. ret void
  11. }
  12. declare i8* @strncpy(i8* %dest, i8* %src, i32 %n) nounwind
  13. define void @test2(i8* %src) {
  14. ; CHECK-LABEL: @test2(
  15. %B = alloca [16 x i8]
  16. %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
  17. ; CHECK-NOT: @strncpy
  18. %call = call i8* @strncpy(i8* %dest, i8* %src, i32 12)
  19. ; CHECK: ret void
  20. ret void
  21. }
  22. declare i8* @strcat(i8* %dest, i8* %src) nounwind
  23. define void @test3(i8* %src) {
  24. ; CHECK-LABEL: @test3(
  25. %B = alloca [16 x i8]
  26. %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
  27. ; CHECK-NOT: @strcat
  28. %call = call i8* @strcat(i8* %dest, i8* %src)
  29. ; CHECK: ret void
  30. ret void
  31. }
  32. declare i8* @strncat(i8* %dest, i8* %src, i32 %n) nounwind
  33. define void @test4(i8* %src) {
  34. ; CHECK-LABEL: @test4(
  35. %B = alloca [16 x i8]
  36. %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
  37. ; CHECK-NOT: @strncat
  38. %call = call i8* @strncat(i8* %dest, i8* %src, i32 12)
  39. ; CHECK: ret void
  40. ret void
  41. }
  42. define void @test5(i8* nocapture %src) {
  43. ; CHECK-LABEL: @test5(
  44. %dest = alloca [100 x i8], align 16
  45. %arraydecay = getelementptr inbounds [100 x i8], [100 x i8]* %dest, i64 0, i64 0
  46. %call = call i8* @strcpy(i8* %arraydecay, i8* %src)
  47. ; CHECK: %call = call i8* @strcpy
  48. %arrayidx = getelementptr inbounds i8, i8* %call, i64 10
  49. store i8 97, i8* %arrayidx, align 1
  50. ret void
  51. }
  52. declare void @user(i8* %p)
  53. define void @test6(i8* %src) {
  54. ; CHECK-LABEL: @test6(
  55. %B = alloca [16 x i8]
  56. %dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
  57. ; CHECK: @strcpy
  58. %call = call i8* @strcpy(i8* %dest, i8* %src)
  59. ; CHECK: @user
  60. call void @user(i8* %dest)
  61. ; CHECK: ret void
  62. ret void
  63. }