[LLVMbugs] [Bug 18459] New: Recursive function inline problems
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jan 13 10:50:14 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=18459
Bug ID: 18459
Summary: Recursive function inline problems
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Transformation Utilities
Assignee: unassignedbugs at nondot.org
Reporter: css20 at mail.ru
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 11863
--> http://llvm.org/bugs/attachment.cgi?id=11863&action=edit
testcase
Follow this steps using attachment puzzle.ll:
llvm-as -f puzzle.ll
llc puzzle.bc
gcc puzzle.s -o puzzle
./puzzle
Found duplicate: 256943
Found duplicate: 106186
Found duplicate: 465226
Found duplicate: 112763
Found duplicate: 406647
Then try optimize bitcode:
opt -inline puzzle.bc -o puzzle.opt.bc
llc puzzle.opt.bc
gcc puzzle.opt.s -o puzzle.opt
./puzzle.opt
Found duplicate: 491574
Found duplicate: 480454
Found duplicate: 447135
Found duplicate: 255009
Found duplicate: 419126
Strange optimization.. ok, try bugpoint
bugpoint --safe-run-llc --run-llc puzzle.bc -inline
...
*** The following function is being miscompiled: .shuffle.createRandomArray
Outputting reduced bitcode files which expose the problem:
Non-optimized portion: Emitted bitcode to 'bugpoint-tonotoptimize.bc'
Portion that is input to optimizer: Emitted bitcode to
'bugpoint-tooptimize.bc'
*** You can reproduce the problem with: opt bugpoint-tooptimize.bc -inline
bugpoint-tooptimize.bc disasseble fragment:
define i32* @.shuffle.createRandomArray(i32* %items, i32 %functionID, i32
%len.size) {
combEntry:
%"collect alloca point17" = bitcast i32 0 to i32
%"collect alloca point16" = bitcast i32 0 to i32
%"collect alloca point15" = bitcast i32 0 to i32
%"collect alloca point14" = bitcast i32 0 to i32
%"collect alloca point13" = bitcast i32 0 to i32
%"collect alloca point12" = bitcast i32 0 to i32
%"collect alloca point11" = bitcast i32 0 to i32
%"collect alloca point" = bitcast i32 0 to i32
switch i32 %functionID, label %codeRepl3 [
i32 38, label %codeRepl2
i32 39, label %entryfcomb1
]
codeRepl2: ; preds = %combEntry
call void @.shuffle.createRandomArray_combEntry.entryfcomb_crit_edge1()
br label %entryfcomb
codeRepl3: ; preds = %combEntry
call void @.shuffle.createRandomArray_combEntry.entryfcomb_crit_edge()
br label %entryfcomb
entryfcomb: ; preds = %codeRepl3,
%codeRepl2
%subfcomb = sub nsw i32 %len.size, 1
%convfcomb = sext i32 %subfcomb to i64
br label %codeRepl4
codeRepl4: ; preds = %entryfcomb
call void @.shuffle.createRandomArray_codeRepl(i64 %convfcomb, i32* %items)
br label %codeRepl
codeRepl: ; preds = %codeRepl4
call void @.shuffle.createRandomArray_for.endfcomb()
br label %for.endfcomb.ret
for.endfcomb.ret: ; preds = %codeRepl
ret i32* null
entryfcomb1: ; preds = %combEntry
%addfcomb3 = add nsw i32 %len.size, 1
%convfcomb4 = sext i32 %addfcomb3 to i64
%mulfcomb5 = mul i64 %convfcomb4, 4
%callfcomb = call i8* @malloc(i64 %mulfcomb5)
%0 = bitcast i8* %callfcomb to i32*
br label %codeRepl5
codeRepl5: ; preds = %entryfcomb1
call void @.shuffle.createRandomArray_codeRepl1(i32 %addfcomb3, i32* %0)
br label %for.endfcomb10
for.endfcomb10: ; preds = %codeRepl5
%call24fcomb = call i32 @.rand.srand.randInt(i32 1, i32 %len.size, i32 38)
%arrayidx3fcomb = getelementptr inbounds i32* %0, i64 0
store i32 %call24fcomb, i32* %arrayidx3fcomb, align 4, !tbaa !1
%1 = call i32* @.shuffle.createRandomArray(i32* %0, i32 38, i32 %addfcomb3)
ret i32* %0
}
look basic block for.endfcomb10, it contains recursive call. Now we can see
content of "for.endfcomb10" basic block after optimization (opt -inline):
for.endfcomb10: ; preds = %codeRepl5
%call24fcomb = call i32 @.rand.srand.randInt(i32 1, i32 %len.size, i32 8)
%arrayidx3fcomb = getelementptr inbounds i32* %0, i64 0
store i32 %call24fcomb, i32* %arrayidx3fcomb, align 4, !tbaa !1
; here was recursive call
call void @.shuffle.createRandomArray_combEntry.entryfcomb_crit_edge1()
%convfcomb.i = sext i32 %addfcomb3 to i64
call void @.shuffle.createRandomArray_codeRepl(i64 %convfcomb.i, i32* %0)
call void @.shuffle.createRandomArray_for.endfcomb()
ret i32* %0
If we try walk manually to call @.shuffle.createRandomArray(i32* %0, i32 38,
i32 %addfcomb3), we must pass this instructions:
call void @.shuffle.createRandomArray_combEntry.entryfcomb_crit_edge1()
%subfcomb = sub nsw i32 %addfcomb3, 1 ; <--- WHERE IS IT???
%convfcomb = sext i32 %subfcomb to i64
call void @.shuffle.createRandomArray_codeRepl(i64 %convfcomb, i32* %items)
call void @.shuffle.createRandomArray_for.endfcomb()
Instruction "%subfcomb = sub nsw i32 %addfcomb3, 1" not exists in listing after
optimization, "-inline" pass loses it?
--
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/20140113/e49325b5/attachment.html>
More information about the llvm-bugs
mailing list