[LLVMbugs] [Bug 16602] New: incorrect loop optimization at O2
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jul 11 14:10:13 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16602
Bug ID: 16602
Summary: incorrect loop optimization at O2
Product: clang
Version: 3.2
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: halayli at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
int x = 23;
int y = 29;
void* set_x(void* arg)
{
(void)arg;
x = 29;
return NULL;
}
int main(void)
{
pthread_t p1;
pthread_create(&p1, NULL, set_x, NULL);
pthread_detach(p1);
while (x < y)
if (x == y)
break;
return 0;
}
The following code runs forever if compiled with -O2.
clang -Wall -Wextra test.c -pthread -o test && ./test
The assembly code generated causes in infinite loop jumping to LBB1_1.
.Ltmp8:
.cfi_def_cfa_register %rbp
subq $16, %rsp
leaq -8(%rbp), %rdi
xorl %esi, %esi
movl $set_x, %edx
xorl %ecx, %ecx
callq pthread_create
movq -8(%rbp), %rdi
callq pthread_detach
movl x(%rip), %eax
cmpl y(%rip), %eax
jge .LBB1_2
.align 16, 0x90
.LBB1_1: # %while.cond
# =>This Inner Loop Header: Depth=1
jmp .LBB1_1
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130711/f11ede4b/attachment.html>
More information about the llvm-bugs
mailing list