[PATCH] D127962: [WinEHPrepare] Propagate funclet tokens when inlining into EH funclets

Stefan Gränitz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 08:16:50 PDT 2022


sgraenitz added a comment.

This is the best solution I found so far. The funclet bundle operand (aka. token) of the inlinee function will be propagated to the set of intrinsics that is (as of today) subject to pre-ISel lowering. This only applies when targeting WinEH and only for functions inlined into EH funclets.

However, there is no check that makes sure the actual set of intrinsics is in sync with the condition I am using here. See my inline comment for a proposal.



================
Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:2313-2324
+          // When targeting WinEH, we must propagate funclet tokens to pre-ISel
+          // intrinsics, if they get inlined into EH funclets. Otherwise,
+          // WinEHPrepare would mark them unreachable and cause truncations.
+          bool PropagateExplicitly = false;
+          if (Personality == EHPersonality::MSVC_CXX) {
+            using namespace llvm::objcarc;
+            ARCInstKind Kind = GetFunctionClass(CalledFn);
----------------
We could simplify the condition here by adding a new helper function in ObjCARCInstKind.h/.cpp:
```
bool llvm::objcarc::IsPreISelIntrinsic(Function *F) {
  ARCInstKind K = GetFunctionClass(F);
  return !IsUser(K) && K != ARCInstKind::None;
}
```

It could be used in D124762 CGCall.cpp as well as in PreISelIntrinsicLowering.cpp to assert the set of pre-ISel intrinsics is in sync with what we do here. This would also connect the three pieces of code explicitly, so it's easier for others to see their relation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127962/new/

https://reviews.llvm.org/D127962



More information about the llvm-commits mailing list