-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assertion failed: (LIsBuiltins && RIsBuiltins && "Non-built-in locations must be rooted in the main file"), function isBeforeInTranslationUnit #22950
Comments
assigned to @DougGregor |
Additional note: removing the #pragma makes the assertion disappear! |
Backtrace (didn't have debug symbols on this build, so will have to do with just function names): #0 0x2ae3a50b in thr_kill () from /lib/libc.so.7 |
Actually, the assembly itself is rather misleading, it does not have anything to do with ARM or the target CPU whatsoever. It is some unexpected case in the diagnostics engine, since this also triggers it:
E.g., just the fact that any warning is triggered for a top-level asm construct causes the assertion. The key word is "top-level", since obviously this does not happen when the asm construct is within a function. |
This happens because the LHS is "" which is a string that is created in llvm MC, the RHS is "name_of_the_file.c". Then the LOffs is {first = {ID = 3}, second = 1} while the ROffs is {first = {ID = 1}, second = 14}. Ie. the method thinks those two are from different files. I dont know if thats expected (the buffer is independent of the file but there seems to be some translation in clang::BackendConsumer::InlineAsmDiagHandler2()) or not. In case this is expected there's some code to handle (I think) similar situation with "" which we handle specially. In either case, this patch (probably wrong) makes clang not crash on this and emit reasonable error: Index: ../tools/clang/lib/Basic/SourceManager.cpp--- ../tools/clang/lib/Basic/SourceManager.cpp (revision 229486)
the output: ./bin/clang crash.c Doug, as you seem to be the person who commited this... can you comment and/or fix this? |
The central issue seems to be that a module's global inline assembler doesn't have a location attached. It would be possible to extend llvm::Module::appendModuleInlineAsm to also pass a location field in or alternatively, keep track of it the location on the clang side before extending it. I'm not sure such a change can be done non-intrusive for merging into 3.6. |
Both test cases appear to be fixed in Clang 3.7: |
@llvm/issue-subscribers-clang-frontend |
Extended Description
This assertion was originally reported in a FreeBSD PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197527
It reproduces with clang trunk r228967, and occurs during compilation of WebKit's LowLevelInterpreter.cpp, which is file containing quite a lot of generated inline assembly for the JavaScript engine.
I reduced the test case to just this two-liner:
Compile this with:
Results in:
The text was updated successfully, but these errors were encountered: