[llvm] r226069 - For PR21145: recognise a builtin call to a known deallocation function even if
Richard Smith
richard-llvm at metafoo.co.uk
Wed Jan 14 17:00:33 PST 2015
Author: rsmith
Date: Wed Jan 14 19:00:33 2015
New Revision: 226069
URL: http://llvm.org/viewvc/llvm-project?rev=226069&view=rev
Log:
For PR21145: recognise a builtin call to a known deallocation function even if
it's defined in the current module. Clang generates this situation for the
C++14 sized deallocation functions, because it generates a weak definition in
case one isn't provided by the C++ runtime library.
Modified:
llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll
Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=226069&r1=226068&r2=226069&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Wed Jan 14 19:00:33 2015
@@ -319,7 +319,7 @@ const CallInst *llvm::isFreeCall(const V
if (!CI || isa<IntrinsicInst>(CI))
return nullptr;
Function *Callee = CI->getCalledFunction();
- if (Callee == nullptr || !Callee->isDeclaration())
+ if (Callee == nullptr)
return nullptr;
StringRef FnName = Callee->getName();
Modified: llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll?rev=226069&r1=226068&r2=226069&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll Wed Jan 14 19:00:33 2015
@@ -146,17 +146,36 @@ lpad.i:
}
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
+declare void @_ZdlPv(i8*) nobuiltin
+declare void @_ZdaPv(i8*) nobuiltin
+
+define linkonce void @_ZdlPvm(i8* %p, i64) nobuiltin {
+ call void @_ZdlPv(i8* %p)
+ ret void
+}
+define linkonce void @_ZdlPvj(i8* %p, i32) nobuiltin {
+ call void @_ZdlPv(i8* %p)
+ ret void
+}
+define linkonce void @_ZdaPvm(i8* %p, i64) nobuiltin {
+ call void @_ZdaPv(i8* %p)
+ ret void
+}
+define linkonce void @_ZdaPvj(i8* %p, i32) nobuiltin {
+ call void @_ZdaPv(i8* %p)
+ ret void
+}
; CHECK-LABEL: @test8(
define void @test8() {
; CHECK-NOT: call
+ %nw = call i8* @_Znwm(i64 32) builtin
+ call void @_ZdlPv(i8* %nw) builtin
+ %na = call i8* @_Znam(i64 32) builtin
+ call void @_ZdaPv(i8* %na) builtin
%nwm = call i8* @_Znwm(i64 32) builtin
call void @_ZdlPvm(i8* %nwm, i64 32) builtin
%nwj = call i8* @_Znwj(i32 32) builtin
More information about the llvm-commits
mailing list