mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[llvm-reduce] Skip chunks that lead to broken modules.
Some reduction passes may create invalid IR. I am not aware of any use case where we would like to proceed reducing invalid IR. Various utils used here, including CloneModule, assume the module to clone is valid and crash otherwise. Ideally, no reduction pass would create invalid IR, but some currently do. ReduceInstructions can be fixed relatively easily (D86210), but others are harder. For example, ReduceBasicBlocks may remove result in invalid PHI nodes. For now, skip the chunks. If we get to the point where all reduction passes result in valid IR, we may want to turn this into an assertion. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D86212
This commit is contained in:
parent
47182191ac
commit
4cf9e27313
@ -1,12 +1,15 @@
|
|||||||
; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
|
; 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: cat %t | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s
|
||||||
|
|
||||||
|
; We cannot change the @alias to undef, because it would result in invalid IR
|
||||||
|
; (Aliasee should be either GlobalValue or ConstantExpr).
|
||||||
|
|
||||||
; CHECK-INTERESTINGNESS: @alias =
|
; CHECK-INTERESTINGNESS: @alias =
|
||||||
; CHECK-FINAL: @alias = alias void (i32), void (i32)* undef
|
; CHECK-FINAL: @alias = alias void (i32), bitcast (void ()* @func to void (i32)*)
|
||||||
|
|
||||||
@alias = alias void (i32), void (i32)* @func
|
@alias = alias void (i32), void (i32)* @func
|
||||||
|
|
||||||
; CHECK-FINAL-NOT: @func()
|
; CHECK-FINAL: @func()
|
||||||
|
|
||||||
define void @func(i32 %arg) {
|
define void @func(i32 %arg) {
|
||||||
entry:
|
entry:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "Delta.h"
|
#include "Delta.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
|
#include "llvm/IR/Verifier.h"
|
||||||
#include "llvm/Support/ToolOutputFile.h"
|
#include "llvm/Support/ToolOutputFile.h"
|
||||||
#include "llvm/Transforms/Utils/Cloning.h"
|
#include "llvm/Transforms/Utils/Cloning.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -105,6 +106,9 @@ void llvm::runDeltaPass(
|
|||||||
errs() << "\nInput isn't interesting! Verify interesting-ness test\n";
|
errs() << "\nInput isn't interesting! Verify interesting-ness test\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(!verifyModule(*Program, &errs()) &&
|
||||||
|
"input module is broken before making changes");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Chunk> ChunksStillConsideredInteresting = {{1, Targets}};
|
std::vector<Chunk> ChunksStillConsideredInteresting = {{1, Targets}};
|
||||||
@ -135,6 +139,13 @@ void llvm::runDeltaPass(
|
|||||||
// Generate Module with only Targets inside Current Chunks
|
// Generate Module with only Targets inside Current Chunks
|
||||||
ExtractChunksFromModule(CurrentChunks, Clone.get());
|
ExtractChunksFromModule(CurrentChunks, Clone.get());
|
||||||
|
|
||||||
|
// Some reductions may result in invalid IR. Skip such reductions.
|
||||||
|
if (verifyModule(*Clone.get(), &errs())) {
|
||||||
|
errs() << " **** WARNING | reduction resulted in invalid module, "
|
||||||
|
"skipping\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
errs() << "Ignoring: ";
|
errs() << "Ignoring: ";
|
||||||
ChunkToCheckForUninterestingness.print();
|
ChunkToCheckForUninterestingness.print();
|
||||||
for (const Chunk &C : UninterestingChunks)
|
for (const Chunk &C : UninterestingChunks)
|
||||||
|
Loading…
Reference in New Issue
Block a user