forked from OSchip/llvm-project
[FuncAttrs] Don't infer willreturn for nonexact definitions
Discovered during attributor testing comparing stats with and without the attributor. Willreturn should not be inferred for nonexact definitions. Differential Revision: https://reviews.llvm.org/D100988
This commit is contained in:
parent
6ae7fc0a29
commit
62cdcd6c5a
|
@ -1432,6 +1432,12 @@ static bool addNoReturnAttrs(const SCCNodeSet &SCCNodes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool functionWillReturn(const Function &F) {
|
static bool functionWillReturn(const Function &F) {
|
||||||
|
// We can infer and propagate function attributes only when we know that the
|
||||||
|
// definition we'll get at link time is *exactly* the definition we see now.
|
||||||
|
// For more details, see GlobalValue::mayBeDerefined.
|
||||||
|
if (!F.hasExactDefinition())
|
||||||
|
return false;
|
||||||
|
|
||||||
// Must-progress function without side-effects must return.
|
// Must-progress function without side-effects must return.
|
||||||
if (F.mustProgress() && F.onlyReadsMemory())
|
if (F.mustProgress() && F.onlyReadsMemory())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -153,5 +153,12 @@ bb2:
|
||||||
br label %bb1
|
br label %bb1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define linkonce i32 @square(i32) {
|
||||||
|
; CHECK-NOT: Function Attrs: {{.*}}willreturn
|
||||||
|
; CHECK: define linkonce i32 @square(
|
||||||
|
%2 = mul nsw i32 %0, %0
|
||||||
|
ret i32 %2
|
||||||
|
}
|
||||||
|
|
||||||
declare i64 @fn_noread() readnone
|
declare i64 @fn_noread() readnone
|
||||||
declare void @fn_willreturn() willreturn
|
declare void @fn_willreturn() willreturn
|
||||||
|
|
Loading…
Reference in New Issue