-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 9614 |
| Resolution | FIXED |
| Resolved on | Mar 07, 2013 16:17 |
| Version | trunk |
| OS | Linux |
| Blocks | llvm/llvm-bugzilla-archive#11199 |
| Attachments | glibc wchar.h |
| Reporter | LLVM Bugzilla Contributor |
| CC | @ahatanak,@andersk,@shining,@echristo,@efriedma-quic,@foutrelis,@ismail |
Extended Description
Clang generates llvm intermediate code with an endless loop, when -O is used.
Here is source .c code:
$ cat test.c
#include <wchar.h>
int main ()
{
return btowc ('\0');
}
And after compilation we have:
(gdb) disas main
Dump of assembler code for function main:
0x00000000004004f0 <+0>: jmp 0x4004f0
End of assembler dump.
Here is LLVM IR:
$ clang -S -emit-llvm test.c; cat test.s
; ModuleID = 'test.c'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-pc-linux-gnu"
define i32 @main() nounwind {
%1 = alloca i32, align 4
store i32 0, i32* %1
%2 = call i32 @btowc(i32 0) nounwind
ret i32 %2
}
declare i32 @btowc(i32) nounwind
$ clang -O -S -emit-llvm test.c; cat test.s
; ModuleID = 'test.c'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-pc-linux-gnu"
define i32 @main() nounwind readnone {
br label %tailrecurse.i
tailrecurse.i: ; preds = %tailrecurse.i, %0
br label %tailrecurse.i
}
I've attached wchar.h just in case.