[PATCH] D86404: [llvm-reduce] Function body reduction: don't forget to unset comdat

Tyker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 30 03:18:19 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGdaedfb632d2a: [llvm-reduce] Function body reduction: don't forget to unset comdat (authored by Tyker).

Changed prior to commit:
  https://reviews.llvm.org/D86404?vs=287214&id=288844#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86404/new/

https://reviews.llvm.org/D86404

Files:
  llvm/test/Reduce/remove-function-bodies-comdat.ll
  llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp


Index: llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
@@ -13,6 +13,7 @@
 
 #include "ReduceFunctionBodies.h"
 #include "Delta.h"
+#include "llvm/IR/GlobalValue.h"
 
 using namespace llvm;
 
@@ -26,8 +27,10 @@
   // Delete out-of-chunk function bodies
   std::vector<Function *> FuncDefsToReduce;
   for (auto &F : *Program)
-    if (!F.isDeclaration() && !O.shouldKeep())
+    if (!F.isDeclaration() && !O.shouldKeep()) {
       F.deleteBody();
+      F.setComdat(nullptr);
+    }
 }
 
 /// Counts the amount of non-declaration functions and prints their
Index: llvm/test/Reduce/remove-function-bodies-comdat.ll
===================================================================
--- /dev/null
+++ llvm/test/Reduce/remove-function-bodies-comdat.ll
@@ -0,0 +1,22 @@
+; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: cat %t | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s
+; RUN: opt -verify %t
+
+; CHECK-FINAL-NOT: = comdat
+; CHECK-INTERESTINGNESS: @callee(
+; CHECK-FINAL: declare void @callee()
+
+$foo = comdat any
+
+define void @callee() comdat($foo) {
+  ret void
+}
+
+; CHECK-ALL: define void @caller()
+define void @caller() {
+entry:
+; CHECK-ALL: call void @callee()
+; CHECK-ALL: ret void
+  call void @callee()
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86404.288844.patch
Type: text/x-patch
Size: 1542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200830/825bfdbe/attachment.bin>


More information about the llvm-commits mailing list