[PATCH] D86404: [llvm-reduce] Prevent llvm-reduce from generated invalid moduels in some cases.

Tyker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 11:52:39 PDT 2020


Tyker created this revision.
Tyker added a reviewer: lebedev.ri.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Tyker requested review of this revision.

althought the interstingness test should usually fail when the module is invalid
this changes reduces the frequency at which llvm-reduce generate invalid IR.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86404

Files:
  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,11 @@
   // 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);
+      F.setLinkage(llvm::GlobalValue::ExternalLinkage);
+    }
 }
 
 /// Counts the amount of non-declaration functions and prints their


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86404.287210.patch
Type: text/x-patch
Size: 806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200822/cd15d736/attachment.bin>


More information about the llvm-commits mailing list