diff options
author | Dan Gohman <gohman@apple.com> | 2009-08-19 00:11:12 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-08-19 00:11:12 +0000 |
commit | 107f41fad5f8df734c72cf39a016a7ea0d874388 (patch) | |
tree | 4eb7a844e364bb61f523a4d8cdf78930a3f047c4 /test | |
parent | 2c9489d6e96d99f77b6c31919805b5e61954deb2 (diff) | |
download | llvm-107f41fad5f8df734c72cf39a016a7ea0d874388.tar.gz llvm-107f41fad5f8df734c72cf39a016a7ea0d874388.tar.bz2 llvm-107f41fad5f8df734c72cf39a016a7ea0d874388.tar.xz |
Fix SimplifyLibcalls and ValueTracking to check mayBeOverridden
before performing optimizations based on constant string values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79384 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/SimplifyLibCalls/weak-symbols.ll | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyLibCalls/weak-symbols.ll b/test/Transforms/SimplifyLibCalls/weak-symbols.ll new file mode 100644 index 0000000000..970ee0ddf1 --- /dev/null +++ b/test/Transforms/SimplifyLibCalls/weak-symbols.ll @@ -0,0 +1,26 @@ +; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | FileCheck %s +; PR4738 + +; SimplifyLibcalls shouldn't assume anything about weak symbols. + +@real_init = weak_odr constant [2 x i8] c"y\00" +@fake_init = weak constant [2 x i8] c"y\00" +@.str = private constant [2 x i8] c"y\00" + +; CHECK: define i32 @foo +; CHECK: call i32 @strcmp +define i32 @foo() nounwind { +entry: + %t0 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8]* @fake_init, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8]* @.str, i64 0, i64 0)) nounwind readonly + ret i32 %t0 +} + +; CHECK: define i32 @bar +; CHECK: ret i32 0 +define i32 @bar() nounwind { +entry: + %t0 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8]* @real_init, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8]* @.str, i64 0, i64 0)) nounwind readonly + ret i32 %t0 +} + +declare i32 @strcmp(i8*, i8*) nounwind readonly |