From dbf6f518e9dd68f87814a6f989399f2e40ea9f86 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 8 Nov 2009 00:45:29 +0000 Subject: [PATCH] Fix the interpreter to not crash due to zeroext/signext git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86428 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/Interpreter/Execution.cpp | 10 ---------- test/ExecutionEngine/interpreter-ext.ll | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 test/ExecutionEngine/interpreter-ext.ll diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 01bd2c7f899..b59cfd162f9 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -882,16 +882,6 @@ void Interpreter::visitCallSite(CallSite CS) { e = SF.Caller.arg_end(); i != e; ++i, ++pNum) { Value *V = *i; ArgVals.push_back(getOperandValue(V, SF)); - // Promote all integral types whose size is < sizeof(i32) into i32. - // We do this by zero or sign extending the value as appropriate - // according to the parameter attributes - const Type *Ty = V->getType(); - if (Ty->isInteger() && (ArgVals.back().IntVal.getBitWidth() < 32)) { - if (CS.paramHasAttr(pNum, Attribute::ZExt)) - ArgVals.back().IntVal = ArgVals.back().IntVal.zext(32); - else if (CS.paramHasAttr(pNum, Attribute::SExt)) - ArgVals.back().IntVal = ArgVals.back().IntVal.sext(32); - } } // To handle indirect calls, we must get the pointer value from the argument diff --git a/test/ExecutionEngine/interpreter-ext.ll b/test/ExecutionEngine/interpreter-ext.ll new file mode 100644 index 00000000000..4aef45a0764 --- /dev/null +++ b/test/ExecutionEngine/interpreter-ext.ll @@ -0,0 +1,19 @@ +; RUN: lli -force-interpreter +; Extending a value due to zeroext/signext will leave it the wrong size +; causing problems later, such as a crash if you try to extend it again. + +define void @zero(i8 zeroext %foo) { + zext i8 %foo to i32 + ret void +} + +define void @sign(i8 signext %foo) { + sext i8 %foo to i32 + ret void +} + +define i32 @main() { + call void @zero(i8 0) + call void @sign(i8 0) + ret i32 0 +} -- 2.34.1