summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-10-03 20:17:06 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-10-03 20:17:06 +0000
commit1ed4229f6f0be720a1d47aaf32947ebf486b1503 (patch)
treebea7e392bb8ad475460c1aed7000cc5d9242846b
parentaae7fefce8ee3e315b6d3bf3a188350e8da95826 (diff)
downloadbcm5719-llvm-1ed4229f6f0be720a1d47aaf32947ebf486b1503.tar.gz
bcm5719-llvm-1ed4229f6f0be720a1d47aaf32947ebf486b1503.zip
PR21145: Teach LLVM about C++14 sized deallocation functions.
C++14 adds new builtin signatures for 'operator delete'. This change allows new/delete pairs to be removed in C++14 onwards, as they were in C++11 and before. llvm-svn: 219014
-rw-r--r--llvm/include/llvm/Target/TargetLibraryInfo.h8
-rw-r--r--llvm/lib/Analysis/MemoryBuiltins.cpp6
-rw-r--r--llvm/lib/Target/TargetLibraryInfo.cpp4
-rw-r--r--llvm/test/Transforms/InstCombine/malloc-free-delete.ll23
4 files changed, 40 insertions, 1 deletions
diff --git a/llvm/include/llvm/Target/TargetLibraryInfo.h b/llvm/include/llvm/Target/TargetLibraryInfo.h
index 389fd250daa..56a89191a58 100644
--- a/llvm/include/llvm/Target/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Target/TargetLibraryInfo.h
@@ -26,10 +26,18 @@ namespace llvm {
ZdaPv,
/// void operator delete[](void*, nothrow);
ZdaPvRKSt9nothrow_t,
+ /// void operator delete[](void*, unsigned int);
+ ZdaPvj,
+ /// void operator delete[](void*, unsigned long);
+ ZdaPvm,
/// void operator delete(void*);
ZdlPv,
/// void operator delete(void*, nothrow);
ZdlPvRKSt9nothrow_t,
+ /// void operator delete(void*, unsigned int);
+ ZdlPvj,
+ /// void operator delete(void*, unsigned long);
+ ZdlPvm,
/// void *new[](unsigned int);
Znaj,
/// void *new[](unsigned int, nothrow);
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 64d339f564d..5316cf9fef7 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -332,7 +332,11 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
TLIFn == LibFunc::ZdlPv || // operator delete(void*)
TLIFn == LibFunc::ZdaPv) // operator delete[](void*)
ExpectedNumParams = 1;
- else if (TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow)
+ else if (TLIFn == LibFunc::ZdlPvj || // delete(void*, uint)
+ TLIFn == LibFunc::ZdlPvm || // delete(void*, ulong)
+ TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow)
+ TLIFn == LibFunc::ZdaPvj || // delete[](void*, uint)
+ TLIFn == LibFunc::ZdaPvm || // delete[](void*, ulong)
TLIFn == LibFunc::ZdaPvRKSt9nothrow_t) // delete[](void*, nothrow)
ExpectedNumParams = 2;
else
diff --git a/llvm/lib/Target/TargetLibraryInfo.cpp b/llvm/lib/Target/TargetLibraryInfo.cpp
index 616ff906730..7ca5c74e935 100644
--- a/llvm/lib/Target/TargetLibraryInfo.cpp
+++ b/llvm/lib/Target/TargetLibraryInfo.cpp
@@ -28,8 +28,12 @@ const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
"_IO_putc",
"_ZdaPv",
"_ZdaPvRKSt9nothrow_t",
+ "_ZdaPvj",
+ "_ZdaPvm",
"_ZdlPv",
"_ZdlPvRKSt9nothrow_t",
+ "_ZdlPvj",
+ "_ZdlPvm",
"_Znaj",
"_ZnajRKSt9nothrow_t",
"_Znam",
diff --git a/llvm/test/Transforms/InstCombine/malloc-free-delete.ll b/llvm/test/Transforms/InstCombine/malloc-free-delete.ll
index 20852065384..ed25e4e49c8 100644
--- a/llvm/test/Transforms/InstCombine/malloc-free-delete.ll
+++ b/llvm/test/Transforms/InstCombine/malloc-free-delete.ll
@@ -144,3 +144,26 @@ lpad.i: ; preds = %entry
call void @_ZdlPvRKSt9nothrow_t(i8* %call.i, i8* %nt) builtin nounwind
resume { i8*, i32 } %0
}
+
+declare i8* @_Znwm(i64) nobuiltin
+declare void @_ZdlPvm(i8*, i64) nobuiltin
+declare i8* @_Znwj(i32) nobuiltin
+declare void @_ZdlPvj(i8*, i32) nobuiltin
+declare i8* @_Znam(i64) nobuiltin
+declare void @_ZdaPvm(i8*, i64) nobuiltin
+declare i8* @_Znaj(i32) nobuiltin
+declare void @_ZdaPvj(i8*, i32) nobuiltin
+
+; CHECK-LABEL: @test8(
+define void @test8() {
+ ; CHECK-NOT: call
+ %nwm = call i8* @_Znwm(i64 32) builtin
+ call void @_ZdlPvm(i8* %nwm, i64 32) builtin
+ %nwj = call i8* @_Znwj(i32 32) builtin
+ call void @_ZdlPvj(i8* %nwj, i32 32) builtin
+ %nam = call i8* @_Znam(i64 32) builtin
+ call void @_ZdaPvm(i8* %nam, i64 32) builtin
+ %naj = call i8* @_Znaj(i32 32) builtin
+ call void @_ZdaPvj(i8* %naj, i32 32) builtin
+ ret void
+}
OpenPOWER on IntegriCloud