Closed llvmbot closed 16 years ago
Removed.
Please just remove the testcase, thanks!
Could you please fix the testcase too? I get this on Darwin:
FAIL: /Volumes/MacOS9/gcc/llvm/test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll for llvm/llvm-bugzilla-archive#1629 Failed with signal(SIGABRT) at line 1 while running: llvm-as < /Volumes/MacOS9/gcc/llvm/test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll -o - | lli -force-interpreter Assertion failed: (0 && "Can't call cxa_guard_acquire on this platform"), function lleXcxa_guard_acquire, file ExternalFunctions.cpp, line 738. 0 lli 0x00461f29 _ZN40_GLOBAL__N_Signals.cpp_00000000_22A60A9E15PrintStackTraceEv + 45 1 lli 0x004622cf _ZN40_GLOBALN_Signals.cpp_00000000_22A60A9E13SignalHandlerEi + 323 2 libSystem.B.dylib 0x9638897b _sigtramp + 43 3 ??? 0xffffffff 0x0 + 4294967295 4 libSystem.B.dylib 0x96401782 raise + 26 5 libSystem.B.dylib 0x96410d3f abort + 73 6 libSystem.B.dylib 0x96402923 assert_rtn + 101 7 lli 0x001297c0 lle_X_rand + 0 8 lli 0x0012db20 _ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionERKSt6vectorINS_12GenericValueESaIS4_EE + 420 9 lli 0x001287e7 _ZN4llvm11Interpreter12callFunctionEPNS_8FunctionERKSt6vectorINS_12GenericValueESaIS4_EE + 317 10 lli 0x00128efa _ZN4llvm11Interpreter13visitCallSiteENS_8CallSiteE + 1276 11 lli 0x00134cf8 _ZN4llvm11Interpreter13visitCallInstERNS_8CallInstE + 42 12 lli 0x00134d12 _ZN4llvm11InstVisitorINS_11InterpreterEvE9visitCallERNS_8CallInstE + 24 13 lli 0x00135772 _ZN4llvm11InstVisitorINS_11InterpreterEvE5visitERNS_11InstructionE + 1286 14 lli 0x00129237 _ZN4llvm11Interpreter3runEv + 159 15 lli 0x0012e012 _ZN4llvm11Interpreter11runFunctionEPNS_8FunctionERKSt6vectorINS_12GenericValueESa make: *** [check-local] Error 1
It is probably not being constructed which is the problem. You may be dealing with garbage in the APInt member vars.
In lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp, GenericValue Interpreter::callExternalFunction(): Line 104: GenericValue Result = GenericValue(Fn(const_cast<FunctionType*>(F->getFunctionType()), ArgVals));
APInt Result.IntVal's BitWidth is bigger than MAX bitwidth. I don't know how can this APInt object be constructed.
Line 106: return Result;
This will incur APInt copy operation, and cause APInt assertion.
The APInt in a GenericValue is initialized with a bitwidth of 0 (purposefully), which is illegal. This is done to explicitly catch this kind of problem. What is the stack trace where this occurs?
I debugged lli, and found that the assertion was caused right after the calling of function @__cxa_guard_acquire().
Seems the lli interpreter converted the returned value of @__cxa_guard_acquire into GenericValue, and then return it (see GenericValue Interpreter::callExternalFunction())
Seems the conversion is not safe which makes the GenericValue.IntVal uninitialized if the GenericValue is not used as APInt.
Extended Description
The following piece of code causes lli to crash when -force-interpreter is set.For Jit, it's okay.
class X { unsigned v; public: X(int val) : v(val) {} };
int main() { static X a(0); return 0; }
Assertion info: lli: /developer/home2/zsth/projects/commit/llvm/lib/Support/APInt.cpp:101: llvm::APInt::APInt(const llvm::APInt&): Assertion `BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"' failed.
The .ll file : ; ModuleID = ''
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i686-pc-linux-gnu"
%struct.X = type { i32 }
@_ZGVZ4mainE1a = internal global i64 0, align 8 ; <i64*> [#uses=3]
define i32 @main() { entry: %tmp2 = load i8 bitcast (i64 @_ZGVZ4mainE1a to i8*), align 8 ; [#uses=1]
%tmp3 = icmp eq i8 %tmp2, 0 ; [#uses=1]
br i1 %tmp3, label %cond_true, label %UnifiedReturnBlock
cond_true: ; preds = %entry %tmp5 = tail call i32 @__cxa_guard_acquire( i64* @_ZGVZ4mainE1a ) ; [#uses=1]
%tmp6 = icmp eq i32 %tmp5, 0 ; [#uses=1]
br i1 %tmp6, label %UnifiedReturnBlock, label %cond_true10
cond_true10: ; preds = %cond_true tail call void @__cxa_guard_release( i64* @_ZGVZ4mainE1a ) ret i32 0
UnifiedReturnBlock: ; preds = %cond_true, %entry ret i32 0 }
declare i32 @__cxa_guard_acquire(i64*)
declare void @__cxa_guard_release(i64*)