[PATCH] D25460: Fix memory issue in AttrBuilder::removeAttribute uses

David Stenberg via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 01:08:11 PDT 2016


dstenb created this revision.
dstenb added a subscriber: llvm-commits.

Found when running Valgrind.

This removes two unnecessary assignments when using AttrBuilder::removeAttribute.

AttrBuilder::removeAttribute returns a reference to the object. As the LHSes were the same as the callees, the assignments resulted in memcpy calls where dst = src.


https://reviews.llvm.org/D25460

Files:
  lib/CodeGen/Analysis.cpp


Index: lib/CodeGen/Analysis.cpp
===================================================================
--- lib/CodeGen/Analysis.cpp
+++ lib/CodeGen/Analysis.cpp
@@ -541,8 +541,8 @@
 
   // Noalias is completely benign as far as calling convention goes, it
   // shouldn't affect whether the call is a tail call.
-  CallerAttrs = CallerAttrs.removeAttribute(Attribute::NoAlias);
-  CalleeAttrs = CalleeAttrs.removeAttribute(Attribute::NoAlias);
+  CallerAttrs.removeAttribute(Attribute::NoAlias);
+  CalleeAttrs.removeAttribute(Attribute::NoAlias);
 
   if (CallerAttrs.contains(Attribute::ZExt)) {
     if (!CalleeAttrs.contains(Attribute::ZExt))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25460.74198.patch
Type: text/x-patch
Size: 644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161011/2b66e451/attachment.bin>


More information about the llvm-commits mailing list