This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add new built-in: __builtin_unreachable()


On Thu, Jun 11, 2009 at 6:24 PM, David Daney<ddaney@caviumnetworks.com> wrote:
> Richard Henderson wrote:
>>
>> David Daney wrote:
>>>
>>> This is exactly the first version of the patch, but we fix
>>> rtl_verify_flow_info() so that it properly handles empty blocks when
>>> searching for missing barriers.
>>
>> ...
>>>
>>> @@ -2041,7 +2041,7 @@ rtl_verify_flow_info (void)
>>> ? ? ? for (insn = BB_END (bb); !insn || !BARRIER_P (insn);
>>> ? ? ? ? ? ?insn = NEXT_INSN (insn))
>>> ? ? ? ? if (!insn
>>> - ? ? ? ?|| NOTE_INSN_BASIC_BLOCK_P (insn))
>>> + ? ? ? ?|| (NOTE_INSN_BASIC_BLOCK_P (insn) && insn != BB_END (bb)))
>>
>> I'd prefer to have this section rewritten as
>>
>>> @@ -2045,16 +2045,18 @@ rtl_verify_flow_info (void)
>>> ? ? ? ?{
>>> ? ? ? ? ?rtx insn;
>>> ?- ? ? ? ? /* Ensure existence of barrier in BB with no fallthru edges.
>>> ?*/
>>> - ? ? ? ? for (insn = BB_END (bb); !insn || !BARRIER_P (insn);
>>> - ? ? ? ? ? ? ?insn = NEXT_INSN (insn))
>>> - ? ? ? ? ? if (!insn
>>> - ? ? ? ? ? ? ? || NOTE_INSN_BASIC_BLOCK_P (insn))
>>> + ? ? ? ? /* Ensure existence of barrier after BB with no fallthru edges.
>>> ?*/
>>> + ? ? ? ? for (insn = NEXT_INSN (BB_END (bb)); ; insn = NEXT_INSN (insn))
>>> + ? ? ? ? ? {
>>> + ? ? ? ? ? ? if (!insn || NOTE_INSN_BASIC_BLOCK_P (insn))
>>> ? ? ? ? ? ? ? ?{
>>> ? ? ? ? ? ? ? ? ?error ("missing barrier after block %i", bb->index);
>>> ? ? ? ? ? ? ? ? ?err = 1;
>>> ? ? ? ? ? ? ? ? ?break;
>>> ? ? ? ? ? ? ? ?}
>>> + ? ? ? ? ? ? if (BARRIER_P (insn))
>>> + ? ? ? ? ? ? ? break;
>>> + ? ? ? ? ? }
>>> ? ? ? ?}
>>> ? ? ? else if (e->src != ENTRY_BLOCK_PTR
>>> ? ? ? ? ? ? ? && e->dest != EXIT_BLOCK_PTR)
>>
>> Note that this version never checks vs BB_END.
>>
>
> Ok, that is cleaner.
>
>> I'd also like you to look into why gcc -O on your
>> builtin-unreachable-2.c test still produces a branch to next:
>>
>>> ? ? ? ?cmpl ? ?$1, %edi
>>> ? ? ? ?jle ? ? .L2
>>> .L2:
>>> ? ? ? ?movl ? ?$1, %eax
>>> ? ? ? ?ret
>>
>
> It was jumping around the empty block with a barrier. ?I modified the patch
> to delete such blocks in try_optimize_cfg(). ?The resulting code omits the
> useless comparison and jump.

Does that then still work for the original intent to mark asms that never
return as such?

Thus, does the patch now delete all blocks that the block with the
__builtin_unreachable () call post-dominates?  If not, isn't that what
we want to do?

;)

Thanks,
Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]