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 | 9dd90ac5b44b6a038c9a84be0cfd4c3d403031a8 (patch) | |
tree | b99e4bb707fbe077b3861559a9d27c6cf733b400 /llvm | |
parent | c20bb32c454afbdd5b9285ac4db3c29c1d33dfd2 (diff) | |
download | bcm5719-llvm-9dd90ac5b44b6a038c9a84be0cfd4c3d403031a8.tar.gz bcm5719-llvm-9dd90ac5b44b6a038c9a84be0cfd4c3d403031a8.zip |
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.
llvm-svn: 179071
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Analysis/MemoryBuiltins.cpp | 8 | ||||
-rw-r--r-- | llvm/test/Transforms/GVN/newoperator.ll | 20 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/invoke.ll | 16 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/objsize-64.ll | 2 |
4 files changed, 21 insertions, 25 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index d490d5419f7..0bf0b478795 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -52,14 +52,6 @@ struct AllocFnsTy { static const AllocFnsTy AllocationFnData[] = { {LibFunc::malloc, MallocLike, 1, 0, -1}, {LibFunc::valloc, MallocLike, 1, 0, -1}, - {LibFunc::Znwj, MallocLike, 1, 0, -1}, // new(unsigned int) - {LibFunc::ZnwjRKSt9nothrow_t, MallocLike, 2, 0, -1}, // new(unsigned int, nothrow) - {LibFunc::Znwm, MallocLike, 1, 0, -1}, // new(unsigned long) - {LibFunc::ZnwmRKSt9nothrow_t, MallocLike, 2, 0, -1}, // new(unsigned long, nothrow) - {LibFunc::Znaj, MallocLike, 1, 0, -1}, // new[](unsigned int) - {LibFunc::ZnajRKSt9nothrow_t, MallocLike, 2, 0, -1}, // new[](unsigned int, nothrow) - {LibFunc::Znam, MallocLike, 1, 0, -1}, // new[](unsigned long) - {LibFunc::ZnamRKSt9nothrow_t, MallocLike, 2, 0, -1}, // new[](unsigned long, nothrow) {LibFunc::posix_memalign, MallocLike, 3, 2, -1}, {LibFunc::calloc, CallocLike, 2, 0, 1}, {LibFunc::realloc, ReallocLike, 2, 1, -1}, diff --git a/llvm/test/Transforms/GVN/newoperator.ll b/llvm/test/Transforms/GVN/newoperator.ll new file mode 100644 index 00000000000..21cfc1db6e1 --- /dev/null +++ b/llvm/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"} diff --git a/llvm/test/Transforms/InstCombine/invoke.ll b/llvm/test/Transforms/InstCombine/invoke.ll index 04eaf86a287..4ef86ddb4d0 100644 --- a/llvm/test/Transforms/InstCombine/invoke.ll +++ b/llvm/test/Transforms/InstCombine/invoke.ll @@ -47,19 +47,3 @@ lpad: unreachable } -; CHECK: @f3 -define void @f3() nounwind uwtable ssp { -; CHECK: invoke void @llvm.donothing() - %call = invoke noalias i8* @_Znwm(i64 13) - to label %invoke.cont unwind label %lpad - -invoke.cont: - ret void - -lpad: - %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - filter [0 x i8*] zeroinitializer - %2 = extractvalue { i8*, i32 } %1, 0 - tail call void @__cxa_call_unexpected(i8* %2) noreturn nounwind - unreachable -} diff --git a/llvm/test/Transforms/InstCombine/objsize-64.ll b/llvm/test/Transforms/InstCombine/objsize-64.ll index 530e1234b4a..6ecc8304408 100644 --- a/llvm/test/Transforms/InstCombine/objsize-64.ll +++ b/llvm/test/Transforms/InstCombine/objsize-64.ll @@ -25,7 +25,7 @@ entry: to label %invoke.cont unwind label %lpad invoke.cont: -; CHECK: ret i64 13 +; CHECK: ret i64 %0 store i8* %call, i8** %esc %0 = tail call i64 @llvm.objectsize.i64(i8* %call, i1 false) ret i64 %0 |