Created attachment 1969879 [details] preprocessed source /usr/bin/g++ -std=gnu++17 -o Unified_cpp_gfx_skia17.o -c -I/root/rpmbuild/BUILD/firefox-115.0/objdir/dist/stl_wrappers -I/root/rpmbuild/BUILD/firefox-115.0/objdir/dist/system_wrappers -include /root/rpmbuild/BUILD/firefox-115.0/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -DNDEBUG=1 -DTRIMMED=1 -DMOZ_SKIA -DSKIA_IMPLEMENTATION=1 -DSK_PDF_USE_HARFBUZZ_SUBSETTING=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/root/rpmbuild/BUILD/firefox-115.0/gfx/skia -I/root/rpmbuild/BUILD/firefox-115.0/objdir/gfx/skia -I/root/rpmbuild/BUILD/firefox-115.0/gfx/skia/skia -I/root/rpmbuild/BUILD/firefox-115.0/gfx/cairo/cairo/src -I/root/rpmbuild/BUILD/firefox-115.0/objdir/dist/include -I/root/rpmbuild/BUILD/firefox-115.0/objdir/dist/include/nspr -I/root/rpmbuild/BUILD/firefox-115.0/objdir/dist/include/nss -DMOZILLA_CLIENT -include /root/rpmbuild/BUILD/firefox-115.0/objdir/mozilla-config.h -fno-sized-deallocation -fno-aligned-new -O2 -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -funwind-tables -fstack-clash-protection -Wformat-security -Wformat -Werror=format-security -fPIC -Wl,-z,relro -Wl,-z,now -DNSS_PKCS11_3_0_STRICT -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -gdwarf-4 -g -O2 -fomit-frame-pointer -funwind-tables -Wall -Wempty-body -Wignored-qualifiers -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wno-invalid-offsetof -Wno-error=deprecated -Wduplicated-cond -Wimplicit-fallthrough -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-multistatement-macros -Wno-error=class-memaccess -Wformat -Wformat-overflow=2 -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-deprecated-declarations -Wno-overloaded-virtual -Wno-sign-compare -Wno-unreachable-code -Wno-unused-function -Wno-logical-op -Wno-maybe-uninitialized -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/fribidi -fno-strict-aliasing -ffp-contract=off -MD -MP -MF .deps/Unified_cpp_gfx_skia17.o.pp Unified_cpp_gfx_skia17.cpp *** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins. Event | Plugins PLUGIN_FINISH_UNIT | annobin: Generate final annotations PLUGIN_START_UNIT | annobin: Generate global annotations PLUGIN_ALL_PASSES_START | annobin: Generate per-function annotations PLUGIN_ALL_PASSES_END | annobin: Register per-function end symbols during RTL pass: final In file included from Unified_cpp_gfx_skia17.cpp:65: /root/rpmbuild/BUILD/firefox-115.0/gfx/skia/skia/src/sksl/SkSLPool.cpp: In static member function ‘static void* SkSL::Pool::AllocMemory(size_t)’: /root/rpmbuild/BUILD/firefox-115.0/gfx/skia/skia/src/sksl/SkSLPool.cpp:81:1: internal compiler error: output_operand: '%&' used without any local dynamic TLS references } ^ Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. {standard input}: Assembler messages: {standard input}:30259: Warning: end of file not at end of a line; newline inserted {standard input}:31260: Error: missing operand Point to source: https://searchfox.org/mozilla-central/source/gfx/skia/skia/src/sksl/SkSLPool.cpp#81 Valid to ppc64le.
Reduced testcase -O2 -fpic: struct A { ~A (); }; static thread_local int *t; int a; A::~A () { t = &a; } long b; void * foo () { void *c; if (t) { c = operator new (b); return c; } void *d = operator new (b); return d; } The bug went away with https://gcc.gnu.org/r9-4463 , but guess that isn't easily backportable. The problem is that for some strange reason we aren't able to figure out that the test of the TLS var is useless during GIMPLE passes (but can't figure it out even when replacing static thread_local with nothing), so it is only RTL optimizations that find out that it is the same thing. But the old PowerPC way of doing TLSLD is clearly unable to cope with all TLSLD references in a function that during expansion had some disappearing. If you want a workaround, I see in MemPool: class MemoryPool { public: static std::unique_ptr<MemoryPool> Make(size_t, size_t) { return std::make_unique<MemoryPool>(); } void resetScratchSpace() {} void reportLeaks() const {} bool isEmpty() const { return true; } void* allocate(size_t size) { return ::operator new(size); } void release(void* p) { ::operator delete(p); } }; and then void* Pool::AllocMemory(size_t size) { MemoryPool* memPool = get_thread_local_memory_pool(); if (memPool) { void* ptr = memPool->allocate(size); ; return ptr; } void* ptr = ::operator new(size); ; return ptr; } in the preprocessed source. If memPool->allocate will always just do ::operator new, what is the point of the messing up with get_thread_local_memory_pool? So, you could in both Pool::AllocMemory and Pool::FreeMemory wrap around the memPool related stuff with #if SK_SUPPORT_GPU or whatever guards in SkSLMemoryPool.h the implementation that actually does something from the dummy one that only uses the system allocator.
Perhaps a fix could be try harder in get_some_local_dynamic_name, if we don't find any TLSLD references in the current function, return any other TLSLD symbol in the current TU. get_some_local_dynamic_name is used only by a couple of targets, so add some global variable next to some_local_dynamic_name (say cu_local_dynamic_name) and set that variable when emitting TLSLD sequences in the backend. Or instead search the varpool for TLS vars with TLSLD model. Or yet another option would be in all the instructions which use %& in the rs6000 backend call get_some_local_dynamic_name () during output and use the template with %& only if it returned non-zero, otherwise use some dummy instruction with the same size - if we don't have any TLSLD instructions left, the value that the instruction sets doesn't really matter.
Workaround only tested on the above reduced testcase (which should go into the testsuite too): --- gcc/final.c.jj 2023-06-09 10:56:10.224167367 +0200 +++ gcc/final.c 2023-06-14 14:10:04.634242884 +0200 @@ -1620,6 +1620,22 @@ get_some_local_dynamic_name () } } + /* If all the TLSLD references from current function were DCEd, try harder and pick + name of any TLSLD symbol in current TU. */ + varpool_node *node; + FOR_EACH_VARIABLE (node) + if (DECL_THREAD_LOCAL_P (node->decl) + && TREE_STATIC (node->decl) + && decl_tls_model (node->decl) == TLS_MODEL_LOCAL_DYNAMIC + && DECL_RTL_SET_P (node->decl)) + { + rtx rtl = DECL_RTL (node->decl); + if (MEM_P (rtl) + && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF + && SYMBOL_REF_TLS_MODEL (XEXP (rtl, 0)) == TLS_MODEL_LOCAL_DYNAMIC) + return some_local_dynamic_name = XSTR (XEXP (rtl, 0), 0); + } + return 0; }
Or perhaps better --- gcc/final.c.jj 2023-06-09 10:56:10.224167367 +0200 +++ gcc/final.c 2023-06-14 14:10:04.634242884 +0200 @@ -1620,6 +1620,23 @@ get_some_local_dynamic_name () } } + /* If all the TLSLD references from current function were DCEd, try harder and pick + name of any TLSLD symbol in current TU. */ + varpool_node *node; + if (!this_is_asm_operands) + FOR_EACH_VARIABLE (node) + if (DECL_THREAD_LOCAL_P (node->decl) + && TREE_STATIC (node->decl) + && decl_tls_model (node->decl) == TLS_MODEL_LOCAL_DYNAMIC + && DECL_RTL_SET_P (node->decl)) + { + rtx rtl = DECL_RTL (node->decl); + if (MEM_P (rtl) + && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF + && SYMBOL_REF_TLS_MODEL (XEXP (rtl, 0)) == TLS_MODEL_LOCAL_DYNAMIC) + return XSTR (XEXP (rtl, 0), 0); + } + return 0; } i.e. don't cache these extra efforts and use them only outside of inline asm, so that we don't change behavior of inline asm.
# rpm -q gcc gcc-8.5.0-19.el8.ppc64le # g++ -c bz.C -O2 -fpic during RTL pass: final bz.C: In function ‘void* foo()’: bz.C:18:1: internal compiler error: output_operand: '%&' used without any local dynamic TLS references } ^ # rpm -q gcc gcc-8.5.0-20.el8.ppc64le # g++ -c bz.C -O2 -fpic # OK