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