Re: [build] Remove SPARC HAVE_AS_REGISTER_PSEUDO_OP
Hi Joseph, > On Thu, 1 Nov 2018, Rainer Orth wrote: > >> * One for ia64 in gcc_cv_as_ia64_ltoffx_ldxmov_relocs) ... >> >> $as_echo ' .text >> addl r15 = @ltoffx(x#), gp >> ;; >> ld8.mov r16 = [r15], x#'[] > conftest.s > > Thanks for pointing this out. I've applied this patch to fix this by > adding a newline at the end of the test input (which is what I did for all > the cases where adding AC_LANG_SOURCE resulted in autoconf errors if the > last line of the AC_LANG_SOURCE argument contained '#'; I don't know how > related the issues are, but it's at least less cryptic for the reader than > using a quadrigraph). very much so, thanks for the hint. I've applied it to my Solaris as SHF_MERGE patch, too. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [PATCH] Add myself to MAINTAINERS (not-committed)
On 11/3/18 1:01 AM, Stafford Horne wrote: > Nevermind, I don not have write access. I will request to: > > overse...@gcc.gnu.org > Use the following form to request write access: https://sourceware.org/cgi-bin/pdw/ps_form.cgi Peter
Re: GOOS updated: Port of gccgo to GNU/Hurd
ping, no feedback so far, is anything missing/are the patches rejected? On Sat, 2018-10-27 at 20:43 +0200, Svante Signell wrote: > Hello, > > As advised by the Debian gcc maintainer Matthias Klose and golang > developer Ian Lance Taylor I'm (re-)submitting the patches for > the port of gccgo to GNU/Hurd again. Now GOOS value is changed from > gnu > to hurd as requested. > > The 13 patches are: > src_gcc_config_i386_gnu.h.diff > src_libgo_build.diff > src_libgo_go_crypto.diff > src_libgo_go_go_build_syslist.go.diff > src_libgo_go_net.diff > src_libgo_go_os.diff > src_libgo_go_runtime.diff > src_libgo_go_syscall.diff > src_libgo_go_syscall_syscall_gnu_test.go.diff > src_libgo_runtime.diff > src_libgo_testsuite_gotest.diff > add-gnu-to-libgo-headers.diff > add-gnu-to-libgo-test-headers.diff > > Preliminary ChangeLog entries are included in each patch. > > With them the latest the latest Debian gcc-snapshot (20181019-1) has > been successfully built. Test results for libgo and go: > > === libgo Summary === > > # of expected passes162 > # of unexpected failures21 > > === go Summary === > > # of expected passes7394 > # of unexpected failures10 > # of expected failures 1 > # of untested testcases 7 > # of unsupported tests 2 > > Thanks!
[nios2, committed] correct sidi3 costs
PR target/87079 reported that with -Os, the nios2 back end was emitting an inferior code sequence for widening multiply instead of using mulx. I tracked this down to the rtx costs hook not recognizing the RTL pattern for sidi3 so it would overestimate the cost. I've been aware for a while that the RTX costs computation in the nios2 backend is far from optimal or even correct :-P but giving it a complete workover is a pretty big project requiring benchmarking etc as well as unit tests. I don't want the perfect to be the enemy of the good, so I've checked in the attached patch to fix this issue and add the test case (both -Os and -O2 variants). -Sandra 2018-11-03 Sandra Loosemore PR target/87079 gcc/ * config/nios2/nios2.c (nios2_rtx_costs): Recognize sidi3 pattern. gcc/testsuite/ * gcc.target/nios2/pr87079-1.c: New. * gcc.target/nios2/pr87079-2.c: New. Index: gcc/config/nios2/nios2.c === --- gcc/config/nios2/nios2.c (revision 265561) +++ gcc/config/nios2/nios2.c (working copy) @@ -1539,6 +1539,19 @@ nios2_rtx_costs (rtx x, machine_mode mod *total = COSTS_N_INSNS (2); /* Latency adjustment. */ else *total = COSTS_N_INSNS (1); + if (TARGET_HAS_MULX && GET_MODE (x) == DImode) + { + enum rtx_code c0 = GET_CODE (XEXP (x, 0)); + enum rtx_code c1 = GET_CODE (XEXP (x, 1)); + if ((c0 == SIGN_EXTEND && c1 == SIGN_EXTEND) + || (c0 == ZERO_EXTEND && c1 == ZERO_EXTEND)) + /* This is the sidi3 pattern, which expands into 4 insns, + 2 multiplies and 2 moves. */ + { + *total = *total * 2 + COSTS_N_INSNS (2); + return true; + } + } return false; } Index: gcc/testsuite/gcc.target/nios2/pr87079-1.c === --- gcc/testsuite/gcc.target/nios2/pr87079-1.c (nonexistent) +++ gcc/testsuite/gcc.target/nios2/pr87079-1.c (working copy) @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -mhw-div -mhw-mul -mhw-mulx" } */ + +#include +#include + +void foo(const uint8_t* str, uint32_t* res) +{ + uint32_t rdVal0, rdVal1, rdVal2; + rdVal0 = rdVal1 = rdVal2 = 0; + unsigned c; + for (;;) { +c = *str++; +unsigned dig = c - '0'; +if (dig > 9) + break; // non-digit +uint64_t x10; + +x10 = (uint64_t)rdVal0*10 + dig; +rdVal0 = (uint32_t)x10; +dig = (uint32_t)(x10 >> 32); + +x10 = (uint64_t)rdVal1*10 + dig; +rdVal1 = (uint32_t)x10; +dig = (uint32_t)(x10 >> 32); + +rdVal2 = rdVal2*10 + dig; + } + res[0] = rdVal0; + res[1] = rdVal1; + res[2] = rdVal2; +} + +/* { dg-final { scan-assembler-times "mulxuu\t" 2 } } */ Index: gcc/testsuite/gcc.target/nios2/pr87079-2.c === --- gcc/testsuite/gcc.target/nios2/pr87079-2.c (nonexistent) +++ gcc/testsuite/gcc.target/nios2/pr87079-2.c (working copy) @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mhw-div -mhw-mul -mhw-mulx" } */ + +#include +#include + +void foo(const uint8_t* str, uint32_t* res) +{ + uint32_t rdVal0, rdVal1, rdVal2; + rdVal0 = rdVal1 = rdVal2 = 0; + unsigned c; + for (;;) { +c = *str++; +unsigned dig = c - '0'; +if (dig > 9) + break; // non-digit +uint64_t x10; + +x10 = (uint64_t)rdVal0*10 + dig; +rdVal0 = (uint32_t)x10; +dig = (uint32_t)(x10 >> 32); + +x10 = (uint64_t)rdVal1*10 + dig; +rdVal1 = (uint32_t)x10; +dig = (uint32_t)(x10 >> 32); + +rdVal2 = rdVal2*10 + dig; + } + res[0] = rdVal0; + res[1] = rdVal1; + res[2] = rdVal2; +} + +/* { dg-final { scan-assembler-times "mulxuu\t" 2 } } */
RE: [patch][x86_64]: AMD znver2 enablement
Hi Uros, > -Original Message- > From: Uros Bizjak > Sent: Friday, November 2, 2018 9:06 PM > To: Kumar, Venkataramanan > Cc: gcc-patches@gcc.gnu.org; Jan Hubicka > Subject: Re: [patch][x86_64]: AMD znver2 enablement > > On Wed, Oct 31, 2018 at 6:25 AM Kumar, Venkataramanan > wrote: > > > > Hi Maintainers, > > > > PFA, the patch that enables support for the next generation AMD Zen CPU > via -march=znver2. > > As of now, znver2 is using the same costs and scheduler descriptions > written for znver1. > > > > We will update scheduler descriptions and costing for znver2 later as we > get more information. > > > > Ok for trunk? > > > > Regards, > > Venkat. > > > > ChangeLog gcc: > > * common/config/i386/i386-common.c (processor_alias_table): Add > znver2 entry. > > * config.gcc (i[34567]86-*-linux* | ...): Add znver2. > > (case ${target}): Add znver2. > > * config/i386/driver-i386.c: (host_detect_local_cpu): Let > > -march=native recognize znver2 processors. > > * config/i386/i386-c.c (ix86_target_macros_internal): Add > > znver2. > > * config/i386/i386.c (m_znver2): New definition. > > (m_ZNVER): New definition. > > (m_AMD_MULTIPLE): Includes m_znver2. > > (processor_cost_table): Add znver2 entry. > > (processor_target_table): Add znver2 entry. > > (get_builtin_code_for_version): Set priority for > > PROCESSOR_ZNVER2. > > (processor_model): Add M_AMDFAM17H_ZNVER2. > > (arch_names_table): Ditto. > > (ix86_reassociation_width): Include znver2. > > * config/i386/i386.h (TARGET_znver2): New definition. > > (struct ix86_size_cost): Add TARGET_ZNVER2. > > (enum processor_type): Add PROCESSOR_ZNVER2. > > * config/i386/i386.md (define_attr "cpu"): Add znver2. > > * config/i386/x86-tune-costs.h: (processor_costs) Add znver2 costs. > > * config/i386/x86-tune-sched.c: (ix86_issue_rate): Add znver2. > > (ix86_adjust_cost): Add znver2. > > * config/i386/x86-tune.def: Replace m_ZNVER1 by m_ZNVER > > * gcc/doc/extend.texi: Add details about znver2. > > * gcc/doc/invoke.texi: Add details about znver2. > > > > ChangeLog libgcc > > * config/i386/cpuinfo.c: (get_amd_cpu): Add znver2. > > (processor_subtypes): Ditto. > > > diff --git a/libgcc/config/i386/cpuinfo.h b/libgcc/config/i386/cpuinfo.h index > 0aa887b..86cb4ea 100644 > --- a/libgcc/config/i386/cpuinfo.h > +++ b/libgcc/config/i386/cpuinfo.h > @@ -67,6 +67,7 @@ enum processor_subtypes >AMDFAM15H_BDVER3, >AMDFAM15H_BDVER4, >AMDFAM17H_ZNVER1, > + AMDFAM17H_ZNVER2, >INTEL_COREI7_IVYBRIDGE, >INTEL_COREI7_HASWELL, >INTEL_COREI7_BROADWELL, > > As the comment above these enums says: > > /* Any new types or subtypes have to be inserted at the end. */ > > So, please add new entry at the end of enum processor_types. > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index > 963c7fc..bbe3bb3 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -32269,6 +32276,7 @@ fold_builtin_cpu (tree fndecl, tree *args) > M_AMDFAM15H_BDVER3, > M_AMDFAM15H_BDVER4, > M_AMDFAM17H_ZNVER1, > +M_AMDFAM17H_ZNVER2, > M_INTEL_COREI7_IVYBRIDGE, > M_INTEL_COREI7_HASWELL, > M_INTEL_COREI7_BROADWELL, > > The above also have to be in sync with enum processor_subtypes. > > Otherwise LGTM. > > Uros. I have updated the patch as per your review comments. Thank you, I will commit the attached patch. Regards, Venkat. ChangeLog: * common/config/i386/i386-common.c (processor_alias_table): Add znver2 entry. * config.gcc (i[34567]86-*-linux* | ...): Add znver2. (case ${target}): Add znver2. * config/i386/driver-i386.c: (host_detect_local_cpu): Let -march=native recognize znver2 processors. * config/i386/i386-c.c (ix86_target_macros_internal): Add znver2. * config/i386/i386.c (m_znver2): New definition. (m_ZNVER): New definition. (m_AMD_MULTIPLE): Includes m_znver2. (processor_cost_table): Add znver2 entry. (processor_target_table): Add znver2 entry. (get_builtin_code_for_version): Set priority for PROCESSOR_ZNVER2. (processor_model): Add M_AMDFAM17H_ZNVER2. (arch_names_table): Ditto. (ix86_reassociation_width): Include znver2. * config/i386/i386.h (TARGET_znver2): New definition. (struct ix86_size_cost): Add TARGET_ZNVER2. (enum processor_type): Add PROCESSOR_ZNVER2. * config/i386/i386.md (define_attr "cpu"): Add znver2. * config/i386/x86-tune-costs.h: (processor_costs) Add znver2 costs. * config/i386/x86-tune-sched.c: (ix86_issue_rate): Add znver2. (ix86_adjust_cost): Add znver2. *
Re: [PATCH] Add myself to MAINTAINERS (not-committed)
On Sat, Nov 03, 2018 at 10:34:40AM -0500, Peter Bergner wrote: > On 11/3/18 1:01 AM, Stafford Horne wrote: > > Nevermind, I don not have write access. I will request to: > > > > overse...@gcc.gnu.org > > > > Use the following form to request write access: > > https://sourceware.org/cgi-bin/pdw/ps_form.cgi Thank you, this is for requesting a new account. I already have an account. The page also mentions if you already have an account and just need write access to a new project then mail `overseers`; which I have just done. -Stafford
Re: Fix D compilation on Solaris
On Wed, 31 Oct 2018 at 10:40, Rainer Orth wrote: > > Hi Iain, > > > My first suspect here would be 'struct UnionExp', see d/dmd/expression.h > > > > Upstream dmd use a poor man's alignment, from what I recall to be > > compatible with the dmc compiler. > > > > // Ensure that the union is suitably aligned. > > real_t for_alignment_only; > > > > What happens if you were to replace that with marking the type as > > __attribute__ ((aligned (8))) ? > > thanks for the suggestion: this worked just fine. After a couple more > libphobos adjustments (described below), I was able to finish the build > on both sparc-sun-solaris2.11 and i386-pc-solaris2.11. > > The link tests still all fail as before, but sparc and x86 are now on > par here :-) > Hi Rainer, On making the relevant change to dmd, this header probably should remain compatible with dmc++, which unfortunately doesn't implement any __attribute__ extensions. Does s/real_t/long double/ also prevent the alignment error from occurring? Iain.
[patch, libgfortran] PR78351 comma not terminating READ of formatted input field
Hi all, The attached patch adds code in read_sf_internal to handle early termination of reads in the presence of comma's. This is to support legacy codes which are not standard conforming as far as we can tell. The additions are executed only if -std=legacy is given at compile time. It does not support kind=4 internal units since in legacy years there should be no kind=4 internal units. I have provuded a simplified test case for various combinations of comma embedded strings. This has been regression tested on x86_64-pc-linux-gnu. OK for trunk? This use to work way back in early versions so should probably go to 7 and 8 branches. Opinions welcome. Regards, Jerry 2018-11-04 Jerry DeLisle * io/transfer.c (read_sf_internal): Add support for early comma termination of internal unit formatted reads. diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 31198a3cc39..0d26101cef0 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -241,16 +241,6 @@ read_sf_internal (st_parameter_dt *dtp, size_t *length) && dtp->u.p.current_unit->pad_status == PAD_NO) hit_eof (dtp); - /* If we have seen an eor previously, return a length of 0. The - caller is responsible for correctly padding the input field. */ - if (dtp->u.p.sf_seen_eor) -{ - *length = 0; - /* Just return something that isn't a NULL pointer, otherwise the - caller thinks an error occurred. */ - return (char*) empty_string; -} - /* There are some cases with mixed DTIO where we have read a character and saved it in the last character buffer, so we need to backup. */ if (unlikely (dtp->u.p.current_unit->child_dtio > 0 && @@ -260,22 +250,80 @@ read_sf_internal (st_parameter_dt *dtp, size_t *length) sseek (dtp->u.p.current_unit->s, -1, SEEK_CUR); } - lorig = *length; - if (is_char4_unit(dtp)) + /* To support legacy code we have to scan the input string one byte + at a time because we don't no where an early comma may be and the + requested length could go passed the end of a comma shortened + string. We only do this if -std=legacy was given at compile + time. We also do not support this on kind=4 strings. */ + if (unlikely(compile_options.warn_std == 0)) // the slow legacy way. { - gfc_char4_t *p = (gfc_char4_t *) mem_alloc_r4 (dtp->u.p.current_unit->s, - length); - base = fbuf_alloc (dtp->u.p.current_unit, lorig); - for (size_t i = 0; i < *length; i++, p++) - base[i] = *p > 255 ? '?' : (unsigned char) *p; -} - else -base = mem_alloc_r (dtp->u.p.current_unit->s, length); + size_t n; + size_t tmp = 1; + char *q; + + /* If we have seen an eor previously, return a length of 0. The + caller is responsible for correctly padding the input field. */ + if (dtp->u.p.sf_seen_eor) + { + *length = 0; + /* Just return something that isn't a NULL pointer, otherwise the + caller thinks an error occurred. */ + return (char*) empty_string; + } + + /* Get the first chracter of the string to establish the base + address and check for comma or end-of-record condition. */ + base = mem_alloc_r (dtp->u.p.current_unit->s, &tmp); + if (tmp == 0) + { + dtp->u.p.sf_seen_eor = 1; + *length = 0; + return (char*) empty_string; + } + if (*base == ',') + { + dtp->u.p.current_unit->bytes_left--; + *length = 0; + return (char*) empty_string; + } - if (unlikely (lorig > *length)) + /* Now we scan the rest and exit deal with an end-of-file + condition or the comma. */ + for (n = 1; n < *length; n++) + { + q = mem_alloc_r (dtp->u.p.current_unit->s, &tmp); + if (tmp == 0) + { + hit_eof (dtp); + return NULL; + } + if (*q == ',') + { + dtp->u.p.current_unit->bytes_left -= n; + *length = n; + break; + } + } +} + else // the fast way { - hit_eof (dtp); - return NULL; + lorig = *length; + if (is_char4_unit(dtp)) + { + gfc_char4_t *p = (gfc_char4_t *) mem_alloc_r4 (dtp->u.p.current_unit->s, + length); + base = fbuf_alloc (dtp->u.p.current_unit, lorig); + for (size_t i = 0; i < *length; i++, p++) + base[i] = *p > 255 ? '?' : (unsigned char) *p; + } + else + base = mem_alloc_r (dtp->u.p.current_unit->s, length); + + if (unlikely (lorig > *length)) + { + hit_eof (dtp); + return NULL; + } } dtp->u.p.current_unit->bytes_left -= *length; ! { dg-do run } ! { dg-options "-std=legacy" } ! PR78351 program read_csv implicit none integer, parameter :: dbl = selected_real_kind(p=14, r=99) call checkit("101,1.,2.,3.,7,7") call checkit ("102,1.,,3.,,7") call checkit (",1.,,3.,, ") contains subroutine checkit (text) character(*) :: text integer :: I1, I2, I3 real(dbl) :: R1, R2, R3 10 format (I8,3ES16.8,2I8) I1=-99; I2=-99;
Re: Fix D compilation on Solaris
On Sat, 3 Nov 2018 at 23:23, Iain Buclaw wrote: > > On Wed, 31 Oct 2018 at 10:40, Rainer Orth > wrote: > > > > Hi Iain, > > > > > My first suspect here would be 'struct UnionExp', see d/dmd/expression.h > > > > > > Upstream dmd use a poor man's alignment, from what I recall to be > > > compatible with the dmc compiler. > > > > > > // Ensure that the union is suitably aligned. > > > real_t for_alignment_only; > > > > > > What happens if you were to replace that with marking the type as > > > __attribute__ ((aligned (8))) ? > > > > thanks for the suggestion: this worked just fine. After a couple more > > libphobos adjustments (described below), I was able to finish the build > > on both sparc-sun-solaris2.11 and i386-pc-solaris2.11. > > > > The link tests still all fail as before, but sparc and x86 are now on > > par here :-) > > > > Hi Rainer, > > On making the relevant change to dmd, this header probably should > remain compatible with dmc++, which unfortunately doesn't implement > any __attribute__ extensions. Does s/real_t/long double/ also prevent > the alignment error from occurring? > Actually, turns out I'm wrong and was grepping for the wrong name. It is supported in the form of #pragma pack(8) https://www.digitalmars.com/ctg/pragmas.html#pack -- Iain
Re: [PATCH libquadmath/PR68686]
On 10/23/18 7:45 PM, Ed Smith-Rowland wrote: > Greetings, > > This is an almost trivial patch to get the correct sign for tgammaq. > > I don't have a testcase as I don't know where to put one. > > OK? > > Ed Smith-Rowland > > > > tgammaq.CL > > 2018-10-24 Edward Smith-Rowland <3dw...@verizon.net> > > PR libquadmath/68686 > * math/tgammaq.c: Correct sign for negative argument. I don't have the relevant background to evaluate this for correctness. Can you refer back to any kind of documentation which indicates what the sign of the return value ought to be? Alternately, if you can point to the relevant code in glibc that handles the resultant sign, that'd be useful too. Note that Joseph's follow-up doesn't touch on the gamma problem AFAICT, but instead touches on the larger issues around trying to keep the quadmath implementations between glibc and gcc more in sync. Jeff
Re: [PATCH, testsuite] ignore some "conflicting types for built-in" messages
On 11/1/18 1:13 PM, Paul Koning wrote: > A number of test cases contain declarations like: > void *memcpy(); > which currently are silently accepted on most platforms but not on all; pdp11 > (and possibly some others) generate a "conflicting types for built-in > function" warning. > > It was suggested to prune those messages because the test cases where these > occur are not looking for the message but are testing some other issue, so > the message is not relevant. The attached patch adds dg-prune-output > directives to do so. > > Ok for trunk? > > paul > > ChangeLog: > > 2018-11-01 Paul Koning > > * gcc.dg/Walloca-16.c: Ignore conflicting types for built-in > warnings. > * gcc.dg/Wrestrict-4.c: Ditto. > * gcc.dg/Wrestrict-5.c: Ditto. > * gcc.dg/pr83463.c: Ditto. > * gcc.dg/torture/pr55890-2.c: Ditto. > * gcc.dg/torture/pr55890-3.c: Ditto. > * gcc.dg/torture/pr71816.c: Ditto. ISTM it'd be better to just fix memcpy to have a correct prototype. jeff
Re: [PATCH] Fix sanitizer frame unwind on 32-bit ABIs (again)
On 10/31/18 4:08 PM, Segher Boessenkool wrote: > This re-applies r258525, and this time adds it to LOCAL_PATCHES. Is this > okay for trunk? > > > Segher > > > 2018-10-31 Segher Boessenkool > > libsanitizer/ > * LOCAL_PATCHES: Add r258525. > * sanitizer_common/sanitizer_stacktrace.cc > (BufferedStackTrace::FastUnwindStack): Use the correct frame offset > for PowerPC SYSV ABI. OK. jeff
[PATCH 2/3] Add a pass to automatically add ptwrite instrumentation
From: Andi Kleen Add a new pass to automatically instrument changes to variables with the new PTWRITE instruction on x86. PTWRITE writes a 4 or 8 byte field into an Processor Trace log, which allows log over head logging of informatin. This allows to reconstruct how values later, which can be useful for debugging or other analysis of the program behavior. With the compiler support this can be done with without having to manually add instrumentation to the code. Using dwarf information this can be later mapped back to the variables. There are new options to enable instrumentation for different types, and also a new attribute to control analysis fine grained per function or variable level. The attributes can be set on both the variable and the type level, and also on structure fields. This allows to enable tracing only for specific code in large programs. The pass is generic, but only the x86 backend enables the necessary hooks. When the backend enables the necessary hooks (with -mptwrite) there is an additional pass that looks through the code for attribute vartrace enabled functions or variables. The -fvartrace-locals options is experimental: it works, but it generates redundant ptwrites because the pass doesn't use the SSA information to minimize instrumentation. This could be optimized later. Currently the code can be tested with SDE, or on a Intel Gemini Lake system with a new enough Linux kernel (v4.10+) that supports PTWRITE for PT. Linux perf can be used to record the values perf record -e intel_pt/ptw=1,branch=0/ program perf script --itrace=crw -F +synth ... I have an experimential version of perf that can also use dwarf information to symbolize many[1] values back to their variable names. So far it is not in standard perf, but available at https://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc.git/log/?h=perf/var-resolve-4 It is currently not able to decode all variable locations to names, but a large subset. Longer term hopefully gdb will support this information too. The CPU can potentially generate very data high bandwidths when code doing a lot of computation is heavily instrumented. This can cause some data loss in both the CPU and also in perf logging the data when the disk cannot keep up. Running some larger workloads most workloads do not cause CPU level overflows, but I've seen it with -fvartrace with crafty, and with more workloads with -fvartrace-locals. Recommendation is to not fully instrument programs, but only areas of interest either at the file level or using the attributes. The other thing is that perf and the disk often cannot keep up with the data bandwidth for longer computations. In this case it's possible to use perf snapshot mode (add --snapshot to the command line above). The data will be only logged to a memory ring buffer then, and only dump the buffers on events of interest by sending SIGUSR2 to the perf binrary. In the future this will be hopefully better supported with core files and gdb. Passes bootstrap and test suite on x86_64-linux, also bootstrapped and tested gcc itself with full -fvartrace and -fvartrace-locals instrumentation. gcc/: 2018-11-03 Andi Kleen * Makefile.in: Add tree-vartrace.o. * common.opt: Add -fvartrace, -fvartrace-returns, -fvartrace-args, -fvartrace-reads, -fvartrace-writes, -fvartrace-locals * config/i386/i386.c (ix86_vartrace_func): Add. (TARGET_VARTRACE_FUNC): Add. * doc/extend.texi: Document vartrace/no_vartrace attributes. * doc/invoke.texi: Document -fvartrace, -fvartrace-returns, -fvartrace-args, -fvartrace-reads, -fvartrace-writes, -fvartrace-locals * doc/tm.texi (TARGET_VARTRACE_FUNC): Add. * passes.def: Add vartrace pass. * target.def (vartrace_func): Add. * tree-pass.h (make_pass_vartrace): Add. * tree-vartrace.c: New file to implement vartrace pass. gcc/c-family/: 2018-11-03 Andi Kleen * c-attribs.c (handle_vartrace_attribute): New function. config/: 2018-11-03 Andi Kleen * bootstrap-vartrace.mk: New. * bootstrap-vartrace-locals.mk: New. --- config/bootstrap-vartrace-locals.mk | 3 + config/bootstrap-vartrace.mk| 3 + gcc/Makefile.in | 1 + gcc/c-family/c-attribs.c| 23 ++ gcc/common.opt | 24 ++ gcc/config/i386/i386.c | 16 + gcc/doc/extend.texi | 13 + gcc/doc/invoke.texi | 29 ++ gcc/doc/tm.texi | 4 + gcc/doc/tm.texi.in | 2 + gcc/passes.def | 1 + gcc/target.def | 7 + gcc/tree-pass.h | 1 + gcc/tree-vartrace.c | 463 14 files changed, 590 insertions(+) create mode 100644 config/bootstrap-vartrace-locals.mk create mode 100644 config/bootstrap-vartrace.mk create mod
[PATCH 1/3] Add PTWRITE builtins for x86
From: Andi Kleen Add builtins/intrinsics for PTWRITE. PTWRITE is a new instruction on Intel Gemini Lake/ Goldmont Plus that allows to write values into the Processor Trace log. This allows very light weight instrumentation of programs. The intrinsics are compatible to icc. Automatically enabled for Goldmont Plus. gcc/: 2018-11-03 Andi Kleen * common/config/i386/i386-common.c (OPTION_MASK_ISA_PTWRITE_SET): New. (OPTION_MASK_ISA_PTWRITE_UNSET): New. (ix86_handle_option): Handle OPT_mptwrite. * config/i386/cpuid.h (bit_PTWRITE): Add. * config/i386/driver-i386.c (host_detect_local_cpu): Detect ptwrite. * config/i386/i386-builtin.def (BDESC): Add ptwrite32/64. * config/i386/i386-c.c (ix86_target_macros_internal): Define __PTWRITE__. * config/i386/i386.c (ix86_target_string): Handle ptwrite. (ix86_option_override_internal): Handle PTA_PTWRITE. (ix86_valid_target_attribute_inner_p): Define ptwrite. (def_builtin2): Force UINT64 to be 64bit only. * config/i386/i386.h (TARGET_PTWRITE): Add. (TARGET_PTWRITE_P): Add. (PTA_PTWRITE): Add. * config/i386/i386.md: Define ptwrite. * config/i386/i386.opt: Add -mptwrite. * config/i386/immintrin.h (_ptwrite64): Add. (_ptwrite32): Add * doc/extend.texi: Document __builtin_ia32_ptwrite*. * doc/invoke.texi: Document -mptwrite. gcc/testsuite/ChangeLog: 2018-11-03 Andi Kleen * gcc.target/i386/ptwrite1.c: New test. * gcc.target/i386/ptwrite2.c: New test. --- gcc/common/config/i386/i386-common.c | 15 gcc/config/i386/cpuid.h | 4 gcc/config/i386/driver-i386.c| 12 ++ gcc/config/i386/i386-builtin.def | 4 gcc/config/i386/i386-c.c | 2 ++ gcc/config/i386/i386.c | 9 ++- gcc/config/i386/i386.h | 5 +++- gcc/config/i386/i386.md | 10 gcc/config/i386/i386.opt | 4 gcc/config/i386/immintrin.h | 26 gcc/doc/extend.texi | 9 +++ gcc/doc/invoke.texi | 7 -- gcc/testsuite/gcc.target/i386/ptwrite1.c | 30 gcc/testsuite/gcc.target/i386/ptwrite2.c | 14 +++ 14 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/ptwrite1.c create mode 100644 gcc/testsuite/gcc.target/i386/ptwrite2.c diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c index f12806ef3a9..f740995c1e4 100644 --- a/gcc/common/config/i386/i386-common.c +++ b/gcc/common/config/i386/i386-common.c @@ -140,6 +140,7 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA_FSGSBASE_SET OPTION_MASK_ISA_FSGSBASE #define OPTION_MASK_ISA_RDRND_SET OPTION_MASK_ISA_RDRND +#define OPTION_MASK_ISA_PTWRITE_SET OPTION_MASK_ISA_PTWRITE #define OPTION_MASK_ISA_F16C_SET \ (OPTION_MASK_ISA_F16C | OPTION_MASK_ISA_AVX_SET) #define OPTION_MASK_ISA_MWAITX_SET OPTION_MASK_ISA_MWAITX @@ -267,6 +268,7 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA_FSGSBASE_UNSET OPTION_MASK_ISA_FSGSBASE #define OPTION_MASK_ISA_RDRND_UNSET OPTION_MASK_ISA_RDRND +#define OPTION_MASK_ISA_PTWRITE_UNSET OPTION_MASK_ISA_PTWRITE #define OPTION_MASK_ISA_F16C_UNSET OPTION_MASK_ISA_F16C #define OPTION_MASK_ISA_GENERAL_REGS_ONLY_UNSET \ @@ -1125,6 +1127,19 @@ ix86_handle_option (struct gcc_options *opts, } return true; +case OPT_mptwrite: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_PTWRITE_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA_PTWRITE_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA_PTWRITE_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA_PTWRITE_UNSET; + } + return true; + case OPT_mf16c: if (value) { diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index 7e9e2d153dc..2e6d4a55602 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -126,6 +126,10 @@ #define bit_XSAVEC (1 << 1) #define bit_XSAVES (1 << 3) +/* PT sub leaf (%eax == 14, %ecx == 0) */ +/* %ebx */ +#define bit_PTWRITE(1 << 4) + /* Signatures for different CPU implementations as returned in uses of cpuid with level 0. */ #define signature_AMD_ebx 0x68747541 diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c index 8c830bde1dd..423b1c3827f 100644 --- a/gcc/config/i386/driver-i386.c +++ b/gcc/config/i386/driver-i386.c @@ -427,6 +427,8 @@ const char *host_detect_local_cpu (int argc, const char **argv) unsigned int has_waitpkg = 0; unsigned int has_cldemote = 0; + unsigned int has_ptwrite = 0; + bool arch; unsigned int l2
[PATCH 3/3] Add tests for the vartrace pass
From: Andi Kleen gcc/testsuite/: 2018-11-03 Andi Kleen * g++.dg/vartrace-3.C: New test. * g++.dg/vartrace-ret.C: New test. * g++.dg/vartrace-ret2.C: New test. * gcc.target/i386/vartrace-1.c: New test. * gcc.target/i386/vartrace-10.c: New test. * gcc.target/i386/vartrace-11.c: New test. * gcc.target/i386/vartrace-12.c: New test. * gcc.target/i386/vartrace-13.c: New test. * gcc.target/i386/vartrace-14.c: New test. * gcc.target/i386/vartrace-15.c: New test. * gcc.target/i386/vartrace-16.c: New test. * gcc.target/i386/vartrace-2.c: New test. * gcc.target/i386/vartrace-3.c: New test. * gcc.target/i386/vartrace-4.c: New test. * gcc.target/i386/vartrace-5.c: New test. * gcc.target/i386/vartrace-6.c: New test. * gcc.target/i386/vartrace-7.c: New test. * gcc.target/i386/vartrace-8.c: New test. * gcc.target/i386/vartrace-9.c: New test. --- gcc/testsuite/g++.dg/vartrace-3.C | 14 +++ gcc/testsuite/g++.dg/vartrace-ret.C | 17 + gcc/testsuite/g++.dg/vartrace-ret2.C| 24 gcc/testsuite/gcc.target/i386/vartrace-1.c | 41 + gcc/testsuite/gcc.target/i386/vartrace-10.c | 13 +++ gcc/testsuite/gcc.target/i386/vartrace-11.c | 16 gcc/testsuite/gcc.target/i386/vartrace-12.c | 16 gcc/testsuite/gcc.target/i386/vartrace-13.c | 18 + gcc/testsuite/gcc.target/i386/vartrace-14.c | 17 + gcc/testsuite/gcc.target/i386/vartrace-15.c | 12 ++ gcc/testsuite/gcc.target/i386/vartrace-16.c | 12 ++ gcc/testsuite/gcc.target/i386/vartrace-17.c | 23 gcc/testsuite/gcc.target/i386/vartrace-2.c | 9 + gcc/testsuite/gcc.target/i386/vartrace-3.c | 9 + gcc/testsuite/gcc.target/i386/vartrace-4.c | 13 +++ gcc/testsuite/gcc.target/i386/vartrace-5.c | 11 ++ gcc/testsuite/gcc.target/i386/vartrace-6.c | 13 +++ gcc/testsuite/gcc.target/i386/vartrace-7.c | 11 ++ gcc/testsuite/gcc.target/i386/vartrace-8.c | 11 ++ gcc/testsuite/gcc.target/i386/vartrace-9.c | 10 + 20 files changed, 310 insertions(+) create mode 100644 gcc/testsuite/g++.dg/vartrace-3.C create mode 100644 gcc/testsuite/g++.dg/vartrace-ret.C create mode 100644 gcc/testsuite/g++.dg/vartrace-ret2.C create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-1.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-10.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-11.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-12.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-13.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-14.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-15.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-16.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-17.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-2.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-3.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-4.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-5.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-6.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-7.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-8.c create mode 100644 gcc/testsuite/gcc.target/i386/vartrace-9.c diff --git a/gcc/testsuite/g++.dg/vartrace-3.C b/gcc/testsuite/g++.dg/vartrace-3.C new file mode 100644 index 000..13f71cca6d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/vartrace-3.C @@ -0,0 +1,14 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -mptwrite -fvartrace-args " } */ +/* { dg-final { scan-assembler "ptwrite" } } */ + +int a; +int b(int c) +{ + if (a) +c += 1; + else +c += b(a); + b(c); + return 0; +} diff --git a/gcc/testsuite/g++.dg/vartrace-ret.C b/gcc/testsuite/g++.dg/vartrace-ret.C new file mode 100644 index 000..2a8a6753bd3 --- /dev/null +++ b/gcc/testsuite/g++.dg/vartrace-ret.C @@ -0,0 +1,17 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -mptwrite -fvartrace-returns " } */ +/* { dg-final { scan-assembler-not "ptwrite" } } */ + +class foo { +public: +short a; +short b; +}; + +foo f1() +{ +foo x = { 1, 2 }; +return x; +} + + diff --git a/gcc/testsuite/g++.dg/vartrace-ret2.C b/gcc/testsuite/g++.dg/vartrace-ret2.C new file mode 100644 index 000..56842d75fb6 --- /dev/null +++ b/gcc/testsuite/g++.dg/vartrace-ret2.C @@ -0,0 +1,24 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -mptwrite -fvartrace " } */ +/* { dg-final { scan-assembler "ptwrite" } } */ + +typedef int a; +enum b +{ }; +struct ac +{ + a operator () (a, a, a, a, a, a); +}; +struct c +{ + ac ag; +} extern ai[]; +a d; +void +l (a e) +{ + b f; + a g, h, i, j, k; + e = d; + ai[f].a
Re: [patch, libgfortran] PR78351 comma not terminating READ of formatted input field
On Nov 03 2018, Jerry DeLisle wrote: > + /* To support legacy code we have to scan the input string one byte > + at a time because we don't no where an early comma may be and the s/no/know/ Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."