st_sink_bugfix_22613.ll 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ; ModuleID = 'bug.c'
  2. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  3. target triple = "x86_64-unknown-linux-gnu"
  4. ; RUN: opt -O2 -S < %s | FileCheck %s
  5. ; CHECK_LABEL: main
  6. ; CHECK: if.end
  7. ; CHECK: store
  8. ; CHECK: memset
  9. ; CHECK: if.then
  10. ; CHECK: store
  11. ; CHECK: memset
  12. @d = common global i32 0, align 4
  13. @b = common global i32 0, align 4
  14. @f = common global [1 x [3 x i8]] zeroinitializer, align 1
  15. @e = common global i32 0, align 4
  16. @c = common global i32 0, align 4
  17. @a = common global i32 0, align 4
  18. ; Function Attrs: nounwind uwtable
  19. define void @fn1() {
  20. entry:
  21. store i32 0, i32* @d, align 4
  22. br label %for.cond
  23. for.cond: ; preds = %for.inc8, %entry
  24. %0 = load i32, i32* @d, align 4
  25. %cmp = icmp slt i32 %0, 2
  26. br i1 %cmp, label %for.body, label %for.end10
  27. for.body: ; preds = %for.cond
  28. %1 = load i32, i32* @d, align 4
  29. %idxprom = sext i32 %1 to i64
  30. %2 = load i32, i32* @b, align 4
  31. %idxprom1 = sext i32 %2 to i64
  32. %arrayidx = getelementptr inbounds [1 x [3 x i8]], [1 x [3 x i8]]* @f, i32 0, i64 %idxprom1
  33. %arrayidx2 = getelementptr inbounds [3 x i8], [3 x i8]* %arrayidx, i32 0, i64 %idxprom
  34. store i8 0, i8* %arrayidx2, align 1
  35. store i32 0, i32* @e, align 4
  36. br label %for.cond3
  37. for.cond3: ; preds = %for.inc, %for.body
  38. %3 = load i32, i32* @e, align 4
  39. %cmp4 = icmp slt i32 %3, 3
  40. br i1 %cmp4, label %for.body5, label %for.end
  41. for.body5: ; preds = %for.cond3
  42. %4 = load i32, i32* @c, align 4
  43. %tobool = icmp ne i32 %4, 0
  44. br i1 %tobool, label %if.then, label %if.end
  45. if.then: ; preds = %for.body5
  46. %5 = load i32, i32* @a, align 4
  47. %dec = add nsw i32 %5, -1
  48. store i32 %dec, i32* @a, align 4
  49. br label %if.end
  50. if.end: ; preds = %if.then, %for.body5
  51. %6 = load i32, i32* @e, align 4
  52. %idxprom6 = sext i32 %6 to i64
  53. %arrayidx7 = getelementptr inbounds [3 x i8], [3 x i8]* getelementptr inbounds ([1 x [3 x i8]], [1 x [3 x i8]]* @f, i32 0, i64 0), i32 0, i64 %idxprom6
  54. store i8 1, i8* %arrayidx7, align 1
  55. br label %for.inc
  56. for.inc: ; preds = %if.end
  57. %7 = load i32, i32* @e, align 4
  58. %inc = add nsw i32 %7, 1
  59. store i32 %inc, i32* @e, align 4
  60. br label %for.cond3
  61. for.end: ; preds = %for.cond3
  62. br label %for.inc8
  63. for.inc8: ; preds = %for.end
  64. %8 = load i32, i32* @d, align 4
  65. %inc9 = add nsw i32 %8, 1
  66. store i32 %inc9, i32* @d, align 4
  67. br label %for.cond
  68. for.end10: ; preds = %for.cond
  69. ret void
  70. }
  71. ; Function Attrs: nounwind uwtable
  72. define i32 @main() {
  73. entry:
  74. %retval = alloca i32, align 4
  75. store i32 0, i32* %retval
  76. call void @fn1()
  77. %0 = load i8, i8* getelementptr inbounds ([1 x [3 x i8]], [1 x [3 x i8]]* @f, i32 0, i64 0, i64 1), align 1
  78. %conv = sext i8 %0 to i32
  79. %cmp = icmp ne i32 %conv, 1
  80. br i1 %cmp, label %if.then, label %if.end
  81. if.then: ; preds = %entry
  82. call void @abort()
  83. unreachable
  84. if.end: ; preds = %entry
  85. ret i32 0
  86. }
  87. ; Function Attrs: noreturn nounwind
  88. declare void @abort()