forked from OSchip/llvm-project
[LTO] Add a function `LTOCodeGenerator::getMergedModule`
One of the uses of `LTOCodeGenerator` is to take it as a middle+back end. Sometimes it is very helpful to access, especially get information from the optimized module. If the information can be changed in optimization, it cannot be get before the module is added to `LTOCodeGenerator`. This patch adds a function `LTOCodeGenerator::getMergedModule` to access the `MergedModule`. Reviewed By: steven_wu Differential Revision: https://reviews.llvm.org/D114201
This commit is contained in:
parent
bb56c2b366
commit
75a5eaf7c6
|
@ -193,6 +193,8 @@ struct LTOCodeGenerator {
|
||||||
void resetMergedModule() { MergedModule.reset(); }
|
void resetMergedModule() { MergedModule.reset(); }
|
||||||
void DiagnosticHandler(const DiagnosticInfo &DI);
|
void DiagnosticHandler(const DiagnosticInfo &DI);
|
||||||
|
|
||||||
|
Module &getMergedModule() { return *MergedModule; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Verify the merged module on first call.
|
/// Verify the merged module on first call.
|
||||||
///
|
///
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
; RUN: llvm-as < %s > %t1
|
||||||
|
; RUN: llvm-lto --dump-linked-module %t1 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
; CHEKCK: target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
|
|
||||||
|
; CHECK: define void @f() {
|
||||||
|
define void @f() {
|
||||||
|
; CHECK-NEXT: entry:
|
||||||
|
entry:
|
||||||
|
; CHECK-NEXT: ret void
|
||||||
|
ret void
|
||||||
|
; CHECK-NEXT: }
|
||||||
|
}
|
|
@ -197,6 +197,11 @@ static cl::opt<bool>
|
||||||
cl::desc("Write merged LTO module to file before CodeGen"),
|
cl::desc("Write merged LTO module to file before CodeGen"),
|
||||||
cl::cat(LTOCategory));
|
cl::cat(LTOCategory));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
DumpLinkedModule("dump-linked-module", cl::init(false),
|
||||||
|
cl::desc("Dump linked LTO module before optimize"),
|
||||||
|
cl::cat(LTOCategory));
|
||||||
|
|
||||||
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
|
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
|
||||||
cl::desc("<input bitcode files>"),
|
cl::desc("<input bitcode files>"),
|
||||||
cl::cat(LTOCategory));
|
cl::cat(LTOCategory));
|
||||||
|
@ -1115,6 +1120,14 @@ int main(int argc, char **argv) {
|
||||||
error("error compiling the code");
|
error("error compiling the code");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (DumpLinkedModule) {
|
||||||
|
if (SaveLinkedModuleFile)
|
||||||
|
error(": -dump-linked-module must be used without -dump-linked-module");
|
||||||
|
|
||||||
|
Module &M = CodeGen.getMergedModule();
|
||||||
|
M.dump();
|
||||||
|
}
|
||||||
|
|
||||||
if (Parallelism != 1)
|
if (Parallelism != 1)
|
||||||
error("-j must be specified together with -o");
|
error("-j must be specified together with -o");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue