weak-symbols.ll 1013 B

123456789101112131415161718192021222324252627282930313233
  1. ; PR4738 - Test that the library call simplifier doesn't assume anything about
  2. ; weak symbols.
  3. ;
  4. ; RUN: opt < %s -instcombine -S | FileCheck %s
  5. @real_init = weak_odr constant [2 x i8] c"y\00"
  6. @fake_init = weak constant [2 x i8] c"y\00"
  7. @.str = private constant [2 x i8] c"y\00"
  8. define i32 @foo() nounwind {
  9. ; CHECK-LABEL: define i32 @foo(
  10. ; CHECK: call i32 @strcmp
  11. ; CHECK: ret i32 %temp1
  12. entry:
  13. %str1 = getelementptr inbounds [2 x i8], [2 x i8]* @fake_init, i64 0, i64 0
  14. %str2 = getelementptr inbounds [2 x i8], [2 x i8]* @.str, i64 0, i64 0
  15. %temp1 = call i32 @strcmp(i8* %str1, i8* %str2) nounwind readonly
  16. ret i32 %temp1
  17. }
  18. define i32 @bar() nounwind {
  19. ; CHECK-LABEL: define i32 @bar(
  20. ; CHECK: ret i32 0
  21. entry:
  22. %str1 = getelementptr inbounds [2 x i8], [2 x i8]* @real_init, i64 0, i64 0
  23. %str2 = getelementptr inbounds [2 x i8], [2 x i8]* @.str, i64 0, i64 0
  24. %temp1 = call i32 @strcmp(i8* %str1, i8* %str2) nounwind readonly
  25. ret i32 %temp1
  26. }
  27. declare i32 @strcmp(i8*, i8*) nounwind readonly