[LLVMbugs] [Bug 16744] New: Clang optimized out a branch function with Os option
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jul 29 18:30:54 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16744
Bug ID: 16744
Summary: Clang optimized out a branch function with Os option
Product: clang
Version: 3.3
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: mrcool0905 at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 10954
--> http://llvm.org/bugs/attachment.cgi?id=10954&action=edit
an example code
I Have some code like this. With Os option, I don't see any branching to
xQueueGenericSend in assembly. Clang 3.2 works correctly in this case.
(pxMutex->uxRecursiveCallCount)--;
if( pxMutex->uxRecursiveCallCount == 0 )
{
xQueueGenericSend( pxMutex, 0, queueMUTEX_GIVE_BLOCK_TIME);
xReturn = pdPASS;
}
/usr/local/rui/toolchains/llvm/3.3/armv7m/bin/clang -mcpu=cortex-m4 -nostdinc
-isystem /usr/local/rui/toolchains/llvm/3.3/armv7m/lib/clang/3.3/include
-mthumb -O2 -Os -c -o test.o test.c
The llvm bytecode generated with -S -emit-llvm:
; ModuleID = 'test.c'
target datalayout =
"e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:32-n32-S64"
target triple = "thumbv7em-none--eabi"
%struct.QueueDefinition = type { i8*, i8*, i8*, i8*, i32, i32, i32, i32, i32,
i8 }
; Function Attrs: nounwind optsize
define i32 @xQueueGiveMutexRecursive(%struct.QueueDefinition* nocapture
%pxMutex) #0 {
entry:
%pcTail = getelementptr inbounds %struct.QueueDefinition* %pxMutex, i32 0,
i32 1
%0 = load i8** %pcTail, align 4, !tbaa !0
%call = tail call i8* @xTaskGetCurrentTaskHandle() #2
%cmp = icmp eq i8* %0, %call
br i1 %cmp, label %if.then, label %if.end5
if.then: ; preds = %entry
%pcReadFrom = getelementptr inbounds %struct.QueueDefinition* %pxMutex, i32
0, i32 3
%1 = load i8** %pcReadFrom, align 4, !tbaa !0
%incdec.ptr = getelementptr inbounds i8* %1, i32 -1
store i8* %incdec.ptr, i8** %pcReadFrom, align 4, !tbaa !0
br label %if.end5
if.end5: ; preds = %entry, %if.then
ret i32 0
}
; Function Attrs: optsize
declare i8* @xTaskGetCurrentTaskHandle() #1
attributes #0 = { nounwind optsize "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true"
"no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #1 = { optsize "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true"
"no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #2 = { nounwind optsize }
!0 = metadata !{metadata !"any pointer", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA"}
Disassembly of section .text:
00000000 <xQueueGiveMutexRecursive>:
0: b5b0 push {r4, r5, r7, lr}
2: 4604 mov r4, r0
4: af02 add r7, sp, #8
6: 6865 ldr r5, [r4, #4]
8: f7ff fffe bl 0 <xTaskGetCurrentTaskHandle>
c: 4285 cmp r5, r0
e: bf02 ittt eq
10: 68e0 ldreq r0, [r4, #12]
12: 3801 subeq r0, #1
14: 60e0 streq r0, [r4, #12]
16: 2000 movs r0, #0
18: bdb0 pop {r4, r5, r7, pc}
1a: bf00 nop
--
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/20130730/36894f54/attachment.html>
More information about the llvm-bugs
mailing list