summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Bhat <siddu.druid@gmail.com>2017-08-09 18:19:46 +0000
committerSiddharth Bhat <siddu.druid@gmail.com>2017-08-09 18:19:46 +0000
commit9298ff2dee67686160b962159f00c0af6028028e (patch)
tree8c2830b2f4ad65202d22414978f907f2840e4586
parent49e5acab33277cb4036d089b7f96635d8958a23d (diff)
downloadbcm5719-llvm-9298ff2dee67686160b962159f00c0af6028028e.tar.gz
bcm5719-llvm-9298ff2dee67686160b962159f00c0af6028028e.zip
[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
-rw-r--r--polly/lib/CodeGen/ManagedMemoryRewrite.cpp2
-rw-r--r--polly/test/GPGPU/managed-memory-rewrite-malloc-free.ll4
2 files changed, 6 insertions, 0 deletions
diff --git a/polly/lib/CodeGen/ManagedMemoryRewrite.cpp b/polly/lib/CodeGen/ManagedMemoryRewrite.cpp
index 92fbf273efa..17a187b8969 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 b67a8dd7455..f646427ab11 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"
OpenPOWER on IntegriCloud