{"action":"created","issue":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/1598","repository_url":"https://api.github.com/repos/ldc-developers/ldc","labels_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1598/labels{/name}","comments_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1598/comments","events_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1598/events","html_url":"https://github.com/ldc-developers/ldc/pull/1598","id":163431514,"number":1598,"title":"Debug info generation fixes for LLVM >= 3.8","user":{"login":"Syniurge","id":4272771,"avatar_url":"https://avatars.githubusercontent.com/u/4272771?v=3","gravatar_id":"","url":"https://api.github.com/users/Syniurge","html_url":"https://github.com/Syniurge","followers_url":"https://api.github.com/users/Syniurge/followers","following_url":"https://api.github.com/users/Syniurge/following{/other_user}","gists_url":"https://api.github.com/users/Syniurge/gists{/gist_id}","starred_url":"https://api.github.com/users/Syniurge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Syniurge/subscriptions","organizations_url":"https://api.github.com/users/Syniurge/orgs","repos_url":"https://api.github.com/users/Syniurge/repos","events_url":"https://api.github.com/users/Syniurge/events{/privacy}","received_events_url":"https://api.github.com/users/Syniurge/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2016-07-01T16:34:00Z","updated_at":"2016-07-27T15:07:56Z","closed_at":"2016-07-18T13:12:30Z","pull_request":{"url":"https://api.github.com/repos/ldc-developers/ldc/pulls/1598","html_url":"https://github.com/ldc-developers/ldc/pull/1598","diff_url":"https://github.com/ldc-developers/ldc/pull/1598.diff","patch_url":"https://github.com/ldc-developers/ldc/pull/1598.patch"},"body":"This is PR #1597 recreated for `master`.\r\n*** * * * * * * ***\r\n\r\nDebug info generation is broken when LDC is built against LLVM 3.8:\r\n\r\n```\r\n(gdb) break test.d:20  <= works\r\n(gdb) run\r\n(gdb) bt  <= no location info\r\n#0  0x0000000000402f49 in D main ()\r\n(gdb) info locals\r\nNo symbol table info available.\r\n```\r\n\r\nA `llvm::Function::setSubprogram()` call to assign the descriptor to the function was missing. Restoring it resulted in new compilation errors while building druntime and phobos, which were due to function parameters accessed from a nested function being declared as function parameters (they're not, they're fields of `nest_arg`) instead of \"auto variables\", and setting two variables for the same parameter index was triggering an assert:\r\n\r\n```\r\nldc2: DwarfDebug.h:125: void llvm::DbgVariable::addMMIEntry(const llvm::DbgVariable&): Assertion `V.Var == Var && \"conflicting variable\"' failed.\r\n```\r\n\r\nThere's also a fix not specific to LLVM 3.8 for closure variables not getting declared correctly in the parent function, and a small IR test case checking that debug info gets emitted properly for functions and nested variables."},"comment":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/comments/235615612","html_url":"https://github.com/ldc-developers/ldc/pull/1598#issuecomment-235615612","issue_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1598","id":235615612,"user":{"login":"JohanEngelen","id":10983051,"avatar_url":"https://avatars.githubusercontent.com/u/10983051?v=3","gravatar_id":"","url":"https://api.github.com/users/JohanEngelen","html_url":"https://github.com/JohanEngelen","followers_url":"https://api.github.com/users/JohanEngelen/followers","following_url":"https://api.github.com/users/JohanEngelen/following{/other_user}","gists_url":"https://api.github.com/users/JohanEngelen/gists{/gist_id}","starred_url":"https://api.github.com/users/JohanEngelen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohanEngelen/subscriptions","organizations_url":"https://api.github.com/users/JohanEngelen/orgs","repos_url":"https://api.github.com/users/JohanEngelen/repos","events_url":"https://api.github.com/users/JohanEngelen/events{/privacy}","received_events_url":"https://api.github.com/users/JohanEngelen/received_events","type":"User","site_admin":false},"created_at":"2016-07-27T15:07:56Z","updated_at":"2016-07-27T15:07:56Z","body":"@kinke @klickverbot @Syniurge By now, I believe we have found an LLVM bug. And we have to find a workaround. I think I've found the best workaround. The clue was in an earlier discussion: https://github.com/ldc-developers/ldc/pull/1598#discussion-diff-69776163 . The original code was wrong (GEP+offset), it was changed to alloca+offset but hits an LLVM bug, and now I've found something that does not bug:  GEP + _deref_. In LLVM source I found that an implicit deref is added on AllocA instructions passed to llvm.dbg.declare; I can't find where anymore... I don't know if a DW_OP_offset is applied before or after that implicit deref. With a GEP + deref, compilation no longer fails, and things look good inside LLDB.\r\nWe now have 3 \"fixes\" for the bug:\r\n1. https://github.com/ldc-developers/ldc/pull/1644\r\n2. https://github.com/ldc-developers/ldc/compare/master...JohanEngelen:alternativedebugfix\r\n3. https://github.com/ldc-developers/ldc/pull/1646\r\n\r\n__Number 3 is the correct fix (I think).__\r\n\r\n"}}
{"actor":{"display_login":"JohanEngelen"}}