[PATCH] D101279: [llvm-reduce] Don't unset dso_local on implicitly dso_local GVs
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 30 11:57:53 PDT 2021
aeubanks updated this revision to Diff 341999.
aeubanks added a comment.
don't use assert, that doesn't work in non-assert builds
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101279/new/
https://reviews.llvm.org/D101279
Files:
llvm/test/tools/llvm-reduce/remove-dso-local.ll
llvm/tools/llvm-reduce/deltas/Delta.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.cpp
Index: llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.cpp
@@ -17,6 +17,10 @@
using namespace llvm;
+static bool isValidDSOLocalReductionGV(GlobalValue &GV) {
+ return GV.isDSOLocal() && !GV.isImplicitDSOLocal();
+}
+
/// Sets dso_local to false for all global values.
static void extractGVsFromModule(std::vector<Chunk> ChunksToKeep,
Module *Program) {
@@ -24,7 +28,7 @@
// remove dso_local from global values
for (auto &GV : Program->global_values())
- if (GV.isDSOLocal() && !O.shouldKeep()) {
+ if (isValidDSOLocalReductionGV(GV) && !O.shouldKeep()) {
GV.setDSOLocal(false);
}
}
@@ -37,7 +41,7 @@
outs() << "GlobalValue Index Reference:\n";
int GVCount = 0;
for (auto &GV : Program->global_values())
- if (GV.isDSOLocal())
+ if (isValidDSOLocalReductionGV(GV))
outs() << "\t" << ++GVCount << ": " << GV.getName() << "\n";
outs() << "----------------------------\n";
return GVCount;
Index: llvm/tools/llvm-reduce/deltas/Delta.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -15,6 +15,7 @@
#include "Delta.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/Verifier.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include <fstream>
@@ -22,6 +23,10 @@
using namespace llvm;
+static cl::opt<bool> AbortOnInvalidReduction(
+ "abort-on-invalid-reduction",
+ cl::desc("Abort if any reduction results in invalid IR"));
+
void writeOutput(llvm::Module *M, llvm::StringRef Message);
bool isReduced(Module &M, TestRunner &Test, SmallString<128> &CurrentFilepath) {
@@ -141,6 +146,10 @@
// Some reductions may result in invalid IR. Skip such reductions.
if (verifyModule(*Clone.get(), &errs())) {
+ if (AbortOnInvalidReduction) {
+ errs() << "Invalid reduction\n";
+ exit(1);
+ }
errs() << " **** WARNING | reduction resulted in invalid module, "
"skipping\n";
continue;
Index: llvm/test/tools/llvm-reduce/remove-dso-local.ll
===================================================================
--- llvm/test/tools/llvm-reduce/remove-dso-local.ll
+++ llvm/test/tools/llvm-reduce/remove-dso-local.ll
@@ -1,6 +1,6 @@
; Test that llvm-reduce can remove dso_local.
;
-; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=global-values --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
; RUN: FileCheck --check-prefix=CHECK-FINAL %s < %t
; CHECK-INTERESTINGNESS: declare
@@ -22,3 +22,7 @@
declare dso_local void @f1(i32, i32)
+; CHECK-INTERESTINGNESS: define {{.*}} @f2
+define private void @f2(i32, i32) {
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101279.341999.patch
Type: text/x-patch
Size: 3209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210430/8a4cf431/attachment.bin>
More information about the llvm-commits
mailing list