2003-07-21-ExternalConstant.ll 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ;
  2. ; Test: ExternalConstant
  3. ;
  4. ; Description:
  5. ; This regression test helps check whether the instruction combining
  6. ; optimization pass correctly handles global variables which are marked
  7. ; as external and constant.
  8. ;
  9. ; If a problem occurs, we should die on an assert(). Otherwise, we
  10. ; should pass through the optimizer without failure.
  11. ;
  12. ; Extra code:
  13. ; RUN: opt < %s -instcombine
  14. ; END.
  15. target datalayout = "e-p:32:32"
  16. @silly = external constant i32 ; <i32*> [#uses=1]
  17. declare void @bzero(i8*, i32)
  18. declare void @bcopy(i8*, i8*, i32)
  19. declare i32 @bcmp(i8*, i8*, i32)
  20. declare i32 @fputs(i8*, i8*)
  21. declare i32 @fputs_unlocked(i8*, i8*)
  22. define i32 @function(i32 %a.1) {
  23. entry:
  24. %a.0 = alloca i32 ; <i32*> [#uses=2]
  25. %result = alloca i32 ; <i32*> [#uses=2]
  26. store i32 %a.1, i32* %a.0
  27. %tmp.0 = load i32, i32* %a.0 ; <i32> [#uses=1]
  28. %tmp.1 = load i32, i32* @silly ; <i32> [#uses=1]
  29. %tmp.2 = add i32 %tmp.0, %tmp.1 ; <i32> [#uses=1]
  30. store i32 %tmp.2, i32* %result
  31. br label %return
  32. return: ; preds = %entry
  33. %tmp.3 = load i32, i32* %result ; <i32> [#uses=1]
  34. ret i32 %tmp.3
  35. }