This showed up when simplifying some large testcase, where the cfi directives became out of sync with the proc's they enclose.
rdar://111459507
Differential D155245
[MC][AsmParser] Diagnose improperly nested .cfi frames jroelofs on Jul 13 2023, 4:03 PM. Authored by
Details This showed up when simplifying some large testcase, where the cfi directives became out of sync with the proc's they enclose. rdar://111459507
Diff Detail
Event TimelineComment Actions on the subject of is there any way to diagnose:
Comment Actions
I tried this one and found it broke a lot of JIT tests, as well as some cases with inline asm.
I'll give this one a shot. I suspect it may also trip up on the same sorts of issues. Comment Actions D153167 is related. Due to Mach-O's .subsections_via_symbols mechanism, non-private labels cannot appear between .cfi_startproc/.cfi_endproc. I think AArch64/cfi-bad-nesting.s deserves a getContext().reportError. Comment Actions this is breaking runtimes builds of aarch64 builtins, e.g. [294/404] Building ASM object CMakeFiles\clang_rt.builtins-aarch64.dir\outline_atomic_helpers.dir\outline_atomic_cas16_1.S.obj FAILED: CMakeFiles/clang_rt.builtins-aarch64.dir/outline_atomic_helpers.dir/outline_atomic_cas16_1.S.obj C:\b\s\w\ir\cache\builder\src\third_party\llvm-build\Release+Asserts\.\bin\clang-cl.exe -target aarch64-pc-windows-msvc /nologo -DHAS_ASM_LSE -DL_cas -DMODEL=1 -DSIZE=16 -IC:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\builtins -fno-lto /Zl -fno-builtin -DCOMPILER_RT_HAS_FLOAT16 /showIncludes /FoCMakeFiles\clang_rt.builtins-aarch64.dir\outline_atomic_helpers.dir\outline_atomic_cas16_1.S.obj /FdCMakeFiles\clang_rt.builtins-aarch64.dir\clang_rt.builtins-aarch64.pdb -c -- C:\b\s\w\ir\cache\builder\src\third_party\llvm-build\Release+Asserts\runtimes\builtins-aarch64-pc-windows-msvc-bins\outline_atomic_helpers.dir\outline_atomic_cas16_1.S C:\\b\\s\\w\\ir\\cache\\builder\\src\\third_party\\llvm-build\\Release+Asserts\\runtimes\\builtins-aarch64-pc-windows-msvc-bins\\outline_atomic_helpers.dir\\outline_atomic_cas16_1.S:145:131: error: non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs .text ; .balign 16 ; .globl __aarch64_cas16_relax ; .def __aarch64_cas16_relax ; .scl 2 ; .type 32 ; .endef ; ; .cfi_startproc ; __aarch64_cas16_relax: ; ^ C:\\b\\s\\w\\ir\\cache\\builder\\src\\third_party\\llvm-build\\Release+Asserts\\runtimes\\builtins-aarch64-pc-windows-msvc-bins\\outline_atomic_helpers.dir\\outline_atomic_cas16_1.S:145:114: error: previous .cfi_startproc was here .text ; .balign 16 ; .globl __aarch64_cas16_relax ; .def __aarch64_cas16_relax ; .scl 2 ; .type 32 ; .endef ; ; .cfi_startproc ; __aarch64_cas16_relax: ; this is at https://github.com/llvm/llvm-project/blob/6a126e279dedc9fb8c204d29cfc227b0652ffe6c/compiler-rt/lib/builtins/aarch64/lse.S#L145 (need to follow a bunch of macros). the builtins should be cleaned up first before landing this Comment Actions This breaks building libffi for 32 bit arm; the following snippet does fallthrough from one global function to another, while sharing one single CFI region for all of them: https://github.com/libffi/libffi/blob/master/src/arm/sysv.S#L139-L213 Based on this patch, the code in libffi looks like it would be invalid and intentionally should fail to compile. However, I noticed a different surprising detail here; it looks like this check fails to trigger on Linux (ELF in general I presume?) targets, while it does trigger on MachO and COFF. This can be tested with something like this: .globl ffi_call_VFP ffi_call_VFP: .cfi_startproc nop .globl ffi_call_SYSV ffi_call_SYSV: nop .cfi_endproc $ clang -target aarch64-linux-gnu -c fallthrough.s $ clang -target aarch64-apple-darwin -c fallthrough.s fallthrough.s:7:1: error: non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs ffi_call_SYSV: ^ fallthrough.s:3:2: error: previous .cfi_startproc was here .cfi_startproc ^ $ clang -target aarch64-windows-gnu -c fallthrough.s fallthrough.s:7:1: error: non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs ffi_call_SYSV: ^ fallthrough.s:3:2: error: previous .cfi_startproc was here .cfi_startproc ^ Comment Actions For cross reference, I filed an issue with libffi at https://github.com/libffi/libffi/issues/807 about this. Comment Actions I may need to restrict this to just MachO, and possibly only when .subsections_via_symbols is present. If this is blocking you, please feel free to revert.
That is really weird. I'll investigate this week. https://github.com/llvm/llvm-project/issues/72802 Thank you! Comment Actions Thanks! I pushed a revert now, and thanks for considering restricting the scope of this error!
Thanks, much appreciated! Comment Actions We're still having issues (https://crbug.com/1504532) due to this, because we're building some compiler-rt code from llvm 17 with clang from head. That's something for us to figure out, but it makes we wonder if perhaps this diagnostic should be a warning rather than a hard error by default? For example, consider someone using clang 18 to build older llvm version for bisection or similar. |
Add a test for isWeakExternal?