mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-13 08:35:46 +00:00
Remove temp. files in the end.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53930 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ce8fdf105c
commit
8502112419
@ -14,7 +14,6 @@
|
||||
|
||||
#include "LTOBugPoint.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ModuleProvider.h"
|
||||
#include "llvm/CodeGen/FileWriters.h"
|
||||
#include "llvm/Target/SubtargetFeature.h"
|
||||
@ -26,7 +25,6 @@
|
||||
#include "llvm/Support/SystemUtils.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/System/Path.h"
|
||||
#include "llvm/Config/config.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@ -46,6 +44,12 @@ LTOBugPoint::LTOBugPoint(std::istream &args, std::istream &ins) {
|
||||
std::string inFile;
|
||||
while(getline(ins, inFile))
|
||||
LinkerInputFiles.push_back(inFile);
|
||||
|
||||
TempDir = sys::Path::GetTemporaryDirectory();
|
||||
}
|
||||
|
||||
LTOBugPoint::~LTOBugPoint() {
|
||||
TempDir.eraseFromDisk(true);
|
||||
}
|
||||
|
||||
/// findTroubleMakers - Find minimum set of input files that causes error
|
||||
@ -178,21 +182,27 @@ bool LTOBugPoint::getNativeObjectFile(std::string &FileName) {
|
||||
M.reset(ParseBitcodeFile(Buffer, &ErrMsg));
|
||||
std::string TargetTriple = M->getTargetTriple();
|
||||
|
||||
sys::Path AsmFile(sys::Path::GetTemporaryDirectory());
|
||||
sys::Path AsmFile(TempDir);
|
||||
if(AsmFile.createTemporaryFileOnDisk(false, &ErrMsg))
|
||||
return false;
|
||||
|
||||
if (assembleBitcode(M.get(), AsmFile.c_str()) == false)
|
||||
if (assembleBitcode(M.get(), AsmFile.c_str()) == false) {
|
||||
AsmFile.eraseFromDisk();
|
||||
return false;
|
||||
}
|
||||
|
||||
sys::Path NativeFile(sys::Path::GetTemporaryDirectory());
|
||||
if(NativeFile.createTemporaryFileOnDisk(false, &ErrMsg))
|
||||
sys::Path NativeFile(TempDir);
|
||||
if(NativeFile.createTemporaryFileOnDisk(false, &ErrMsg)) {
|
||||
AsmFile.eraseFromDisk();
|
||||
return false;
|
||||
}
|
||||
|
||||
// find compiler driver
|
||||
const sys::Path gcc = sys::Program::FindProgramByName("gcc");
|
||||
if ( gcc.isEmpty() ) {
|
||||
ErrMsg = "can't locate gcc";
|
||||
AsmFile.eraseFromDisk();
|
||||
NativeFile.eraseFromDisk();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -227,8 +237,12 @@ bool LTOBugPoint::getNativeObjectFile(std::string &FileName) {
|
||||
|
||||
// invoke assembler
|
||||
if (sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 0, 0, &ErrMsg)) {
|
||||
ErrMsg = "error in assembly";
|
||||
ErrMsg = "error in assembly";
|
||||
AsmFile.eraseFromDisk();
|
||||
NativeFile.eraseFromDisk();
|
||||
return false;
|
||||
}
|
||||
|
||||
AsmFile.eraseFromDisk();
|
||||
return true;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/System/Path.h"
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
@ -21,6 +22,7 @@ class LTOBugPoint {
|
||||
public:
|
||||
|
||||
LTOBugPoint(std::istream &args, std::istream &ins);
|
||||
~LTOBugPoint();
|
||||
|
||||
/// findTroubleMakers - Find minimum set of input files that causes error
|
||||
/// identified by the script.
|
||||
@ -50,6 +52,7 @@ class LTOBugPoint {
|
||||
std::string getFeatureString(const char *TargetTriple);
|
||||
std::string ErrMsg;
|
||||
|
||||
llvm::sys::Path TempDir;
|
||||
private:
|
||||
/// assembleBitcode - Generate assembly code from the module. Return false
|
||||
/// in case of an error.
|
||||
|
Loading…
x
Reference in New Issue
Block a user