diff options
author | Nadav Rotem <nrotem@apple.com> | 2013-04-08 23:40:47 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2013-04-08 23:40:47 +0000 |
commit | 0a9b452aa457ef911e5a6c327ae4b5596df55bca (patch) | |
tree | ff84949c98e33016a8cb4e395f3106158ad62bba /test/Transforms/GVN | |
parent | 92c3742319cc219f8a57aa7d8eea5b17ec93ad06 (diff) | |
download | llvm-0a9b452aa457ef911e5a6c327ae4b5596df55bca.tar.gz llvm-0a9b452aa457ef911e5a6c327ae4b5596df55bca.tar.bz2 llvm-0a9b452aa457ef911e5a6c327ae4b5596df55bca.tar.xz |
c++ new operators are not malloc-like functions because they do not return uninitialized memory.
Users may overide new-operators and implement any function that they like.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN')
-rw-r--r-- | test/Transforms/GVN/newoperator.ll | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Transforms/GVN/newoperator.ll b/test/Transforms/GVN/newoperator.ll new file mode 100644 index 0000000000..21cfc1db6e --- /dev/null +++ b/test/Transforms/GVN/newoperator.ll @@ -0,0 +1,20 @@ +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s + +; We can't remove the load because new operators are overideable and can return non-undefined memory. +;CHECK: main +;CHECK: load +;CHECK: ret +define i32 @main(i32 %argc, i8** nocapture %argv) ssp uwtable { + %1 = tail call noalias i8* @_Znam(i64 800) + %2 = bitcast i8* %1 to i32** + %3 = load i32** %2, align 8, !tbaa !0 + %4 = icmp eq i32* %3, null + %5 = zext i1 %4 to i32 + ret i32 %5 +} + +declare noalias i8* @_Znam(i64) + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} |