Skip to content

Commit

Permalink
Just use the Module unique_ptr object directly in many places instead…
Browse files Browse the repository at this point in the history
… of separate pointer that's kept in sync with it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224004 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Dec 11, 2014
1 parent 11043f9 commit 4fca0dd
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tools/llc/llc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
// Load the module to be compiled...
SMDiagnostic Err;
std::unique_ptr<Module> M;
Module *mod = nullptr;
Triple TheTriple;

bool SkipModule = MCPU == "help" ||
Expand All @@ -220,16 +219,15 @@ static int compileModule(char **argv, LLVMContext &Context) {
// If user just wants to list available options, skip module loading
if (!SkipModule) {
M = parseIRFile(InputFilename, Err, Context);
mod = M.get();
if (mod == nullptr) {
if (!M) {
Err.print(argv[0], errs());
return 1;
}

// If we are supposed to override the target triple, do so now.
if (!TargetTriple.empty())
mod->setTargetTriple(Triple::normalize(TargetTriple));
TheTriple = Triple(mod->getTargetTriple());
M->setTargetTriple(Triple::normalize(TargetTriple));
TheTriple = Triple(M->getTargetTriple());
} else {
TheTriple = Triple(Triple::normalize(TargetTriple));
}
Expand Down Expand Up @@ -284,7 +282,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
if (SkipModule)
return 0;

assert(mod && "Should have exited if we didn't have a module!");
assert(M && "Should have exited if we didn't have a module!");
TargetMachine &Target = *target.get();

if (GenerateSoftFloatCalls)
Expand All @@ -306,7 +304,7 @@ static int compileModule(char **argv, LLVMContext &Context) {

// Add the target data from the target machine, if it exists, or the module.
if (const DataLayout *DL = Target.getSubtargetImpl()->getDataLayout())
mod->setDataLayout(DL);
M->setDataLayout(DL);
PM.add(new DataLayoutPass());

if (RelaxAll.getNumOccurrences() > 0 &&
Expand Down Expand Up @@ -348,7 +346,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
// Before executing passes, print the final values of the LLVM options.
cl::PrintOptionValues();

PM.run(*mod);
PM.run(*M);
}

// Declare success.
Expand Down

0 comments on commit 4fca0dd

Please sign in to comment.