-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
ipoInterprocedural optimizationsInterprocedural optimizationsllvm:analysisIncludes value tracking, cost tables and constant foldingIncludes value tracking, cost tables and constant foldingmiscompilation
Description
FunctionAttrs assumes that readonly (or readnone) and nounwind function that
don't return a value can't capture arguments. That is incorrect, since such a
function can vary its behavior by terminating or not terminating.
An example demonstrating the issue:
$ cat a.ll
define void @f(ptr %a, ptr %b) {
start:
call void @g(ptr %a, ptr %b)
ret void
}
define void @g(ptr %a, ptr %b) {
start:
%0 = icmp eq ptr %a, %b
br i1 %0, label %bb2, label %bb1
bb1:
br label %bb1
bb2:
ret void
}
$ opt-21 -S --passes=function-attrs a.ll
; ModuleID = 'a.ll'
source_filename = "a.ll"
; Function Attrs: nofree norecurse nosync nounwind memory(none)
define void @f(ptr readnone captures(none) %a, ptr readnone captures(none) %b) #0 {
start:
call void @g(ptr %a, ptr %b)
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(none)
define void @g(ptr readnone %a, ptr readnone %b) #0 {
start:
%0 = icmp eq ptr %a, %b
br i1 %0, label %bb2, label %bb1
bb1: ; preds = %bb1, %start
br label %bb1
bb2: ; preds = %start
ret void
}
attributes #0 = { nofree norecurse nosync nounwind memory(none) }
Metadata
Metadata
Assignees
Labels
ipoInterprocedural optimizationsInterprocedural optimizationsllvm:analysisIncludes value tracking, cost tables and constant foldingIncludes value tracking, cost tables and constant foldingmiscompilation