[LLVMbugs] [Bug 24185] New: LICM incorrectly hoists load because Instruction::mayThrow does not correctly handle invokes
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jul 19 23:58:47 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24185
Bug ID: 24185
Summary: LICM incorrectly hoists load because
Instruction::mayThrow does not correctly handle
invokes
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: sanjoy at playingwithpointers.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Running -licm on the following IR hoists the load of `%m` outside the loop.
This is incorrect because it is possible that @f throws something that does not
unwind to `%right` (because the exception's type does not match `@_ZTIi`).
Such a throw will exit the frame. Thus, the load from %ptr is not executed on
all paths through the loop and cannot be safely speculated.
As far as I can tell, the bug is in Instruction::mayThrow -- LLVM cannot
certify that an `invoke` does not throw without analyzing all of its
landingpads.
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
@_ZTIi = external constant i8*
declare i32 @__gxx_personality_v0(...)
declare i32 @f(i32) readnone
define i32 @g(i32* %ptr) personality i8* bitcast (i32 (...)*
@__gxx_personality_v0 to i8*) {
entry:
br label %loop
loop:
%acc = phi i32 [ 0, %entry ], [ %acc.next, %merge ]
%x = invoke i32 @f(i32 %acc) to label %left unwind label %right
left:
br label %merge
right:
%v = landingpad { i8*, i32 } catch i8* bitcast (i8** @_ZTIi to i8*)
br label %merge
merge:
%vv = phi i32 [ %x, %left ], [ 0, %right]
%m = load i32, i32* %ptr
%acc.next = add i32 %m, %acc
%c = icmp eq i32 %vv, 0
br i1 %c, label %loop, label %exit
exit:
ret i32 %acc
}
--
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/20150720/968455d9/attachment.html>
More information about the llvm-bugs
mailing list