forked from OSchip/llvm-project
[llvm-reduce] Remove unwanted module inline asm
We can clear line by line, but that's likely not very important. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D99921
This commit is contained in:
parent
04b3c8c52c
commit
9c8b28a69b
|
@ -0,0 +1,11 @@
|
|||
; RUN: llvm-reduce --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
|
||||
|
||||
; CHECK-FINAL-NOT: module asm
|
||||
; CHECK-FINAL: declare void @g
|
||||
|
||||
module asm "foo"
|
||||
|
||||
declare void @g()
|
|
@ -25,6 +25,7 @@ add_llvm_tool(llvm-reduce
|
|||
deltas/ReduceGlobalVars.cpp
|
||||
deltas/ReduceInstructions.cpp
|
||||
deltas/ReduceMetadata.cpp
|
||||
deltas/ReduceModuleInlineAsm.cpp
|
||||
deltas/ReduceOperandBundles.cpp
|
||||
deltas/ReduceSpecialGlobals.cpp
|
||||
llvm-reduce.cpp
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "deltas/ReduceGlobalVars.h"
|
||||
#include "deltas/ReduceInstructions.h"
|
||||
#include "deltas/ReduceMetadata.h"
|
||||
#include "deltas/ReduceModuleInlineAsm.h"
|
||||
#include "deltas/ReduceOperandBundles.h"
|
||||
#include "deltas/ReduceSpecialGlobals.h"
|
||||
|
||||
|
@ -45,6 +46,7 @@ void runDeltaPasses(TestRunner &Tester) {
|
|||
reduceInstructionsDeltaPass(Tester);
|
||||
reduceOperandBundesDeltaPass(Tester);
|
||||
reduceAttributesDeltaPass(Tester);
|
||||
reduceModuleInlineAsmDeltaPass(Tester);
|
||||
// TODO: Implement the remaining Delta Passes
|
||||
}
|
||||
} // namespace llvm
|
||||
} // namespace llvm
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
//===- ReduceModuleInlineAsm.cpp ------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements a function which calls the Generic Delta pass to reduce
|
||||
// module inline asm.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "ReduceModuleInlineAsm.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/GlobalValue.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static void clearModuleInlineAsm(std::vector<Chunk> ChunksToKeep,
|
||||
Module *Program) {
|
||||
Oracle O(ChunksToKeep);
|
||||
|
||||
// TODO: clear line by line rather than all at once
|
||||
if (!O.shouldKeep())
|
||||
Program->setModuleInlineAsm("");
|
||||
}
|
||||
|
||||
void llvm::reduceModuleInlineAsmDeltaPass(TestRunner &Test) {
|
||||
outs() << "*** Reducing Module Inline Asm...\n";
|
||||
runDeltaPass(Test, 1, clearModuleInlineAsm);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
//===- ReduceModuleInlineAsm.h --------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVM_REDUCE_DELTAS_REDUCE_MODULEINLINEASM_H
|
||||
#define LLVM_TOOLS_LLVM_REDUCE_DELTAS_REDUCE_MODULEINLINEASM_H
|
||||
|
||||
#include "Delta.h"
|
||||
|
||||
namespace llvm {
|
||||
void reduceModuleInlineAsmDeltaPass(TestRunner &Test);
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
|
@ -23,6 +23,7 @@ executable("llvm-reduce") {
|
|||
"deltas/ReduceGlobalVars.cpp",
|
||||
"deltas/ReduceInstructions.cpp",
|
||||
"deltas/ReduceMetadata.cpp",
|
||||
"deltas/ReduceModuleInlineAsm.cpp",
|
||||
"deltas/ReduceOperandBundles.cpp",
|
||||
"deltas/ReduceSpecialGlobals.cpp",
|
||||
"llvm-reduce.cpp",
|
||||
|
|
Loading…
Reference in New Issue