mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
The interpreter assumes that the caller of runFunction() must be lli, and
therefore the function being called must be a main() returning an int. The consequences when these assumptions are false are not good, so don't assume them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26031 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -553,7 +553,7 @@ void Interpreter::exitCalled(GenericValue GV) {
|
|||||||
|
|
||||||
/// Pop the last stack frame off of ECStack and then copy the result
|
/// Pop the last stack frame off of ECStack and then copy the result
|
||||||
/// back into the result variable if we are not returning void. The
|
/// back into the result variable if we are not returning void. The
|
||||||
/// result variable may be the ExitCode, or the Value of the calling
|
/// result variable may be the ExitValue, or the Value of the calling
|
||||||
/// CallInst if there was a previous stack frame. This method may
|
/// CallInst if there was a previous stack frame. This method may
|
||||||
/// invalidate any ECStack iterators you have. This method also takes
|
/// invalidate any ECStack iterators you have. This method also takes
|
||||||
/// care of switching to the normal destination BB, if we are returning
|
/// care of switching to the normal destination BB, if we are returning
|
||||||
@@ -566,9 +566,9 @@ void Interpreter::popStackAndReturnValueToCaller (const Type *RetTy,
|
|||||||
|
|
||||||
if (ECStack.empty()) { // Finished main. Put result into exit code...
|
if (ECStack.empty()) { // Finished main. Put result into exit code...
|
||||||
if (RetTy && RetTy->isIntegral()) { // Nonvoid return type?
|
if (RetTy && RetTy->isIntegral()) { // Nonvoid return type?
|
||||||
ExitCode = Result.IntVal; // Capture the exit code of the program
|
ExitValue = Result; // Capture the exit value of the program
|
||||||
} else {
|
} else {
|
||||||
ExitCode = 0;
|
memset(&ExitValue, 0, sizeof(ExitValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If we have a previous stack frame, and we have a previous call,
|
// If we have a previous stack frame, and we have a previous call,
|
||||||
|
@@ -50,10 +50,11 @@ ExecutionEngine *Interpreter::create(Module *M, IntrinsicLowering *IL) {
|
|||||||
//
|
//
|
||||||
Interpreter::Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
|
Interpreter::Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
|
||||||
IntrinsicLowering *il)
|
IntrinsicLowering *il)
|
||||||
: ExecutionEngine(M), ExitCode(0),
|
: ExecutionEngine(M),
|
||||||
TD("lli", isLittleEndian, isLongPointer ? 8 : 4, isLongPointer ? 8 : 4,
|
TD("lli", isLittleEndian, isLongPointer ? 8 : 4, isLongPointer ? 8 : 4,
|
||||||
isLongPointer ? 8 : 4), IL(il) {
|
isLongPointer ? 8 : 4), IL(il) {
|
||||||
|
|
||||||
|
memset(&ExitValue, 0, sizeof(ExitValue));
|
||||||
setTargetData(TD);
|
setTargetData(TD);
|
||||||
// Initialize the "backend"
|
// Initialize the "backend"
|
||||||
initializeExecutionEngine();
|
initializeExecutionEngine();
|
||||||
@@ -100,8 +101,6 @@ Interpreter::runFunction(Function *F,
|
|||||||
// Start executing the function.
|
// Start executing the function.
|
||||||
run();
|
run();
|
||||||
|
|
||||||
GenericValue rv;
|
return ExitValue;
|
||||||
rv.IntVal = ExitCode;
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ struct ExecutionContext {
|
|||||||
// Interpreter - This class represents the entirety of the interpreter.
|
// Interpreter - This class represents the entirety of the interpreter.
|
||||||
//
|
//
|
||||||
class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
|
class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
|
||||||
int ExitCode; // The exit code to be returned by the lli util
|
GenericValue ExitValue; // The return value of the called function
|
||||||
TargetData TD;
|
TargetData TD;
|
||||||
IntrinsicLowering *IL;
|
IntrinsicLowering *IL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user