This is an archive of the discontinued LLVM Phabricator instance.

WIP: Unwindabort: add support for IR transforms and analysis.
Needs ReviewPublic

Authored by jyknight on Jan 17 2023, 3:53 AM.

Details

Summary

This is part of a series of changes to enable generating more
efficient code for C++ "noexcept" functions. See also the RFC,
https://discourse.llvm.org/t/rfc-add-call-unwindabort-to-llvm-ir/62543

In previous commits, we added the core Instruction support for
'unwindabort'. This commit adds support for its semantics to the
IR-level transforms and analyses.

Depends on D141915

Diff Detail

Event Timeline

jyknight created this revision.Jan 17 2023, 3:53 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 17 2023, 3:53 AM
jyknight requested review of this revision.Jan 17 2023, 3:53 AM
lebedev.ri added inline comments.
llvm/include/llvm/Transforms/Utils/Local.h
357

?

358
llvm/test/Instrumentation/ThreadSanitizer/eh.ll
2

Please precommit all such regenerations

This is missing a very important correctness change to haveSameSpecialState()/FunctionComparator::cmpOperations()

barannikov88 added inline comments.
llvm/test/Transforms/FunctionAttrs/nounwind.ll
85

_could_ it be marked nounwind?

In general -- no. One has to prove that the destructor of the caught exception does not throw.

jroelofs added inline comments.
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
1678

I don't understand the choice of the word "may" here. Isn't an unwind through an unwindabort supposed to /always/ lead to an abort?

llvm/lib/Transforms/Utils/InlineFunction.cpp
2324–2327
llvm/lib/Transforms/Utils/Local.cpp
2657
jroelofs added inline comments.Jul 28 2023, 12:07 PM
llvm/include/llvm/Transforms/Utils/Local.h
365–367
jyknight updated this revision to Diff 546611.Aug 2 2023, 2:23 PM
jyknight edited the summary of this revision. (Show Details)

Rebase patch.

jyknight marked 8 inline comments as done.Aug 10 2023, 11:53 AM

This is missing a very important correctness change to haveSameSpecialState()/FunctionComparator::cmpOperations()

Yikes -- thanks for pointing that out. It's quite unfortunate that we hide equality and comparisons for Instruction types in 2 other non-obvious places. It'd be great to move all of that into methods _on_ the type, so it's more obvious that it needs to be changed when adding data to an instruction. It looks like I don't need to change FunctionComparator, since it just generically checks getRawSubclassData() for equality. But, I do need to modify hasSameSpecialState, since it does not do so (yikes^2 that these functions differ in that way!).

I'll add those changes to into the previous 3 patches in this series.

llvm/include/llvm/Transforms/Utils/Local.h
357

I'll keep the current name, in order to make clear this enum is intended to be specific for this function's argument, rather than general-purpose.

llvm/test/Transforms/FunctionAttrs/nounwind.ll
85

Ah, right. TODO removed, explanation added.