llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Target constant materialization in fast-isel doesn't handle non-small code model reliably

Open darkbuck opened this issue 14 years ago • 2 comments

Bugzilla Link 13727
Resolution FIXED
Resolved on Oct 17, 2013 01:26
Version trunk
OS Linux
Attachments test case triggering this issue
CC @isanbard

Extended Description

the attached test case crash on 64-bit Linux (LLVM trunk r) with the following output:

$ lli -use-mcjit -O0 bug.ll lli: /home/buck/working/llvm/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:213: void llvm::RuntimeDyldELF::resolveX86_64Relocation(uint8_t*, uint64_t, uint64_t, uint32_t, int64_t): Assertion `(Type == ELF::R_X86_64_32 && (Value <= (4294967295U))) || (Type == ELF::R_X86_64_32S && ((int64_t)Value <= (2147483647) && (int64_t)Value >= (-2147483647-1)))' failed. Stack dump: 0. Program arguments: lli -use-mcjit -O0 bug.ll Aborted (core dumped)

The assertion reports an overflow of a 32-bit relative addressing even though MCJIT is designed to use large code model.

After investigation, it's turned out that target constant materialization in x86's fast-isel doesn't handle large code model reliably by generate PC-relative addressing which trigger this assertion when .rodata section is allocated faraway from code segment.

(PS: the test case is generated by copying test/ExecutionEngine/MCJIT/test-common-symbols.ll and applying the following patch, i.e. changing constant 1.0 to 1.1

$ diff -u test/ExecutionEngine/MCJIT/test-common-symbols.ll bug.ll --- test/ExecutionEngine/MCJIT/test-common-symbols.ll 2012-08-29 16:32:56.632968836 -0700 +++ bug.ll 2012-08-29 16:54:02.612934213 -0700 @@ -37,7 +37,7 @@ %arrayidx = getelementptr inbounds [10 x i32]* @​zero_arr, i32 0, i64 %idxprom store i32 40, i32* %arrayidx, align 4 %1 = load double* @​zero_double, align 8

  • %cmp = fcmp olt double %1, 1.000000e+00
  • %cmp = fcmp olt double %1, 1.100000e+00 br i1 %cmp, label %if.then, label %if.end

if.then: ; preds = %entry

)

darkbuck avatar Aug 30 '12 02:08 darkbuck

Please open a new bug for the fast-isel large code model improvement.

isanbard avatar Oct 17 '13 08:10 isanbard

Bug is fixed by r162881 but it fast-isel may need better support for Large code model.

darkbuck avatar Aug 30 '12 18:08 darkbuck