[clang] [llvm] [mlir] [RFC] [IR] Change personality function type from Constant* to Function* (PR #176952)
Jameson Nash via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 20 08:08:17 PST 2026
https://github.com/vtjnash created https://github.com/llvm/llvm-project/pull/176952
The purpose of this change is to remove a couple places that rely on `GlobalValue->getValueType()` being semantically meaningful. This is an RFC to get feedback on whether this is the right direction to go with restricting the valid IR format for personalities, or whether there is consensus whether this should instead gain better support taking a different approach.
Force the personality function of a function to be exactly Function, not any arbitrary constant or alias. This change tries to enforce this at the type level by changing Function::setPersonalityFn to take Function* instead of Constant*. While a couple backends had test that the front-end would accept arbitrary values here, the backends generally had bad support for that, since on many backends (WASM, COFF) this must be emitted as a PCrel value, and on many passes, this value is unconditionally cast to Function or GlobalValue. If it cannot be cast, it is instead simply dropped by some passes or asserts.
Key changes:
- Function::getPersonalityFn() now returns Function* instead of Constant*
- Function::setPersonalityFn() now takes Function* instead of Constant*
- LLParser creates Function forward references when parsing personality
- LLParser validates that forward refs used as personality resolve to functions
- BitCode reader warns and drops invalid personalities (null, undef, aliases, arbitrary constants) for backward compatibility with old bitcode
- Verifier checks that personality is a Function (no longer accepts aliases)
- Updated all target-specific code and tests
This is a breaking change for code that relied on using aliases or other constants as personality functions. Such usage doesn't appear that it would previously be well-supported, but might have worked in some cases. For example, llvm-reduce relies on doing RAUW of functions with `ptr null`, even though it appears that this could cause various backends to crash, such as `DwarfCFIException` which needs to dereference `P` to construct a symbol pointing to it:
```
@@ -124,8 +122,7 @@ void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) {
auto &F = MBB.getParent()->getFunction();
auto *P = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
assert(P && "Expected personality function");
// Record the personality function.
addPersonality(P);
```
One alternative I considered is to make this only a verifier error, which defers the error detection until later, though may require more effort in other passes to more carefully handle malformed IR. The advantage of that however is that if something does RAUW this to an unsupported kind of value, the printer itself crashes (the cast in getPersonalityFn is invalid), making it hard to inspect what happened that it going wrong.
Since the purpose of this change is to remove some uses of `GlobalValue->getValueType()`, a second alternative I considered is simply to assume that the personality does in fact points at a function, and remove the code that tries to ignore any personalities that might not point at a function based on the getValueType result.
-[ ] TODO: need to prevent llvm-reduce from trying to RAUW a personality to a constant ptr null.
-[ ] TODO: determine if either proposed alternative is preferred
>From 93b2f3f495050b7f8b268ade958b02ee6b20c8ba Mon Sep 17 00:00:00 2001
From: Jameson Nash <vtjnash+github at gmail.com>
Date: Tue, 20 Jan 2026 14:20:34 +0000
Subject: [PATCH] [RFC] [IR] Change personality function type from Constant* to
Function*
The purpose of this change is to remove some places that rely on
`GlobalValue->getValueType()` being semantically meaningful.
Force the personality function of a function to be exactly Function, not
any arbitrary constant or alias. This change tries to enforce this at
the type level by changing Function::setPersonalityFn to take Function*
instead of Constant*. While a couple backends had test that the
front-end would accept arbitrary values here, the backends generally had
bad support for that, since on many backends (WASM, COFF) this must be
emitted as a PCrel value, and on many passes, this value is
unconditionally cast to Function or GlobalValue. If it cannot be cast,
it is instead simply dropped by some passes or asserts.
Key changes:
- Function::getPersonalityFn() now returns Function* instead of Constant*
- Function::setPersonalityFn() now takes Function* instead of Constant*
- LLParser creates Function forward references when parsing personality
- LLParser validates that forward refs used as personality resolve to functions
- BitCode reader warns and drops invalid personalities (null, undef, aliases,
arbitrary constants) for backward compatibility with old bitcode
- Verifier checks that personality is a Function (no longer accepts aliases)
- Updated all target-specific code and tests
This is a breaking change for code that relied on using aliases or other
constants as personality functions. Such usage doesn't appear that it
would previously be well-supported, but might have worked in some cases.
For example, llvm-reduce relies on doing RAUW of functions with `ptr
null`, even though this could even cause various backends to crash, such
as `DwarfCFIException` which needs to dereference `P` to construct a
symbol pointing to it:
```
@@ -124,8 +122,7 @@ void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) {
auto &F = MBB.getParent()->getFunction();
auto *P = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
assert(P && "Expected personality function");
// Record the personality function.
addPersonality(P);
```
One alternative I considered is to make this only a verifier error,
which defers the error detection until later, though may require more
effort in other passes to more carefully handle malformed IR. The
advantage of that however is that if something does RAUW this to an
unsupported kind of value, the printer itself crashes (the cast in
getPersonalityFn is invalid), making it hard to inspect what happened
that it going wrong.
Since the purpose of this change is to remove some uses of
`GlobalValue->getValueType()`, a second alternative I considered is
simply to assume that the personality does in fact points at a function,
and remove the code that tries to ignore any personalities that might
not point at a function based on the getValueType result.
-[ ] TODO: need to prevent llvm-reduce from trying to RAUW a personality to a
constant ptr null.
-[ ] TODO: determine if either proposed alternative is preferred
Co-Authored-By: Claude Opus 4.5 <noreply at anthropic.com>
---
clang/lib/CodeGen/CGException.cpp | 6 +-
llvm/docs/LangRef.rst | 2 +-
llvm/include/llvm/AsmParser/LLParser.h | 13 ++-
llvm/include/llvm/CodeGen/TargetLowering.h | 4 +-
llvm/include/llvm/IR/EHPersonalities.h | 2 +-
llvm/include/llvm/IR/Function.h | 4 +-
llvm/lib/Analysis/MustExecute.cpp | 2 +-
llvm/lib/AsmParser/LLParser.cpp | 82 ++++++++++++++++---
llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 26 +++++-
llvm/lib/CodeGen/AsmPrinter/AIXException.cpp | 3 +-
llvm/lib/CodeGen/AsmPrinter/ARMException.cpp | 4 +-
.../CodeGen/AsmPrinter/DwarfCFIException.cpp | 7 +-
llvm/lib/CodeGen/AsmPrinter/WinException.cpp | 10 +--
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 2 +-
llvm/lib/CodeGen/MachineLICM.cpp | 2 +-
llvm/lib/CodeGen/RDFGraph.cpp | 2 +-
.../SelectionDAG/SelectionDAGBuilder.cpp | 2 +-
.../CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 +-
.../CodeGen/TargetLoweringObjectFileImpl.cpp | 4 +-
llvm/lib/IR/Core.cpp | 2 +-
llvm/lib/IR/EHPersonalities.cpp | 10 +--
llvm/lib/IR/Function.cpp | 6 +-
llvm/lib/IR/Verifier.cpp | 9 +-
.../AArch64/AArch64Arm64ECCallLowering.cpp | 11 +--
.../Target/AArch64/AArch64ISelLowering.cpp | 4 +-
llvm/lib/Target/AArch64/AArch64ISelLowering.h | 4 +-
llvm/lib/Target/ARM/ARMISelLowering.cpp | 4 +-
llvm/lib/Target/ARM/ARMISelLowering.h | 4 +-
llvm/lib/Target/CSKY/CSKYISelLowering.cpp | 4 +-
llvm/lib/Target/CSKY/CSKYISelLowering.h | 4 +-
llvm/lib/Target/Hexagon/HexagonISelLowering.h | 4 +-
.../LoongArch/LoongArchISelLowering.cpp | 4 +-
.../Target/LoongArch/LoongArchISelLowering.h | 4 +-
llvm/lib/Target/M68k/M68kISelLowering.cpp | 4 +-
llvm/lib/Target/M68k/M68kISelLowering.h | 4 +-
llvm/lib/Target/Mips/MipsISelLowering.h | 4 +-
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 4 +-
llvm/lib/Target/PowerPC/PPCISelLowering.h | 4 +-
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 4 +-
llvm/lib/Target/RISCV/RISCVISelLowering.h | 4 +-
llvm/lib/Target/Sparc/SparcISelLowering.h | 4 +-
llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 3 +-
.../Target/SystemZ/SystemZISelLowering.cpp | 4 +-
llvm/lib/Target/SystemZ/SystemZISelLowering.h | 4 +-
.../WebAssemblyLowerEmscriptenEHSjLj.cpp | 5 +-
llvm/lib/Target/X86/X86ISelLowering.cpp | 4 +-
llvm/lib/Target/X86/X86ISelLowering.h | 4 +-
llvm/lib/Target/X86/X86WinEHState.cpp | 4 +-
llvm/lib/Target/XCore/XCoreFrameLowering.cpp | 6 +-
llvm/lib/Target/XCore/XCoreISelLowering.h | 4 +-
.../Instrumentation/DataFlowSanitizer.cpp | 8 +-
.../Instrumentation/HWAddressSanitizer.cpp | 7 +-
llvm/lib/Transforms/Utils/CloneFunction.cpp | 6 +-
llvm/lib/Transforms/Utils/CloneModule.cpp | 3 +-
.../lib/Transforms/Utils/EscapeEnumerator.cpp | 11 +--
llvm/lib/Transforms/Utils/InlineFunction.cpp | 18 ++--
.../BlockFrequencyInfo/loop_with_invoke.ll | 3 +-
.../Analysis/BranchProbabilityInfo/loop.ll | 3 +-
.../CallGraph/do-nothing-intrinsic.ll | 3 +-
...t-guard-info-with-multiple-predecessors.ll | 4 +-
.../function-operand-uselistorder.ll | 5 +-
llvm/test/Assembler/personality-alias.ll | 20 +++++
llvm/test/Assembler/personality-constant.ll | 16 ++++
.../personality-forward-ref-not-function.ll | 20 +++++
.../test/Assembler/personality-forward-ref.ll | 26 ++++++
.../personality-generic-then-not-function.ll | 28 +++++++
.../Assembler/personality-not-function.ll | 18 ++++
llvm/test/Assembler/personality-null.ll | 7 ++
llvm/test/Bitcode/compatibility-3.7.ll | 4 +-
llvm/test/Bitcode/compatibility-3.8.ll | 4 +-
llvm/test/Bitcode/compatibility-3.9.ll | 4 +-
llvm/test/Bitcode/compatibility-4.0.ll | 4 +-
llvm/test/Bitcode/compatibility-5.0.ll | 4 +-
llvm/test/Bitcode/compatibility-6.0.ll | 4 +-
llvm/test/Bitcode/compatibility.ll | 26 +++---
.../function-address-space-fwd-decl.ll | 4 +-
llvm/test/Bitcode/operand-bundles.ll | 13 +--
llvm/test/Bitcode/use-list-order2.ll | 5 +-
.../aarch64-fixup-statepoint-regs-crash.ll | 8 +-
.../AArch64/unwind-preserved-from-mir.mir | 3 +-
llvm/test/CodeGen/AArch64/unwind-preserved.ll | 13 ++-
.../CodeGen/PowerPC/aix-personality-alias.ll | 74 -----------------
llvm/test/CodeGen/X86/deopt-bundles.ll | 5 +-
llvm/test/CodeGen/X86/eh-null-personality.ll | 3 +-
.../CodeGen/X86/stack-protector-no-return.ll | 4 +-
.../X86/x86-no_callee_saved_registers.ll | 3 +-
.../test/Feature/OperandBundles/merge-func.ll | 5 +-
.../HWAddressSanitizer/personality-bti.ll | 36 +++-----
.../HWAddressSanitizer/personality.ll | 36 +++-----
llvm/test/Linker/drop-attribute.ll | 3 +-
.../CodeGenPrepare/X86/fold-loop-of-urem.ll | 4 +-
.../CodeGenPrepare/X86/sink-addr-recreate.ll | 5 +-
.../ConstantHoisting/ARM/bad-cases.ll | 4 +-
.../reproducer-remarks.ll | 3 +-
.../coro-await-suspend-lower-invoke.ll | 3 +-
.../Transforms/Coroutines/coro-catchswitch.ll | 3 +-
llvm/test/Transforms/Coroutines/coro-debug.ll | 11 +--
.../Coroutines/coro-eh-aware-edge-split-00.ll | 3 +-
.../Coroutines/coro-eh-aware-edge-split-01.ll | 3 +-
.../Coroutines/coro-eh-aware-edge-split-02.ll | 3 +-
.../Transforms/Coroutines/coro-elide-stat.ll | 3 +-
llvm/test/Transforms/Coroutines/coro-elide.ll | 3 +-
.../Coroutines/coro-frame-unreachable.ll | 3 +-
llvm/test/Transforms/Coroutines/coro-frame.ll | 3 +-
.../Transforms/Coroutines/coro-heap-elide.ll | 7 +-
.../Coroutines/coro-resume-destroy.ll | 4 +-
.../coro-spill-defs-before-corobegin.ll | 3 +-
.../Transforms/Coroutines/coro-split-eh-00.ll | 3 +-
.../Transforms/Coroutines/coro-split-eh-01.ll | 3 +-
.../Coroutines/coro-split-final-suspend.ll | 5 +-
.../Coroutines/coro-split-musttail13.ll | 3 +-
llvm/test/Transforms/Coroutines/no-suspend.ll | 7 +-
.../test/Transforms/DeadArgElim/aggregates.ll | 3 +-
.../captures-before-call.ll | 3 +-
.../DeadStoreElimination/inter-procedural.ll | 3 +-
.../DivRemPairs/X86/div-rem-pairs.ll | 5 +-
.../Transforms/GVN/calloc-load-removal.ll | 3 +-
.../Transforms/GVN/mssa-update-dead-def.ll | 5 +-
.../test/Transforms/GVN/preserve-memoryssa.ll | 3 +-
llvm/test/Transforms/GlobalOpt/invoke.ll | 3 +-
llvm/test/Transforms/HotColdSplit/eh-pads.ll | 7 +-
llvm/test/Transforms/HotColdSplit/resume.ll | 3 +-
llvm/test/Transforms/HotColdSplit/unwind.ll | 3 +-
.../Transforms/IROutliner/illegal-catchpad.ll | 5 +-
.../Transforms/IROutliner/illegal-cleanup.ll | 5 +-
.../Transforms/IROutliner/illegal-invoke.ll | 5 +-
.../IROutliner/illegal-landingpad.ll | 5 +-
.../IndVarSimplify/AArch64/widen-loop-comp.ll | 3 +-
.../test/Transforms/IndVarSimplify/pr55925.ll | 5 +-
.../Inline/X86/inline-landing-pad.ll | 10 ++-
llvm/test/Transforms/Inline/deopt-bundles.ll | 13 +--
.../Transforms/Inline/deoptimize-intrinsic.ll | 3 +-
.../test/Transforms/Inline/guard-intrinsic.ll | 3 +-
.../Transforms/Inline/inline_returns_twice.ll | 5 +-
llvm/test/Transforms/Inline/invoke-cleanup.ll | 5 +-
.../Inline/invoke-combine-clauses.ll | 13 +--
llvm/test/Transforms/Inline/pr53206.ll | 5 +-
.../InstCombine/debuginfo-invoke.ll | 5 +-
llvm/test/Transforms/InstCombine/fabs.ll | 3 +-
.../InstCombine/freeze-landingpad.ll | 4 +-
llvm/test/Transforms/InstCombine/freeze.ll | 21 ++---
llvm/test/Transforms/InstSimplify/freeze.ll | 3 +-
.../invalid-load-operand-infinite-loop.ll | 3 +-
.../InstSimplify/known-never-nan.ll | 3 +-
.../loop-with-ehpad-not-executed.ll | 6 +-
llvm/test/Transforms/LoopDeletion/pr62160.ll | 5 +-
.../X86/eh-insertion-point-2.ll | 3 +-
.../X86/eh-insertion-point.ll | 3 +-
.../phi_ehpad_ignore_sameval.ll | 4 +-
.../LoopUnroll/peel-loop-conditions.ll | 3 +-
.../LoopVectorize/expand-scev-after-invoke.ll | 5 +-
.../Transforms/LowerInvoke/lowerinvoke.ll | 3 +-
llvm/test/Transforms/MemCpyOpt/stack-move.ll | 5 +-
.../call-and-invoke-with-ranges-attr.ll | 8 +-
.../MergeFunc/call-and-invoke-with-ranges.ll | 8 +-
.../RewriteStatepointsForGC/basic.ll | 5 +-
.../RewriteStatepointsForGC/preprocess.ll | 3 +-
llvm/test/Transforms/SCCP/landingpad.ll | 3 +-
.../small-tree-not-schedulable-bv-node.ll | 10 ++-
.../X86/catchswitch-block-in-use.ll | 6 +-
.../X86/extractelement-phi-in-landingpad.ll | 6 +-
.../X86/landing-pad-for-split-node.ll | 6 +-
.../X86/no-schedule-terminate-inst.ll | 6 +-
...cessors-domtree-preservation-edgecase-2.ll | 3 +-
.../Transforms/SimplifyCFG/X86/bug-25299.ll | 4 +-
.../X86/debugloc-invoke-to-call-br.ll | 5 +-
.../merge-compatible-invokes-of-landingpad.ll | 4 +-
.../SimplifyCFG/dbgloc-merge-invoke.ll | 5 +-
.../unreachable-multi-basic-block-funclet.ll | 30 +++----
.../Transforms/TailCallElim/deopt-bundle.ll | 3 +-
.../Transforms/Util/strip-gc-relocates.ll | 3 +-
llvm/test/Verifier/deoptimize-intrinsic.ll | 3 +-
llvm/test/Verifier/guard-intrinsic.ll | 3 +-
.../test/Verifier/invalid-cleanuppad-chain.ll | 4 +-
llvm/test/Verifier/operand-bundles.ll | 3 +-
.../Inputs/mips64_eh.ll | 2 +-
.../Inputs/mips64_eh.ll.expected | 2 +-
.../invoke-with-missing-landingpad.ll | 5 +-
.../Analysis/IRSimilarityIdentifierTest.cpp | 6 +-
.../Transforms/Utils/CodeExtractorTest.cpp | 6 +-
mlir/lib/Target/LLVMIR/ModuleImport.cpp | 18 +---
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 2 +-
182 files changed, 734 insertions(+), 526 deletions(-)
create mode 100644 llvm/test/Assembler/personality-alias.ll
create mode 100644 llvm/test/Assembler/personality-constant.ll
create mode 100644 llvm/test/Assembler/personality-forward-ref-not-function.ll
create mode 100644 llvm/test/Assembler/personality-forward-ref.ll
create mode 100644 llvm/test/Assembler/personality-generic-then-not-function.ll
create mode 100644 llvm/test/Assembler/personality-not-function.ll
create mode 100644 llvm/test/Assembler/personality-null.ll
delete mode 100644 llvm/test/CodeGen/PowerPC/aix-personality-alias.ll
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index e9d20672ce185..e3338e619e68d 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -270,10 +270,10 @@ static llvm::FunctionCallee getPersonalityFn(CodeGenModule &CGM,
llvm::AttributeList(), /*Local=*/true);
}
-static llvm::Constant *getOpaquePersonalityFn(CodeGenModule &CGM,
- const EHPersonality &Personality) {
+static llvm::Function *getOpaquePersonalityFn(CodeGenModule &CGM,
+ const EHPersonality &Personality) {
llvm::FunctionCallee Fn = getPersonalityFn(CGM, Personality);
- return cast<llvm::Constant>(Fn.getCallee());
+ return cast<llvm::Function>(Fn.getCallee());
}
/// Check whether a landingpad instruction only uses C++ features.
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index a6881099f81f4..62ae9f4b76411 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -986,7 +986,7 @@ Syntax::
<ResultType> @<FunctionName> ([argument list])
[(unnamed_addr|local_unnamed_addr)] [AddrSpace] [fn Attrs]
[section "name"] [partition "name"] [comdat [($name)]] [align N]
- [gc] [prefix Constant] [prologue Constant] [personality Constant]
+ [gc] [prefix Constant] [prologue Constant] [personality Function]
(!name !N)* { ... }
The argument list is a comma-separated sequence of arguments where each
diff --git a/llvm/include/llvm/AsmParser/LLParser.h b/llvm/include/llvm/AsmParser/LLParser.h
index 9eb31d7e0a451..17210a755bd8e 100644
--- a/llvm/include/llvm/AsmParser/LLParser.h
+++ b/llvm/include/llvm/AsmParser/LLParser.h
@@ -227,9 +227,12 @@ namespace llvm {
/// getGlobalVal - Get a value with the specified name or ID, creating a
/// forward reference record if needed. This can return null if the value
- /// exists but does not have the right type.
- GlobalValue *getGlobalVal(const std::string &N, Type *Ty, LocTy Loc);
- GlobalValue *getGlobalVal(unsigned ID, Type *Ty, LocTy Loc);
+ /// exists but does not have the right type. If ExpectFunction is true,
+ /// forward references will be created as Function placeholders.
+ GlobalValue *getGlobalVal(const std::string &N, Type *Ty, LocTy Loc,
+ bool ExpectFunction = false);
+ GlobalValue *getGlobalVal(unsigned ID, Type *Ty, LocTy Loc,
+ bool ExpectFunction = false);
/// Get a Comdat with the specified name, creating a forward reference
/// record if needed.
@@ -520,7 +523,8 @@ namespace llvm {
};
bool convertValIDToValue(Type *Ty, ValID &ID, Value *&V,
- PerFunctionState *PFS);
+ PerFunctionState *PFS,
+ bool ExpectFunction = false);
Value *checkValidVariableType(LocTy Loc, const Twine &Name, Type *Ty,
Value *Val);
@@ -577,6 +581,7 @@ namespace llvm {
Type *ExpectedTy = nullptr);
bool parseGlobalValue(Type *Ty, Constant *&C);
bool parseGlobalTypeAndValue(Constant *&V);
+ bool parsePersonality(Function *&F);
bool parseGlobalValueVector(SmallVectorImpl<Constant *> &Elts);
bool parseOptionalComdat(StringRef GlobalName, Comdat *&C);
bool parseSanitizer(GlobalVariable *GV);
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 3bbeee5e1616b..15ee20943fba0 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -2099,14 +2099,14 @@ class LLVM_ABI TargetLoweringBase {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
virtual Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const {
+ getExceptionPointerRegister(const Function *PersonalityFn) const {
return Register();
}
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
virtual Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const {
+ getExceptionSelectorRegister(const Function *PersonalityFn) const {
return Register();
}
diff --git a/llvm/include/llvm/IR/EHPersonalities.h b/llvm/include/llvm/IR/EHPersonalities.h
index 39f6817b3dc38..895eb5f778881 100644
--- a/llvm/include/llvm/IR/EHPersonalities.h
+++ b/llvm/include/llvm/IR/EHPersonalities.h
@@ -40,7 +40,7 @@ enum class EHPersonality {
/// See if the given exception handling personality function is one
/// that we understand. If so, return a description of it; otherwise return
/// Unknown.
-LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers);
+LLVM_ABI EHPersonality classifyEHPersonality(const Function *Pers);
LLVM_ABI StringRef getEHPersonalityName(EHPersonality Pers);
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index d3497716ca844..e9d0ef3dd0946 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -905,8 +905,8 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
}
/// Get the personality function associated with this function.
- Constant *getPersonalityFn() const;
- void setPersonalityFn(Constant *Fn);
+ Function *getPersonalityFn() const;
+ void setPersonalityFn(Function *Fn);
/// Check whether this function has prefix data.
bool hasPrefixData() const {
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp
index fde6bbf9eb181..4a48f0bd89b3e 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -104,7 +104,7 @@ void LoopSafetyInfo::computeBlockColors(const Loop *CurLoop) {
// personality routine.
Function *Fn = CurLoop->getHeader()->getParent();
if (Fn->hasPersonalityFn())
- if (Constant *PersonalityFn = Fn->getPersonalityFn())
+ if (Function *PersonalityFn = Fn->getPersonalityFn())
if (isScopedEHPersonality(classifyEHPersonality(PersonalityFn)))
BlockColors = colorEHFunclets(*Fn);
}
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 03b808c4fdeef..d9231d8eb8837 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -1288,6 +1288,10 @@ bool LLParser::parseAliasOrIFunc(const std::string &Name, unsigned NameID,
NumberedVals.add(NameID, GV);
if (GVal) {
+ if (isa<Function>(GVal))
+ return error(NameLoc,
+ "forward reference used as personality must be a function");
+
// Verify that types agree.
if (GVal->getType() != GV->getType())
return error(
@@ -1445,6 +1449,10 @@ bool LLParser::parseGlobal(const std::string &Name, unsigned NameID,
GV->setUnnamedAddr(UnnamedAddr);
if (GVal) {
+ if (isa<Function>(GVal))
+ return error(NameLoc,
+ "forward reference used as personality must be a function");
+
if (GVal->getAddressSpace() != AddrSpace)
return error(
TyLoc,
@@ -1759,9 +1767,14 @@ bool LLParser::parseFnAttributeValuePairs(AttrBuilder &B,
// GlobalValue Reference/Resolution Routines.
//===----------------------------------------------------------------------===//
-static inline GlobalValue *createGlobalFwdRef(Module *M, PointerType *PTy) {
+static inline GlobalValue *createGlobalFwdRef(Module *M, PointerType *PTy,
+ bool ExpectFunction = false) {
// The used global type does not matter. We will later RAUW it with a
// global/function of the correct type.
+ if (ExpectFunction)
+ return Function::Create(
+ FunctionType::get(Type::getVoidTy(M->getContext()), false),
+ GlobalValue::ExternalWeakLinkage, PTy->getAddressSpace(), "", M);
return new GlobalVariable(*M, Type::getInt8Ty(M->getContext()), false,
GlobalValue::ExternalWeakLinkage, nullptr, "",
nullptr, GlobalVariable::NotThreadLocal,
@@ -1786,7 +1799,7 @@ Value *LLParser::checkValidVariableType(LocTy Loc, const Twine &Name, Type *Ty,
/// forward reference record if needed. This can return null if the value
/// exists but does not have the right type.
GlobalValue *LLParser::getGlobalVal(const std::string &Name, Type *Ty,
- LocTy Loc) {
+ LocTy Loc, bool ExpectFunction) {
PointerType *PTy = dyn_cast<PointerType>(Ty);
if (!PTy) {
error(Loc, "global variable reference must have pointer type");
@@ -1801,8 +1814,17 @@ GlobalValue *LLParser::getGlobalVal(const std::string &Name, Type *Ty,
// forward ref record.
if (!Val) {
auto I = ForwardRefVals.find(Name);
- if (I != ForwardRefVals.end())
+ if (I != ForwardRefVals.end()) {
Val = I->second.first;
+ // If we expect a function but the forward ref is not one, RAUW it.
+ if (ExpectFunction && !isa<Function>(Val)) {
+ GlobalValue *FwdVal = createGlobalFwdRef(M, PTy, /*ExpectFunction=*/true);
+ Val->replaceAllUsesWith(FwdVal);
+ Val->eraseFromParent();
+ ForwardRefVals[Name] = std::make_pair(FwdVal, I->second.second);
+ return FwdVal;
+ }
+ }
}
// If we have the value in the symbol table or fwd-ref table, return it.
@@ -1811,12 +1833,13 @@ GlobalValue *LLParser::getGlobalVal(const std::string &Name, Type *Ty,
checkValidVariableType(Loc, "@" + Name, Ty, Val));
// Otherwise, create a new forward reference for this value and remember it.
- GlobalValue *FwdVal = createGlobalFwdRef(M, PTy);
+ GlobalValue *FwdVal = createGlobalFwdRef(M, PTy, ExpectFunction);
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
return FwdVal;
}
-GlobalValue *LLParser::getGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
+GlobalValue *LLParser::getGlobalVal(unsigned ID, Type *Ty, LocTy Loc,
+ bool ExpectFunction) {
PointerType *PTy = dyn_cast<PointerType>(Ty);
if (!PTy) {
error(Loc, "global variable reference must have pointer type");
@@ -1829,8 +1852,17 @@ GlobalValue *LLParser::getGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
// forward ref record.
if (!Val) {
auto I = ForwardRefValIDs.find(ID);
- if (I != ForwardRefValIDs.end())
+ if (I != ForwardRefValIDs.end()) {
Val = I->second.first;
+ // If we expect a function but the forward ref is not one, RAUW it.
+ if (ExpectFunction && !isa<Function>(Val)) {
+ GlobalValue *FwdVal = createGlobalFwdRef(M, PTy, /*ExpectFunction=*/true);
+ Val->replaceAllUsesWith(FwdVal);
+ Val->eraseFromParent();
+ ForwardRefValIDs[ID] = std::make_pair(FwdVal, I->second.second);
+ return FwdVal;
+ }
+ }
}
// If we have the value in the symbol table or fwd-ref table, return it.
@@ -1839,7 +1871,7 @@ GlobalValue *LLParser::getGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
checkValidVariableType(Loc, "@" + Twine(ID), Ty, Val));
// Otherwise, create a new forward reference for this value and remember it.
- GlobalValue *FwdVal = createGlobalFwdRef(M, PTy);
+ GlobalValue *FwdVal = createGlobalFwdRef(M, PTy, ExpectFunction);
ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
return FwdVal;
}
@@ -4615,6 +4647,31 @@ bool LLParser::parseGlobalTypeAndValue(Constant *&V) {
return parseType(Ty) || parseGlobalValue(Ty, V);
}
+/// parsePersonality
+/// ::= TypeAndValue (expecting a function, null, undef, or poison)
+bool LLParser::parsePersonality(Function *&F) {
+ Type *Ty = nullptr;
+ if (parseType(Ty))
+ return true;
+ F = nullptr;
+ ValID ID;
+ Value *V = nullptr;
+ LocTy Loc = Lex.getLoc();
+ bool Parsed = parseValID(ID, /*PFS=*/nullptr, Ty) ||
+ convertValIDToValue(Ty, ID, V, nullptr, /*ExpectFunction=*/true);
+ if (Parsed)
+ return true;
+ if (!V)
+ return false;
+ // Allow null/zero/undef/poison constants and treat them as nullptr (no personality) for parsing legacy IR.
+ if (isa<ConstantPointerNull>(V) || isa<UndefValue>(V) ||
+ (isa<Constant>(V) && cast<Constant>(V)->isNullValue()))
+ return false;
+ if (!(F = dyn_cast<Function>(V)))
+ return error(Loc, "expected function");
+ return false;
+}
+
bool LLParser::parseOptionalComdat(StringRef GlobalName, Comdat *&C) {
C = nullptr;
@@ -6494,7 +6551,8 @@ bool LLParser::parseMetadata(Metadata *&MD, PerFunctionState *PFS) {
//===----------------------------------------------------------------------===//
bool LLParser::convertValIDToValue(Type *Ty, ValID &ID, Value *&V,
- PerFunctionState *PFS) {
+ PerFunctionState *PFS,
+ bool ExpectFunction) {
if (Ty->isFunctionTy())
return error(ID.Loc, "functions are not values, refer to them as pointers");
@@ -6520,12 +6578,12 @@ bool LLParser::convertValIDToValue(Type *Ty, ValID &ID, Value *&V,
return false;
}
case ValID::t_GlobalName:
- V = getGlobalVal(ID.StrVal, Ty, ID.Loc);
+ V = getGlobalVal(ID.StrVal, Ty, ID.Loc, ExpectFunction);
if (V && ID.NoCFI)
V = NoCFIValue::get(cast<GlobalValue>(V));
return V == nullptr;
case ValID::t_GlobalID:
- V = getGlobalVal(ID.UIntVal, Ty, ID.Loc);
+ V = getGlobalVal(ID.UIntVal, Ty, ID.Loc, ExpectFunction);
if (V && ID.NoCFI)
V = NoCFIValue::get(cast<GlobalValue>(V));
return V == nullptr;
@@ -6808,7 +6866,7 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine,
unsigned AddrSpace = 0;
Constant *Prefix = nullptr;
Constant *Prologue = nullptr;
- Constant *PersonalityFn = nullptr;
+ Function *PersonalityFn = nullptr;
Comdat *C;
if (parseArgumentList(ArgList, UnnamedArgNums, IsVarArg) ||
@@ -6824,7 +6882,7 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine,
(EatIfPresent(lltok::kw_prefix) && parseGlobalTypeAndValue(Prefix)) ||
(EatIfPresent(lltok::kw_prologue) && parseGlobalTypeAndValue(Prologue)) ||
(EatIfPresent(lltok::kw_personality) &&
- parseGlobalTypeAndValue(PersonalityFn)))
+ parsePersonality(PersonalityFn)))
return true;
if (FuncAttrs.contains(Attribute::Builtin))
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 34dcce92a8cdd..b3897b6eab1e8 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3193,7 +3193,24 @@ Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() {
Expected<Constant *> MaybeC = getValueForInitializer(ValID);
if (!MaybeC)
return MaybeC.takeError();
- Info.F->setPersonalityFn(MaybeC.get());
+ Constant *C = MaybeC.get();
+ // Old bitcode may have null/undef/poison as personality - treat as none.
+ // Also unwrap any ConstantExpr (bitcast, etc.) to get the underlying
+ // function.
+ if (!C->isNullValue() && !isa<UndefValue>(C)) {
+ C = C->stripPointerCasts();
+ if (!C->isNullValue() && !isa<UndefValue>(C)) {
+ Function *PersonalityFn = dyn_cast<Function>(C);
+ if (!PersonalityFn) {
+ // Warn and drop unsupported personality (e.g. alias, constant).
+ errs() << "warning: dropping unsupported personality for "
+ << Info.F->getName() << " (got "
+ << C->getNameOrAsOperand() << ")\n";
+ } else {
+ Info.F->setPersonalityFn(PersonalityFn);
+ }
+ }
+ }
Info.PersonalityFn = 0;
}
}
@@ -6204,9 +6221,12 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
nullptr))
return error("Invalid landingpad record");
+ Function *PersonalityFn = dyn_cast<Function>(PersFn);
+ if (!PersonalityFn)
+ return error("Personality function is not a Function");
if (!F->hasPersonalityFn())
- F->setPersonalityFn(cast<Constant>(PersFn));
- else if (F->getPersonalityFn() != cast<Constant>(PersFn))
+ F->setPersonalityFn(PersonalityFn);
+ else if (F->getPersonalityFn() != PersonalityFn)
return error("Personality function mismatch");
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/AIXException.cpp b/llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
index 873ac8f05c1e0..534ca879d8138 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
@@ -84,8 +84,7 @@ void AIXException::endFunction(const MachineFunction *MF) {
const Function &F = MF->getFunction();
assert(F.hasPersonalityFn() &&
"Landingpads are presented, but no personality routine is found.");
- const auto *Per =
- cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
+ const Function *Per = F.getPersonalityFn();
const MCSymbol *PerSym = Asm->TM.getSymbol(Per);
emitExceptionInfoTable(LSDALabel, PerSym);
diff --git a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp
index 51342c6b91345..705320ed47113 100644
--- a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp
@@ -58,9 +58,7 @@ void ARMException::markFunctionEnd() {
void ARMException::endFunction(const MachineFunction *MF) {
ARMTargetStreamer &ATS = getTargetStreamer();
const Function &F = MF->getFunction();
- const Function *Per = nullptr;
- if (F.hasPersonalityFn())
- Per = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ const Function *Per = F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr;
bool forceEmitPersonality =
F.hasPersonalityFn() && !isNoOpWithoutInvoke(classifyEHPersonality(Per)) &&
F.needsUnwindTableEntry();
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
index 6b8d08cb201d6..803a2f763700a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
@@ -69,9 +69,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
unsigned PerEncoding = TLOF.getPersonalityEncoding();
- const GlobalValue *Per = nullptr;
- if (F.hasPersonalityFn())
- Per = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
+ const Function *Per = F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr;
// Emit a personality function even when there are no landing pads
forceEmitPersonality =
@@ -124,8 +122,7 @@ void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) {
return;
auto &F = MBB.getParent()->getFunction();
- auto *P = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
- assert(P && "Expected personality function");
+ Function *P = F.getPersonalityFn();
// Record the personality function.
addPersonality(P);
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
index 13fd270ec7410..372e14166d494 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
@@ -77,7 +77,7 @@ void WinException::beginFunction(const MachineFunction *MF) {
EHPersonality Per = EHPersonality::Unknown;
const Function *PerFn = nullptr;
if (F.hasPersonalityFn()) {
- PerFn = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ PerFn = F.getPersonalityFn();
Per = classifyEHPersonality(PerFn);
}
@@ -128,7 +128,7 @@ void WinException::endFunction(const MachineFunction *MF) {
const Function &F = MF->getFunction();
EHPersonality Per = EHPersonality::Unknown;
if (F.hasPersonalityFn())
- Per = classifyEHPersonality(F.getPersonalityFn()->stripPointerCasts());
+ Per = classifyEHPersonality(F.getPersonalityFn());
endFuncletImpl();
@@ -223,7 +223,7 @@ void WinException::beginFunclet(const MachineBasicBlock &MBB,
// Determine which personality routine we are using for this funclet.
if (F.hasPersonalityFn())
- PerFn = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ PerFn = F.getPersonalityFn();
const MCSymbol *PersHandlerSym =
TLOF.getCFIPersonalitySymbol(PerFn, Asm->TM, MMI);
@@ -256,7 +256,7 @@ void WinException::endFuncletImpl() {
const Function &F = MF->getFunction();
EHPersonality Per = EHPersonality::Unknown;
if (F.hasPersonalityFn())
- Per = classifyEHPersonality(F.getPersonalityFn()->stripPointerCasts());
+ Per = classifyEHPersonality(F.getPersonalityFn());
if (Per == EHPersonality::MSVC_CXX && shouldEmitPersonality &&
!CurrentFuncletEntry->isCleanupFuncletEntry()) {
@@ -999,7 +999,7 @@ void WinException::emitExceptHandlerTable(const MachineFunction *MF) {
OS.emitValueToAlignment(Align(4));
OS.emitLabel(LSDALabel);
- const auto *Per = cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ const Function *Per = F.getPersonalityFn();
StringRef PerName = Per->getName();
int BaseState = -1;
if (PerName == "_except_handler4") {
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 63ca973bc224e..ef1aaa20194a4 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -3125,7 +3125,7 @@ bool IRTranslator::translateLandingPad(const User &U,
// If there aren't registers to copy the values into (e.g., during SjLj
// exceptions), then don't bother.
- const Constant *PersonalityFn = MF->getFunction().getPersonalityFn();
+ const Function *PersonalityFn = MF->getFunction().getPersonalityFn();
if (TLI->getExceptionPointerRegister(PersonalityFn) == 0 &&
TLI->getExceptionSelectorRegister(PersonalityFn) == 0)
return true;
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 52760a39ca133..1d62550496374 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -623,7 +623,7 @@ void MachineLICMImpl::HoistRegionPostRA(MachineLoop *CurLoop) {
// EH landing pads clobber exception pointer/selector registers.
if (BB->isEHPad()) {
const MachineFunction &MF = *BB->getParent();
- const Constant *PersonalityFn = MF.getFunction().getPersonalityFn();
+ const Function *PersonalityFn = MF.getFunction().getPersonalityFn();
const TargetLowering &TLI = *MF.getSubtarget().getTargetLowering();
if (MCRegister Reg = TLI.getExceptionPointerRegister(PersonalityFn))
for (MCRegUnit Unit : TRI->regunits(Reg))
diff --git a/llvm/lib/CodeGen/RDFGraph.cpp b/llvm/lib/CodeGen/RDFGraph.cpp
index 7e7407e117dee..850a72e5b25f8 100644
--- a/llvm/lib/CodeGen/RDFGraph.cpp
+++ b/llvm/lib/CodeGen/RDFGraph.cpp
@@ -743,7 +743,7 @@ unsigned DataFlowGraph::DefStack::nextDown(unsigned P) const {
RegisterAggr DataFlowGraph::getLandingPadLiveIns() const {
RegisterAggr LR(getPRI());
const Function &F = MF.getFunction();
- const Constant *PF = F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr;
+ const Function *PF = F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr;
const TargetLowering &TLI = *MF.getSubtarget().getTargetLowering();
if (RegisterId R = TLI.getExceptionPointerRegister(PF))
LR.insert(RegisterRef(R));
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 5e943472ef6ba..d71c41536c2c8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3593,7 +3593,7 @@ void SelectionDAGBuilder::visitLandingPad(const LandingPadInst &LP) {
// If there aren't registers to copy the values into (e.g., during SjLj
// exceptions), then don't bother to create these DAG nodes.
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
- const Constant *PersonalityFn = FuncInfo.Fn->getPersonalityFn();
+ const Function *PersonalityFn = FuncInfo.Fn->getPersonalityFn();
if (TLI.getExceptionPointerRegister(PersonalityFn) == 0 &&
TLI.getExceptionSelectorRegister(PersonalityFn) == 0)
return;
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index b2b8c6692bf94..eeede1ab8756a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1440,7 +1440,7 @@ static void mapWasmLandingPadIndex(MachineBasicBlock *MBB,
/// do other setup for EH landing-pad blocks.
bool SelectionDAGISel::PrepareEHLandingPad() {
MachineBasicBlock *MBB = FuncInfo->MBB;
- const Constant *PersonalityFn = FuncInfo->Fn->getPersonalityFn();
+ const Function *PersonalityFn = FuncInfo->Fn->getPersonalityFn();
const BasicBlock *LLVMBB = MBB->getBasicBlock();
const TargetRegisterClass *PtrRC =
TLI->getRegClassFor(TLI->getPointerTy(CurDAG->getDataLayout()));
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index b29543a8e5901..898d131d7bae6 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2356,9 +2356,7 @@ bool TargetLoweringObjectFileXCOFF::ShouldEmitEHBlock(
if (!F.hasPersonalityFn() || !F.needsUnwindTableEntry())
return false;
- const GlobalValue *Per =
- dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
- assert(Per && "Personality routine is not a GlobalValue type.");
+ const Function *Per = F.getPersonalityFn();
if (isNoOpWithoutInvoke(classifyEHPersonality(Per)))
return false;
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index d31322a3013b6..2ffd8daf44338 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -2472,7 +2472,7 @@ LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn) {
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn) {
unwrap<Function>(Fn)->setPersonalityFn(
- PersonalityFn ? unwrap<Constant>(PersonalityFn) : nullptr);
+ PersonalityFn ? unwrap<Function>(PersonalityFn) : nullptr);
}
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn) {
diff --git a/llvm/lib/IR/EHPersonalities.cpp b/llvm/lib/IR/EHPersonalities.cpp
index 12ae4748e1f4a..2e9393cb99202 100644
--- a/llvm/lib/IR/EHPersonalities.cpp
+++ b/llvm/lib/IR/EHPersonalities.cpp
@@ -20,14 +20,12 @@ using namespace llvm;
/// See if the given exception handling personality function is one that we
/// understand. If so, return a description of it; otherwise return Unknown.
-EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
- const GlobalValue *F =
- Pers ? dyn_cast<GlobalValue>(Pers->stripPointerCasts()) : nullptr;
- if (!F || !F->getValueType() || !F->getValueType()->isFunctionTy())
+EHPersonality llvm::classifyEHPersonality(const Function *Pers) {
+ if (!Pers)
return EHPersonality::Unknown;
- StringRef Name = F->getName();
- if (F->getParent()->getTargetTriple().isWindowsArm64EC()) {
+ StringRef Name = Pers->getName();
+ if (Pers->getParent()->getTargetTriple().isWindowsArm64EC()) {
// ARM64EC function symbols are mangled by prefixing them with "#".
// Demangle them by skipping this prefix.
Name.consume_front("#");
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 31a294447152e..75b7d46d98c11 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1036,12 +1036,12 @@ bool Function::callsFunctionThatReturnsTwice() const {
return false;
}
-Constant *Function::getPersonalityFn() const {
+Function *Function::getPersonalityFn() const {
assert(hasPersonalityFn() && getNumOperands());
- return cast<Constant>(Op<0>());
+ return cast<Function>(Op<0>());
}
-void Function::setPersonalityFn(Constant *Fn) {
+void Function::setPersonalityFn(Function *Fn) {
setHungoffOperand<0>(Fn);
setValueSubclassDataBit(3, Fn != nullptr);
}
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 92e90384c7aab..71fce479d0bce 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -3198,11 +3198,10 @@ void Verifier::visitFunction(const Function &F) {
// Check validity of the personality function
if (F.hasPersonalityFn()) {
- auto *Per = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
- if (Per)
- Check(Per->getParent() == F.getParent(),
- "Referencing personality function in another module!", &F,
- F.getParent(), Per, Per->getParent());
+ Function *Per = F.getPersonalityFn();
+ Check(Per->getParent() == F.getParent(),
+ "Referencing personality function in another module!", &F,
+ F.getParent(), Per, Per->getParent());
}
// EH funclet coloring can be expensive, recompute on-demand
diff --git a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
index c27a693ceecc1..2c87caa93e812 100644
--- a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
@@ -830,13 +830,10 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
for (Function &F : Mod) {
if (F.hasPersonalityFn()) {
- GlobalValue *PersFn =
- cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
- if (PersFn->getValueType() && PersFn->getValueType()->isFunctionTy()) {
- if (std::optional<std::string> MangledName =
- getArm64ECMangledFunctionName(*PersFn)) {
- PersFn->setName(MangledName.value());
- }
+ Function *PersFn = F.getPersonalityFn();
+ if (std::optional<std::string> MangledName =
+ getArm64ECMangledFunctionName(*PersFn)) {
+ PersFn->setName(MangledName.value());
}
}
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index d550dbaf40a4d..4e02a39330ebc 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -30143,7 +30143,7 @@ AArch64TargetLowering::getSafeStackPointerLocation(IRBuilderBase &IRB) const {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register AArch64TargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
// FIXME: This is a guess. Has this been defined yet?
return AArch64::X0;
}
@@ -30151,7 +30151,7 @@ Register AArch64TargetLowering::getExceptionPointerRegister(
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register AArch64TargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
// FIXME: This is a guess. Has this been defined yet?
return AArch64::X1;
}
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
index 1bf36559edd27..1ffc843636d08 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -379,12 +379,12 @@ class AArch64TargetLowering : public TargetLowering {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
bool isIntDivCheap(EVT VT, AttributeList Attr) const override;
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 07d90422cb4ca..d39b96086d11f 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -21722,7 +21722,7 @@ bool ARMTargetLowering::functionArgumentNeedsConsecutiveRegisters(
}
Register ARMTargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
// Platforms which do not use SjLj EH may return values in these registers
// via the personality function.
ExceptionHandling EM = getTargetMachine().getExceptionModel();
@@ -21730,7 +21730,7 @@ Register ARMTargetLowering::getExceptionPointerRegister(
}
Register ARMTargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
// Platforms which do not use SjLj EH may return values in these registers
// via the personality function.
ExceptionHandling EM = getTargetMachine().getExceptionModel();
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.h b/llvm/lib/Target/ARM/ARMISelLowering.h
index 96d08cc89a6eb..95faae314f3f4 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.h
+++ b/llvm/lib/Target/ARM/ARMISelLowering.h
@@ -348,12 +348,12 @@ class VectorType;
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
Instruction *makeDMB(IRBuilderBase &Builder, ARM_MB::MemBOpt Domain) const;
Value *emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy, Value *Addr,
diff --git a/llvm/lib/Target/CSKY/CSKYISelLowering.cpp b/llvm/lib/Target/CSKY/CSKYISelLowering.cpp
index 09b91240907f9..142bfc4ab2991 100644
--- a/llvm/lib/Target/CSKY/CSKYISelLowering.cpp
+++ b/llvm/lib/Target/CSKY/CSKYISelLowering.cpp
@@ -1224,12 +1224,12 @@ SDValue CSKYTargetLowering::LowerRETURNADDR(SDValue Op,
}
Register CSKYTargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return CSKY::R0;
}
Register CSKYTargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return CSKY::R1;
}
diff --git a/llvm/lib/Target/CSKY/CSKYISelLowering.h b/llvm/lib/Target/CSKY/CSKYISelLowering.h
index 94b63939fc0c3..3deb9ac81f471 100644
--- a/llvm/lib/Target/CSKY/CSKYISelLowering.h
+++ b/llvm/lib/Target/CSKY/CSKYISelLowering.h
@@ -57,12 +57,12 @@ class CSKYTargetLowering : public TargetLowering {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
bool isSelectSupported(SelectSupportKind Kind) const override {
// CSKY does not support scalar condition selects on vectors.
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.h b/llvm/lib/Target/Hexagon/HexagonISelLowering.h
index d576de4049e6b..a3b7cb8dfcee0 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.h
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.h
@@ -187,14 +187,14 @@ class HexagonTargetLowering : public TargetLowering {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override {
+ getExceptionPointerRegister(const Function *PersonalityFn) const override {
return Hexagon::R0;
}
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override {
return Hexagon::R1;
}
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 0de861ec39ccf..27e5d40f4a9f3 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -9303,12 +9303,12 @@ bool LoongArchTargetLowering::isFMAFasterThanFMulAndFAdd(
}
Register LoongArchTargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return LoongArch::R4;
}
Register LoongArchTargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return LoongArch::R5;
}
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
index 74d2b7dff0db5..dbea61cbb5035 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
@@ -86,10 +86,10 @@ class LoongArchTargetLowering : public TargetLowering {
EVT VT) const override;
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
bool isFsqrtCheap(SDValue Operand, SelectionDAG &DAG) const override {
return true;
diff --git a/llvm/lib/Target/M68k/M68kISelLowering.cpp b/llvm/lib/Target/M68k/M68kISelLowering.cpp
index 33a6bdc10a5b1..8accadac0bb23 100644
--- a/llvm/lib/Target/M68k/M68kISelLowering.cpp
+++ b/llvm/lib/Target/M68k/M68kISelLowering.cpp
@@ -198,12 +198,12 @@ M68kTargetLowering::shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const {
}
Register
-M68kTargetLowering::getExceptionPointerRegister(const Constant *) const {
+M68kTargetLowering::getExceptionPointerRegister(const Function *) const {
return M68k::D0;
}
Register
-M68kTargetLowering::getExceptionSelectorRegister(const Constant *) const {
+M68kTargetLowering::getExceptionSelectorRegister(const Function *) const {
return M68k::D1;
}
diff --git a/llvm/lib/Target/M68k/M68kISelLowering.h b/llvm/lib/Target/M68k/M68kISelLowering.h
index cbb5c92f49b4c..50cd78a98f384 100644
--- a/llvm/lib/Target/M68k/M68kISelLowering.h
+++ b/llvm/lib/Target/M68k/M68kISelLowering.h
@@ -107,12 +107,12 @@ class M68kTargetLowering : public TargetLowering {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
InlineAsm::ConstraintCode
getInlineAsmMemConstraint(StringRef ConstraintCode) const override;
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.h b/llvm/lib/Target/Mips/MipsISelLowering.h
index 8302835a3ae9f..d37855c012f4f 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.h
+++ b/llvm/lib/Target/Mips/MipsISelLowering.h
@@ -141,14 +141,14 @@ class TargetRegisterClass;
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override {
+ getExceptionPointerRegister(const Function *PersonalityFn) const override {
return ABI.IsN64() ? Mips::A0_64 : Mips::A0;
}
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override {
return ABI.IsN64() ? Mips::A1_64 : Mips::A1;
}
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index ac70eca8f9781..ad1fc6ca29312 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -18998,12 +18998,12 @@ PPCTargetLowering::getScratchRegisters(CallingConv::ID) const {
}
Register PPCTargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return Subtarget.isPPC64() ? PPC::X3 : PPC::R3;
}
Register PPCTargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return Subtarget.isPPC64() ? PPC::X4 : PPC::R4;
}
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.h b/llvm/lib/Target/PowerPC/PPCISelLowering.h
index fe883eacb44c4..ab2768d0d9b87 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.h
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.h
@@ -556,12 +556,12 @@ namespace llvm {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
/// Override to support customized stack guard loading.
bool useLoadStackGuardNode(const Module &M) const override;
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 5427bcfe8eef8..d33f6ed46a7fa 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -25348,12 +25348,12 @@ ISD::NodeType RISCVTargetLowering::getExtendForAtomicRMWArg(unsigned Op) const {
}
Register RISCVTargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return RISCV::X10;
}
Register RISCVTargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return RISCV::X11;
}
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index cbf3afd72311c..056e83b79438a 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -260,12 +260,12 @@ class RISCVTargetLowering : public TargetLowering {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
bool shouldExtendTypeInLibCall(EVT Type) const override;
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;
diff --git a/llvm/lib/Target/Sparc/SparcISelLowering.h b/llvm/lib/Target/Sparc/SparcISelLowering.h
index f97b0ab9edd93..4406260543826 100644
--- a/llvm/lib/Target/Sparc/SparcISelLowering.h
+++ b/llvm/lib/Target/Sparc/SparcISelLowering.h
@@ -64,14 +64,14 @@ namespace llvm {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override {
+ getExceptionPointerRegister(const Function *PersonalityFn) const override {
return SP::I0;
}
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override {
return SP::I1;
}
diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
index a5fe29095503b..44a57d7f5788d 100644
--- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -1551,8 +1551,7 @@ void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) {
// Emit C++ EH information block
const Function *Per = nullptr;
if (NeedEmitEHBlock) {
- Per = dyn_cast<Function>(
- MF->getFunction().getPersonalityFn()->stripPointerCasts());
+ Per = MF->getFunction().getPersonalityFn();
MCSymbol *PersonalityRoutine =
Per ? MF->getTarget().getSymbol(Per) : nullptr;
assert(PersonalityRoutine && "Missing personality routine");
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index bf9db80c6b0bc..8e5422b8992db 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -1738,12 +1738,12 @@ SystemZTargetLowering::getRegisterByName(const char *RegName, LLT VT,
}
Register SystemZTargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return Subtarget.isTargetXPLINK64() ? SystemZ::R1D : SystemZ::R6D;
}
Register SystemZTargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
return Subtarget.isTargetXPLINK64() ? SystemZ::R2D : SystemZ::R7D;
}
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.h b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
index 889949f9f9440..8403b9ff2bf03 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.h
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
@@ -211,12 +211,12 @@ class SystemZTargetLowering : public TargetLowering {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
/// Override to support customized stack guard loading.
bool useLoadStackGuardNode(const Module &M) const override { return true; }
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index c3990d12f2c28..fbd4eb9adf4bb 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -1597,9 +1597,8 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
StringRef PersName = getEHPersonalityName(EHPersonality::Wasm_CXX);
FunctionType *PersType =
FunctionType::get(IRB.getInt32Ty(), /* isVarArg */ true);
- Value *PersF = M.getOrInsertFunction(PersName, PersType).getCallee();
- F.setPersonalityFn(
- cast<Constant>(IRB.CreateBitCast(PersF, IRB.getPtrTy())));
+ FunctionCallee PersFC = M.getOrInsertFunction(PersName, PersType);
+ F.setPersonalityFn(cast<Function>(PersFC.getCallee()));
}
// Use the entry BB's debugloc as a fallback
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 20330acdc8be5..24ae16b626c15 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -28635,7 +28635,7 @@ SDValue X86TargetLowering::LowerFRAME_TO_ARGS_OFFSET(SDValue Op,
}
Register X86TargetLowering::getExceptionPointerRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
if (classifyEHPersonality(PersonalityFn) == EHPersonality::CoreCLR)
return Subtarget.isTarget64BitLP64() ? X86::RDX : X86::EDX;
@@ -28643,7 +28643,7 @@ Register X86TargetLowering::getExceptionPointerRegister(
}
Register X86TargetLowering::getExceptionSelectorRegister(
- const Constant *PersonalityFn) const {
+ const Function *PersonalityFn) const {
// Funclet personalities don't use selectors (the runtime does the selection).
if (isFuncletEHPersonality(classifyEHPersonality(PersonalityFn)))
return X86::NoRegister;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h
index 8881dc3ea1912..bf8973eb3f289 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.h
+++ b/llvm/lib/Target/X86/X86ISelLowering.h
@@ -1600,12 +1600,12 @@ namespace llvm {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+ getExceptionPointerRegister(const Function *PersonalityFn) const override;
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override;
bool needsFixedCatchObjects() const override;
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index b568f1b4086ed..87d66407350f6 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -158,9 +158,7 @@ bool WinEHStatePass::runOnFunction(Function &F) {
// Check the personality. Do nothing if this personality doesn't use funclets.
if (!F.hasPersonalityFn())
return false;
- PersonalityFn = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
- if (!PersonalityFn)
- return false;
+ PersonalityFn = F.getPersonalityFn();
Personality = classifyEHPersonality(PersonalityFn);
if (!isFuncletEHPersonality(Personality))
return false;
diff --git a/llvm/lib/Target/XCore/XCoreFrameLowering.cpp b/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
index 351a221c92ebd..64c00f663e0df 100644
--- a/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
+++ b/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
@@ -157,7 +157,7 @@ static void GetSpillList(SmallVectorImpl<StackSlotInfo> &SpillList,
/// As offsets are negative, the largest offsets will be first.
static void GetEHSpillList(SmallVectorImpl<StackSlotInfo> &SpillList,
MachineFrameInfo &MFI, XCoreFunctionInfo *XFI,
- const Constant *PersonalityFn,
+ const Function *PersonalityFn,
const TargetLowering *TL) {
assert(XFI->hasEHSpillSlot() && "There are no EH register spill slots");
const int *EHSlot = XFI->getEHSpillSlot();
@@ -321,7 +321,7 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF,
// The unwinder requires stack slot & CFI offsets for the exception info.
// We do not save/spill these registers.
const Function *Fn = &MF.getFunction();
- const Constant *PersonalityFn =
+ const Function *PersonalityFn =
Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr;
SmallVector<StackSlotInfo, 2> SpillList;
GetEHSpillList(SpillList, MFI, XFI, PersonalityFn,
@@ -356,7 +356,7 @@ void XCoreFrameLowering::emitEpilogue(MachineFunction &MF,
// 'Restore' the exception info the unwinder has placed into the stack
// slots.
const Function *Fn = &MF.getFunction();
- const Constant *PersonalityFn =
+ const Function *PersonalityFn =
Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr;
SmallVector<StackSlotInfo, 2> SpillList;
GetEHSpillList(SpillList, MFI, XFI, PersonalityFn,
diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.h b/llvm/lib/Target/XCore/XCoreISelLowering.h
index bad6588cad740..fd2ffc74ec9aa 100644
--- a/llvm/lib/Target/XCore/XCoreISelLowering.h
+++ b/llvm/lib/Target/XCore/XCoreISelLowering.h
@@ -61,14 +61,14 @@ namespace llvm {
/// If a physical register, this returns the register that receives the
/// exception address on entry to an EH pad.
Register
- getExceptionPointerRegister(const Constant *PersonalityFn) const override {
+ getExceptionPointerRegister(const Function *PersonalityFn) const override {
return XCore::R0;
}
/// If a physical register, this returns the register that receives the
/// exception typeid on entry to a landing pad.
Register
- getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
+ getExceptionSelectorRegister(const Function *PersonalityFn) const override {
return XCore::R1;
}
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 7f63bf6b4941f..ace3f98d8fcc9 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -1557,20 +1557,18 @@ bool DataFlowSanitizer::runImpl(
std::vector<Function *> FnsToInstrument;
SmallPtrSet<Function *, 2> FnsWithNativeABI;
SmallPtrSet<Function *, 2> FnsWithForceZeroLabel;
- SmallPtrSet<Constant *, 1> PersonalityFns;
+ SmallPtrSet<Function *, 1> PersonalityFns;
for (Function &F : M)
if (!F.isIntrinsic() && !DFSanRuntimeFunctions.contains(&F) &&
!LibAtomicFunction(F) &&
!F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation)) {
FnsToInstrument.push_back(&F);
if (F.hasPersonalityFn())
- PersonalityFns.insert(F.getPersonalityFn()->stripPointerCasts());
+ PersonalityFns.insert(F.getPersonalityFn());
}
if (ClIgnorePersonalityRoutine) {
- for (auto *C : PersonalityFns) {
- assert(isa<Function>(C) && "Personality routine is not a function!");
- Function *F = cast<Function>(C);
+ for (Function *F : PersonalityFns) {
if (!isInstrumented(F))
llvm::erase(FnsToInstrument, F);
}
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 832592e7663b2..179fae5460e25 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1829,13 +1829,13 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
// function that has a personality function or that can be unwound past has
// its personality function changed to a thunk that calls the personality
// function wrapper in the runtime.
- MapVector<Constant *, std::vector<Function *>> PersonalityFns;
+ MapVector<Function *, std::vector<Function *>> PersonalityFns;
for (Function &F : M) {
if (F.isDeclaration() || !F.hasFnAttribute(Attribute::SanitizeHWAddress))
continue;
if (F.hasPersonalityFn()) {
- PersonalityFns[F.getPersonalityFn()->stripPointerCasts()].push_back(&F);
+ PersonalityFns[F.getPersonalityFn()].push_back(&F);
} else if (!F.hasFnAttribute(Attribute::NoUnwind)) {
PersonalityFns[nullptr].push_back(&F);
}
@@ -1856,8 +1856,7 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
ThunkName += ("." + P.first->getName()).str();
FunctionType *ThunkFnTy = FunctionType::get(
Int32Ty, {Int32Ty, Int32Ty, Int64Ty, PtrTy, PtrTy}, false);
- bool IsLocal = P.first && (!isa<GlobalValue>(P.first) ||
- cast<GlobalValue>(P.first)->hasLocalLinkage());
+ bool IsLocal = P.first && P.first->hasLocalLinkage();
auto *ThunkFn = Function::Create(ThunkFnTy,
IsLocal ? GlobalValue::InternalLinkage
: GlobalValue::LinkOnceODRLinkage,
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 260dc3a12df43..dd46b14d043e4 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -171,9 +171,9 @@ void llvm::CloneFunctionAttributesInto(Function *NewFunc,
// Fix up the personality function that got copied over.
if (OldFunc->hasPersonalityFn())
- NewFunc->setPersonalityFn(MapValue(OldFunc->getPersonalityFn(), VMap,
- FuncGlobalRefFlags, TypeMapper,
- Materializer));
+ NewFunc->setPersonalityFn(
+ cast<Function>(MapValue(OldFunc->getPersonalityFn(), VMap,
+ FuncGlobalRefFlags, TypeMapper, Materializer)));
if (OldFunc->hasPrefixData()) {
NewFunc->setPrefixData(MapValue(OldFunc->getPrefixData(), VMap,
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp
index ae6234c1349d6..6a51b20cd0c81 100644
--- a/llvm/lib/Transforms/Utils/CloneModule.cpp
+++ b/llvm/lib/Transforms/Utils/CloneModule.cpp
@@ -158,7 +158,8 @@ std::unique_ptr<Module> llvm::CloneModule(
Returns);
if (I.hasPersonalityFn())
- F->setPersonalityFn(MapValue(I.getPersonalityFn(), VMap));
+ F->setPersonalityFn(
+ cast<Function>(MapValue(I.getPersonalityFn(), VMap)));
copyComdat(F, &I);
}
diff --git a/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp b/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
index bafaf6feaaee6..95b4cf35df153 100644
--- a/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
+++ b/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
@@ -19,12 +19,14 @@
using namespace llvm;
-static FunctionCallee getDefaultPersonalityFn(Module *M) {
+static Function *getDefaultPersonalityFn(Module *M) {
LLVMContext &C = M->getContext();
Triple T(M->getTargetTriple());
EHPersonality Pers = getDefaultEHPersonality(T);
- return M->getOrInsertFunction(getEHPersonalityName(Pers),
- FunctionType::get(Type::getInt32Ty(C), true));
+ return cast<Function>(
+ M->getOrInsertFunction(getEHPersonalityName(Pers),
+ FunctionType::get(Type::getInt32Ty(C), true))
+ .getCallee());
}
IRBuilder<> *EscapeEnumerator::Next() {
@@ -72,8 +74,7 @@ IRBuilder<> *EscapeEnumerator::Next() {
BasicBlock *CleanupBB = BasicBlock::Create(C, CleanupBBName, &F);
Type *ExnTy = StructType::get(PointerType::getUnqual(C), Type::getInt32Ty(C));
if (!F.hasPersonalityFn()) {
- FunctionCallee PersFn = getDefaultPersonalityFn(F.getParent());
- F.setPersonalityFn(cast<Constant>(PersFn.getCallee()));
+ F.setPersonalityFn(getDefaultPersonalityFn(F.getParent()));
}
if (isScopedEHPersonality(classifyEHPersonality(F.getPersonalityFn()))) {
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index aa902f687d8aa..95e4eea6deeb0 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2525,18 +2525,14 @@ llvm::InlineResult llvm::CanInlineCallSite(const CallBase &CB,
}
// Get the personality function from the callee if it contains a landing pad.
- Constant *CalledPersonality =
- CalledFunc->hasPersonalityFn()
- ? CalledFunc->getPersonalityFn()->stripPointerCasts()
- : nullptr;
+ Function *CalledPersonality =
+ CalledFunc->hasPersonalityFn() ? CalledFunc->getPersonalityFn() : nullptr;
// Find the personality function used by the landing pads of the caller. If it
// exists, then check to see that it matches the personality function used in
// the callee.
- Constant *CallerPersonality =
- Caller->hasPersonalityFn()
- ? Caller->getPersonalityFn()->stripPointerCasts()
- : nullptr;
+ Function *CallerPersonality =
+ Caller->hasPersonalityFn() ? Caller->getPersonalityFn() : nullptr;
if (CalledPersonality) {
// If the personality functions match, then we can perform the
// inlining. Otherwise, we can't inline.
@@ -2640,13 +2636,11 @@ void llvm::InlineFunctionImpl(CallBase &CB, InlineFunctionInfo &IFI,
}
if (CalledFunc->hasPersonalityFn()) {
- Constant *CalledPersonality =
- CalledFunc->getPersonalityFn()->stripPointerCasts();
+ Function *CalledPersonality = CalledFunc->getPersonalityFn();
if (!Caller->hasPersonalityFn()) {
Caller->setPersonalityFn(CalledPersonality);
} else
- assert(Caller->getPersonalityFn()->stripPointerCasts() ==
- CalledPersonality &&
+ assert(Caller->getPersonalityFn() == CalledPersonality &&
"CanInlineCallSite should have verified compatible personality");
}
diff --git a/llvm/test/Analysis/BlockFrequencyInfo/loop_with_invoke.ll b/llvm/test/Analysis/BlockFrequencyInfo/loop_with_invoke.ll
index 5137860006dd0..951362f2ca1bf 100644
--- a/llvm/test/Analysis/BlockFrequencyInfo/loop_with_invoke.ll
+++ b/llvm/test/Analysis/BlockFrequencyInfo/loop_with_invoke.ll
@@ -2,7 +2,7 @@
; CHECK-LABEL: Printing analysis {{.*}} for function 'loop_with_invoke':
; CHECK-NEXT: block-frequency-info: loop_with_invoke
-define void @loop_with_invoke(i32 %n) personality i8 0 {
+define void @loop_with_invoke(i32 %n) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
entry:
br label %loop
@@ -29,6 +29,7 @@ exit:
ret void
}
+declare i32 @__gxx_personality_v0(...)
declare void @foo()
!0 = !{!"branch_weights", i32 9999, i32 1}
diff --git a/llvm/test/Analysis/BranchProbabilityInfo/loop.ll b/llvm/test/Analysis/BranchProbabilityInfo/loop.ll
index ffac1cd466641..03236c68b60ea 100644
--- a/llvm/test/Analysis/BranchProbabilityInfo/loop.ll
+++ b/llvm/test/Analysis/BranchProbabilityInfo/loop.ll
@@ -1,6 +1,7 @@
; Test the static branch probability heuristics for no-return functions.
; RUN: opt < %s -passes='print<branch-prob>' --disable-output 2>&1 | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @g1()
declare void @g2()
declare void @g3()
@@ -490,7 +491,7 @@ for.inc:
; The loop heuristic should not overwrite the invoke heuristic. The unwind destination
; of an invoke should be considered VERY rare even in a loop.
-define void @test12(i32 %a) personality i8 0 {
+define void @test12(i32 %a) personality ptr @__gxx_personality_v0 {
entry:
br label %loop
; CHECK: edge %entry -> %loop probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
diff --git a/llvm/test/Analysis/CallGraph/do-nothing-intrinsic.ll b/llvm/test/Analysis/CallGraph/do-nothing-intrinsic.ll
index fc2c541736e7b..05c715b8f87bb 100644
--- a/llvm/test/Analysis/CallGraph/do-nothing-intrinsic.ll
+++ b/llvm/test/Analysis/CallGraph/do-nothing-intrinsic.ll
@@ -1,7 +1,7 @@
; RUN: opt < %s -passes='require<callgraph>'
; PR13903
-define void @main() personality i8 0 {
+define void @main() personality ptr @__gxx_personality_v0 {
invoke void @llvm.donothing()
to label %ret unwind label %unw
unw:
@@ -10,4 +10,5 @@ unw:
ret:
ret void
}
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.donothing() nounwind readnone
diff --git a/llvm/test/Analysis/ScalarEvolution/backedge-taken-count-guard-info-with-multiple-predecessors.ll b/llvm/test/Analysis/ScalarEvolution/backedge-taken-count-guard-info-with-multiple-predecessors.ll
index 564ce6b7d622f..4ecb4298a5a87 100644
--- a/llvm/test/Analysis/ScalarEvolution/backedge-taken-count-guard-info-with-multiple-predecessors.ll
+++ b/llvm/test/Analysis/ScalarEvolution/backedge-taken-count-guard-info-with-multiple-predecessors.ll
@@ -1,5 +1,7 @@
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-max-iterations=0 -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
+
define void @slt(i16 %a, i16 %b, i1 %c) {
; CHECK-LABEL: 'slt'
; CHECK-NEXT: Determining loop execution counts for: @slt
@@ -365,7 +367,7 @@ exit:
ret void
}
-define void @hang_due_to_unreachable_phi_inblock() personality ptr null {
+define void @hang_due_to_unreachable_phi_inblock() personality ptr @__gxx_personality_v0 {
bb:
br label %bb6
diff --git a/llvm/test/Assembler/function-operand-uselistorder.ll b/llvm/test/Assembler/function-operand-uselistorder.ll
index d3f020e84b33e..12862827d6aad 100644
--- a/llvm/test/Assembler/function-operand-uselistorder.ll
+++ b/llvm/test/Assembler/function-operand-uselistorder.ll
@@ -1,11 +1,12 @@
; RUN: verify-uselistorder %s
@g = global i8 0
+declare i32 @__gxx_personality_v0(...)
-define void @f1() prefix ptr @g prologue ptr @g personality ptr @g {
+define void @f1() prefix ptr @g prologue ptr @g personality ptr @__gxx_personality_v0 {
ret void
}
-define void @f2() prefix ptr @g prologue ptr @g personality ptr @g {
+define void @f2() prefix ptr @g prologue ptr @g personality ptr @__gxx_personality_v0 {
ret void
}
diff --git a/llvm/test/Assembler/personality-alias.ll b/llvm/test/Assembler/personality-alias.ll
new file mode 100644
index 0000000000000..aba001e46e5a7
--- /dev/null
+++ b/llvm/test/Assembler/personality-alias.ll
@@ -0,0 +1,20 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+; Test that using an alias as personality is rejected.
+
+; CHECK: expected function
+
+declare i32 @real_personality(...)
+
+ at personality_alias = alias i32 (...), ptr @real_personality
+
+define void @test() personality ptr @personality_alias {
+entry:
+ invoke void @may_throw() to label %cont unwind label %lpad
+cont:
+ ret void
+lpad:
+ %lp = landingpad { ptr, i32 } cleanup
+ ret void
+}
+
+declare void @may_throw()
diff --git a/llvm/test/Assembler/personality-constant.ll b/llvm/test/Assembler/personality-constant.ll
new file mode 100644
index 0000000000000..b0ae3a575ee08
--- /dev/null
+++ b/llvm/test/Assembler/personality-constant.ll
@@ -0,0 +1,16 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+; Test that constant integer as personality is rejected.
+
+; CHECK: expected function
+
+define void @test() personality i32 42 {
+entry:
+ invoke void @may_throw() to label %cont unwind label %lpad
+cont:
+ ret void
+lpad:
+ %lp = landingpad { ptr, i32 } cleanup
+ ret void
+}
+
+declare void @may_throw()
diff --git a/llvm/test/Assembler/personality-forward-ref-not-function.ll b/llvm/test/Assembler/personality-forward-ref-not-function.ll
new file mode 100644
index 0000000000000..40358570cce2c
--- /dev/null
+++ b/llvm/test/Assembler/personality-forward-ref-not-function.ll
@@ -0,0 +1,20 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+; Test that forward reference used as personality, then declared as global variable, fails.
+
+; CHECK: forward reference used as personality must be a function
+
+; Use @notfunc as personality first (forward reference)
+define void @test() personality ptr @notfunc {
+entry:
+ invoke void @may_throw() to label %cont unwind label %lpad
+cont:
+ ret void
+lpad:
+ %lp = landingpad { ptr, i32 } cleanup
+ ret void
+}
+
+; Then declare @notfunc as a global variable (not a function)
+ at notfunc = global i32 42
+
+declare void @may_throw()
diff --git a/llvm/test/Assembler/personality-forward-ref.ll b/llvm/test/Assembler/personality-forward-ref.ll
new file mode 100644
index 0000000000000..93e1f395788ee
--- /dev/null
+++ b/llvm/test/Assembler/personality-forward-ref.ll
@@ -0,0 +1,26 @@
+; RUN: llvm-as %s -o /dev/null
+; RUN: verify-uselistorder %s
+; Test that forward references to personality functions work correctly.
+
+; Use @personality in a generic pointer context first (call argument)
+define void @use_as_ptr() {
+ call void @take_ptr(ptr @personality)
+ ret void
+}
+
+; Then use @personality as a personality function
+define void @use_as_personality() personality ptr @personality {
+entry:
+ invoke void @may_throw() to label %cont unwind label %lpad
+cont:
+ ret void
+lpad:
+ %lp = landingpad { ptr, i32 } cleanup
+ ret void
+}
+
+; Finally declare @personality as a function
+declare i32 @personality(...)
+
+declare void @take_ptr(ptr)
+declare void @may_throw()
diff --git a/llvm/test/Assembler/personality-generic-then-not-function.ll b/llvm/test/Assembler/personality-generic-then-not-function.ll
new file mode 100644
index 0000000000000..b6995e857eded
--- /dev/null
+++ b/llvm/test/Assembler/personality-generic-then-not-function.ll
@@ -0,0 +1,28 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+; Test that value used in generic context, then as personality, then declared
+; as global variable, correctly fails.
+
+; CHECK: forward reference used as personality must be a function
+
+; Use @val in generic pointer context first
+define void @use_generic() {
+ call void @take_ptr(ptr @val)
+ ret void
+}
+
+; Then use @val as personality
+define void @use_as_personality() personality ptr @val {
+entry:
+ invoke void @may_throw() to label %cont unwind label %lpad
+cont:
+ ret void
+lpad:
+ %lp = landingpad { ptr, i32 } cleanup
+ ret void
+}
+
+; Finally declare @val as a global variable (not a function)
+ at val = global i32 42
+
+declare void @take_ptr(ptr)
+declare void @may_throw()
diff --git a/llvm/test/Assembler/personality-not-function.ll b/llvm/test/Assembler/personality-not-function.ll
new file mode 100644
index 0000000000000..cfc0a5fd9d7ae
--- /dev/null
+++ b/llvm/test/Assembler/personality-not-function.ll
@@ -0,0 +1,18 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+; Test that using a global variable (defined before use) as personality is rejected.
+
+; CHECK: expected function
+
+ at not_a_function = global i32 42
+
+define void @test() personality ptr @not_a_function {
+entry:
+ invoke void @may_throw() to label %cont unwind label %lpad
+cont:
+ ret void
+lpad:
+ %lp = landingpad { ptr, i32 } cleanup
+ ret void
+}
+
+declare void @may_throw()
diff --git a/llvm/test/Assembler/personality-null.ll b/llvm/test/Assembler/personality-null.ll
new file mode 100644
index 0000000000000..b0aac4e37b83c
--- /dev/null
+++ b/llvm/test/Assembler/personality-null.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-as %s -o /dev/null
+; Test that null personality is silently accepted as "no personality" for
+; backward compatibility with legacy IR.
+
+define void @test() personality ptr null {
+ ret void
+}
diff --git a/llvm/test/Bitcode/compatibility-3.7.ll b/llvm/test/Bitcode/compatibility-3.7.ll
index fed9cce2a0091..25a854c2f156f 100644
--- a/llvm/test/Bitcode/compatibility-3.7.ll
+++ b/llvm/test/Bitcode/compatibility-3.7.ll
@@ -227,7 +227,7 @@ declare void @g.f1()
; <ResultType> @<FunctionName> ([argument list])
; [unnamed_addr] [fn Attrs] [section "name"] [comdat [($name)]]
; [align N] [gc] [prefix Constant] [prologue Constant]
-; [personality Constant] { ... }
+; [personality Function] { ... }
; Functions -- Simple
declare void @f1 ()
@@ -557,7 +557,7 @@ declare void @f.prologuearray() prologue [4 x i32] [i32 0, i32 1, i32 2, i32 3]
declare void @llvm.donothing() nounwind readnone
; CHECK: declare void @llvm.donothing() #32
define void @f.no_personality() personality i8 3 {
-; CHECK: define void @f.no_personality() personality i8 3
+; CHECK: define void @f.no_personality() {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
diff --git a/llvm/test/Bitcode/compatibility-3.8.ll b/llvm/test/Bitcode/compatibility-3.8.ll
index 92695b9a41b80..0080a7443f90d 100644
--- a/llvm/test/Bitcode/compatibility-3.8.ll
+++ b/llvm/test/Bitcode/compatibility-3.8.ll
@@ -252,7 +252,7 @@ declare void @g.f1()
; <ResultType> @<FunctionName> ([argument list])
; [unnamed_addr] [fn Attrs] [section "name"] [comdat [($name)]]
; [align N] [gc] [prefix Constant] [prologue Constant]
-; [personality Constant] { ... }
+; [personality Function] { ... }
; Functions -- Simple
declare void @f1 ()
@@ -588,7 +588,7 @@ declare void @f.prologuearray() prologue [4 x i32] [i32 0, i32 1, i32 2, i32 3]
declare void @llvm.donothing() nounwind readnone
; CHECK: declare void @llvm.donothing() #35
define void @f.no_personality() personality i8 3 {
-; CHECK: define void @f.no_personality() personality i8 3
+; CHECK: define void @f.no_personality() {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
diff --git a/llvm/test/Bitcode/compatibility-3.9.ll b/llvm/test/Bitcode/compatibility-3.9.ll
index aa11917332e11..d076e5c7e0ca1 100644
--- a/llvm/test/Bitcode/compatibility-3.9.ll
+++ b/llvm/test/Bitcode/compatibility-3.9.ll
@@ -281,7 +281,7 @@ entry:
; <ResultType> @<FunctionName> ([argument list])
; [(unnamed_addr|local_unnamed_addr)] [fn Attrs] [section "name"] [comdat [($name)]]
; [align N] [gc] [prefix Constant] [prologue Constant]
-; [personality Constant] { ... }
+; [personality Function] { ... }
; Functions -- Simple
declare void @f1 ()
@@ -659,7 +659,7 @@ declare void @f.prologuearray() prologue [4 x i32] [i32 0, i32 1, i32 2, i32 3]
declare void @llvm.donothing() nounwind readnone
; CHECK: declare void @llvm.donothing() #35
define void @f.no_personality() personality i8 3 {
-; CHECK: define void @f.no_personality() personality i8 3
+; CHECK: define void @f.no_personality() {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
diff --git a/llvm/test/Bitcode/compatibility-4.0.ll b/llvm/test/Bitcode/compatibility-4.0.ll
index cefccdc02c08c..a1224d70b113b 100644
--- a/llvm/test/Bitcode/compatibility-4.0.ll
+++ b/llvm/test/Bitcode/compatibility-4.0.ll
@@ -281,7 +281,7 @@ entry:
; <ResultType> @<FunctionName> ([argument list])
; [(unnamed_addr|local_unnamed_addr)] [fn Attrs] [section "name"] [comdat [($name)]]
; [align N] [gc] [prefix Constant] [prologue Constant]
-; [personality Constant] { ... }
+; [personality Function] { ... }
; Functions -- Simple
declare void @f1 ()
@@ -659,7 +659,7 @@ declare void @f.prologuearray() prologue [4 x i32] [i32 0, i32 1, i32 2, i32 3]
declare void @llvm.donothing() nounwind readnone
; CHECK: declare void @llvm.donothing() #35
define void @f.no_personality() personality i8 3 {
-; CHECK: define void @f.no_personality() personality i8 3
+; CHECK: define void @f.no_personality() {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
diff --git a/llvm/test/Bitcode/compatibility-5.0.ll b/llvm/test/Bitcode/compatibility-5.0.ll
index ae3e2e8ffbb0f..028bb76923f14 100644
--- a/llvm/test/Bitcode/compatibility-5.0.ll
+++ b/llvm/test/Bitcode/compatibility-5.0.ll
@@ -281,7 +281,7 @@ entry:
; <ResultType> @<FunctionName> ([argument list])
; [(unnamed_addr|local_unnamed_addr)] [fn Attrs] [section "name"] [comdat [($name)]]
; [align N] [gc] [prefix Constant] [prologue Constant]
-; [personality Constant] { ... }
+; [personality Function] { ... }
; Functions -- Simple
declare void @f1 ()
@@ -664,7 +664,7 @@ declare void @f.prologuearray() prologue [4 x i32] [i32 0, i32 1, i32 2, i32 3]
declare void @llvm.donothing() nounwind readnone
; CHECK: declare void @llvm.donothing() #35
define void @f.no_personality() personality i8 3 {
-; CHECK: define void @f.no_personality() personality i8 3
+; CHECK: define void @f.no_personality() {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
diff --git a/llvm/test/Bitcode/compatibility-6.0.ll b/llvm/test/Bitcode/compatibility-6.0.ll
index cfb5ff7b350a2..6cac37f2d7684 100644
--- a/llvm/test/Bitcode/compatibility-6.0.ll
+++ b/llvm/test/Bitcode/compatibility-6.0.ll
@@ -279,7 +279,7 @@ entry:
; <ResultType> @<FunctionName> ([argument list])
; [(unnamed_addr|local_unnamed_addr)] [fn Attrs] [section "name"] [comdat [($name)]]
; [align N] [gc] [prefix Constant] [prologue Constant]
-; [personality Constant] { ... }
+; [personality Function] { ... }
; Functions -- Simple
declare void @f1 ()
@@ -670,7 +670,7 @@ declare void @f.prologuearray() prologue [4 x i32] [i32 0, i32 1, i32 2, i32 3]
declare void @llvm.donothing() nounwind readnone
; CHECK: declare void @llvm.donothing() #35
define void @f.no_personality() personality i8 3 {
-; CHECK: define void @f.no_personality() personality i8 3
+; CHECK: define void @f.no_personality() {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll
index 53cbe2d6ffd37..f22f093dd4ba8 100644
--- a/llvm/test/Bitcode/compatibility.ll
+++ b/llvm/test/Bitcode/compatibility.ll
@@ -316,7 +316,7 @@ entry:
; <ResultType> @<FunctionName> ([argument list])
; [(unnamed_addr|local_unnamed_addr)] [fn Attrs] [section "name"] [comdat [($name)]]
; [align N] [gc] [prefix Constant] [prologue Constant]
-; [personality Constant] { ... }
+; [personality Function] { ... }
; Functions -- Simple
declare void @f1 ()
@@ -782,8 +782,8 @@ declare void @f.prologuearray() prologue [4 x i32] [i32 0, i32 1, i32 2, i32 3]
; Functions -- Personality constant
declare void @llvm.donothing() nounwind readnone
; CHECK: declare void @llvm.donothing() #35
-define void @f.no_personality() personality i8 3 {
-; CHECK: define void @f.no_personality() personality i8 3
+define void @f.no_personality() personality ptr @f.personality_handler {
+; CHECK: define void @f.no_personality() personality ptr @f.personality_handler
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
@@ -1289,7 +1289,7 @@ define void @inlineasm(i32 %arg) {
;; Instructions
; Instructions -- Terminators
-define void @instructions.terminators(i8 %val) personality i32 -10 {
+define void @instructions.terminators(i8 %val) personality ptr @f.personality_handler {
br i1 false, label %iftrue, label %iffalse
; CHECK: br i1 false, label %iftrue, label %iffalse
br label %iftrue
@@ -1339,7 +1339,7 @@ exc:
ret void
}
-define i32 @instructions.win_eh.1() personality i32 -3 {
+define i32 @instructions.win_eh.1() personality ptr @f.personality_handler {
entry:
%arg1 = alloca i32
%arg2 = alloca i32
@@ -1384,7 +1384,7 @@ normal:
ret i32 0
}
;
-define i32 @instructions.win_eh.2() personality i32 -4 {
+define i32 @instructions.win_eh.2() personality ptr @f.personality_handler {
entry:
invoke void @f.ccc() to label %invoke.cont unwind label %catchswitch
@@ -1756,7 +1756,7 @@ define void @instructions.call_notail() {
ret void
}
-define void @instructions.landingpad() personality i32 -2 {
+define void @instructions.landingpad() personality ptr @f.personality_handler {
invoke void @llvm.donothing() to label %proceed unwind label %catch1
invoke void @llvm.donothing() to label %proceed unwind label %catch2
invoke void @llvm.donothing() to label %proceed unwind label %catch3
@@ -1984,7 +1984,7 @@ define void @call_with_operand_bundle4(ptr %ptr) {
; Invoke versions of the above tests:
-define void @invoke_with_operand_bundle0(ptr %ptr) personality i8 3 {
+define void @invoke_with_operand_bundle0(ptr %ptr) personality ptr @f.personality_handler {
; CHECK-LABEL: @invoke_with_operand_bundle0(
entry:
%l = load i32, ptr %ptr
@@ -1999,7 +1999,7 @@ normal:
ret void
}
-define void @invoke_with_operand_bundle1(ptr %ptr) personality i8 3 {
+define void @invoke_with_operand_bundle1(ptr %ptr) personality ptr @f.personality_handler {
; CHECK-LABEL: @invoke_with_operand_bundle1(
entry:
%l = load i32, ptr %ptr
@@ -2032,7 +2032,7 @@ normal2:
ret void
}
-define void @invoke_with_operand_bundle2(ptr %ptr) personality i8 3 {
+define void @invoke_with_operand_bundle2(ptr %ptr) personality ptr @f.personality_handler {
; CHECK-LABEL: @invoke_with_operand_bundle2(
entry:
invoke void @op_bundle_callee_0() [ "foo"() ] to label %normal unwind label %exception
@@ -2045,7 +2045,7 @@ normal:
ret void
}
-define void @invoke_with_operand_bundle3(ptr %ptr) personality i8 3 {
+define void @invoke_with_operand_bundle3(ptr %ptr) personality ptr @f.personality_handler {
; CHECK-LABEL: @invoke_with_operand_bundle3(
entry:
%l = load i32, ptr %ptr
@@ -2060,7 +2060,7 @@ normal:
ret void
}
-define void @invoke_with_operand_bundle4(ptr %ptr) personality i8 3 {
+define void @invoke_with_operand_bundle4(ptr %ptr) personality ptr @f.personality_handler {
; CHECK-LABEL: @invoke_with_operand_bundle4(
entry:
%l = load i32, ptr %ptr
@@ -2077,7 +2077,7 @@ normal:
}
declare void @vaargs_func(...)
-define void @invoke_with_operand_bundle_vaarg(ptr %ptr) personality i8 3 {
+define void @invoke_with_operand_bundle_vaarg(ptr %ptr) personality ptr @f.personality_handler {
; CHECK-LABEL: @invoke_with_operand_bundle_vaarg(
entry:
%l = load i32, ptr %ptr
diff --git a/llvm/test/Bitcode/function-address-space-fwd-decl.ll b/llvm/test/Bitcode/function-address-space-fwd-decl.ll
index cc74d5d942c40..32c4aa1e89275 100644
--- a/llvm/test/Bitcode/function-address-space-fwd-decl.ll
+++ b/llvm/test/Bitcode/function-address-space-fwd-decl.ll
@@ -16,7 +16,9 @@ entry:
}
-define i32 @invoked() personality i8* null {
+declare i32 @__gxx_personality_v0(...)
+
+define i32 @invoked() personality ptr @__gxx_personality_v0 {
entry:
%0 = invoke addrspace(40) i32 @foo() to label %l1 unwind label %lpad
; CHECK: invoke addrspace(40) i32 @foo()
diff --git a/llvm/test/Bitcode/operand-bundles.ll b/llvm/test/Bitcode/operand-bundles.ll
index a8e086f784c6c..b90827484c6b0 100644
--- a/llvm/test/Bitcode/operand-bundles.ll
+++ b/llvm/test/Bitcode/operand-bundles.ll
@@ -1,5 +1,6 @@
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @callee0()
declare void @callee1(i32,i32)
@@ -66,7 +67,7 @@ entry:
; Invoke versions of the above tests:
-define void @g0(i32* %ptr) personality i8 3 {
+define void @g0(i32* %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @g0(
entry:
%l = load i32, i32* %ptr
@@ -81,7 +82,7 @@ normal:
ret void
}
-define void @g1(i32* %ptr) personality i8 3 {
+define void @g1(i32* %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @g1(
entry:
%l = load i32, i32* %ptr
@@ -114,7 +115,7 @@ normal2:
ret void
}
-define void @g2(i32* %ptr) personality i8 3 {
+define void @g2(i32* %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @g2(
entry:
invoke void @callee0() [ "foo"() ] to label %normal unwind label %exception
@@ -127,7 +128,7 @@ normal:
ret void
}
-define void @g3(i32* %ptr) personality i8 3 {
+define void @g3(i32* %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @g3(
entry:
%l = load i32, i32* %ptr
@@ -142,7 +143,7 @@ normal:
ret void
}
-define void @g4(i32* %ptr) personality i8 3 {
+define void @g4(i32* %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @g4(
entry:
%l = load i32, i32* %ptr
@@ -158,7 +159,7 @@ normal:
ret void
}
-define void @g5(ptr %ptr) personality i8 3 {
+define void @g5(ptr %ptr) personality ptr @__gxx_personality_v0 {
entry:
%l = load i32, ptr %ptr, align 4
%x = add i32 42, 1
diff --git a/llvm/test/Bitcode/use-list-order2.ll b/llvm/test/Bitcode/use-list-order2.ll
index aafa3d552bbee..d46e38198db6e 100644
--- a/llvm/test/Bitcode/use-list-order2.ll
+++ b/llvm/test/Bitcode/use-list-order2.ll
@@ -3,9 +3,10 @@
; Test 1
@g1 = global i8 0
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.donothing() nounwind readnone
-define void @f.no_personality1() personality i8 0 {
+define void @f.no_personality1() personality ptr @__gxx_personality_v0 {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
@@ -18,7 +19,7 @@ normal:
@g2 = global i8 -1
@g3 = global i8 -1
-define void @f.no_personality2() personality i8 -1 {
+define void @f.no_personality2() personality ptr @__gxx_personality_v0 {
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
%cleanup = landingpad i8 cleanup
diff --git a/llvm/test/CodeGen/AArch64/aarch64-fixup-statepoint-regs-crash.ll b/llvm/test/CodeGen/AArch64/aarch64-fixup-statepoint-regs-crash.ll
index f66245b8a1d37..a689cddbb080a 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-fixup-statepoint-regs-crash.ll
+++ b/llvm/test/CodeGen/AArch64/aarch64-fixup-statepoint-regs-crash.ll
@@ -2,12 +2,12 @@
; REQUIRES: asserts
; RUN: llc -verify-machineinstrs -max-registers-for-gc-values=256 -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
+
; Verify that FixupStatepointCallerSaved pass uses correct intruction for spilling a register after copyprop
-define dso_local ptr addrspace(1) @foo(ptr addrspace(1) %arg) gc "statepoint-example" personality ptr null {
+define dso_local ptr addrspace(1) @foo(ptr addrspace(1) %arg) gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: foo:
-; CHECK: .Lfunc_begin0:
-; CHECK-NEXT: .cfi_startproc
-; CHECK-NEXT: // %bb.0:
+; CHECK: // %bb.0:
; CHECK-NEXT: sub sp, sp, #48
; CHECK-NEXT: stp x30, x19, [sp, #32] // 16-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 48
diff --git a/llvm/test/CodeGen/AArch64/unwind-preserved-from-mir.mir b/llvm/test/CodeGen/AArch64/unwind-preserved-from-mir.mir
index 7faab8c45aa7a..ac058c13979fe 100644
--- a/llvm/test/CodeGen/AArch64/unwind-preserved-from-mir.mir
+++ b/llvm/test/CodeGen/AArch64/unwind-preserved-from-mir.mir
@@ -9,7 +9,8 @@
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
- define aarch64_vector_pcs <4 x i32> @invoke_callee_may_throw_neon(<4 x i32> %v) personality i8 0 {
+ declare i32 @__gxx_personality_v0(...)
+ define aarch64_vector_pcs <4 x i32> @invoke_callee_may_throw_neon(<4 x i32> %v) personality ptr @__gxx_personality_v0 {
%result = invoke aarch64_vector_pcs <4 x i32> @may_throw_neon(<4 x i32> %v)
to label %.Lcontinue unwind label %.Lunwind
diff --git a/llvm/test/CodeGen/AArch64/unwind-preserved.ll b/llvm/test/CodeGen/AArch64/unwind-preserved.ll
index c1062561733c3..6c24228ce05be 100644
--- a/llvm/test/CodeGen/AArch64/unwind-preserved.ll
+++ b/llvm/test/CodeGen/AArch64/unwind-preserved.ll
@@ -3,10 +3,12 @@
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -O0 -global-isel=1 -global-isel-abort=0 < %s | FileCheck %s --check-prefix=GISEL
; Test that z0 is saved/restored, as the unwinder may only retain the low 64bits (d0).
-define <vscale x 4 x i32> @invoke_callee_may_throw_sve(<vscale x 4 x i32> %v) uwtable personality i8 0 {
+define <vscale x 4 x i32> @invoke_callee_may_throw_sve(<vscale x 4 x i32> %v) uwtable personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: invoke_callee_may_throw_sve:
; CHECK: .Lfunc_begin0:
; CHECK-NEXT: .cfi_startproc
+; CHECK-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0
+; CHECK-NEXT: .cfi_lsda 28, .Lexception0
; CHECK-NEXT: // %bb.0:
; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
@@ -159,6 +161,8 @@ define <vscale x 4 x i32> @invoke_callee_may_throw_sve(<vscale x 4 x i32> %v) uw
; GISEL-LABEL: invoke_callee_may_throw_sve:
; GISEL: .Lfunc_begin0:
; GISEL-NEXT: .cfi_startproc
+; GISEL-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0
+; GISEL-NEXT: .cfi_lsda 28, .Lexception0
; GISEL-NEXT: // %bb.0:
; GISEL-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
; GISEL-NEXT: .cfi_def_cfa_offset 16
@@ -315,14 +319,17 @@ define <vscale x 4 x i32> @invoke_callee_may_throw_sve(<vscale x 4 x i32> %v) uw
ret <vscale x 4 x i32> %v;
}
+declare i32 @__gxx_personality_v0(...)
declare <vscale x 4 x i32> @may_throw_sve(<vscale x 4 x i32> %v);
; Test that q0 is saved/restored, as the unwinder may only retain the low 64bits (d0).
-define aarch64_vector_pcs <4 x i32> @invoke_callee_may_throw_neon(<4 x i32> %v) uwtable personality i8 0 {
+define aarch64_vector_pcs <4 x i32> @invoke_callee_may_throw_neon(<4 x i32> %v) uwtable personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: invoke_callee_may_throw_neon:
; CHECK: .Lfunc_begin1:
; CHECK-NEXT: .cfi_startproc
+; CHECK-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0
+; CHECK-NEXT: .cfi_lsda 28, .Lexception1
; CHECK-NEXT: // %bb.0:
; CHECK-NEXT: sub sp, sp, #304
; CHECK-NEXT: .cfi_def_cfa_offset 304
@@ -430,6 +437,8 @@ define aarch64_vector_pcs <4 x i32> @invoke_callee_may_throw_neon(<4 x i32> %v)
; GISEL-LABEL: invoke_callee_may_throw_neon:
; GISEL: .Lfunc_begin1:
; GISEL-NEXT: .cfi_startproc
+; GISEL-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0
+; GISEL-NEXT: .cfi_lsda 28, .Lexception1
; GISEL-NEXT: // %bb.0:
; GISEL-NEXT: sub sp, sp, #304
; GISEL-NEXT: .cfi_def_cfa_offset 304
diff --git a/llvm/test/CodeGen/PowerPC/aix-personality-alias.ll b/llvm/test/CodeGen/PowerPC/aix-personality-alias.ll
deleted file mode 100644
index fd4b4103d2f83..0000000000000
--- a/llvm/test/CodeGen/PowerPC/aix-personality-alias.ll
+++ /dev/null
@@ -1,74 +0,0 @@
-;; Test if we are still able to compile even when the personality routine is just an alias.
-
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec \
-; RUN: -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s --check-prefixes=SYM,SYM32
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec \
-; RUN: -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s --check-prefixes=SYM,SYM64
-
- at __xlcxx_personality_v1 = alias i32 (), ptr @__gxx_personality_v0
-define i32 @__gxx_personality_v0() {
-entry:
- ret i32 1
-}
-
-define dso_local signext i32 @_Z3foov() #0 personality ptr @__xlcxx_personality_v1 {
-entry:
- %retval = alloca i32, align 4
- %exn.slot = alloca ptr, align 8
- %ehselector.slot = alloca i32, align 4
- invoke void @_Z3barv()
- to label %invoke.cont unwind label %lpad
-
-invoke.cont: ; preds = %entry
- br label %try.cont
-
-lpad: ; preds = %entry
- %0 = landingpad { ptr, i32 }
- catch ptr null
- %1 = extractvalue { ptr, i32 } %0, 0
- store ptr %1, ptr %exn.slot, align 8
- %2 = extractvalue { ptr, i32 } %0, 1
- store i32 %2, ptr %ehselector.slot, align 4
- br label %catch
-
-catch: ; preds = %lpad
- %exn = load ptr, ptr %exn.slot, align 8
- br label %return
-
-try.cont: ; preds = %invoke.cont
- store i32 2, ptr %retval, align 4
- br label %return
-
-return: ; preds = %try.cont, %catch
- ret i32 1
-}
-
-declare void @_Z3barv()
-
-; SYM: .globl __gxx_personality_v0[DS] # -- Begin function __gxx_personality_v0
-; SYM: .globl .__gxx_personality_v0
-; SYM: .align 4
-; SYM: .csect __gxx_personality_v0[DS]
-; SYM: __xlcxx_personality_v1: # @__gxx_personality_v0
-; SYM32: .vbyte 4, .__gxx_personality_v0
-; SYM32: .vbyte 4, TOC[TC0]
-; SYM32: .vbyte 4, 0
-; SYM64: .vbyte 8, .__gxx_personality_v0
-; SYM64: .vbyte 8, TOC[TC0]
-; SYM64: .vbyte 8, 0
-; SYM: .csect ..text..[PR],5
-; SYM: .__gxx_personality_v0:
-; SYM: .__xlcxx_personality_v1:
-; SYM: # %bb.0: # %entry
-; SYM: li 3, 1
-; SYM: blr
-
-; SYM: .csect .eh_info_table[RW],2
-; SYM: __ehinfo.1:
-; SYM: .vbyte 4, 0
-; SYM32: .align 2
-; SYM32: .vbyte 4, GCC_except_table1
-; SYM32: .vbyte 4, __xlcxx_personality_v1
-; SYM64: .align 3
-; SYM64: .vbyte 8, GCC_except_table1
-; SYM64: .vbyte 8, __xlcxx_personality_v1
diff --git a/llvm/test/CodeGen/X86/deopt-bundles.ll b/llvm/test/CodeGen/X86/deopt-bundles.ll
index 8cb69dd72408d..637f2f17b85d5 100644
--- a/llvm/test/CodeGen/X86/deopt-bundles.ll
+++ b/llvm/test/CodeGen/X86/deopt-bundles.ll
@@ -50,6 +50,7 @@ target triple = "x86_64-apple-macosx10.11.0"
; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 55 [encoding: .byte 4, .byte 0, .short 8, .short 0, .short 0, .int 55]
; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers
+declare i32 @__gxx_personality_v0(...)
declare i32 @callee_0()
declare i32 @callee_1(i32)
declare i32 @callee_vararg(...)
@@ -84,7 +85,7 @@ entry:
ret i32 %v
}
-define i32 @invoker_0() personality i8 0 {
+define i32 @invoker_0() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: _invoker_0
entry:
%v = invoke i32 @callee_0() [ "deopt"(i32 2) ]
@@ -105,7 +106,7 @@ uw:
; CHECK: retq
}
-define i32 @invoker_1() personality i8 0 {
+define i32 @invoker_1() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: _invoker_1
entry:
%v = invoke i32 @callee_1(i32 45) "statepoint-num-patch-bytes"="9" [ "deopt"(i32 3) ]
diff --git a/llvm/test/CodeGen/X86/eh-null-personality.ll b/llvm/test/CodeGen/X86/eh-null-personality.ll
index 8025d93d59641..94f7144918b25 100644
--- a/llvm/test/CodeGen/X86/eh-null-personality.ll
+++ b/llvm/test/CodeGen/X86/eh-null-personality.ll
@@ -3,10 +3,11 @@
; We should treat non-Function personalities as the unknown personality, which
; is usually Itanium.
+declare i32 @__gxx_personality_v0(...)
declare void @g()
declare void @terminate(ptr)
-define void @f() personality ptr null {
+define void @f() personality ptr @__gxx_personality_v0 {
invoke void @g()
to label %ret unwind label %lpad
ret:
diff --git a/llvm/test/CodeGen/X86/stack-protector-no-return.ll b/llvm/test/CodeGen/X86/stack-protector-no-return.ll
index cfebf0080a6d6..0ed5e88e4af89 100644
--- a/llvm/test/CodeGen/X86/stack-protector-no-return.ll
+++ b/llvm/test/CodeGen/X86/stack-protector-no-return.ll
@@ -2,8 +2,10 @@
; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu -o - -verify-dom-info | FileCheck %s
; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu -disable-check-noreturn-call=true -o - -verify-dom-info | FileCheck --check-prefix=DISNOTET %s
+declare i32 @__gxx_personality_v0(...)
+
; Function Attrs: sspreq
-define void @_Z7catchesv() #0 personality ptr null {
+define void @_Z7catchesv() #0 personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: _Z7catchesv:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: pushq %rax
diff --git a/llvm/test/CodeGen/X86/x86-no_callee_saved_registers.ll b/llvm/test/CodeGen/X86/x86-no_callee_saved_registers.ll
index 0b0344128a12e..c3948053427c2 100644
--- a/llvm/test/CodeGen/X86/x86-no_callee_saved_registers.ll
+++ b/llvm/test/CodeGen/X86/x86-no_callee_saved_registers.ll
@@ -2,6 +2,7 @@
; RUN: llc -mtriple=x86_64-unknown-unknown -O0 < %s | FileCheck --check-prefixes=CHECK,CHECK-O0 %s
; RUN: llc -mtriple=x86_64-unknown-unknown -O3 < %s | FileCheck --check-prefixes=CHECK,CHECK-O3 %s
+declare i32 @__gxx_personality_v0(...)
declare void @external()
declare void @no_csr() "no_callee_saved_registers"
@@ -107,7 +108,7 @@ define void @test2() {
}
; on an invoke instead
-define i32 @test3() personality ptr undef {
+define i32 @test3() personality ptr @__gxx_personality_v0 {
; CHECK-O0-LABEL: test3:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: pushq %rbp
diff --git a/llvm/test/Feature/OperandBundles/merge-func.ll b/llvm/test/Feature/OperandBundles/merge-func.ll
index 772cd774c8e53..2c32656c74007 100644
--- a/llvm/test/Feature/OperandBundles/merge-func.ll
+++ b/llvm/test/Feature/OperandBundles/merge-func.ll
@@ -3,6 +3,7 @@
; Minor note: functions need to be at least three instructions long
; to be considered by -mergefunc.
+declare i32 @__gxx_personality_v0(...)
declare i32 @foo(...)
define i32 @f() {
@@ -33,7 +34,7 @@ define i32 @g() {
ret i32 %v2
}
-define i32 @f.invoke() personality i8 3 {
+define i32 @f.invoke() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @f.invoke(
entry:
; CHECK: %v0 = invoke i32 (...) @foo(i32 10) [ "foo"(i32 20) ]
@@ -48,7 +49,7 @@ define i32 @f.invoke() personality i8 3 {
ret i32 0
}
-define i32 @g.invoke() personality i8 3 {
+define i32 @g.invoke() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @g.invoke(
entry:
; CHECK: %v0 = invoke i32 (...) @foo() [ "foo"(i32 10, i32 20) ]
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/personality-bti.ll b/llvm/test/Instrumentation/HWAddressSanitizer/personality-bti.ll
index 3183a184c9d0d..10245e8d50540 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/personality-bti.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/personality-bti.ll
@@ -28,8 +28,6 @@ define internal void @local() {
ret void
}
- at local_alias = internal alias void (), ptr @local
-
; NOPERS: personality ptr @local
; PERS: personality {{.*}} @__hwasan_personality_thunk.local
define void @stack3() sanitize_hwaddress "branch-target-enforcement" personality ptr @local {
@@ -38,25 +36,17 @@ define void @stack3() sanitize_hwaddress "branch-target-enforcement" personality
ret void
}
-; NOPERS: personality ptr @local_alias
-; PERS: personality {{.*}} @__hwasan_personality_thunk.local_alias
-define void @stack4() sanitize_hwaddress "branch-target-enforcement" personality ptr @local_alias {
- %p = alloca i8
- call void @sink(ptr %p)
- ret void
-}
-
-; NOPERS: personality ptr inttoptr (i64 1 to ptr)
-; PERS: personality ptr @__hwasan_personality_thunk.
-define void @stack5() sanitize_hwaddress "branch-target-enforcement" personality ptr inttoptr (i64 1 to ptr) {
+; NOPERS: personality ptr @pers1
+; PERS: personality ptr @__hwasan_personality_thunk.pers1
+define void @stack5() sanitize_hwaddress "branch-target-enforcement" personality ptr @pers1 {
%p = alloca i8
call void @sink(ptr %p)
ret void
}
-; NOPERS: personality ptr inttoptr (i64 2 to ptr)
-; PERS: personality ptr @__hwasan_personality_thunk..1
-define void @stack6() sanitize_hwaddress "branch-target-enforcement" personality ptr inttoptr (i64 2 to ptr) {
+; NOPERS: personality ptr @pers2
+; PERS: personality ptr @__hwasan_personality_thunk.pers2
+define void @stack6() sanitize_hwaddress "branch-target-enforcement" personality ptr @pers2 {
%p = alloca i8
call void @sink(ptr %p)
ret void
@@ -64,6 +54,8 @@ define void @stack6() sanitize_hwaddress "branch-target-enforcement" personality
declare void @global()
declare void @sink(ptr)
+declare void @pers1()
+declare void @pers2()
!llvm.module.flags = !{!0}
!0 = !{i32 8, !"branch-target-enforcement", i32 1}
@@ -80,16 +72,12 @@ declare void @sink(ptr)
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @local, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
; PERS: ret i32 %5
-; PERS: define internal i32 @__hwasan_personality_thunk.local_alias(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) {{.*}}[[ATTRS]]
-; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @local_alias, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
-; PERS: ret i32 %5
-
-; PERS: define internal i32 @__hwasan_personality_thunk.(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) {{.*}}[[ATTRS]] {
-; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr inttoptr (i64 1 to ptr), ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
+; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk.pers1(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) {{.*}}[[ATTRS]] comdat
+; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @pers1, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
; PERS: ret i32 %5
-; PERS: define internal i32 @__hwasan_personality_thunk..1(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) {{.*}}[[ATTRS]] {
-; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr inttoptr (i64 2 to ptr), ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
+; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk.pers2(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) {{.*}}[[ATTRS]] comdat
+; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @pers2, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
; PERS: ret i32 %5
; PERS: {{.*}}[[ATTRS]] = {{.*}}branch-target-enforcement
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/personality.ll b/llvm/test/Instrumentation/HWAddressSanitizer/personality.ll
index 54b7b70dfa863..0b60c159fa5dd 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/personality.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/personality.ll
@@ -28,8 +28,6 @@ define internal void @local() {
ret void
}
- at local_alias = internal alias void (), ptr @local
-
; NOPERS: personality ptr @local
; PERS: personality {{.*}} @__hwasan_personality_thunk.local
define void @stack3() sanitize_hwaddress personality ptr @local {
@@ -38,25 +36,17 @@ define void @stack3() sanitize_hwaddress personality ptr @local {
ret void
}
-; NOPERS: personality ptr @local_alias
-; PERS: personality {{.*}} @__hwasan_personality_thunk.local_alias
-define void @stack4() sanitize_hwaddress personality ptr @local_alias {
- %p = alloca i8
- call void @sink(ptr %p)
- ret void
-}
-
-; NOPERS: personality ptr inttoptr (i64 1 to ptr)
-; PERS: personality ptr @__hwasan_personality_thunk.
-define void @stack5() sanitize_hwaddress personality ptr inttoptr (i64 1 to ptr) {
+; NOPERS: personality ptr @pers1
+; PERS: personality ptr @__hwasan_personality_thunk.pers1
+define void @stack5() sanitize_hwaddress personality ptr @pers1 {
%p = alloca i8
call void @sink(ptr %p)
ret void
}
-; NOPERS: personality ptr inttoptr (i64 2 to ptr)
-; PERS: personality ptr @__hwasan_personality_thunk..1
-define void @stack6() sanitize_hwaddress personality ptr inttoptr (i64 2 to ptr) {
+; NOPERS: personality ptr @pers2
+; PERS: personality ptr @__hwasan_personality_thunk.pers2
+define void @stack6() sanitize_hwaddress personality ptr @pers2 {
%p = alloca i8
call void @sink(ptr %p)
ret void
@@ -64,6 +54,8 @@ define void @stack6() sanitize_hwaddress personality ptr inttoptr (i64 2 to ptr)
declare void @global()
declare void @sink(ptr)
+declare void @pers1()
+declare void @pers2()
; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) comdat
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr null, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
@@ -77,14 +69,10 @@ declare void @sink(ptr)
; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @local, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
; PERS: ret i32 %5
-; PERS: define internal i32 @__hwasan_personality_thunk.local_alias(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4)
-; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @local_alias, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
-; PERS: ret i32 %5
-
-; PERS: define internal i32 @__hwasan_personality_thunk.(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) {
-; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr inttoptr (i64 1 to ptr), ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
+; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk.pers1(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) comdat
+; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @pers1, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
; PERS: ret i32 %5
-; PERS: define internal i32 @__hwasan_personality_thunk..1(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) {
-; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr inttoptr (i64 2 to ptr), ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
+; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk.pers2(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4) comdat
+; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, ptr %3, ptr %4, ptr @pers2, ptr @_Unwind_GetGR, ptr @_Unwind_GetCFA)
; PERS: ret i32 %5
diff --git a/llvm/test/Linker/drop-attribute.ll b/llvm/test/Linker/drop-attribute.ll
index 3d4c13c2ffc75..4d7a1e15d67e8 100644
--- a/llvm/test/Linker/drop-attribute.ll
+++ b/llvm/test/Linker/drop-attribute.ll
@@ -12,7 +12,7 @@
; CHECK-NEXT: call void @test_nocallback_declaration_definition_linked_in()
; Test that checks that nocallback attribute on a call-site in an invoke instruction is dropped.
; CHECK-NEXT: invoke void @test_nocallback_call_site(){{$}}
-define i32 @main() personality i8 0 {
+define i32 @main() personality ptr @__gxx_personality_v0 {
entry:
call void @test_nocallback_definition()
call void @test_nocallback_call_site() nocallback
@@ -36,6 +36,7 @@ define void @test_nocallback_definition() nocallback {
; Test that checks that nocallback attribute on a call site is dropped.
; CHECK: declare void @test_nocallback_call_site(){{$}}
+declare i32 @__gxx_personality_v0(...)
declare void @test_nocallback_call_site()
; Test that checks that nocallback attribute on an intrinsic is NOT dropped.
diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/fold-loop-of-urem.ll b/llvm/test/Transforms/CodeGenPrepare/X86/fold-loop-of-urem.ll
index f53127f015391..a47fad1da078b 100644
--- a/llvm/test/Transforms/CodeGenPrepare/X86/fold-loop-of-urem.ll
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/fold-loop-of-urem.ll
@@ -782,9 +782,9 @@ for.body:
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
}
-define void @weird_loop(i64 %sub.ptr.div.i56) personality ptr null {
+define void @weird_loop(i64 %sub.ptr.div.i56) {
; CHECK-LABEL: define void @weird_loop(
-; CHECK-SAME: i64 [[SUB_PTR_DIV_I56:%.*]]) personality ptr null {
+; CHECK-SAME: i64 [[SUB_PTR_DIV_I56:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ADD74_US:%.*]] = add nuw i64 0, 1
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[ADD74_US]], [[SUB_PTR_DIV_I56]]
diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-recreate.ll b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-recreate.ll
index d0d87b38e0589..1aa48450440a9 100644
--- a/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-recreate.ll
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addr-recreate.ll
@@ -5,12 +5,13 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:
target triple = "x86_64-grtev4-linux-gnu"
@globalptr = external global ptr
+declare i32 @__gxx_personality_v0(...)
declare ptr @get_ptr(i64)
; Can't recreate invoke instruction
-define void @addr_from_invoke() personality ptr null {
-; CHECK-LABEL: define void @addr_from_invoke() personality ptr null {
+define void @addr_from_invoke() personality ptr @__gxx_personality_v0 {
+; CHECK-LABEL: define void @addr_from_invoke() personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[PTR:%.*]] = invoke ptr @get_ptr(i64 0)
; CHECK-NEXT: to label %[[BODY_1:.*]] unwind label %[[EHCLEANUP:.*]]
diff --git a/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll
index 2cb46afb1f5be..92ff45a1aaf3f 100644
--- a/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll
+++ b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll
@@ -1,6 +1,8 @@
; RUN: opt -passes=consthoist -S < %s | FileCheck %s
target triple = "thumbv6m-none-eabi"
+declare i32 @__gxx_personality_v0(...)
+
; Allocas in the entry block get handled (for free) by
; prologue/epilogue. Elsewhere they're fair game though.
define void @avoid_allocas() {
@@ -111,7 +113,7 @@ entry:
@exception_type = external global i8
; Constants in inline ASM should not be hoisted.
-define i32 @inline_asm_invoke() personality ptr null {
+define i32 @inline_asm_invoke() personality ptr @__gxx_personality_v0 {
;CHECK-LABEL: @inline_asm_invoke
;CHECK-NOT: %const = 214672
;CHECK: %X = invoke i32 asm "bswap $0", "=r,r"(i32 214672)
diff --git a/llvm/test/Transforms/ConstraintElimination/reproducer-remarks.ll b/llvm/test/Transforms/ConstraintElimination/reproducer-remarks.ll
index 63e1826ece5d7..7bf425f8a1579 100644
--- a/llvm/test/Transforms/ConstraintElimination/reproducer-remarks.ll
+++ b/llvm/test/Transforms/ConstraintElimination/reproducer-remarks.ll
@@ -2,6 +2,7 @@
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+declare i32 @__gxx_personality_v0(...)
declare void @use(i1)
declare void @llvm.assume(i1)
@@ -202,7 +203,7 @@ exit:
ret i32 0
}
-define i32 @test_invoke(i32 %a) personality ptr null {
+define i32 @test_invoke(i32 %a) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i1 @"{{.+}}test_invokerepro"(i32 %l, i32 %a) {
; CHECK-NEXT: entry:
; CHECK-NEXT: %0 = icmp slt i32 %a, %l
diff --git a/llvm/test/Transforms/Coroutines/coro-await-suspend-lower-invoke.ll b/llvm/test/Transforms/Coroutines/coro-await-suspend-lower-invoke.ll
index 67d179a8f9b04..91bbb446079f5 100644
--- a/llvm/test/Transforms/Coroutines/coro-await-suspend-lower-invoke.ll
+++ b/llvm/test/Transforms/Coroutines/coro-await-suspend-lower-invoke.ll
@@ -5,7 +5,7 @@
; CHECK: define {{[^@]*}} @f.resume(ptr {{[^%]*}} %[[HDL:.+]])
; CHECK: %[[AWAITER:.+]] = getelementptr inbounds %f.Frame, ptr %[[HDL]], i32 0, i32 0
-define void @f() presplitcoroutine personality i32 0 {
+define void @f() presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%awaiter = alloca %Awaiter
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
@@ -96,6 +96,7 @@ ret:
; CHECK-LABEL: @f.destroy(
; CHECK-LABEL: @f.cleanup(
+declare i32 @__gxx_personality_v0(...)
declare void @await_suspend_wrapper_void(ptr, ptr)
declare i1 @await_suspend_wrapper_bool(ptr, ptr)
declare ptr @await_suspend_wrapper_handle(ptr, ptr)
diff --git a/llvm/test/Transforms/Coroutines/coro-catchswitch.ll b/llvm/test/Transforms/Coroutines/coro-catchswitch.ll
index 06f1435dc966c..af668f84c63ff 100644
--- a/llvm/test/Transforms/Coroutines/coro-catchswitch.ll
+++ b/llvm/test/Transforms/Coroutines/coro-catchswitch.ll
@@ -5,7 +5,7 @@ target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"
; CHECK-LABEL: define void @f(
-define void @f(i1 %cond) presplitcoroutine personality i32 0 {
+define void @f(i1 %cond) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 8, ptr null, ptr null, ptr null)
%size = call i32 @llvm.coro.size.i32()
@@ -63,6 +63,7 @@ cleanuppad:
}
; Function Attrs: argmemonly nounwind readonly
+declare i32 @__gxx_personality_v0(...)
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
; Function Attrs: nounwind
diff --git a/llvm/test/Transforms/Coroutines/coro-debug.ll b/llvm/test/Transforms/Coroutines/coro-debug.ll
index 109be51ffea85..d07608c2002e9 100644
--- a/llvm/test/Transforms/Coroutines/coro-debug.ll
+++ b/llvm/test/Transforms/Coroutines/coro-debug.ll
@@ -6,7 +6,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: noinline nounwind
-define ptr @flink(i32 %x) #0 personality i32 0 !dbg !6 {
+define ptr @flink(i32 %x) #0 personality ptr @__gxx_personality_v0 !dbg !6 {
entry:
%x.addr = alloca i32, align 4
%coro_hdl = alloca ptr, align 8
@@ -82,6 +82,7 @@ ehcleanup:
}
; Function Attrs: nounwind readnone speculatable
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.dbg.value(metadata, metadata, metadata)
; Function Attrs: nounwind readnone speculatable
@@ -157,13 +158,13 @@ attributes #0 = { noinline nounwind presplitcoroutine }
!32 = !DILocalVariable(name: "inline_asm", scope: !6, file: !7, line: 55, type: !11)
; Check that the original function is visible and capture its debug info id.
-; CHECK: define ptr @flink(i32 %x) #0 personality i32 0 !dbg ![[ORIG:[0-9]+]]
+; CHECK: define ptr @flink(i32 %x) #0 personality ptr @__gxx_personality_v0 !dbg ![[ORIG:[0-9]+]]
; Check that the resume function is present and capture its debug info id.
; Also check that it contains `#dbg_declare` and `#dbg_value` debug instructions
; making the debug variables available to the debugger.
;
-; CHECK: define internal fastcc void @flink.resume(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 personality i32 0 !dbg ![[RESUME:[0-9]+]]
+; CHECK: define internal fastcc void @flink.resume(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 personality ptr @__gxx_personality_v0 !dbg ![[RESUME:[0-9]+]]
; CHECK: entry.resume:
; CHECK: %[[DBG_PTR:.*]] = alloca ptr
; CHECK-NEXT: #dbg_declare(ptr %[[DBG_PTR]], ![[RESUME_COROHDL:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_plus_uconst,
@@ -188,8 +189,8 @@ attributes #0 = { noinline nounwind presplitcoroutine }
; Check that the destroy and cleanup functions are present and capture their debug info id.
;
-; CHECK: define internal fastcc void @flink.destroy(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 personality i32 0 !dbg ![[DESTROY:[0-9]+]]
-; CHECK: define internal fastcc void @flink.cleanup(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 personality i32 0 !dbg ![[CLEANUP:[0-9]+]]
+; CHECK: define internal fastcc void @flink.destroy(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 personality ptr @__gxx_personality_v0 !dbg ![[DESTROY:[0-9]+]]
+; CHECK: define internal fastcc void @flink.cleanup(ptr noundef nonnull align 8 dereferenceable(40) %0) #0 personality ptr @__gxx_personality_v0 !dbg ![[CLEANUP:[0-9]+]]
; Check that the linkage name of the original function is set correctly.
;
diff --git a/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll b/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
index ad84f7b33dc65..6cec1e7e96618 100644
--- a/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
+++ b/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll
@@ -5,7 +5,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK-LABEL: define internal fastcc void @f.resume(
-define void @f(i1 %cond) presplitcoroutine personality i32 0 {
+define void @f(i1 %cond) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 16, ptr null, ptr null, ptr null)
%size = tail call i64 @llvm.coro.size.i64()
@@ -73,6 +73,7 @@ unreach:
}
; Function Attrs: argmemonly nounwind readonly
+declare i32 @__gxx_personality_v0(...)
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
declare noalias ptr @malloc(i64)
declare i64 @llvm.coro.size.i64()
diff --git a/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll b/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
index 0b9bce5f9ad77..29456cf742857 100644
--- a/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
+++ b/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll
@@ -5,7 +5,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK-LABEL: define internal fastcc void @g.resume(
-define void @g(i1 %cond, i32 %x, i32 %y) presplitcoroutine personality i32 0 {
+define void @g(i1 %cond, i32 %x, i32 %y) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 16, ptr null, ptr null, ptr null)
%size = tail call i64 @llvm.coro.size.i64()
@@ -67,6 +67,7 @@ unreach:
}
; Function Attrs: argmemonly nounwind readonly
+declare i32 @__gxx_personality_v0(...)
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
declare noalias ptr @malloc(i64)
declare i64 @llvm.coro.size.i64()
diff --git a/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll b/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
index 6202df1fe00e6..bd401de074bf5 100644
--- a/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
+++ b/llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll
@@ -5,7 +5,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK-LABEL: define internal fastcc void @h.resume(
-define void @h(i1 %cond, i32 %x, i32 %y) presplitcoroutine personality i32 0 {
+define void @h(i1 %cond, i32 %x, i32 %y) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 16, ptr null, ptr null, ptr null)
%size = tail call i64 @llvm.coro.size.i64()
@@ -64,6 +64,7 @@ coro.ret:
}
; Function Attrs: argmemonly nounwind readonly
+declare i32 @__gxx_personality_v0(...)
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
declare noalias ptr @malloc(i64)
declare i64 @llvm.coro.size.i64()
diff --git a/llvm/test/Transforms/Coroutines/coro-elide-stat.ll b/llvm/test/Transforms/Coroutines/coro-elide-stat.ll
index eeb300af5068e..73b2ec8d3a10c 100644
--- a/llvm/test/Transforms/Coroutines/coro-elide-stat.ll
+++ b/llvm/test/Transforms/Coroutines/coro-elide-stat.ll
@@ -14,6 +14,7 @@
; FILE: Elide f in callResume
; FILE: Elide f in callResumeMultiRetDommmed
+declare i32 @__gxx_personality_v0(...)
declare void @print(i32) nounwind
; resume part of the coroutine
@@ -94,7 +95,7 @@ ret:
ret void
}
-define void @eh() personality ptr null {
+define void @eh() personality ptr @__gxx_personality_v0 {
entry:
%hdl = call ptr @f()
diff --git a/llvm/test/Transforms/Coroutines/coro-elide.ll b/llvm/test/Transforms/Coroutines/coro-elide.ll
index 86ed88167bfe4..c8bd27ecd1279 100644
--- a/llvm/test/Transforms/Coroutines/coro-elide.ll
+++ b/llvm/test/Transforms/Coroutines/coro-elide.ll
@@ -4,6 +4,7 @@
; RUN: -passes='cgscc(inline,function(coro-elide,dce),inline,function(coro-elide,dce))' \
; RUN: | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @print(i32) nounwind
; resume part of the coroutine
@@ -97,7 +98,7 @@ ret:
}
; CHECK-LABEL: @eh(
-define void @eh() personality ptr null {
+define void @eh() personality ptr @__gxx_personality_v0 {
entry:
%hdl = call ptr @f()
diff --git a/llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll b/llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
index 3d290554e22c9..c53d95e386d52 100644
--- a/llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
+++ b/llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll
@@ -1,7 +1,7 @@
; Check that coro-split doesn't choke on intrinsics in unreachable blocks
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S
-define ptr @f(i1 %arg) presplitcoroutine personality i32 0 {
+define ptr @f(i1 %arg) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%arg.addr = alloca i1
store i1 %arg, ptr %arg.addr
@@ -34,6 +34,7 @@ no.predecessors:
}
+declare i32 @__gxx_personality_v0(...)
declare ptr @llvm.coro.free(token, ptr)
declare i32 @llvm.coro.size.i32()
declare i8 @llvm.coro.suspend(token, i1)
diff --git a/llvm/test/Transforms/Coroutines/coro-frame.ll b/llvm/test/Transforms/Coroutines/coro-frame.ll
index d25d335fe63c6..8e5856154030b 100644
--- a/llvm/test/Transforms/Coroutines/coro-frame.ll
+++ b/llvm/test/Transforms/Coroutines/coro-frame.ll
@@ -1,7 +1,7 @@
; Check that we can handle spills of the result of the invoke instruction
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
-define ptr @f(i64 %this) presplitcoroutine personality i32 0 {
+define ptr @f(i64 %this) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%this.addr = alloca i64
store i64 %this, ptr %this.addr
@@ -49,6 +49,7 @@ pad:
; CHECK: call double @print(double %r.reload)
; CHECK: ret void
+declare i32 @__gxx_personality_v0(...)
declare ptr @llvm.coro.free(token, ptr)
declare i32 @llvm.coro.size.i32()
declare i8 @llvm.coro.suspend(token, i1)
diff --git a/llvm/test/Transforms/Coroutines/coro-heap-elide.ll b/llvm/test/Transforms/Coroutines/coro-heap-elide.ll
index 633045d4c9b83..e281698619977 100644
--- a/llvm/test/Transforms/Coroutines/coro-heap-elide.ll
+++ b/llvm/test/Transforms/Coroutines/coro-heap-elide.ll
@@ -5,6 +5,7 @@
; RUN: -passes='cgscc(inline,function(coro-elide,instsimplify,simplifycfg))' \
; RUN: -aa-pipeline='basic-aa' | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @print(i32) nounwind
%f.frame = type {i32}
@@ -23,7 +24,7 @@ declare void @CustomFree(ptr)
[ptr @f.resume, ptr @f.destroy, ptr @f.cleanup]
; a coroutine start function
-define ptr @f() personality ptr null {
+define ptr @f() personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null,
ptr @f,
@@ -126,7 +127,7 @@ coro.ret:
}
; CHECK-LABEL: @callResume_with_coro_suspend_2(
-define void @callResume_with_coro_suspend_2() personality ptr null {
+define void @callResume_with_coro_suspend_2() personality ptr @__gxx_personality_v0 {
entry:
; CHECK: alloca [4 x i8], align 4
; CHECK-NOT: coro.begin
@@ -303,7 +304,7 @@ return:
; a coroutine start function (cannot elide heap alloc, due to second argument to
; coro.begin not pointint to coro.alloc)
-define ptr @f_no_elision() personality ptr null {
+define ptr @f_no_elision() personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null,
ptr @f_no_elision,
diff --git a/llvm/test/Transforms/Coroutines/coro-resume-destroy.ll b/llvm/test/Transforms/Coroutines/coro-resume-destroy.ll
index 157aa8e372e69..7fdf898ffce49 100644
--- a/llvm/test/Transforms/Coroutines/coro-resume-destroy.ll
+++ b/llvm/test/Transforms/Coroutines/coro-resume-destroy.ll
@@ -1,6 +1,8 @@
; Tests that CoroEarly pass correctly lowers coro.resume, coro.destroy
; RUN: opt < %s -S -passes=coro-early | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
+
; CHECK-LABEL: @callResume(
define void @callResume(ptr %hdl) {
; CHECK-NEXT: entry
@@ -18,7 +20,7 @@ entry:
}
; CHECK-LABEL: @eh(
-define void @eh(ptr %hdl) personality ptr null {
+define void @eh(ptr %hdl) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: entry
entry:
; CHECK-NEXT: %0 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 0)
diff --git a/llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll b/llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
index 16df22b19fd11..7d2bc510df396 100644
--- a/llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
+++ b/llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll
@@ -1,7 +1,7 @@
; Verifies that phi and invoke definitions before CoroBegin are spilled properly.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse,simplifycfg' -S | FileCheck %s
-define ptr @f(i1 %n) presplitcoroutine personality i32 0 {
+define ptr @f(i1 %n) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%size = call i32 @llvm.coro.size.i32()
@@ -61,6 +61,7 @@ lpad:
; CHECK-NEXT: %value_phi.spill.addr = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 2
; CHECK-NEXT: store i32 %spec.select, ptr %value_phi.spill.addr
+declare i32 @__gxx_personality_v0(...)
declare ptr @llvm.coro.free(token, ptr)
declare i32 @llvm.coro.size.i32()
declare i8 @llvm.coro.suspend(token, i1)
diff --git a/llvm/test/Transforms/Coroutines/coro-split-eh-00.ll b/llvm/test/Transforms/Coroutines/coro-split-eh-00.ll
index 0695071306d8d..323678046fc2e 100644
--- a/llvm/test/Transforms/Coroutines/coro-split-eh-00.ll
+++ b/llvm/test/Transforms/Coroutines/coro-split-eh-00.ll
@@ -2,7 +2,7 @@
; and retains it in the start function.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
-define ptr @f(i1 %val) presplitcoroutine personality i32 3 {
+define ptr @f(i1 %val) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%hdl = call ptr @llvm.coro.begin(token %id, ptr null)
@@ -72,6 +72,7 @@ eh.resume:
; CHECK-NEXT: store ptr null, ptr %hdl, align 8
; CHECK-NEXT: resume { ptr, i32 } %lpval
+declare i32 @__gxx_personality_v0(...)
declare ptr @llvm.coro.free(token, ptr)
declare i32 @llvm.coro.size.i32()
declare i8 @llvm.coro.suspend(token, i1)
diff --git a/llvm/test/Transforms/Coroutines/coro-split-eh-01.ll b/llvm/test/Transforms/Coroutines/coro-split-eh-01.ll
index 093fd85b80cdd..3b68c6f71fb50 100644
--- a/llvm/test/Transforms/Coroutines/coro-split-eh-01.ll
+++ b/llvm/test/Transforms/Coroutines/coro-split-eh-01.ll
@@ -2,7 +2,7 @@
; and retains it in the start function.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
-define ptr @f2(i1 %val) presplitcoroutine personality i32 4 {
+define ptr @f2(i1 %val) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%hdl = call ptr @llvm.coro.begin(token %id, ptr null)
@@ -65,6 +65,7 @@ cleanup.cont:
; CHECK-NEXT: store ptr null, ptr %hdl, align 8
; CHECK-NEXT: cleanupret from %tok unwind to caller
+declare i32 @__gxx_personality_v0(...)
declare ptr @llvm.coro.free(token, ptr)
declare i32 @llvm.coro.size.i32()
declare i8 @llvm.coro.suspend(token, i1)
diff --git a/llvm/test/Transforms/Coroutines/coro-split-final-suspend.ll b/llvm/test/Transforms/Coroutines/coro-split-final-suspend.ll
index b620b2d7fa4be..2316617afd324 100644
--- a/llvm/test/Transforms/Coroutines/coro-split-final-suspend.ll
+++ b/llvm/test/Transforms/Coroutines/coro-split-final-suspend.ll
@@ -1,7 +1,7 @@
; Tests that we'll generate the store to the final suspend index if we see the unwind coro end.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
-define ptr @unwind_coro_end() presplitcoroutine personality i32 3 {
+define ptr @unwind_coro_end() presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%hdl = call ptr @llvm.coro.begin(token %id, ptr null)
@@ -71,7 +71,7 @@ eh.resume:
; CHECK: %[[INDEX:.+]] = load i1, ptr %index.addr
; CHECK-NEXT: switch i1 %[[INDEX]],
-define ptr @nounwind_coro_end(i1 %val) presplitcoroutine personality i32 3 {
+define ptr @nounwind_coro_end(i1 %val) presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%hdl = call ptr @llvm.coro.begin(token %id, ptr null)
@@ -114,6 +114,7 @@ suspend:
; CHECK: %[[RESUME_FN:.+]] = load ptr, ptr %hdl, align 8
; CHECK: %{{.*}} = icmp eq ptr %[[RESUME_FN]], null
+declare i32 @__gxx_personality_v0(...)
declare ptr @llvm.coro.free(token, ptr)
declare i32 @llvm.coro.size.i32()
declare i8 @llvm.coro.suspend(token, i1)
diff --git a/llvm/test/Transforms/Coroutines/coro-split-musttail13.ll b/llvm/test/Transforms/Coroutines/coro-split-musttail13.ll
index c726810e25d13..28a5cf5ca55c1 100644
--- a/llvm/test/Transforms/Coroutines/coro-split-musttail13.ll
+++ b/llvm/test/Transforms/Coroutines/coro-split-musttail13.ll
@@ -2,11 +2,12 @@
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @fakeresume1(ptr)
declare void @may_throw(ptr)
declare void @print()
-define void @f(i1 %cond) #0 personality i32 3 {
+define void @f(i1 %cond) #0 personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%alloc = call ptr @malloc(i64 16) #3
diff --git a/llvm/test/Transforms/Coroutines/no-suspend.ll b/llvm/test/Transforms/Coroutines/no-suspend.ll
index c08423d6053fc..fbb876c84f14e 100644
--- a/llvm/test/Transforms/Coroutines/no-suspend.ll
+++ b/llvm/test/Transforms/Coroutines/no-suspend.ll
@@ -94,7 +94,7 @@ suspend:
; CHECK-NEXT: call void @print(i32 1)
; CHECK-NEXT: ret void
;
-define void @simplify_destroy() presplitcoroutine personality i32 0 {
+define void @simplify_destroy() presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%need.dyn.alloc = call i1 @llvm.coro.alloc(token %id)
@@ -256,7 +256,7 @@ suspend:
; CHECK-NEXT: entry:
; CHECK-NEXT: llvm.coro.id
-define void @cannot_simplify_calls_in_terminator() presplitcoroutine personality i32 0 {
+define void @cannot_simplify_calls_in_terminator() presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%need.dyn.alloc = call i1 @llvm.coro.alloc(token %id)
@@ -353,7 +353,7 @@ suspend:
; CHECK-NEXT: entry:
; CHECK-NEXT: llvm.coro.id
;
-define void @cannot_simplify_final_suspend() presplitcoroutine personality i32 0 {
+define void @cannot_simplify_final_suspend() presplitcoroutine personality ptr @__gxx_personality_v0 {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
%need.dyn.alloc = call i1 @llvm.coro.alloc(token %id)
@@ -398,6 +398,7 @@ lpad:
resume { ptr, i32 } %lpval
}
+declare i32 @__gxx_personality_v0(...)
declare ptr @malloc(i32) allockind("alloc,uninitialized") allocsize(0)
declare void @free(ptr) willreturn allockind("free")
declare void @print(i32)
diff --git a/llvm/test/Transforms/DeadArgElim/aggregates.ll b/llvm/test/Transforms/DeadArgElim/aggregates.ll
index 784ac3af64c75..a9c8988157eb6 100644
--- a/llvm/test/Transforms/DeadArgElim/aggregates.ll
+++ b/llvm/test/Transforms/DeadArgElim/aggregates.ll
@@ -68,6 +68,7 @@ use_aggregate:
ret { i32, i32 } %val
}
+declare i32 @__gxx_personality_v0(...)
declare void @callee(i32)
; Case 3: the insertvalue meant %in was live if ret-slot-1 was, but we were only
@@ -170,7 +171,7 @@ entry:
; CHECK: %[[invoke:.*]] = invoke i32 @agg_ret()
; CHECK: %[[oldret:.*]] = insertvalue { i32 } poison, i32 %[[invoke]], 0
; CHECK: phi { i32 } [ %[[oldret]],
-define void @PR24906() personality ptr poison {
+define void @PR24906() personality ptr @__gxx_personality_v0 {
entry:
%tmp2 = invoke { i32 } @agg_ret()
to label %bb3 unwind label %bb4
diff --git a/llvm/test/Transforms/DeadStoreElimination/captures-before-call.ll b/llvm/test/Transforms/DeadStoreElimination/captures-before-call.ll
index 9a23c738ef689..7dd6e038b411b 100644
--- a/llvm/test/Transforms/DeadStoreElimination/captures-before-call.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/captures-before-call.ll
@@ -34,6 +34,7 @@ entry:
ret i32 %add
}
+declare i32 @__gxx_personality_v0(...)
declare void @escape(ptr)
declare i32 @getval()
@@ -622,7 +623,7 @@ bb:
}
-define void @test_invoke_captures() personality ptr undef {
+define void @test_invoke_captures() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test_invoke_captures(
; CHECK-NEXT: bb:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
diff --git a/llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll b/llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll
index 5f8ab56c22754..a1768333f3e04 100644
--- a/llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=dse -enable-dse-initializes-attr-improvement -S | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @p1_write_only(ptr nocapture noundef writeonly initializes((0, 2)) dead_on_unwind)
declare void @p1_write_then_read(ptr nocapture noundef initializes((0, 2)) dead_on_unwind)
declare void @p1_clobber(ptr nocapture noundef)
@@ -77,7 +78,7 @@ define i16 @p1_write_then_read_caller_with_clobber() {
}
declare void @p1_write_then_read_raw(ptr nocapture noundef initializes((0, 2)))
-define i16 @p1_initializes_invoke() personality ptr undef {
+define i16 @p1_initializes_invoke() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @p1_initializes_invoke(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR:%.*]] = alloca i16, align 2
diff --git a/llvm/test/Transforms/DivRemPairs/X86/div-rem-pairs.ll b/llvm/test/Transforms/DivRemPairs/X86/div-rem-pairs.ll
index 8bf75bb5bcb2e..8fdb6db2d0c72 100644
--- a/llvm/test/Transforms/DivRemPairs/X86/div-rem-pairs.ll
+++ b/llvm/test/Transforms/DivRemPairs/X86/div-rem-pairs.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=div-rem-pairs -S -mtriple=x86_64-unknown-unknown | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @foo(i32, i32)
define void @decompose_illegal_srem_same_block(i32 %a, i32 %b) {
@@ -466,7 +467,7 @@ return:
declare void @dummy()
-define i32 @invoke_not_willreturn(i32 %a, i32 %b) personality ptr null {
+define i32 @invoke_not_willreturn(i32 %a, i32 %b) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoke_not_willreturn(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @dummy()
@@ -495,7 +496,7 @@ lpad:
ret i32 %rem
}
-define i32 @invoke_willreturn(i32 %a, i32 %b) personality ptr null {
+define i32 @invoke_willreturn(i32 %a, i32 %b) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoke_willreturn(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[A:%.*]], [[B:%.*]]
diff --git a/llvm/test/Transforms/GVN/calloc-load-removal.ll b/llvm/test/Transforms/GVN/calloc-load-removal.ll
index 3a21344581d39..6386b2ff54ecb 100644
--- a/llvm/test/Transforms/GVN/calloc-load-removal.ll
+++ b/llvm/test/Transforms/GVN/calloc-load-removal.ll
@@ -20,7 +20,7 @@ define i32 @test1() {
}
-define i32 @as_invoke(i1 %c) personality ptr undef {
+define i32 @as_invoke(i1 %c) personality ptr @__gxx_personality_v0 {
bb3:
%mem = invoke noalias ptr @calloc(i64 1, i64 4)
to label %bb4 unwind label %bb1
@@ -43,4 +43,5 @@ bb4:
; CHECK_NO_LIBCALLS: ret i32 %
}
+declare i32 @__gxx_personality_v0(...)
declare noalias ptr @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1)
diff --git a/llvm/test/Transforms/GVN/mssa-update-dead-def.ll b/llvm/test/Transforms/GVN/mssa-update-dead-def.ll
index 1a5b7043676c2..d7b49826ac0f7 100644
--- a/llvm/test/Transforms/GVN/mssa-update-dead-def.ll
+++ b/llvm/test/Transforms/GVN/mssa-update-dead-def.ll
@@ -4,8 +4,8 @@
; This is a regression test for a bug in MemorySSA updater.
; Make sure that we don't crash and end up with a valid MemorySSA.
-define void @test() personality ptr null {
-; CHECK-LABEL: define void @test() personality ptr null {
+define void @test() personality ptr @__gxx_personality_v0 {
+; CHECK-LABEL: define void @test() personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: invoke void @bar()
; CHECK-NEXT: to label %[[BAR_NORMAL:.*]] unwind label %[[EXCEPTIONAL:.*]]
; CHECK: [[BAR_NORMAL]]:
@@ -44,6 +44,7 @@ exceptional:
ret void
}
+declare i32 @__gxx_personality_v0(...)
declare void @foo()
declare void @bar()
declare void @baz()
diff --git a/llvm/test/Transforms/GVN/preserve-memoryssa.ll b/llvm/test/Transforms/GVN/preserve-memoryssa.ll
index 57152964e7aad..45e84a8930b90 100644
--- a/llvm/test/Transforms/GVN/preserve-memoryssa.ll
+++ b/llvm/test/Transforms/GVN/preserve-memoryssa.ll
@@ -3,6 +3,7 @@
; REQUIRES: asserts
+declare i32 @__gxx_personality_v0(...)
declare void @use(i32) readnone
define i32 @test(ptr %ptr.0, ptr %ptr.1, i1 %c) {
@@ -140,7 +141,7 @@ define i32 @test_assume_false_to_store_undef_3(ptr %ptr, ptr %ptr.2) {
}
; Test case for PR48616.
-define void @rename_unreachable_block(i1 %c) personality ptr undef {
+define void @rename_unreachable_block(i1 %c) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @rename_unreachable_block(
; CHECK-NEXT: ret void
; CHECK: bb1:
diff --git a/llvm/test/Transforms/GlobalOpt/invoke.ll b/llvm/test/Transforms/GlobalOpt/invoke.ll
index b24b9aa54b468..52240f1c69a59 100644
--- a/llvm/test/Transforms/GlobalOpt/invoke.ll
+++ b/llvm/test/Transforms/GlobalOpt/invoke.ll
@@ -4,6 +4,7 @@
; Globalopt should be able to evaluate an invoke.
; CHECK: @tmp = local_unnamed_addr global i32 1
+declare i32 @__gxx_personality_v0(...)
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__I_a, ptr null }]
@tmp = global i32 0
@@ -11,7 +12,7 @@ define i32 @one() {
ret i32 1
}
-define void @_GLOBAL__I_a() personality ptr undef {
+define void @_GLOBAL__I_a() personality ptr @__gxx_personality_v0 {
bb:
%tmp1 = invoke i32 @one()
to label %bb2 unwind label %bb4
diff --git a/llvm/test/Transforms/HotColdSplit/eh-pads.ll b/llvm/test/Transforms/HotColdSplit/eh-pads.ll
index ad7baf97f68d0..f61e1125980df 100644
--- a/llvm/test/Transforms/HotColdSplit/eh-pads.ll
+++ b/llvm/test/Transforms/HotColdSplit/eh-pads.ll
@@ -6,7 +6,7 @@ target triple = "x86_64-apple-macosx10.14.0"
; CHECK-LABEL: define {{.*}}@foo(
; CHECK: landingpad
; CHECK: sideeffect(i32 2)
-define void @foo(i32 %cond) personality i8 0 {
+define void @foo(i32 %cond) personality ptr @__gxx_personality_v0 {
entry:
invoke void @llvm.donothing() to label %normal unwind label %exception
@@ -30,7 +30,7 @@ normal:
;
; CHECK-LABEL: define {{.*}}@bar(
; CHECK: landingpad
-define void @bar(i32 %cond) personality i8 0 {
+define void @bar(i32 %cond) personality ptr @__gxx_personality_v0 {
entry:
br i1 undef, label %exit, label %continue
@@ -54,7 +54,7 @@ normal:
ret void
}
-define void @baz() personality i8 0 {
+define void @baz() personality ptr @__gxx_personality_v0 {
entry:
br i1 undef, label %exit, label %cold1
@@ -95,6 +95,7 @@ cold4:
; CHECK-LABEL: define {{.*}}@baz.cold.2(
; CHECK: sideeffect(i32 1)
+declare i32 @__gxx_personality_v0(...)
declare void @sideeffect(i32)
declare void @sink() cold
diff --git a/llvm/test/Transforms/HotColdSplit/resume.ll b/llvm/test/Transforms/HotColdSplit/resume.ll
index 8c1ff1b01c00c..9e259a6caf8f1 100644
--- a/llvm/test/Transforms/HotColdSplit/resume.ll
+++ b/llvm/test/Transforms/HotColdSplit/resume.ll
@@ -8,9 +8,10 @@ target triple = "x86_64-apple-macosx10.14.0"
; CHECK-LABEL: define {{.*}}@foo.cold.1(
; CHECK: call {{.*}}@sink(
+declare i32 @__gxx_personality_v0(...)
declare void @sink() cold
-define i32 @foo() personality i8 0 {
+define i32 @foo() personality ptr @__gxx_personality_v0 {
entry:
br i1 undef, label %pre-resume-eh, label %normal
diff --git a/llvm/test/Transforms/HotColdSplit/unwind.ll b/llvm/test/Transforms/HotColdSplit/unwind.ll
index 058fb32f319ab..2b2ec2387f9ce 100644
--- a/llvm/test/Transforms/HotColdSplit/unwind.ll
+++ b/llvm/test/Transforms/HotColdSplit/unwind.ll
@@ -11,7 +11,7 @@ target triple = "x86_64-apple-macosx10.14.0"
; CHECK-NOT: noreturn
-define i32 @foo() personality i8 0 {
+define i32 @foo() personality ptr @__gxx_personality_v0 {
entry:
invoke void @llvm.donothing() to label %normal unwind label %exception
@@ -35,6 +35,7 @@ exit:
ret i32 0
}
+declare i32 @__gxx_personality_v0(...)
declare void @sideeffect(i32)
declare void @sink() cold
diff --git a/llvm/test/Transforms/IROutliner/illegal-catchpad.ll b/llvm/test/Transforms/IROutliner/illegal-catchpad.ll
index a25007fd8034d..3422232ca2caf 100644
--- a/llvm/test/Transforms/IROutliner/illegal-catchpad.ll
+++ b/llvm/test/Transforms/IROutliner/illegal-catchpad.ll
@@ -5,9 +5,10 @@
; in a similar section. Dealing with exception handling inside of an outlined
; function would require a lot of handling that is not implemented yet.
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.donothing() nounwind readnone
-define void @function1() personality i8 3 {
+define void @function1() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
@@ -38,7 +39,7 @@ normal:
ret void
}
-define void @function2() personality i8 3 {
+define void @function2() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
diff --git a/llvm/test/Transforms/IROutliner/illegal-cleanup.ll b/llvm/test/Transforms/IROutliner/illegal-cleanup.ll
index b9eeba911f578..1d9be6f59900c 100644
--- a/llvm/test/Transforms/IROutliner/illegal-cleanup.ll
+++ b/llvm/test/Transforms/IROutliner/illegal-cleanup.ll
@@ -5,9 +5,10 @@
; in a similar section. Dealing with exception handling inside of an outlined
; function would require a lot of handling that is not implemented yet.
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.donothing() nounwind readnone
-define void @function1() personality i8 3 {
+define void @function1() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
@@ -34,7 +35,7 @@ normal:
ret void
}
-define void @function2() personality i8 3 {
+define void @function2() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
diff --git a/llvm/test/Transforms/IROutliner/illegal-invoke.ll b/llvm/test/Transforms/IROutliner/illegal-invoke.ll
index 82d62b928a3f8..565b2ee724856 100644
--- a/llvm/test/Transforms/IROutliner/illegal-invoke.ll
+++ b/llvm/test/Transforms/IROutliner/illegal-invoke.ll
@@ -5,9 +5,10 @@
; in a similar section. Outlining does not currently handle control flow
; changes.
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.donothing() nounwind readnone
-define void @function1() personality i8 3 {
+define void @function1() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
@@ -35,7 +36,7 @@ normal:
ret void
}
-define void @function2() personality i8 3 {
+define void @function2() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
diff --git a/llvm/test/Transforms/IROutliner/illegal-landingpad.ll b/llvm/test/Transforms/IROutliner/illegal-landingpad.ll
index 5d70d55ab6e4e..a5a0b59109a50 100644
--- a/llvm/test/Transforms/IROutliner/illegal-landingpad.ll
+++ b/llvm/test/Transforms/IROutliner/illegal-landingpad.ll
@@ -5,9 +5,10 @@
; in a similar section. Dealing with exception handling inside of an outlined
; function would require a lot of handling that is not implemented yet.
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.donothing() nounwind readnone
-define void @function1() personality i8 3 {
+define void @function1() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
@@ -35,7 +36,7 @@ normal:
ret void
}
-define void @function2() personality i8 3 {
+define void @function2() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @function2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
diff --git a/llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll b/llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll
index d4498baf0577a..15be73365b77a 100644
--- a/llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll
+++ b/llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll
@@ -223,6 +223,7 @@ for.end:
ret i32 %sum.0
}
+declare i32 @__gxx_personality_v0(...)
declare i32 @fn1(i8 signext)
; PR21030
@@ -738,7 +739,7 @@ declare void @test14a-callee(i1 %cond)
; Same as @test14 but with unwind exit.
; Trunc instructions must be added below the landing pad.
-define i32 @test14a(i32 %start, ptr %p, ptr %q, i1 %c) personality i1 1 {
+define i32 @test14a(i32 %start, ptr %p, ptr %q, i1 %c) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test14a(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[START:%.*]] to i64
diff --git a/llvm/test/Transforms/IndVarSimplify/pr55925.ll b/llvm/test/Transforms/IndVarSimplify/pr55925.ll
index 2ad187add4e10..bb07c4d7669a3 100644
--- a/llvm/test/Transforms/IndVarSimplify/pr55925.ll
+++ b/llvm/test/Transforms/IndVarSimplify/pr55925.ll
@@ -6,9 +6,10 @@
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
+declare i32 @__gxx_personality_v0(...)
declare i32 @foo(i32)
-define void @test(ptr %p) personality ptr undef {
+define void @test(ptr %p) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
@@ -48,7 +49,7 @@ exit:
ret void
}
-define void @test_critedge(i1 %c, ptr %p) personality ptr undef {
+define void @test_critedge(i1 %c, ptr %p) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test_critedge(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
diff --git a/llvm/test/Transforms/Inline/X86/inline-landing-pad.ll b/llvm/test/Transforms/Inline/X86/inline-landing-pad.ll
index 8422a4c1082a9..e540a56201feb 100644
--- a/llvm/test/Transforms/Inline/X86/inline-landing-pad.ll
+++ b/llvm/test/Transforms/Inline/X86/inline-landing-pad.ll
@@ -4,9 +4,11 @@
;; "resume" instruction with a branch to the landing pad block, we also transfer
;; the resume's source location to the branch.
-define void @widget() personality ptr null !dbg !11 {
+declare i32 @__gxx_personality_v0(...)
+
+define void @widget() personality ptr @__gxx_personality_v0 !dbg !11 {
; CHECK-LABEL: define void @widget(
-; CHECK-SAME: ) personality ptr null !dbg [[DBG4:![0-9]+]] {
+; CHECK-SAME: ) personality ptr @__gxx_personality_v0 !dbg [[DBG4:![0-9]+]] {
; CHECK-NEXT: [[BAZ_EXIT:.*]]:
; CHECK-NEXT: br label %[[BB2_BODY:.*]], !dbg [[DBG7:![0-9]+]]
; CHECK: [[BAZ_EXIT1:.*:]]
@@ -34,9 +36,9 @@ bb2: ; preds = %bb
br label %bb1
}
-define i32 @baz(ptr %arg, ptr %arg1) personality ptr null !dbg !14 {
+define i32 @baz(ptr %arg, ptr %arg1) personality ptr @__gxx_personality_v0 !dbg !14 {
; CHECK-LABEL: define i32 @baz(
-; CHECK-SAME: ptr [[ARG:%.*]], ptr [[ARG1:%.*]]) personality ptr null !dbg [[DBG8:![0-9]+]] {
+; CHECK-SAME: ptr [[ARG:%.*]], ptr [[ARG1:%.*]]) personality ptr @__gxx_personality_v0 !dbg [[DBG8:![0-9]+]] {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: resume { ptr, i32 } zeroinitializer, !dbg [[DBG10:![0-9]+]]
;
diff --git a/llvm/test/Transforms/Inline/deopt-bundles.ll b/llvm/test/Transforms/Inline/deopt-bundles.ll
index 57175fabf0df4..7e57b05fd9561 100644
--- a/llvm/test/Transforms/Inline/deopt-bundles.ll
+++ b/llvm/test/Transforms/Inline/deopt-bundles.ll
@@ -1,5 +1,6 @@
; RUN: opt -S -passes=always-inline < %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @f()
declare i32 @g()
declare fastcc i32 @g.fastcc()
@@ -63,7 +64,7 @@ define i32 @callee_3() alwaysinline {
ret i32 %v
}
-define i32 @caller_3() personality i8 3 {
+define i32 @caller_3() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @caller_3(
entry:
%x = invoke i32 @callee_3() [ "deopt"(i32 7) ] to label %normal unwind label %unwind
@@ -77,7 +78,7 @@ define i32 @caller_3() personality i8 3 {
ret i32 101
}
-define i32 @callee_4() alwaysinline personality i8 3 {
+define i32 @callee_4() alwaysinline personality ptr @__gxx_personality_v0 {
entry:
%v = invoke i32 @g() [ "deopt"(i32 0, i32 1), "foo"(double 0.0) ] to label %normal unwind label %unwind
@@ -97,7 +98,7 @@ define i32 @caller_4() {
ret i32 %x
}
-define i32 @callee_5() alwaysinline personality i8 3 {
+define i32 @callee_5() alwaysinline personality ptr @__gxx_personality_v0 {
entry:
%v = invoke fastcc i32 @g.fastcc() #0 [ "deopt"(i32 0, i32 1), "foo"(double 0.0) ] to label %normal unwind label %unwind
@@ -117,7 +118,7 @@ define i32 @caller_5() {
ret i32 %x
}
-define i32 @callee_6() alwaysinline personality i8 3 {
+define i32 @callee_6() alwaysinline personality ptr @__gxx_personality_v0 {
entry:
%v = call fastcc i32 @g.fastcc() #0 [ "deopt"(i32 0, i32 1), "foo"(double 0.0) ]
ret i32 %v
@@ -131,7 +132,7 @@ define i32 @caller_6() {
ret i32 %x
}
-define i32 @callee_7(i1 %val) alwaysinline personality i8 3 {
+define i32 @callee_7(i1 %val) alwaysinline personality ptr @__gxx_personality_v0 {
; We want something that PruningFunctionCloner is not smart enough to
; recognize, but can be recognized by recursivelySimplifyInstruction.
@@ -162,7 +163,7 @@ define i32 @caller_7() {
ret i32 %x
}
-define i32 @callee_8(i1 %val) alwaysinline personality i8 3 {
+define i32 @callee_8(i1 %val) alwaysinline personality ptr @__gxx_personality_v0 {
; We want something that PruningFunctionCloner is not smart enough to
; recognize, but can be recognized by recursivelySimplifyInstruction.
diff --git a/llvm/test/Transforms/Inline/deoptimize-intrinsic.ll b/llvm/test/Transforms/Inline/deoptimize-intrinsic.ll
index 1cc327ada7ee3..8e8ed69f20f10 100644
--- a/llvm/test/Transforms/Inline/deoptimize-intrinsic.ll
+++ b/llvm/test/Transforms/Inline/deoptimize-intrinsic.ll
@@ -1,5 +1,6 @@
; RUN: opt -S -passes=always-inline < %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare i8 @llvm.experimental.deoptimize.i8(...)
declare i32 @llvm.experimental.deoptimize.i32(...)
@@ -56,7 +57,7 @@ entry:
}
-define i32 @caller_1(ptr %c, ptr %ptr) personality i8 3 {
+define i32 @caller_1(ptr %c, ptr %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @caller_1(
entry:
%v = invoke i8 @callee(ptr %c) [ "deopt"(i32 3) ] to label %normal
diff --git a/llvm/test/Transforms/Inline/guard-intrinsic.ll b/llvm/test/Transforms/Inline/guard-intrinsic.ll
index 4e2bdfb196a40..2427c5df44780 100644
--- a/llvm/test/Transforms/Inline/guard-intrinsic.ll
+++ b/llvm/test/Transforms/Inline/guard-intrinsic.ll
@@ -1,5 +1,6 @@
; RUN: opt -S -passes=always-inline < %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.experimental.guard(i1, ...)
define i8 @callee(ptr %c_ptr) alwaysinline {
@@ -20,7 +21,7 @@ entry:
ret void
}
-define i32 @caller_1(ptr %c, ptr %ptr) personality i8 3 {
+define i32 @caller_1(ptr %c, ptr %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @caller_1(
; CHECK: [[COND:%[^ ]+]] = load volatile i1, ptr %c
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND]], i32 1) [ "deopt"(i32 3, i32 1) ]
diff --git a/llvm/test/Transforms/Inline/inline_returns_twice.ll b/llvm/test/Transforms/Inline/inline_returns_twice.ll
index cacedc0e0bcf0..a890293985c08 100644
--- a/llvm/test/Transforms/Inline/inline_returns_twice.ll
+++ b/llvm/test/Transforms/Inline/inline_returns_twice.ll
@@ -4,6 +4,7 @@
; Check that functions with "returns_twice" calls are only inlined,
; if they are themselves marked as such.
+declare i32 @__gxx_personality_v0(...)
declare i32 @a() returns_twice
define i32 @inner1() {
@@ -38,7 +39,7 @@ entry:
ret i32 %add
}
-define i32 @inner3() personality ptr null {
+define i32 @inner3() personality ptr @__gxx_personality_v0 {
entry:
%invoke = invoke i32 @a() returns_twice
to label %cont unwind label %lpad
@@ -61,7 +62,7 @@ entry:
ret i32 %add
}
-define i32 @inner4() returns_twice personality ptr null {
+define i32 @inner4() returns_twice personality ptr @__gxx_personality_v0 {
entry:
%invoke = invoke i32 @a() returns_twice
to label %cont unwind label %lpad
diff --git a/llvm/test/Transforms/Inline/invoke-cleanup.ll b/llvm/test/Transforms/Inline/invoke-cleanup.ll
index 9e0344b5b08a4..7b2a1e2e03d37 100644
--- a/llvm/test/Transforms/Inline/invoke-cleanup.ll
+++ b/llvm/test/Transforms/Inline/invoke-cleanup.ll
@@ -2,13 +2,14 @@
; RUN: opt %s -passes='cgscc(inline)' -S | FileCheck %s
; RUN: opt %s -passes='module-inline' -S | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @external_func()
@exception_type1 = external global i8
@exception_type2 = external global i8
-define internal void @inner() personality ptr null {
+define internal void @inner() personality ptr @__gxx_personality_v0 {
invoke void @external_func()
to label %cont unwind label %lpad
cont:
@@ -23,7 +24,7 @@ lpad:
; this call site (PR17872), otherwise C++ destructors will not be
; called when they should be.
-define void @outer() personality ptr null {
+define void @outer() personality ptr @__gxx_personality_v0 {
invoke void @inner()
to label %cont unwind label %lpad
cont:
diff --git a/llvm/test/Transforms/Inline/invoke-combine-clauses.ll b/llvm/test/Transforms/Inline/invoke-combine-clauses.ll
index ec1dafe8b68a6..5b1c5025d09b0 100644
--- a/llvm/test/Transforms/Inline/invoke-combine-clauses.ll
+++ b/llvm/test/Transforms/Inline/invoke-combine-clauses.ll
@@ -1,6 +1,7 @@
; RUN: opt %s -passes='cgscc(inline)' -S | FileCheck %s
; RUN: opt %s -passes='module-inline' -S | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @external_func()
declare void @abort()
@@ -13,7 +14,7 @@ declare void @abort()
; inlined function caused "catch ptr @exception_outer" to appear
; multiple times in the resulting landingpad.
-define internal void @inner_multiple_resume() personality ptr null {
+define internal void @inner_multiple_resume() personality ptr @__gxx_personality_v0 {
invoke void @external_func()
to label %cont unwind label %lpad
cont:
@@ -29,7 +30,7 @@ resume2:
resume i32 2
}
-define void @outer_multiple_resume() personality ptr null {
+define void @outer_multiple_resume() personality ptr @__gxx_personality_v0 {
invoke void @inner_multiple_resume()
to label %cont unwind label %lpad
cont:
@@ -51,7 +52,7 @@ lpad:
; inlined function caused "catch ptr @exception_outer" to appear
; multiple times in the resulting landingpad.
-define internal void @inner_resume_and_call() personality ptr null {
+define internal void @inner_resume_and_call() personality ptr @__gxx_personality_v0 {
call void @external_func()
invoke void @external_func()
to label %cont unwind label %lpad
@@ -63,7 +64,7 @@ lpad:
resume i32 %lp
}
-define void @outer_resume_and_call() personality ptr null {
+define void @outer_resume_and_call() personality ptr @__gxx_personality_v0 {
invoke void @inner_resume_and_call()
to label %cont unwind label %lpad
cont:
@@ -87,7 +88,7 @@ lpad:
; function (since the outer function's landingpad will not be
; reachable), but it's OK to include this clause.
-define internal void @inner_no_resume_or_call() personality ptr null {
+define internal void @inner_no_resume_or_call() personality ptr @__gxx_personality_v0 {
invoke void @external_func()
to label %cont unwind label %lpad
cont:
@@ -100,7 +101,7 @@ lpad:
unreachable
}
-define void @outer_no_resume_or_call() personality ptr null {
+define void @outer_no_resume_or_call() personality ptr @__gxx_personality_v0 {
invoke void @inner_no_resume_or_call()
to label %cont unwind label %lpad
cont:
diff --git a/llvm/test/Transforms/Inline/pr53206.ll b/llvm/test/Transforms/Inline/pr53206.ll
index 266a7f8083ea2..315ca3b2c559d 100644
--- a/llvm/test/Transforms/Inline/pr53206.ll
+++ b/llvm/test/Transforms/Inline/pr53206.ll
@@ -4,7 +4,8 @@
; Check that the exception handling code is fully pruned, and does not
; leave behind invalid IR.
-define internal void @foo(i1 %arg) personality ptr undef {
+declare i32 @__gxx_personality_v0(...)
+define internal void @foo(i1 %arg) personality ptr @__gxx_personality_v0 {
entry:
br i1 false, label %join, label %split
@@ -42,7 +43,7 @@ exit:
ret void
}
-define void @test() personality ptr undef {
+define void @test() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test(
; CHECK-NEXT: ret void
;
diff --git a/llvm/test/Transforms/InstCombine/debuginfo-invoke.ll b/llvm/test/Transforms/InstCombine/debuginfo-invoke.ll
index 287582b9baf3b..431565d8363ea 100644
--- a/llvm/test/Transforms/InstCombine/debuginfo-invoke.ll
+++ b/llvm/test/Transforms/InstCombine/debuginfo-invoke.ll
@@ -1,9 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -passes=instcombine -S %s -o - | FileCheck %s
-define void @foo() personality ptr null !dbg !4 {
+define void @foo() personality ptr @__gxx_personality_v0 !dbg !4 {
; CHECK-LABEL: define void @foo(
-; CHECK-SAME: ) personality ptr null !dbg [[DBG3:![0-9]+]] {
+; CHECK-SAME: ) personality ptr @__gxx_personality_v0 !dbg [[DBG3:![0-9]+]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: invoke void @llvm.donothing()
; CHECK-NEXT: to label %[[COMMON_RET:.*]] unwind label %[[LPAD159:.*]], !dbg [[DBG7:![0-9]+]]
@@ -27,6 +27,7 @@ lpad159: ; preds = %entry
br label %common.ret
}
+declare i32 @__gxx_personality_v0(...)
declare ptr @_Znam(i64)
!llvm.dbg.cu = !{!0}
diff --git a/llvm/test/Transforms/InstCombine/fabs.ll b/llvm/test/Transforms/InstCombine/fabs.ll
index 9870f96bb9925..cce0c684c0093 100644
--- a/llvm/test/Transforms/InstCombine/fabs.ll
+++ b/llvm/test/Transforms/InstCombine/fabs.ll
@@ -3,6 +3,7 @@
; Make sure libcalls are replaced with intrinsic calls.
+declare i32 @__gxx_personality_v0(...)
declare float @llvm.fabs.f32(float)
declare <2 x float> @llvm.fabs.v2f32(<2 x float>)
declare double @llvm.fabs.f64(double)
@@ -1649,7 +1650,7 @@ define <2 x i1> @test_fabs_used_vp_is_fpclass_zero_or_pinf(<2 x float> %x, <2 x
ret <2 x i1> %is_fpclass
}
-define void @test_fabs_nsz_used_by_invoke(float %x) personality ptr null {
+define void @test_fabs_nsz_used_by_invoke(float %x) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test_fabs_nsz_used_by_invoke(
; CHECK-NEXT: [[SEL:%.*]] = call nsz float @llvm.fabs.f32(float [[X:%.*]])
; CHECK-NEXT: invoke void @use(float nofpclass(nan) [[SEL]])
diff --git a/llvm/test/Transforms/InstCombine/freeze-landingpad.ll b/llvm/test/Transforms/InstCombine/freeze-landingpad.ll
index 29167958c857f..81a3f7c8c8cc9 100644
--- a/llvm/test/Transforms/InstCombine/freeze-landingpad.ll
+++ b/llvm/test/Transforms/InstCombine/freeze-landingpad.ll
@@ -2,7 +2,9 @@
; Check that no freeze instruction gets inserted before landingpad in a basic block
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
-define i32 @propagate_freeze_in_landingpad() personality ptr null {
+declare i32 @__gxx_personality_v0(...)
+
+define i32 @propagate_freeze_in_landingpad() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @propagate_freeze_in_landingpad(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[INVOKE_BB1:%.*]]
diff --git a/llvm/test/Transforms/InstCombine/freeze.ll b/llvm/test/Transforms/InstCombine/freeze.ll
index 6ff13c005a999..0304b6913196d 100644
--- a/llvm/test/Transforms/InstCombine/freeze.ll
+++ b/llvm/test/Transforms/InstCombine/freeze.ll
@@ -30,6 +30,7 @@ define i32 @and_freeze_undef(i32 %x) {
ret i32 %res
}
+declare i32 @__gxx_personality_v0(...)
declare void @use_i32(i32)
declare void @use_p32(ptr)
@@ -410,9 +411,9 @@ join:
ret i32 %phi
}
-define i32 @freeze_invoke_use_in_phi(i1 %c) personality ptr undef {
+define i32 @freeze_invoke_use_in_phi(i1 %c) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @freeze_invoke_use_in_phi(
-; CHECK-SAME: i1 [[C:%.*]]) personality ptr undef {
+; CHECK-SAME: i1 [[C:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[X:%.*]] = invoke i32 @get_i32()
; CHECK-NEXT: to label %[[INVOKE_CONT:.*]] unwind label %[[INVOKE_UNWIND:.*]]
@@ -443,9 +444,9 @@ invoke.unwind:
unreachable
}
-define i32 @freeze_invoke_use_after_phi(i1 %c) personality ptr undef {
+define i32 @freeze_invoke_use_after_phi(i1 %c) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @freeze_invoke_use_after_phi(
-; CHECK-SAME: i1 [[C:%.*]]) personality ptr undef {
+; CHECK-SAME: i1 [[C:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[X:%.*]] = invoke i32 @get_i32()
; CHECK-NEXT: to label %[[INVOKE_CONT:.*]] unwind label %[[INVOKE_UNWIND:.*]]
@@ -1248,9 +1249,9 @@ exit:
; When the phi input comes from an invoke, we need to be careful the freeze
; isn't pushed after the invoke.
-define void @fold_phi_noundef_start_value_with_invoke(ptr noundef %init, i1 %cond.0, i1 %cond.1) personality ptr undef {
+define void @fold_phi_noundef_start_value_with_invoke(ptr noundef %init, i1 %cond.0, i1 %cond.1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @fold_phi_noundef_start_value_with_invoke(
-; CHECK-SAME: ptr noundef [[INIT:%.*]], i1 [[COND_0:%.*]], i1 [[COND_1:%.*]]) personality ptr undef {
+; CHECK-SAME: ptr noundef [[INIT:%.*]], i1 [[COND_0:%.*]], i1 [[COND_1:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: br label %[[LOOP:.*]]
; CHECK: [[LOOP]]:
@@ -1302,9 +1303,9 @@ exit:
ret void
}
-define void @fold_phi_invoke_start_value(i32 %n) personality ptr undef {
+define void @fold_phi_invoke_start_value(i32 %n) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @fold_phi_invoke_start_value(
-; CHECK-SAME: i32 [[N:%.*]]) personality ptr undef {
+; CHECK-SAME: i32 [[N:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[INIT:%.*]] = invoke i32 @get_i32()
; CHECK-NEXT: to label %[[LOOP:.*]] unwind label %[[UNWIND:.*]]
@@ -1340,9 +1341,9 @@ exit:
ret void
}
-define void @fold_phi_invoke_noundef_start_value(i32 %n) personality ptr undef {
+define void @fold_phi_invoke_noundef_start_value(i32 %n) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @fold_phi_invoke_noundef_start_value(
-; CHECK-SAME: i32 [[N:%.*]]) personality ptr undef {
+; CHECK-SAME: i32 [[N:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[INIT:%.*]] = invoke noundef i32 @get_i32()
; CHECK-NEXT: to label %[[LOOP:.*]] unwind label %[[UNWIND:.*]]
diff --git a/llvm/test/Transforms/InstSimplify/freeze.ll b/llvm/test/Transforms/InstSimplify/freeze.ll
index 6c4b16076e724..ff3f1ac139dce 100644
--- a/llvm/test/Transforms/InstSimplify/freeze.ll
+++ b/llvm/test/Transforms/InstSimplify/freeze.ll
@@ -266,7 +266,7 @@ define ptr @call_noundef_ptr(ptr %ptr) {
ret ptr %q
}
-define ptr @invoke_noundef_ptr(ptr %ptr) personality i8 1 {
+define ptr @invoke_noundef_ptr(ptr %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoke_noundef_ptr(
; CHECK-NEXT: invoke void @f3(ptr noundef [[PTR:%.*]])
; CHECK-NEXT: to label [[NORMAL:%.*]] unwind label [[UNWIND:%.*]]
@@ -459,6 +459,7 @@ EXIT:
ret i32 %fr2
}
+declare i32 @__gxx_personality_v0(...)
declare i32 @any_num()
define i32 @brcond_call() {
diff --git a/llvm/test/Transforms/InstSimplify/invalid-load-operand-infinite-loop.ll b/llvm/test/Transforms/InstSimplify/invalid-load-operand-infinite-loop.ll
index 06323267e196b..4fd3e373bc11f 100644
--- a/llvm/test/Transforms/InstSimplify/invalid-load-operand-infinite-loop.ll
+++ b/llvm/test/Transforms/InstSimplify/invalid-load-operand-infinite-loop.ll
@@ -1,9 +1,10 @@
; RUN: opt -passes=jump-threading -S < %s | FileCheck %s
; CHECK: @main
+declare i32 @__gxx_personality_v0(...)
%struct.wobble = type { i8 }
-define i32 @main() local_unnamed_addr personality ptr undef {
+define i32 @main() local_unnamed_addr personality ptr @__gxx_personality_v0 {
bb12:
br i1 false, label %bb13, label %bb28
diff --git a/llvm/test/Transforms/InstSimplify/known-never-nan.ll b/llvm/test/Transforms/InstSimplify/known-never-nan.ll
index 907eca0a856a8..a63db432a1f04 100644
--- a/llvm/test/Transforms/InstSimplify/known-never-nan.ll
+++ b/llvm/test/Transforms/InstSimplify/known-never-nan.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S -passes=instsimplify | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare double @func()
define i1 @nnan_call() {
@@ -532,7 +533,7 @@ define i1 @isKnownNeverNaN_nofpclass_indirect_callsite(ptr %fptr) {
ret i1 %tmp
}
-define i1 @isKnownNeverNaN_invoke_callsite(ptr %ptr) personality i8 1 {
+define i1 @isKnownNeverNaN_invoke_callsite(ptr %ptr) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @isKnownNeverNaN_invoke_callsite(
; CHECK-NEXT: [[INVOKE:%.*]] = invoke nofpclass(nan) float [[PTR:%.*]]()
; CHECK-NEXT: to label [[NORMAL:%.*]] unwind label [[UNWIND:%.*]]
diff --git a/llvm/test/Transforms/LoopDeletion/loop-with-ehpad-not-executed.ll b/llvm/test/Transforms/LoopDeletion/loop-with-ehpad-not-executed.ll
index e5871df96d3a9..dede0dd6bad3d 100644
--- a/llvm/test/Transforms/LoopDeletion/loop-with-ehpad-not-executed.ll
+++ b/llvm/test/Transforms/LoopDeletion/loop-with-ehpad-not-executed.ll
@@ -1,8 +1,10 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt %s -passes=loop-deletion -S | FileCheck %s
-define void @wombat() personality ptr null {
-; CHECK-LABEL: define void @wombat() personality ptr null {
+declare i32 @__gxx_personality_v0(...)
+
+define void @wombat() personality ptr @__gxx_personality_v0 {
+; CHECK-LABEL: define void @wombat() personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: bb:
; CHECK-NEXT: br i1 false, label [[BB1:%.*]], label [[BB4:%.*]]
; CHECK: bb1:
diff --git a/llvm/test/Transforms/LoopDeletion/pr62160.ll b/llvm/test/Transforms/LoopDeletion/pr62160.ll
index cf6d34d888d4d..84dd2e73b4e12 100644
--- a/llvm/test/Transforms/LoopDeletion/pr62160.ll
+++ b/llvm/test/Transforms/LoopDeletion/pr62160.ll
@@ -5,9 +5,9 @@
; branch to it. We would need a different approach here that still retains
; the invoke.
-define i32 @test() mustprogress personality ptr poison {
+define i32 @test() mustprogress personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @test
-; CHECK-SAME: () #[[ATTR0:[0-9]+]] personality ptr poison {
+; CHECK-SAME: () #[[ATTR0:[0-9]+]] personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
@@ -36,4 +36,5 @@ loop.latch:
br label %loop
}
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.donothing()
diff --git a/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point-2.ll b/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point-2.ll
index 02e00f505d424..e0e42b9f5b748 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point-2.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point-2.ll
@@ -4,10 +4,11 @@
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
+declare i32 @__gxx_personality_v0(...)
declare void @maybe_throws()
declare void @use1(i1)
-define void @is_not_42(ptr %baseptr, ptr %finalptr) local_unnamed_addr align 2 personality ptr undef {
+define void @is_not_42(ptr %baseptr, ptr %finalptr) local_unnamed_addr align 2 personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @is_not_42(
; CHECK-NEXT: preheader:
; CHECK-NEXT: br label [[HEADER:%.*]]
diff --git a/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point.ll b/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point.ll
index 82b6c52d33728..dc2893fd98c57 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point.ll
@@ -4,10 +4,11 @@
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
+declare i32 @__gxx_personality_v0(...)
declare void @maybe_throws()
declare void @use1(i1)
-define void @is_not_null(ptr %baseptr) local_unnamed_addr align 2 personality ptr undef {
+define void @is_not_null(ptr %baseptr) local_unnamed_addr align 2 personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @is_not_null(
; CHECK-NEXT: preheader:
; CHECK-NEXT: br label [[HEADER:%.*]]
diff --git a/llvm/test/Transforms/LoopStrengthReduce/phi_ehpad_ignore_sameval.ll b/llvm/test/Transforms/LoopStrengthReduce/phi_ehpad_ignore_sameval.ll
index 83beb4f0793f0..e2cab8c35f554 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/phi_ehpad_ignore_sameval.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/phi_ehpad_ignore_sameval.ll
@@ -12,7 +12,7 @@ target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:6:
%"class.std::allocator" = type { i8 }
%"class.absl::Storage" = type {}
-define void @0() personality ptr undef {
+define void @0() personality ptr @__gxx_personality_v0 {
init1:
%i14 = invoke ptr undef(ptr null, i8 0)
to label %init2 unwind label %unwind
@@ -53,3 +53,5 @@ unwind: ; preds = %caught, %loop.unwin
%i33 = cleanuppad within none []
cleanupret from %i33 unwind to caller
}
+
+declare i32 @__gxx_personality_v0(...)
diff --git a/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll b/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
index 4d08645a1e536..ad26edad2f550 100644
--- a/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
+++ b/llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S -passes=loop-unroll -unroll-peel-max-count=4 -verify-dom-info | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @f1()
declare void @f2()
declare void @f3(i32)
@@ -1182,7 +1183,7 @@ for.end:
ret void
}
-define void @test17() personality ptr undef{
+define void @test17() personality ptr @__gxx_personality_v0{
; CHECK-LABEL: @test17(
; CHECK-NEXT: body:
; CHECK-NEXT: br label [[LOOP_PEEL_BEGIN:%.*]]
diff --git a/llvm/test/Transforms/LoopVectorize/expand-scev-after-invoke.ll b/llvm/test/Transforms/LoopVectorize/expand-scev-after-invoke.ll
index 9d94f289c29a7..96b9e4cc6b6cf 100644
--- a/llvm/test/Transforms/LoopVectorize/expand-scev-after-invoke.ll
+++ b/llvm/test/Transforms/LoopVectorize/expand-scev-after-invoke.ll
@@ -1,13 +1,14 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --version 5
; RUN: opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare i32 @foo()
; Test case for https://github.com/llvm/llvm-project/issues/128838. Make sure
; we do not crash when expanding %step.
-define void @test(ptr %dst) personality ptr null {
+define void @test(ptr %dst) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @test(
-; CHECK-SAME: ptr [[DST:%.*]]) personality ptr null {
+; CHECK-SAME: ptr [[DST:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[STEP:%.*]] = invoke i32 @foo()
; CHECK-NEXT: to label %[[LOOP_PREHEADER:.*]] unwind label %[[LPAD:.*]]
diff --git a/llvm/test/Transforms/LowerInvoke/lowerinvoke.ll b/llvm/test/Transforms/LowerInvoke/lowerinvoke.ll
index 0ffc27ee40f94..2b1dec3c3d93a 100644
--- a/llvm/test/Transforms/LowerInvoke/lowerinvoke.ll
+++ b/llvm/test/Transforms/LowerInvoke/lowerinvoke.ll
@@ -1,9 +1,10 @@
; RUN: opt < %s -passes=lower-invoke -S | FileCheck %s
; RUN: opt < %s -passes='lower-invoke' -S | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare i32 @external_func(i64 %arg)
-define i32 @invoke_test(i64 %arg) personality ptr null {
+define i32 @invoke_test(i64 %arg) personality ptr @__gxx_personality_v0 {
entry:
%result = invoke fastcc i32 @external_func(i64 inreg %arg)
to label %cont unwind label %lpad
diff --git a/llvm/test/Transforms/MemCpyOpt/stack-move.ll b/llvm/test/Transforms/MemCpyOpt/stack-move.ll
index cf91ea98b2a55..e965e13deda7f 100644
--- a/llvm/test/Transforms/MemCpyOpt/stack-move.ll
+++ b/llvm/test/Transforms/MemCpyOpt/stack-move.ll
@@ -3,6 +3,7 @@
%struct.Foo = type { i32, i32, i32 }
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
declare void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
declare void @llvm.memcpy.p2.p1.i64(ptr addrspace(2) noalias nocapture writeonly, ptr addrspace(1) noalias nocapture readonly, i64, i1 immarg)
@@ -393,8 +394,8 @@ define void @avoid_memory_use_last_user_crash() {
}
; For multi-bb patch, we will insert it for next immediate post dominator block.
-define void @terminator_lastuse() personality i32 0 {
-; CHECK-LABEL: define void @terminator_lastuse() personality i32 0 {
+define void @terminator_lastuse() personality ptr @__gxx_personality_v0 {
+; CHECK-LABEL: define void @terminator_lastuse() personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[SRC:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4
; CHECK-NEXT: store [[STRUCT_FOO]] { i32 10, i32 20, i32 30 }, ptr [[SRC]], align 4
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @use_nocapture(ptr captures(none) [[SRC]])
diff --git a/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges-attr.ll b/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges-attr.ll
index b5f29906b051e..495ab20b94b66 100644
--- a/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges-attr.ll
+++ b/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges-attr.ll
@@ -42,7 +42,7 @@ define i8 @call_different_range() {
ret i8 %out
}
-define i8 @invoke_with_range() personality ptr undef {
+define i8 @invoke_with_range() personality ptr @__gxx_personality_v0 {
%out = invoke range(i8 0, 2) i8 @dummy() to label %next unwind label %lpad
next:
@@ -53,7 +53,7 @@ lpad:
resume { ptr, i32 } zeroinitializer
}
-define i8 @invoke_no_range() personality ptr undef {
+define i8 @invoke_no_range() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoke_no_range()
; CHECK-NEXT: invoke i8 @dummy
%out = invoke i8 @dummy() to label %next unwind label %lpad
@@ -66,7 +66,7 @@ lpad:
resume { ptr, i32 } zeroinitializer
}
-define i8 @invoke_different_range() personality ptr undef {
+define i8 @invoke_different_range() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoke_different_range()
; CHECK-NEXT: invoke range(i8 5, 7) i8 @dummy
%out = invoke range(i8 5, 7) i8 @dummy() to label %next unwind label %lpad
@@ -79,7 +79,7 @@ lpad:
resume { ptr, i32 } zeroinitializer
}
-define i8 @invoke_with_same_range() personality ptr undef {
+define i8 @invoke_with_same_range() personality ptr @__gxx_personality_v0 {
; CHECK-DAG: @invoke_with_same_range()
; CHECK-DAG: tail call i8 @invoke_with_range()
%out = invoke range(i8 0, 2) i8 @dummy() to label %next unwind label %lpad
diff --git a/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll b/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll
index 39e5a11181a4f..9adf35b01d038 100644
--- a/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll
+++ b/llvm/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll
@@ -26,7 +26,7 @@ define i8 @call_different_range() {
ret i8 %out
}
-define i8 @invoke_with_range() personality ptr undef {
+define i8 @invoke_with_range() personality ptr @__gxx_personality_v0 {
%out = invoke i8 @dummy() to label %next unwind label %lpad, !range !0
next:
@@ -37,7 +37,7 @@ lpad:
resume { ptr, i32 } zeroinitializer
}
-define i8 @invoke_no_range() personality ptr undef {
+define i8 @invoke_no_range() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoke_no_range()
; CHECK-NEXT: invoke i8 @dummy
%out = invoke i8 @dummy() to label %next unwind label %lpad
@@ -50,7 +50,7 @@ lpad:
resume { ptr, i32 } zeroinitializer
}
-define i8 @invoke_different_range() personality ptr undef {
+define i8 @invoke_different_range() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @invoke_different_range()
; CHECK-NEXT: invoke i8 @dummy
%out = invoke i8 @dummy() to label %next unwind label %lpad, !range !1
@@ -63,7 +63,7 @@ lpad:
resume { ptr, i32 } zeroinitializer
}
-define i8 @invoke_with_same_range() personality ptr undef {
+define i8 @invoke_with_same_range() personality ptr @__gxx_personality_v0 {
; CHECK-DAG: @invoke_with_same_range()
; CHECK-DAG: tail call i8 @invoke_with_range()
%out = invoke i8 @dummy() to label %next unwind label %lpad, !range !0
diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/basic.ll b/llvm/test/Transforms/RewriteStatepointsForGC/basic.ll
index 7fe7220e40454..3bdfbe20a7df7 100644
--- a/llvm/test/Transforms/RewriteStatepointsForGC/basic.ll
+++ b/llvm/test/Transforms/RewriteStatepointsForGC/basic.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @g()
declare i32 @h()
@@ -17,7 +18,7 @@ define ptr addrspace(1) @f0(ptr addrspace(1) %arg) gc "statepoint-example" {
ret ptr addrspace(1) %arg
}
-define ptr addrspace(1) @f1(ptr addrspace(1) %arg) gc "statepoint-example" personality i32 8 {
+define ptr addrspace(1) @f1(ptr addrspace(1) %arg) gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @f1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @g, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ]
@@ -59,7 +60,7 @@ define ptr addrspace(1) @f2(ptr addrspace(1) %arg) gc "statepoint-example" {
ret ptr addrspace(1) %arg
}
-define ptr addrspace(1) @f3(ptr addrspace(1) %arg) gc "statepoint-example" personality i32 8 {
+define ptr addrspace(1) @f3(ptr addrspace(1) %arg) gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @f3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(i32 ()) @h, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ]
diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/preprocess.ll b/llvm/test/Transforms/RewriteStatepointsForGC/preprocess.ll
index 4c7f9d66d92f6..ce342a2d59f83 100644
--- a/llvm/test/Transforms/RewriteStatepointsForGC/preprocess.ll
+++ b/llvm/test/Transforms/RewriteStatepointsForGC/preprocess.ll
@@ -3,6 +3,7 @@
; Test to make sure we destroy LCSSA's single entry phi nodes before
; running liveness
+declare i32 @__gxx_personality_v0(...)
declare void @consume(...) "gc-leaf-function"
define void @test6(ptr addrspace(1) %obj) gc "statepoint-example" {
@@ -38,7 +39,7 @@ unreached: ; preds = %unreached
br label %unreached
}
-define void @test8() gc "statepoint-example" personality ptr undef {
+define void @test8() gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: test8
; CHECK-NOT: gc.statepoint
; Bound the last check-not
diff --git a/llvm/test/Transforms/SCCP/landingpad.ll b/llvm/test/Transforms/SCCP/landingpad.ll
index 507a972334b98..1e63600bfe9d6 100644
--- a/llvm/test/Transforms/SCCP/landingpad.ll
+++ b/llvm/test/Transforms/SCCP/landingpad.ll
@@ -3,9 +3,10 @@
; SCCP should never remove landingpads.
+declare i32 @__gxx_personality_v0(...)
declare void @fn()
-define void @test() personality ptr null {
+define void @test() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test(
; CHECK-NEXT: invoke void @fn()
; CHECK-NEXT: to label [[SUCCESS:%.*]] unwind label [[FAILURE:%.*]]
diff --git a/llvm/test/Transforms/SLPVectorizer/RISCV/small-tree-not-schedulable-bv-node.ll b/llvm/test/Transforms/SLPVectorizer/RISCV/small-tree-not-schedulable-bv-node.ll
index 26f3fcae3a333..8d7f8df83461a 100644
--- a/llvm/test/Transforms/SLPVectorizer/RISCV/small-tree-not-schedulable-bv-node.ll
+++ b/llvm/test/Transforms/SLPVectorizer/RISCV/small-tree-not-schedulable-bv-node.ll
@@ -1,9 +1,11 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -S -mtriple=riscv64-unknown-linux-gnu -slp-threshold=-100 -mattr=+v < %s | FileCheck %s
-define void @test1() personality ptr null {
+declare i32 @__gxx_personality_v0(...)
+
+define void @test1() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @test1(
-; CHECK-SAME: ) #[[ATTR0:[0-9]+]] personality ptr null {
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CALL33:%.*]] = invoke ptr null(i64 0, ptr null)
; CHECK-NEXT: to label [[INVOKE_CONT32:%.*]] unwind label [[LPAD31_LOOPEXIT:%.*]]
@@ -70,9 +72,9 @@ ehcleanup47:
resume { ptr, i32 } zeroinitializer
}
-define i32 @test2(i64 %idx.ext.i48.pre-phi) {
+define i32 @test2(i64 %idx.ext.i48.pre-phi) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @test2(
-; CHECK-SAME: i64 [[IDX_EXT_I48_PRE_PHI:%.*]]) #[[ATTR0]] {
+; CHECK-SAME: i64 [[IDX_EXT_I48_PRE_PHI:%.*]]) #[[ATTR0]] personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[DO_ACTION:%.*]]
; CHECK: do_action:
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/catchswitch-block-in-use.ll b/llvm/test/Transforms/SLPVectorizer/X86/catchswitch-block-in-use.ll
index 8ecb5af404a72..704408b7b9693 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/catchswitch-block-in-use.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/catchswitch-block-in-use.ll
@@ -1,12 +1,14 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-pc-windows-msvc19.40.33811 < %s | FileCheck %s
+declare i32 @__CxxFrameHandler3(...)
+
%"class.boost::execution_exception" = type { i32, %"class.boost::unit_test::basic_cstring", %"struct.boost::execution_exception::location" }
%"class.boost::unit_test::basic_cstring" = type { ptr, ptr }
%"struct.boost::execution_exception::location" = type { %"class.boost::unit_test::basic_cstring", i64, %"class.boost::unit_test::basic_cstring" }
-define void @test() personality ptr null {
-; CHECK-LABEL: define void @test() personality ptr null {
+define void @test() personality ptr @__CxxFrameHandler3 {
+; CHECK-LABEL: define void @test() personality ptr @__CxxFrameHandler3 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: br label %[[FOR_COND109:.*]]
; CHECK: [[FOR_COND109]]:
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/extractelement-phi-in-landingpad.ll b/llvm/test/Transforms/SLPVectorizer/X86/extractelement-phi-in-landingpad.ll
index adbe9c33140b6..fdc44ee9e4ae7 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/extractelement-phi-in-landingpad.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/extractelement-phi-in-landingpad.ll
@@ -1,8 +1,10 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
-define void @test() personality ptr null {
-; CHECK-LABEL: define void @test() personality ptr null {
+declare i32 @__gxx_personality_v0(...)
+
+define void @test() personality ptr @__gxx_personality_v0 {
+; CHECK-LABEL: define void @test() personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[BB:.*]]:
; CHECK-NEXT: invoke void null()
; CHECK-NEXT: to label %[[BB65:.*]] unwind label %[[BB4:.*]]
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/landing-pad-for-split-node.ll b/llvm/test/Transforms/SLPVectorizer/X86/landing-pad-for-split-node.ll
index 6c729d17c1a9b..89e6b62578522 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/landing-pad-for-split-node.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/landing-pad-for-split-node.ll
@@ -1,9 +1,11 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-9999 < %s | FileCheck %s
-define void @test(i32 %arg) personality ptr null {
+declare i32 @__gxx_personality_v0(...)
+
+define void @test(i32 %arg) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @test(
-; CHECK-SAME: i32 [[ARG:%.*]]) personality ptr null {
+; CHECK-SAME: i32 [[ARG:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[BB:.*]]:
; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr addrspace(3) null, align 4
; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr addrspace(3) null, align 4
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/no-schedule-terminate-inst.ll b/llvm/test/Transforms/SLPVectorizer/X86/no-schedule-terminate-inst.ll
index 2ae8d15a3c75d..eee5e6b2a94d7 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/no-schedule-terminate-inst.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/no-schedule-terminate-inst.ll
@@ -1,8 +1,10 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
-define void @test() gc "statepoint-example" personality ptr null {
-; CHECK-LABEL: define void @test() gc "statepoint-example" personality ptr null {
+declare i32 @__gxx_personality_v0(...)
+
+define void @test() gc "statepoint-example" personality ptr @__gxx_personality_v0 {
+; CHECK-LABEL: define void @test() gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: [[INVOKE:%.*]] = invoke i32 null(ptr addrspace(1) null, i32 0, i32 0, i32 0)
; CHECK-NEXT: to label %[[BB2:.*]] unwind label %[[BB8:.*]]
diff --git a/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase-2.ll b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase-2.ll
index 3583cd7bed9eb..f66fdced96c24 100644
--- a/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase-2.ll
+++ b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase-2.ll
@@ -1,12 +1,13 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @widget()
declare i16 @baz()
declare void @snork()
declare void @spam()
-define void @zot() local_unnamed_addr align 2 personality ptr undef {
+define void @zot() local_unnamed_addr align 2 personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @zot(
; CHECK-NEXT: bb:
; CHECK-NEXT: invoke void @widget()
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll b/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll
index da5c976873d72..4a9af89e20446 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll
@@ -6,7 +6,9 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
-define void @f(i1 %B) personality i1 undef {
+declare i32 @__gxx_personality_v0(...)
+
+define void @f(i1 %B) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @f(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @g()
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/debugloc-invoke-to-call-br.ll b/llvm/test/Transforms/SimplifyCFG/X86/debugloc-invoke-to-call-br.ll
index 12aa7fe1a9f84..fc2df06fb1a0e 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/debugloc-invoke-to-call-br.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/debugloc-invoke-to-call-br.ll
@@ -8,9 +8,9 @@
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
-define void @widget(i1 %arg) personality ptr null !dbg !5 {
+define void @widget(i1 %arg) personality ptr @__gxx_personality_v0 !dbg !5 {
; CHECK-LABEL: define void @widget(
-; CHECK-SAME: i1 [[ARG:%.*]]) personality ptr null !dbg [[DBG5:![0-9]+]] {
+; CHECK-SAME: i1 [[ARG:%.*]]) personality ptr @__gxx_personality_v0 !dbg [[DBG5:![0-9]+]] {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: br i1 [[ARG]], label %[[BB2:.*]], label %[[BB1:.*]]
; CHECK: [[BB1]]:
@@ -36,6 +36,7 @@ bb3: ; preds = %bb1
ret void
}
+declare i32 @__gxx_personality_v0(...)
declare void @baz(ptr)
!llvm.dbg.cu = !{!0}
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/merge-compatible-invokes-of-landingpad.ll b/llvm/test/Transforms/SimplifyCFG/X86/merge-compatible-invokes-of-landingpad.ll
index 95114abb4ef5f..4e0bc39f59239 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/merge-compatible-invokes-of-landingpad.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/merge-compatible-invokes-of-landingpad.ll
@@ -2616,9 +2616,9 @@ if.end:
ret void
}
-define void @dont_merge_different_immargs(i1 %c1) gc "statepoint-example" personality ptr null {
+define void @dont_merge_different_immargs(i1 %c1) gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @dont_merge_different_immargs(
-; CHECK-SAME: i1 [[C1:%.*]]) gc "statepoint-example" personality ptr null {
+; CHECK-SAME: i1 [[C1:%.*]]) gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: br i1 [[C1]], label %[[IF:.*]], label %[[ELSE:.*]]
; CHECK: [[IF]]:
; CHECK-NEXT: [[T1:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 1, i32 0, ptr elementtype(void (ptr addrspace(1))) null, i32 1, i32 0, ptr addrspace(1) null, i64 0, i64 0)
diff --git a/llvm/test/Transforms/SimplifyCFG/dbgloc-merge-invoke.ll b/llvm/test/Transforms/SimplifyCFG/dbgloc-merge-invoke.ll
index 8f6ffd0dbd0c8..c1dc74d7d7ca7 100644
--- a/llvm/test/Transforms/SimplifyCFG/dbgloc-merge-invoke.ll
+++ b/llvm/test/Transforms/SimplifyCFG/dbgloc-merge-invoke.ll
@@ -8,11 +8,12 @@
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
+declare i32 @__gxx_personality_v0(...)
declare ptr @baz()
-define i32 @foo(i1 %call66, ptr %.str.8) personality ptr null {
+define i32 @foo(i1 %call66, ptr %.str.8) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @foo(
-; CHECK-SAME: i1 [[CALL66:%.*]], ptr [[DOTSTR_8:%.*]]) personality ptr null {
+; CHECK-SAME: i1 [[CALL66:%.*]], ptr [[DOTSTR_8:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[CALL661:%.*]] = invoke i1 @bar(ptr null)
; CHECK-NEXT: to label %[[INVOKE_CONT65:.*]] unwind label %[[LPAD45_LOOPEXIT_SPLIT_LP_LOOPEXIT_SPLIT_LP:.*]]
diff --git a/llvm/test/Transforms/SimplifyCFG/unreachable-multi-basic-block-funclet.ll b/llvm/test/Transforms/SimplifyCFG/unreachable-multi-basic-block-funclet.ll
index 0f0fc78ec7add..d8af52543f679 100644
--- a/llvm/test/Transforms/SimplifyCFG/unreachable-multi-basic-block-funclet.ll
+++ b/llvm/test/Transforms/SimplifyCFG/unreachable-multi-basic-block-funclet.ll
@@ -1,11 +1,13 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -passes=simplifycfg -S < %s | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
+
; cleanuppad/cleanupret
-define void @unreachable_cleanuppad_linear(i64 %shapes.1) personality ptr null {
+define void @unreachable_cleanuppad_linear(i64 %shapes.1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @unreachable_cleanuppad_linear(
-; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null {
+; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[START:.*:]]
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]]
; CHECK-NEXT: ret void
@@ -22,9 +24,9 @@ funclet_end:
cleanupret from %cleanuppad unwind to caller
}
-define void @unreachable_cleanuppad_linear_middle_block(i64 %shapes.1) personality ptr null {
+define void @unreachable_cleanuppad_linear_middle_block(i64 %shapes.1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @unreachable_cleanuppad_linear_middle_block(
-; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null {
+; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[START:.*:]]
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]]
; CHECK-NEXT: ret void
@@ -45,9 +47,9 @@ funclet_end:
cleanupret from %cleanuppad unwind to caller
}
-define void @unreachable_cleanuppad_multiple_predecessors(i64 %shapes.1) personality ptr null {
+define void @unreachable_cleanuppad_multiple_predecessors(i64 %shapes.1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @unreachable_cleanuppad_multiple_predecessors(
-; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null {
+; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[START:.*:]]
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]]
; CHECK-NEXT: ret void
@@ -79,9 +81,9 @@ funclet_end:
; catchpad/catchret
-define void @unreachable_catchpad_linear(i64 %shapes.1) personality ptr null {
+define void @unreachable_catchpad_linear(i64 %shapes.1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @unreachable_catchpad_linear(
-; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null {
+; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[START:.*:]]
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]]
; CHECK-NEXT: ret void
@@ -105,9 +107,9 @@ unreachable:
unreachable
}
-define void @unreachable_catchpad_multiple_predecessors(i64 %shapes.1) personality ptr null {
+define void @unreachable_catchpad_multiple_predecessors(i64 %shapes.1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @unreachable_catchpad_multiple_predecessors(
-; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null {
+; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[START:.*:]]
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]]
; CHECK-NEXT: ret void
@@ -145,9 +147,9 @@ unreachable:
; Issue reproducer
-define void @gh148052(i64 %shapes.1) personality ptr null {
+define void @gh148052(i64 %shapes.1) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @gh148052(
-; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null {
+; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[START:.*:]]
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]]
; CHECK-NEXT: call void @llvm.assume(i1 [[_7]])
@@ -194,9 +196,9 @@ bb13:
declare x86_thiscallcc ptr @quux(ptr, ptr, i32)
-define x86_thiscallcc ptr @baz(ptr %arg, ptr %arg1, ptr %arg2, i1 %arg3, ptr %arg4) personality ptr null {
+define x86_thiscallcc ptr @baz(ptr %arg, ptr %arg1, ptr %arg2, i1 %arg3, ptr %arg4) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define x86_thiscallcc ptr @baz(
-; CHECK-SAME: ptr [[ARG:%.*]], ptr [[ARG1:%.*]], ptr [[ARG2:%.*]], i1 [[ARG3:%.*]], ptr [[ARG4:%.*]]) personality ptr null {
+; CHECK-SAME: ptr [[ARG:%.*]], ptr [[ARG1:%.*]], ptr [[ARG2:%.*]], i1 [[ARG3:%.*]], ptr [[ARG4:%.*]]) personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: [[ALLOCA:%.*]] = alloca [2 x %struct.foo], align 4
; CHECK-NEXT: [[INVOKE:%.*]] = call x86_thiscallcc ptr @quux(ptr null, ptr null, i32 0) #[[ATTR1:[0-9]+]]
diff --git a/llvm/test/Transforms/TailCallElim/deopt-bundle.ll b/llvm/test/Transforms/TailCallElim/deopt-bundle.ll
index c05fe5c820028..90772d0d3ea86 100644
--- a/llvm/test/Transforms/TailCallElim/deopt-bundle.ll
+++ b/llvm/test/Transforms/TailCallElim/deopt-bundle.ll
@@ -35,9 +35,10 @@ return:
ret i32 1
}
+declare i32 @__gxx_personality_v0(...)
declare void @func()
-define void @f_3(i1 %B) personality i8 42 {
+define void @f_3(i1 %B) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @f_3(
entry:
invoke void @func()
diff --git a/llvm/test/Transforms/Util/strip-gc-relocates.ll b/llvm/test/Transforms/Util/strip-gc-relocates.ll
index c6013bc54fbe2..d1707e7aa62d1 100644
--- a/llvm/test/Transforms/Util/strip-gc-relocates.ll
+++ b/llvm/test/Transforms/Util/strip-gc-relocates.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=strip-gc-relocates,instcombine < %s | FileCheck %s
; test utility/debugging pass which removes gc.relocates, inserted by -rewrite-statepoints-for-gc
+declare i32 @__gxx_personality_v0(...)
declare void @use_obj32(ptr addrspace(1)) "gc-leaf-function"
declare void @g()
@@ -50,7 +51,7 @@ entry:
}
; landing pad gc.relocates removed by instcombine since it has no uses.
-define ptr addrspace(1) @test3(ptr addrspace(1) %arg) gc "statepoint-example" personality i32 8 {
+define ptr addrspace(1) @test3(ptr addrspace(1) %arg) gc "statepoint-example" personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr nonnull elementtype(void ()) @g, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"() ]
diff --git a/llvm/test/Verifier/deoptimize-intrinsic.ll b/llvm/test/Verifier/deoptimize-intrinsic.ll
index 158620dd358f4..9ae3f65e7e729 100644
--- a/llvm/test/Verifier/deoptimize-intrinsic.ll
+++ b/llvm/test/Verifier/deoptimize-intrinsic.ll
@@ -1,5 +1,6 @@
; RUN: not opt -passes=verify < %s 2>&1 | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare i8 @llvm.experimental.deoptimize.i8(...)
declare void @llvm.experimental.deoptimize.isVoid(...)
declare cc40 void @llvm.experimental.deoptimize.double(...)
@@ -21,7 +22,7 @@ entry:
ret void
}
-define void @f_invoke() personality i8 3 {
+define void @f_invoke() personality ptr @__gxx_personality_v0 {
entry:
invoke void(...) @llvm.experimental.deoptimize.isVoid(i32 0, float 0.0) to label %ok unwind label %not_ok
; CHECK: experimental_deoptimize cannot be invoked
diff --git a/llvm/test/Verifier/guard-intrinsic.ll b/llvm/test/Verifier/guard-intrinsic.ll
index 3260f92d35774..a531da7806009 100644
--- a/llvm/test/Verifier/guard-intrinsic.ll
+++ b/llvm/test/Verifier/guard-intrinsic.ll
@@ -1,5 +1,6 @@
; RUN: not opt -S -passes=verify < %s 2>&1 | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
declare void @llvm.experimental.guard(i1, ...)
declare void @unknown()
@@ -11,7 +12,7 @@ entry:
ret void
}
-define void @f_invoke() personality i8 3 {
+define void @f_invoke() personality ptr @__gxx_personality_v0 {
entry:
invoke void(i1, ...) @llvm.experimental.guard(i1 undef, i32 0, float 0.0) [ "deopt"() ] to label %ok unwind label %not_ok
; CHECK: guard cannot be invoked
diff --git a/llvm/test/Verifier/invalid-cleanuppad-chain.ll b/llvm/test/Verifier/invalid-cleanuppad-chain.ll
index 7df0adc93a4d8..ab799dd289eda 100644
--- a/llvm/test/Verifier/invalid-cleanuppad-chain.ll
+++ b/llvm/test/Verifier/invalid-cleanuppad-chain.ll
@@ -1,12 +1,14 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+declare i32 @__gxx_personality_v0(...)
+
; CHECK: CleanupReturnInst needs to be provided a CleanupPad
; CHECK-NEXT: cleanupret from undef unwind label %bb2
; CHECK-NEXT: token undef
; CHECK: Parent pad must be catchpad/cleanuppad/catchswitch
; CHECK-NEXT: cleanupret from undef unwind label %bb2
-define void @test() personality ptr undef {
+define void @test() personality ptr @__gxx_personality_v0 {
br label %bb1
bb1:
diff --git a/llvm/test/Verifier/operand-bundles.ll b/llvm/test/Verifier/operand-bundles.ll
index db85b6ae6ef5f..dc2508b73090f 100644
--- a/llvm/test/Verifier/operand-bundles.ll
+++ b/llvm/test/Verifier/operand-bundles.ll
@@ -1,6 +1,7 @@
; RUN: not opt -passes=verify < %s 2>&1 | FileCheck %s
%0 = type opaque
+declare i32 @__gxx_personality_v0(...)
declare void @g()
declare ptr @foo0()
declare i8 @foo1()
@@ -21,7 +22,7 @@ define void @f0(ptr %ptr) {
ret void
}
-define void @f1(ptr %ptr) personality i8 3 {
+define void @f1(ptr %ptr) personality ptr @__gxx_personality_v0 {
; CHECK: Instruction does not dominate all uses!
; CHECK-NEXT: %x = add i32 42, 1
; CHECK-NEXT: invoke void @g() [ "foo"(i32 42, i64 100, i32 %x), "bar"(float 0.000000e+00, i64 100, i32 %l) ]
diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll
index 14d9cdbab802c..4cb6108515270 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll
@@ -1,6 +1,6 @@
; RUN: llc -mtriple=mips64-unknown-linux < %s | FileCheck %s
-define i32 @main() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*){
+define i32 @main() personality ptr @__gxx_personality_v0 {
%1 = invoke i32 @foo() to label %good unwind label %bad
good:
ret i32 5
diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll.expected
index 56058bbc4c402..5e9d021697c34 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/mips64_eh.ll.expected
@@ -1,7 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=mips64-unknown-linux < %s | FileCheck %s
-define i32 @main() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*){
+define i32 @main() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: main:
; CHECK: # %bb.0:
; CHECK-NEXT: daddiu $sp, $sp, -16
diff --git a/llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll b/llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll
index 6c306c1d3fafd..d9f848a1a99a5 100644
--- a/llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll
+++ b/llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll
@@ -3,7 +3,7 @@
; CHECK-INTERESTINGNESS: call void @foo()
-; CHECK: define void @test() personality ptr null {
+; CHECK: define void @test() personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: entry:
; CHECK-NEXT: br label %cont
; CHECK-EMPTY:
@@ -15,7 +15,7 @@
; CHECK-NEXT: ret void
; CHECK-NEXT: }
-define void @test() personality ptr null {
+define void @test() personality ptr @__gxx_personality_v0 {
entry:
invoke void @foo()
to label %cont unwind label %lpad
@@ -34,4 +34,5 @@ exit:
ret void
}
+declare i32 @__gxx_personality_v0(...)
declare void @foo()
diff --git a/llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp b/llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp
index a4187c242870d..6d1c26c4080f0 100644
--- a/llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp
+++ b/llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp
@@ -1458,8 +1458,9 @@ TEST(IRInstructionMapper, ExceptionHandlingExceptionPointerIllegal) {
TEST(IRInstructionMapper, CatchpadIllegal) {
StringRef ModuleString = R"(
declare void @llvm.donothing() nounwind readnone
+ declare i32 @__gxx_personality_v0(...)
- define void @function() personality i8 3 {
+ define void @function() personality ptr @__gxx_personality_v0 {
entry:
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
@@ -1490,8 +1491,9 @@ TEST(IRInstructionMapper, CatchpadIllegal) {
TEST(IRInstructionMapper, CleanuppadIllegal) {
StringRef ModuleString = R"(
declare void @llvm.donothing() nounwind readnone
+ declare i32 @__gxx_personality_v0(...)
- define void @function() personality i8 3 {
+ define void @function() personality ptr @__gxx_personality_v0 {
entry:
invoke void @llvm.donothing() to label %normal unwind label %exception
exception:
diff --git a/llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp b/llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp
index 90f06204ec9b3..4842a4b97b8a2 100644
--- a/llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp
+++ b/llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp
@@ -316,8 +316,9 @@ TEST(CodeExtractor, StoreOutputInvokeResultAfterEHPad) {
SMDiagnostic Err;
std::unique_ptr<Module> M(parseAssemblyString(R"invalid(
declare i8 @hoge()
+ declare i32 @__gxx_personality_v0(...)
- define i32 @foo() personality ptr null {
+ define i32 @foo() personality ptr @__gxx_personality_v0 {
entry:
%call = invoke i8 @hoge()
to label %invoke.cont unwind label %lpad
@@ -383,8 +384,9 @@ TEST(CodeExtractor, StoreOutputInvokeResultInExitStub) {
SMDiagnostic Err;
std::unique_ptr<Module> M(parseAssemblyString(R"invalid(
declare i32 @bar()
+ declare i32 @__gxx_personality_v0(...)
- define i32 @foo() personality ptr null {
+ define i32 @foo() personality ptr @__gxx_personality_v0 {
entry:
%0 = invoke i32 @bar() to label %exit unwind label %lpad
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index cec968c02078d..65dc391ecedbd 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -2599,22 +2599,8 @@ FlatSymbolRefAttr ModuleImport::getPersonalityAsAttr(llvm::Function *f) {
if (!f->hasPersonalityFn())
return nullptr;
- llvm::Constant *pf = f->getPersonalityFn();
-
- // If it directly has a name, we can use it.
- if (pf->hasName())
- return SymbolRefAttr::get(builder.getContext(), pf->getName());
-
- // If it doesn't have a name, currently, only function pointers that are
- // bitcast to i8* are parsed.
- if (auto *ce = dyn_cast<llvm::ConstantExpr>(pf)) {
- if (ce->getOpcode() == llvm::Instruction::BitCast &&
- ce->getType() == llvm::PointerType::getUnqual(f->getContext())) {
- if (auto *func = dyn_cast<llvm::Function>(ce->getOperand(0)))
- return SymbolRefAttr::get(builder.getContext(), func->getName());
- }
- }
- return FlatSymbolRefAttr();
+ llvm::Function *pf = f->getPersonalityFn();
+ return SymbolRefAttr::get(builder.getContext(), pf->getName());
}
static void processMemoryEffects(llvm::Function *func, LLVMFuncOp funcOp) {
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index fad9bd6b78018..aeaa18c128632 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1527,7 +1527,7 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
llvm::Type *ty = llvm::PointerType::getUnqual(llvmFunc->getContext());
if (llvm::Constant *pfunc = getLLVMConstant(ty, func.getPersonalityAttr(),
func.getLoc(), *this))
- llvmFunc->setPersonalityFn(pfunc);
+ llvmFunc->setPersonalityFn(cast<llvm::Function>(pfunc));
}
if (std::optional<StringRef> section = func.getSection())
More information about the cfe-commits
mailing list