inline_ssp.ll 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. ; RUN: opt -inline %s -S | FileCheck %s
  2. ; Ensure SSP attributes are propagated correctly when inlining.
  3. @.str = private unnamed_addr constant [11 x i8] c"fun_nossp\0A\00", align 1
  4. @.str1 = private unnamed_addr constant [9 x i8] c"fun_ssp\0A\00", align 1
  5. @.str2 = private unnamed_addr constant [15 x i8] c"fun_sspstrong\0A\00", align 1
  6. @.str3 = private unnamed_addr constant [12 x i8] c"fun_sspreq\0A\00", align 1
  7. ; These first four functions (@fun_sspreq, @fun_sspstrong, @fun_ssp, @fun_nossp)
  8. ; are used by the remaining functions to ensure that the SSP attributes are
  9. ; propagated correctly. The caller should have its SSP attribute set as:
  10. ; strictest(caller-ssp-attr, callee-ssp-attr), where strictness is ordered as:
  11. ; sspreq > sspstrong > ssp > [no ssp]
  12. define internal void @fun_sspreq() nounwind sspreq uwtable {
  13. entry:
  14. %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str3, i32 0, i32 0))
  15. ret void
  16. }
  17. define internal void @fun_sspstrong() nounwind sspstrong uwtable {
  18. entry:
  19. %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str2, i32 0, i32 0))
  20. ret void
  21. }
  22. define internal void @fun_ssp() nounwind ssp uwtable {
  23. entry:
  24. %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str1, i32 0, i32 0))
  25. ret void
  26. }
  27. define internal void @fun_nossp() nounwind uwtable {
  28. entry:
  29. %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0))
  30. ret void
  31. }
  32. ; Tests start below
  33. define void @inline_req_req() nounwind sspreq uwtable {
  34. entry:
  35. ; CHECK: @inline_req_req() #0
  36. call void @fun_sspreq()
  37. ret void
  38. }
  39. define void @inline_req_strong() nounwind sspstrong uwtable {
  40. entry:
  41. ; CHECK: @inline_req_strong() #0
  42. call void @fun_sspreq()
  43. ret void
  44. }
  45. define void @inline_req_ssp() nounwind ssp uwtable {
  46. entry:
  47. ; CHECK: @inline_req_ssp() #0
  48. call void @fun_sspreq()
  49. ret void
  50. }
  51. define void @inline_req_nossp() nounwind uwtable {
  52. entry:
  53. ; CHECK: @inline_req_nossp() #0
  54. call void @fun_sspreq()
  55. ret void
  56. }
  57. define void @inline_strong_req() nounwind sspreq uwtable {
  58. entry:
  59. ; CHECK: @inline_strong_req() #0
  60. call void @fun_sspstrong()
  61. ret void
  62. }
  63. define void @inline_strong_strong() nounwind sspstrong uwtable {
  64. entry:
  65. ; CHECK: @inline_strong_strong() #1
  66. call void @fun_sspstrong()
  67. ret void
  68. }
  69. define void @inline_strong_ssp() nounwind ssp uwtable {
  70. entry:
  71. ; CHECK: @inline_strong_ssp() #1
  72. call void @fun_sspstrong()
  73. ret void
  74. }
  75. define void @inline_strong_nossp() nounwind uwtable {
  76. entry:
  77. ; CHECK: @inline_strong_nossp() #1
  78. call void @fun_sspstrong()
  79. ret void
  80. }
  81. define void @inline_ssp_req() nounwind sspreq uwtable {
  82. entry:
  83. ; CHECK: @inline_ssp_req() #0
  84. call void @fun_ssp()
  85. ret void
  86. }
  87. define void @inline_ssp_strong() nounwind sspstrong uwtable {
  88. entry:
  89. ; CHECK: @inline_ssp_strong() #1
  90. call void @fun_ssp()
  91. ret void
  92. }
  93. define void @inline_ssp_ssp() nounwind ssp uwtable {
  94. entry:
  95. ; CHECK: @inline_ssp_ssp() #2
  96. call void @fun_ssp()
  97. ret void
  98. }
  99. define void @inline_ssp_nossp() nounwind uwtable {
  100. entry:
  101. ; CHECK: @inline_ssp_nossp() #2
  102. call void @fun_ssp()
  103. ret void
  104. }
  105. define void @inline_nossp_req() nounwind uwtable sspreq {
  106. entry:
  107. ; CHECK: @inline_nossp_req() #0
  108. call void @fun_nossp()
  109. ret void
  110. }
  111. define void @inline_nossp_strong() nounwind sspstrong uwtable {
  112. entry:
  113. ; CHECK: @inline_nossp_strong() #1
  114. call void @fun_nossp()
  115. ret void
  116. }
  117. define void @inline_nossp_ssp() nounwind ssp uwtable {
  118. entry:
  119. ; CHECK: @inline_nossp_ssp() #2
  120. call void @fun_nossp()
  121. ret void
  122. }
  123. define void @inline_nossp_nossp() nounwind uwtable {
  124. entry:
  125. ; CHECK: @inline_nossp_nossp() #3
  126. call void @fun_nossp()
  127. ret void
  128. }
  129. declare i32 @printf(i8*, ...)
  130. ; CHECK: attributes #0 = { nounwind sspreq uwtable }
  131. ; CHECK: attributes #1 = { nounwind sspstrong uwtable }
  132. ; CHECK: attributes #2 = { nounwind ssp uwtable }
  133. ; CHECK: attributes #3 = { nounwind uwtable }