union.ll 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ; RUN: opt < %s -dfsan -S | FileCheck %s
  2. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  3. target triple = "x86_64-unknown-linux-gnu"
  4. @a = common global i32 0
  5. @b = common global i32 0
  6. ; Check that we reuse unions where possible.
  7. ; CHECK-LABEL: @"dfs$f"
  8. define void @f(i32 %x, i32 %y) {
  9. ; CHECK: call{{.*}}__dfsan_union
  10. %xay = add i32 %x, %y
  11. store i32 %xay, i32* @a
  12. ; CHECK-NOT: call{{.*}}__dfsan_union
  13. %xmy = mul i32 %x, %y
  14. store i32 %xmy, i32* @b
  15. ret void
  16. }
  17. ; In this case, we compute the unions on both sides because neither block
  18. ; dominates the other.
  19. ; CHECK-LABEL: @"dfs$g"
  20. define void @g(i1 %p, i32 %x, i32 %y) {
  21. br i1 %p, label %l1, label %l2
  22. l1:
  23. ; CHECK: call{{.*}}__dfsan_union
  24. %xay = add i32 %x, %y
  25. store i32 %xay, i32* @a
  26. br label %l3
  27. l2:
  28. ; CHECK: call{{.*}}__dfsan_union
  29. %xmy = mul i32 %x, %y
  30. store i32 %xmy, i32* @b
  31. br label %l3
  32. l3:
  33. ret void
  34. }
  35. ; In this case, we know that the label for %xayax subsumes the label for %xay.
  36. ; CHECK-LABEL: @"dfs$h"
  37. define i32 @h(i32 %x, i32 %y) {
  38. ; CHECK: call{{.*}}__dfsan_union
  39. %xay = add i32 %x, %y
  40. ; CHECK-NOT: call{{.*}}__dfsan_union
  41. %xayax = add i32 %xay, %x
  42. ret i32 %xayax
  43. }