From 9298ff2dee67686160b962159f00c0af6028028e Mon Sep 17 00:00:00 2001 From: Siddharth Bhat Date: Wed, 9 Aug 2017 18:19:46 +0000 Subject: [PATCH] [ManagedMemoryRewrite] [Polly] Erase original malloc and free. [NFC] We do not need to keep `malloc` and `free` around since they are replaced by `polly_{malloc,free}Managed.` llvm-svn: 310504 --- polly/lib/CodeGen/ManagedMemoryRewrite.cpp | 2 ++ polly/test/GPGPU/managed-memory-rewrite-malloc-free.ll | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/polly/lib/CodeGen/ManagedMemoryRewrite.cpp b/polly/lib/CodeGen/ManagedMemoryRewrite.cpp index 92fbf27..17a187b 100644 --- a/polly/lib/CodeGen/ManagedMemoryRewrite.cpp +++ b/polly/lib/CodeGen/ManagedMemoryRewrite.cpp @@ -102,6 +102,7 @@ public: Function *PollyMallocManaged = GetOrCreatePollyMallocManaged(M); assert(PollyMallocManaged && "unable to create polly_mallocManaged"); Malloc->replaceAllUsesWith(PollyMallocManaged); + Malloc->eraseFromParent(); } Function *Free = M.getFunction("free"); @@ -110,6 +111,7 @@ public: Function *PollyFreeManaged = GetOrCreatePollyFreeManaged(M); assert(PollyFreeManaged && "unable to create polly_freeManaged"); Free->replaceAllUsesWith(PollyFreeManaged); + Free->eraseFromParent(); } return true; diff --git a/polly/test/GPGPU/managed-memory-rewrite-malloc-free.ll b/polly/test/GPGPU/managed-memory-rewrite-malloc-free.ll index b67a8dd..f646427 100644 --- a/polly/test/GPGPU/managed-memory-rewrite-malloc-free.ll +++ b/polly/test/GPGPU/managed-memory-rewrite-malloc-free.ll @@ -41,6 +41,10 @@ ; HOST-IR call void @polly_freeManaged(i8* %toFreeBitcast) ; HOST-IR: declare void @polly_freeManaged(i8*) +; // Check that we remove the original malloc,free +; HOST-IR-NOT: declare i8* @malloc(i64) +; HOST-IR-NOT: declare void @free(i8*) + target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.12.0" -- 2.7.4