New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 34323 - DW_OP_bit_piece refactoring broke handling of Q0 and friends on SPARC64
Summary: DW_OP_bit_piece refactoring broke handling of Q0 and friends on SPARC64
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Adrian Prantl
URL:
Keywords:
: 35344 (view as bug list)
Depends on:
Blocks: 33849 release-5.0.1
  Show dependency tree
 
Reported: 2017-08-25 09:30 PDT by Jörg Sonnenberger
Modified: 2017-12-05 14:37 PST (History)
4 users (show)

See Also:
Fixed By Commit(s): r311951 r312038 r314567


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg Sonnenberger 2017-08-25 09:30:45 PDT
Compile

  long double a; fn1() { long double _Complex b = a = b * 1.0L; }

with -O2 -g -target sparc64 and watch it assert due to oversized debug fragments. This is fallout from r289266.
Comment 1 Adrian Prantl 2017-08-25 09:33:12 PDT
Assertion failed: (FragmentOffset >= OffsetInBits && "overlapping or duplicate fragments"), function addFragmentOffset, file /Volumes/Fusion/Data/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp, line 405.

Reproduced.
Comment 2 Adrian Prantl 2017-08-28 13:54:05 PDT
define signext i32 @fn1() local_unnamed_addr #0 !dbg !11 {
entry:
  tail call void @llvm.dbg.declare(metadata { fp128, fp128 }* undef, metadata !16, metadata !DIExpression()), !dbg !18
  store fp128 fmul (fp128 undef, fp128 0xL00000000000000003FFF000000000000), fp128* @a, align 16, !dbg !19, !tbaa !20
  tail call void @llvm.dbg.value(metadata fp128 fmul (fp128 undef, fp128 0xL00000000000000003FFF000000000000), metadata !16, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 128)), !dbg !18
  tail call void @llvm.dbg.value(metadata fp128 0xL00000000000000000000000000000000, metadata !16, metadata !DIExpression(DW_OP_LLVM_fragment, 128, 128)), !dbg !18
  ret i32 undef, !dbg !24
}
Comment 3 Adrian Prantl 2017-08-28 14:16:56 PDT
looks like DwarfExpression::addMachineReg is misbehaving.
Comment 4 Jörg Sonnenberger 2017-08-28 14:38:53 PDT
Yes, I think it gets confused by Q0 being aliased to two 64bit registers, which in turn have two 32bit register aliases each.
Comment 5 Adrian Prantl 2017-08-28 16:08:16 PDT
Should be fixed in r311951.
Comment 6 Jörg Sonnenberger 2017-08-29 05:16:06 PDT
Confirmed. Should be merged into 5.0 or 5.0.1.
Comment 7 Adrian Prantl 2017-08-29 07:41:16 PDT
That's a safe change to pick up.
Comment 8 Hans Wennborg 2017-08-29 10:23:31 PDT
(In reply to Adrian Prantl from comment #7)
> That's a safe change to pick up.

When I merge r311951 to the branch, the test asserts as shown below.

Since we're so late in the process (and if the original failure started with r289266 it's not technically a regression from 4.0.0), I don't think we shuold attempt to merge it for 5.0.0.



[70/71] Running the LLVM regression tests
FAIL: LLVM :: DebugInfo/Sparc/subreg.ll (13449 of 21471)
******************** TEST 'LLVM :: DebugInfo/Sparc/subreg.ll' FAILED ********************
Script:
--
/work/llvm-5.0/build.release/./bin/llc -filetype=obj -O0 < /usr/local/google/work/llvm-5.0/llvm.src/test/DebugInfo/Sparc/subreg.ll -mtriple sparc64-unknown-linux-gnu | /work/llvm-5.0/build.release/./bin/llvm-dwarfdump - | /work/llvm-5.0/build.release/./bin/FileCheck /usr/local/google/work/llvm-5.0/llvm.src/test/DebugInfo/Sparc/subreg.ll
--
Exit Code: 2

Command Output (stderr):
--
Intrinsic has incorrect argument type!
void (metadata, metadata, metadata)* @llvm.dbg.value
llc: /work/llvm-5.0/llvm.src/include/llvm/IR/Instructions.h:1572: llvm::Value* llvm::CallInst::getArgOperand(unsigned int) const: Assertion `i < getNumArgOperands() && "Out of bounds!"' failed.
#0 0x0000000001d6122a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/work/llvm-5.0/build.release/./bin/llc+0x1d6122a)
#1 0x0000000001d5f2de llvm::sys::RunSignalHandlers() (/work/llvm-5.0/build.release/./bin/llc+0x1d5f2de)
#2 0x0000000001d5f442 SignalHandler(int) (/work/llvm-5.0/build.release/./bin/llc+0x1d5f442)
#3 0x00007fc498303330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007fc4970f3c37 gsignal /build/eglibc-SvCtMH/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fc4970f7028 abort /build/eglibc-SvCtMH/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fc4970ecbf6 __assert_fail_base /build/eglibc-SvCtMH/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fc4970ecca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000006c743e llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getOperandBundleAt(unsigned int) const [clone .part.1004] (/work/llvm-5.0/build.release/./bin/llc+0x6c743e)
#9 0x00000000018c5121 llvm::DbgValueInst::getRawExpression() const (/work/llvm-5.0/build.release/./bin/llc+0x18c5121)
#10 0x00000000018d4db3 (anonymous namespace)::Verifier::visitInstruction(llvm::Instruction&) (/work/llvm-5.0/build.release/./bin/llc+0x18d4db3)
#11 0x00000000018d83a0 (anonymous namespace)::Verifier::verifyCallSite(llvm::CallSite) (/work/llvm-5.0/build.release/./bin/llc+0x18d83a0)
#12 0x00000000018da9f0 (anonymous namespace)::Verifier::visitCallInst(llvm::CallInst&) (/work/llvm-5.0/build.release/./bin/llc+0x18da9f0)
#13 0x00000000018dd070 (anonymous namespace)::Verifier::verify(llvm::Function const&) (/work/llvm-5.0/build.release/./bin/llc+0x18dd070)
#14 0x00000000018dde44 llvm::verifyModule(llvm::Module const&, llvm::raw_ostream*, bool*) (/work/llvm-5.0/build.release/./bin/llc+0x18dde44)
#15 0x000000000077a5b0 compileModule(char**, llvm::LLVMContext&) (/work/llvm-5.0/build.release/./bin/llc+0x77a5b0)
#16 0x000000000071649c main (/work/llvm-5.0/build.release/./bin/llc+0x71649c)
#17 0x00007fc4970def45 __libc_start_main /build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:321:0
#18 0x000000000076faaa _start (/work/llvm-5.0/build.release/./bin/llc+0x76faaa)
Stack dump:
0.	Program arguments: /work/llvm-5.0/build.release/./bin/llc -filetype=obj -O0 -mtriple sparc64-unknown-linux-gnu 
-: The file was not recognized as a valid object file
FileCheck error: '-' is empty.
FileCheck command line:  /work/llvm-5.0/build.release/./bin/FileCheck /usr/local/google/work/llvm-5.0/llvm.src/test/DebugInfo/Sparc/subreg.ll

--
Comment 9 Adrian Prantl 2017-08-29 10:27:04 PDT
Looks like the IR in the test is too new for the 5.0 branch.
Jörg, how important is this fix for you? Do you want to try and backport the test to 5.0?
Comment 10 Jörg Sonnenberger 2017-08-29 14:18:24 PDT
I've adjusted the test case in 312038.
Comment 11 Brad Smith 2017-12-02 14:53:56 PST
*** Bug 35344 has been marked as a duplicate of this bug. ***