From patchwork Sat Jul 18 21:34:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Dudka X-Patchwork-Id: 36215 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6ILYSK8009756 for ; Sat, 18 Jul 2009 21:34:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753615AbZGRVeY (ORCPT ); Sat, 18 Jul 2009 17:34:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753674AbZGRVeY (ORCPT ); Sat, 18 Jul 2009 17:34:24 -0400 Received: from mx2.redhat.com ([66.187.237.31]:47714 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753615AbZGRVeY (ORCPT ); Sat, 18 Jul 2009 17:34:24 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6ILYNjU012208 for ; Sat, 18 Jul 2009 17:34:23 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6ILYNgi030711 for ; Sat, 18 Jul 2009 17:34:23 -0400 Received: from vpn-10-12.str.redhat.com (vpn-10-12.str.redhat.com [10.32.10.12]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6ILYLOB024411 for ; Sat, 18 Jul 2009 17:34:22 -0400 From: Kamil Dudka To: Sparse Mailing-list Subject: [PATCH] compile-i386: do not generate an infinite loop Date: Sat, 18 Jul 2009 23:34:10 +0200 User-Agent: KMail/1.9.7 MIME-Version: 1.0 X-Length: 2962 X-UID: 33648 Message-Id: <200907182334.10900.kdudka@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Hello, I've probably encountered a bug within compile-i386.c. It generates an infinite loop for 'while' statement. My testing example and proposed patch are enclosed. Kamil Acked-by: Jeff Garzik From 60c47d120b577092f0d8fe9001ca6753706dcdbc Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Sat, 18 Jul 2009 23:24:38 +0200 Subject: [PATCH] compile-i386: do not generate an infinite loop --- compile-i386.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compile-i386.c b/compile-i386.c index 37ea52e..abe9313 100644 --- a/compile-i386.c +++ b/compile-i386.c @@ -1913,6 +1913,10 @@ static void emit_loop(struct statement *stmt) x86_symbol_decl(stmt->iterator_syms); x86_statement(pre_statement); + if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value) { + loop_top = new_label(); + emit_label(loop_top, "loop top"); + } if (pre_condition) { if (pre_condition->type == EXPR_VALUE) { if (!pre_condition->value) { @@ -1936,10 +1940,6 @@ static void emit_loop(struct statement *stmt) insn("jz", lbv, NULL, NULL); } } - if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value) { - loop_top = new_label(); - emit_label(loop_top, "loop top"); - } x86_statement(statement); if (stmt->iterator_continue->used) emit_label(loop_continue, "'continue' iterator"); -- 1.6.3.3