mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Fix the interpreter to not crash due to zeroext/signext
llvm-svn: 86428
This commit is contained in:
parent
c41ee3a43d
commit
21dd3f31b0
@ -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
|
||||
|
19
test/ExecutionEngine/interpreter-ext.ll
Normal file
19
test/ExecutionEngine/interpreter-ext.ll
Normal file
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user