diff options
Diffstat (limited to 'contrib/llvm/lib/ExecutionEngine/Interpreter')
4 files changed, 24 insertions, 30 deletions
diff --git a/contrib/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/contrib/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp index 1eb4f7d..923f6e7 100644 --- a/contrib/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/contrib/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -999,7 +999,7 @@ GenericValue Interpreter::executeGEPOperation(Value *Ptr, gep_type_iterator I, uint64_t Total = 0; for (; I != E; ++I) { - if (StructType *STy = dyn_cast<StructType>(*I)) { + if (StructType *STy = I.getStructTypeOrNull()) { const StructLayout *SLO = getDataLayout().getStructLayout(STy); const ConstantInt *CPU = cast<ConstantInt>(I.getOperand()); @@ -1007,7 +1007,6 @@ GenericValue Interpreter::executeGEPOperation(Value *Ptr, gep_type_iterator I, Total += SLO->getElementOffset(Index); } else { - SequentialType *ST = cast<SequentialType>(*I); // Get the index number for the array... which must be long type... GenericValue IdxGV = getOperandValue(I.getOperand(), SF); @@ -1020,7 +1019,7 @@ GenericValue Interpreter::executeGEPOperation(Value *Ptr, gep_type_iterator I, assert(BitWidth == 64 && "Invalid index type for getelementptr"); Idx = (int64_t)IdxGV.IntVal.getZExtValue(); } - Total += getDataLayout().getTypeAllocSize(ST->getElementType()) * Idx; + Total += getDataLayout().getTypeAllocSize(I.getIndexedType()) * Idx; } } diff --git a/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 441f0eb..ee75bee 100644 --- a/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -20,20 +20,31 @@ //===----------------------------------------------------------------------===// #include "Interpreter.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Config/config.h" // Detect libffi +#include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" -#include "llvm/IR/Module.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/Type.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Mutex.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/UniqueLock.h" +#include <cassert> #include <cmath> #include <csignal> +#include <cstdint> #include <cstdio> #include <cstring> #include <map> +#include <string> +#include <utility> +#include <vector> #ifdef HAVE_FFI_CALL #ifdef HAVE_FFI_H @@ -290,7 +301,6 @@ GenericValue Interpreter::callExternalFunction(Function *F, return GenericValue(); } - //===----------------------------------------------------------------------===// // Functions "exported" to the running application... // @@ -331,7 +341,7 @@ static GenericValue lle_X_sprintf(FunctionType *FT, // close enough for now. GenericValue GV; GV.IntVal = APInt(32, strlen(FmtStr)); - while (1) { + while (true) { switch (*FmtStr) { case 0: return GV; // Null terminator... default: // Normal nonspecial character diff --git a/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp index bc7da2e..9818adf 100644 --- a/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -35,9 +35,13 @@ extern "C" void LLVMLinkInInterpreter() { } ExecutionEngine *Interpreter::create(std::unique_ptr<Module> M, std::string *ErrStr) { // Tell this Module to materialize everything and release the GVMaterializer. - if (std::error_code EC = M->materializeAll()) { + if (Error Err = M->materializeAll()) { + std::string Msg; + handleAllErrors(std::move(Err), [&](ErrorInfoBase &EIB) { + Msg = EIB.message(); + }); if (ErrStr) - *ErrStr = EC.message(); + *ErrStr = Msg; // We got an error, just return 0 return nullptr; } diff --git a/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h b/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h index 2e5a867..5c16448 100644 --- a/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/contrib/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -41,12 +41,9 @@ class AllocaHolder { public: AllocaHolder() {} - // Make this type move-only. Define explicit move special members for MSVC. - AllocaHolder(AllocaHolder &&RHS) : Allocations(std::move(RHS.Allocations)) {} - AllocaHolder &operator=(AllocaHolder &&RHS) { - Allocations = std::move(RHS.Allocations); - return *this; - } + // Make this type move-only. + AllocaHolder(AllocaHolder &&) = default; + AllocaHolder &operator=(AllocaHolder &&RHS) = default; ~AllocaHolder() { for (void *Allocation : Allocations) @@ -72,22 +69,6 @@ struct ExecutionContext { AllocaHolder Allocas; // Track memory allocated by alloca ExecutionContext() : CurFunction(nullptr), CurBB(nullptr), CurInst(nullptr) {} - - ExecutionContext(ExecutionContext &&O) - : CurFunction(O.CurFunction), CurBB(O.CurBB), CurInst(O.CurInst), - Caller(O.Caller), Values(std::move(O.Values)), - VarArgs(std::move(O.VarArgs)), Allocas(std::move(O.Allocas)) {} - - ExecutionContext &operator=(ExecutionContext &&O) { - CurFunction = O.CurFunction; - CurBB = O.CurBB; - CurInst = O.CurInst; - Caller = O.Caller; - Values = std::move(O.Values); - VarArgs = std::move(O.VarArgs); - Allocas = std::move(O.Allocas); - return *this; - } }; // Interpreter - This class represents the entirety of the interpreter. |