[llvm] daedfb6 - [llvm-reduce] Function body reduction: don't forget to unset comdat
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 30 03:18:13 PDT 2020
Author: Tyker
Date: 2020-08-30T12:17:33+02:00
New Revision: daedfb632d2a81611ec91fd9abfba08bd849fb52
URL: https://github.com/llvm/llvm-project/commit/daedfb632d2a81611ec91fd9abfba08bd849fb52
DIFF: https://github.com/llvm/llvm-project/commit/daedfb632d2a81611ec91fd9abfba08bd849fb52.diff
LOG: [llvm-reduce] Function body reduction: don't forget to unset comdat
althought the interstingness test should usually fail when the module is invalid
this changes reduces the frequency at which llvm-reduce generate invalid IR.
Reviewed By: lebedev.ri
Differential Revision: https://reviews.llvm.org/D86404
Added:
llvm/test/Reduce/remove-function-bodies-comdat.ll
Modified:
llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
Removed:
################################################################################
diff --git a/llvm/test/Reduce/remove-function-bodies-comdat.ll b/llvm/test/Reduce/remove-function-bodies-comdat.ll
new file mode 100644
index 000000000000..b76f439b7425
--- /dev/null
+++ b/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
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp b/llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
index a047d42b50c5..99be76eac3e4 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
+++ b/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 @@ extractFunctionBodiesFromModule(const std::vector<Chunk> &ChunksToKeep,
// 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
More information about the llvm-commits
mailing list