Message ID | 54B28270.8000208@sunrus.com.cn |
---|---|
State | New |
Headers | show |
On 01/11/15 07:02, Chen Gang S wrote: > The related commit "1a1ed14 config/h8300: Use rtx_insn" gives an extra > check for rtx, which will cause building libgcc break, after regress it, > it can still generate the correct assemble code. > > The related information is below: > > [root@localhost libgcc]# cat libgcc2.i > typedef int DItype __attribute__ ((mode (DI))); > DItype __muldi3 (DItype u, DItype v) > { > return u + v; > } > [root@localhost libgcc]# /upstream/build-gcc-h8300/gcc/cc1 -ms -O2 libgcc2.i > __muldi3 > Analyzing compilation unit > Performing interprocedural optimizations > <*free_lang_data> <visibility> <build_ssa_passes> <chkp_passes> <opt_local_passes> <free-inline-summary> <emutls> <whole-program> <profile_estimate> <icf> <devirt> <cp> <inline> <pure-const> <static-var> <single-use> <comdats>Assembling functions: > __muldi3 > libgcc2.i: In function '__muldi3': > libgcc2.i:5:1: internal compiler error: in as_a, at is-a.h:192 > } This indicates a violation of the type safety invariants we're adding to GCC. Simply changing the code to use rtx rather than rtx_insn is probably a step in the wrong direction. Part of the problem here is that RTX_FRAME_RELATED_P is valid on both rtx_insn and rtx objects. That's something we'll have to fix as the type safety work moves forward, assuming we continue towards the goal of totally separating rtx and rtx_insn objects. Returning to the code in h8300.c, we have "F" which assumes its argument is an rtx_insn. We should never be calling "F" will anything other than an rtx_insn argument. The calls from "Fpa" are the only violators of that invariant. Given that the vectors inside the PARALLEL will always be rtx objects and that we always want to set RTX_FRAME_RELATED on those objects, it seems that we could just replace the call to "F" in "Fpa" with RTX_FRAME_RELATED_P (XVECEXP (par, 0, i)) = 1; That simplifies the code and removes a bogus as_a cast. Can you try that and report back to me? Thanks, Jeff ps. Someone should have chastised DJ for using such poor function names as "F" and "Fpa". If you wanted to clean that up and use more descriptive function names, that would be appreciated as a separate patch.
On 01/12/15 10:01, Jeff Law wrote: > This indicates a violation of the type safety invariants we're adding to > GCC. Simply changing the code to use rtx rather than rtx_insn is > probably a step in the wrong direction. > > Part of the problem here is that RTX_FRAME_RELATED_P is valid on both > rtx_insn and rtx objects. That's something we'll have to fix as the > type safety work moves forward, assuming we continue towards the goal of > totally separating rtx and rtx_insn objects. > > Returning to the code in h8300.c, we have "F" which assumes its argument > is an rtx_insn. We should never be calling "F" will anything other than > an rtx_insn argument. The calls from "Fpa" are the only violators of > that invariant. > > Given that the vectors inside the PARALLEL will always be rtx objects > and that we always want to set RTX_FRAME_RELATED on those objects, it > seems that we could just replace the call to "F" in "Fpa" with > > RTX_FRAME_RELATED_P (XVECEXP (par, 0, i)) = 1; > > > That simplifies the code and removes a bogus as_a cast. > > Can you try that and report back to me? Nevermind. I went ahead and made this change and verified that libgcc, libquadmath and newlib would build for the h8300-elf configuration. Jeff
On 1/13/15 01:32, Jeff Law wrote: > On 01/12/15 10:01, Jeff Law wrote: >> This indicates a violation of the type safety invariants we're adding to >> GCC. Simply changing the code to use rtx rather than rtx_insn is >> probably a step in the wrong direction. >> >> Part of the problem here is that RTX_FRAME_RELATED_P is valid on both >> rtx_insn and rtx objects. That's something we'll have to fix as the >> type safety work moves forward, assuming we continue towards the goal of >> totally separating rtx and rtx_insn objects. >> >> Returning to the code in h8300.c, we have "F" which assumes its argument >> is an rtx_insn. We should never be calling "F" will anything other than >> an rtx_insn argument. The calls from "Fpa" are the only violators of >> that invariant. >> Oh, what you said above sound reasonable to me. "F" is also used by others which pass rtx_insn to "F". >> Given that the vectors inside the PARALLEL will always be rtx objects >> and that we always want to set RTX_FRAME_RELATED on those objects, it >> seems that we could just replace the call to "F" in "Fpa" with >> >> RTX_FRAME_RELATED_P (XVECEXP (par, 0, i)) = 1; >> >> >> That simplifies the code and removes a bogus as_a cast. >> Yeah, for me, it is a good idea. >> Can you try that and report back to me? > Nevermind. I went ahead and made this change and verified that libgcc, libquadmath and newlib would build for the h8300-elf configuration. > Thank you for your work.
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index fe85df5..994c38f 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -506,8 +506,8 @@ byte_reg (rtx x, int b) && !crtl->is_leaf))) /* We use this to wrap all emitted insns in the prologue. */ -static rtx_insn * -F (rtx_insn *x, bool set_it) +static rtx +F (rtx x, bool set_it) { if (set_it) RTX_FRAME_RELATED_P (x) = 1; @@ -527,7 +527,7 @@ Fpa (rtx par) int i; for (i = 0; i < len; i++) - F (as_a <rtx_insn *> (XVECEXP (par, 0, i)), true); + F (XVECEXP (par, 0, i), true); return par; }