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 00000000000000..b76f439b7425c7 --- /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 a047d42b50c569..99be76eac3e4db 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 &ChunksToKeep, // Delete out-of-chunk function bodies std::vector 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