mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Replace also-emit-llvm with save-temps.
The also-emit-llvm option only supported getting the IR before optimizations. This patch replaces it with a more generic save-temps option that saves the IR both before and after optimizations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220885 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0d36b9d692
commit
25016f9d2e
@ -8,23 +8,21 @@
|
|||||||
; RUN: FileCheck --check-prefix=API %s < %T/../apifile.txt
|
; RUN: FileCheck --check-prefix=API %s < %T/../apifile.txt
|
||||||
|
|
||||||
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
|
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
|
||||||
; RUN: -m elf_x86_64 --plugin-opt=also-emit-llvm \
|
; RUN: -m elf_x86_64 --plugin-opt=save-temps \
|
||||||
; RUN: -shared %t.o -o %t3.o
|
; RUN: -shared %t.o -o %t3.o
|
||||||
; RUN: llvm-dis %t3.o.bc -o /dev/null
|
; RUN: llvm-dis %t3.o.bc -o - | FileCheck %s
|
||||||
|
; RUN: llvm-dis %t3.o.opt.bc -o - | FileCheck --check-prefix=OPT %s
|
||||||
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
|
|
||||||
; RUN: -m elf_x86_64 --plugin-opt=also-emit-llvm=%t4 \
|
|
||||||
; RUN: -shared %t.o -o %t3.o
|
|
||||||
; RUN: llvm-dis %t4 -o /dev/null
|
|
||||||
|
|
||||||
target triple = "x86_64-unknown-linux-gnu"
|
target triple = "x86_64-unknown-linux-gnu"
|
||||||
|
|
||||||
; CHECK: define internal void @f1()
|
; CHECK: define internal void @f1()
|
||||||
|
; OPT-NOT: @f1
|
||||||
define hidden void @f1() {
|
define hidden void @f1() {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: define hidden void @f2()
|
; CHECK: define hidden void @f2()
|
||||||
|
; OPT: define hidden void @f2()
|
||||||
define hidden void @f2() {
|
define hidden void @f2() {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
@ -32,23 +30,27 @@ define hidden void @f2() {
|
|||||||
@llvm.used = appending global [1 x i8*] [ i8* bitcast (void ()* @f2 to i8*)]
|
@llvm.used = appending global [1 x i8*] [ i8* bitcast (void ()* @f2 to i8*)]
|
||||||
|
|
||||||
; CHECK: define void @f3()
|
; CHECK: define void @f3()
|
||||||
|
; OPT: define void @f3()
|
||||||
define void @f3() {
|
define void @f3() {
|
||||||
call void @f4()
|
call void @f4()
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: define internal void @f4()
|
; CHECK: define internal void @f4()
|
||||||
|
; OPT-NOT: @f4
|
||||||
define linkonce_odr void @f4() {
|
define linkonce_odr void @f4() {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: define linkonce_odr void @f5()
|
; CHECK: define linkonce_odr void @f5()
|
||||||
|
; OPT: define linkonce_odr void @f5()
|
||||||
define linkonce_odr void @f5() {
|
define linkonce_odr void @f5() {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
@g5 = global void()* @f5
|
@g5 = global void()* @f5
|
||||||
|
|
||||||
; CHECK: define internal void @f6() unnamed_addr
|
; CHECK: define internal void @f6() unnamed_addr
|
||||||
|
; OPT: define internal void @f6() unnamed_addr
|
||||||
define linkonce_odr void @f6() unnamed_addr {
|
define linkonce_odr void @f6() unnamed_addr {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,9 @@ static std::vector<std::string> Cleanup;
|
|||||||
static llvm::TargetOptions TargetOpts;
|
static llvm::TargetOptions TargetOpts;
|
||||||
|
|
||||||
namespace options {
|
namespace options {
|
||||||
enum generate_bc { BC_NO, BC_ALSO, BC_ONLY };
|
enum generate_bc { BC_NO, BC_ONLY, BC_SAVE_TEMPS };
|
||||||
static bool generate_api_file = false;
|
static bool generate_api_file = false;
|
||||||
static generate_bc generate_bc_file = BC_NO;
|
static generate_bc generate_bc_file = BC_NO;
|
||||||
static std::string bc_path;
|
|
||||||
static std::string obj_path;
|
static std::string obj_path;
|
||||||
static std::string extra_library_path;
|
static std::string extra_library_path;
|
||||||
static std::string triple;
|
static std::string triple;
|
||||||
@ -111,18 +110,8 @@ namespace options {
|
|||||||
obj_path = opt.substr(strlen("obj-path="));
|
obj_path = opt.substr(strlen("obj-path="));
|
||||||
} else if (opt == "emit-llvm") {
|
} else if (opt == "emit-llvm") {
|
||||||
generate_bc_file = BC_ONLY;
|
generate_bc_file = BC_ONLY;
|
||||||
} else if (opt == "also-emit-llvm") {
|
} else if (opt == "save-temps") {
|
||||||
generate_bc_file = BC_ALSO;
|
generate_bc_file = BC_SAVE_TEMPS;
|
||||||
} else if (opt.startswith("also-emit-llvm=")) {
|
|
||||||
llvm::StringRef path = opt.substr(strlen("also-emit-llvm="));
|
|
||||||
generate_bc_file = BC_ALSO;
|
|
||||||
if (!bc_path.empty()) {
|
|
||||||
message(LDPL_WARNING, "Path to the output IL file specified twice. "
|
|
||||||
"Discarding %s",
|
|
||||||
opt_);
|
|
||||||
} else {
|
|
||||||
bc_path = path;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Save this option to pass to the code generator.
|
// Save this option to pass to the code generator.
|
||||||
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
|
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
|
||||||
@ -691,6 +680,14 @@ static void runLTOPasses(Module &M, TargetMachine &TM) {
|
|||||||
passes.run(M);
|
passes.run(M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void saveBCFile(StringRef Path, Module &M) {
|
||||||
|
std::error_code EC;
|
||||||
|
raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::F_None);
|
||||||
|
if (EC)
|
||||||
|
message(LDPL_FATAL, "Failed to write the output file.");
|
||||||
|
WriteBitcodeToFile(&M, OS);
|
||||||
|
}
|
||||||
|
|
||||||
static void codegen(Module &M) {
|
static void codegen(Module &M) {
|
||||||
const std::string &TripleStr = M.getTargetTriple();
|
const std::string &TripleStr = M.getTargetTriple();
|
||||||
Triple TheTriple(TripleStr);
|
Triple TheTriple(TripleStr);
|
||||||
@ -715,6 +712,9 @@ static void codegen(Module &M) {
|
|||||||
|
|
||||||
runLTOPasses(M, *TM);
|
runLTOPasses(M, *TM);
|
||||||
|
|
||||||
|
if (options::generate_bc_file == options::BC_SAVE_TEMPS)
|
||||||
|
saveBCFile(output_name + ".opt.bc", M);
|
||||||
|
|
||||||
PassManager CodeGenPasses;
|
PassManager CodeGenPasses;
|
||||||
CodeGenPasses.add(new DataLayoutPass());
|
CodeGenPasses.add(new DataLayoutPass());
|
||||||
|
|
||||||
@ -800,17 +800,9 @@ static ld_plugin_status allSymbolsReadHook(raw_fd_ostream *ApiFile) {
|
|||||||
std::string path;
|
std::string path;
|
||||||
if (options::generate_bc_file == options::BC_ONLY)
|
if (options::generate_bc_file == options::BC_ONLY)
|
||||||
path = output_name;
|
path = output_name;
|
||||||
else if (!options::bc_path.empty())
|
|
||||||
path = options::bc_path;
|
|
||||||
else
|
else
|
||||||
path = output_name + ".bc";
|
path = output_name + ".bc";
|
||||||
{
|
saveBCFile(path, *L.getModule());
|
||||||
std::error_code EC;
|
|
||||||
raw_fd_ostream OS(path, EC, sys::fs::OpenFlags::F_None);
|
|
||||||
if (EC)
|
|
||||||
message(LDPL_FATAL, "Failed to write the output file.");
|
|
||||||
WriteBitcodeToFile(L.getModule(), OS);
|
|
||||||
}
|
|
||||||
if (options::generate_bc_file == options::BC_ONLY)
|
if (options::generate_bc_file == options::BC_ONLY)
|
||||||
return LDPS_OK;
|
return LDPS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user