attr-noduplicate.ll 880 B

12345678910111213141516171819202122232425262728293031323334353637
  1. ; RUN: opt < %s -simplifycfg -S | FileCheck %s
  2. ; This test checks that the SimplifyCFG pass won't duplicate a call to a
  3. ; function marked noduplicate.
  4. ;
  5. ; CHECK-LABEL: @noduplicate
  6. ; CHECK: call void @barrier
  7. ; CHECK-NOT: call void @barrier
  8. define void @noduplicate(i32 %cond, i32* %out) {
  9. entry:
  10. %out1 = getelementptr i32, i32* %out, i32 1
  11. %out2 = getelementptr i32, i32* %out, i32 2
  12. %cmp = icmp eq i32 %cond, 0
  13. br i1 %cmp, label %if.then, label %if.end
  14. if.then:
  15. store i32 5, i32* %out
  16. br label %if.end
  17. if.end:
  18. call void @barrier() #0
  19. br i1 %cmp, label %cond.end, label %cond.false
  20. cond.false:
  21. store i32 5, i32* %out1
  22. br label %cond.end
  23. cond.end:
  24. %value = phi i32 [ 1, %cond.false ], [ 0, %if.end ]
  25. store i32 %value, i32* %out2
  26. ret void
  27. }
  28. ; Function Attrs: noduplicate nounwind
  29. declare void @barrier() #0
  30. attributes #0 = { noduplicate nounwind }