[SystemZ][z/OS] Fix crash when personality function is null - #217947
Open
redstar wants to merge 1 commit into
Open
[SystemZ][z/OS] Fix crash when personality function is null#217947redstar wants to merge 1 commit into
redstar wants to merge 1 commit into
Conversation
When the personality function is specified as `null`, then the current code triggers an assertion. The correct behaviour, like on Linux, is to not emit the DWARF EH data and the reference to the personality function.
|
@llvm/pr-subscribers-backend-systemz Author: Kai Nacke (redstar) ChangesWhen the personality function is specified as Full diff: https://github.com/llvm/llvm-project/pull/217947.diff 2 Files Affected:
diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
index 50c0c04a70df2..235d8eea84ec5 100644
--- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -1609,13 +1609,13 @@ void SystemZAsmPrinter::calculatePPA1() {
const Function *Per = dyn_cast<Function>(
MF->getFunction().getPersonalityFn()->stripPointerCasts());
PersonalityRoutine = Per ? MF->getTarget().getSymbol(Per) : nullptr;
- assert(PersonalityRoutine && "Missing personality routine");
-
- GCCEH = MF->getContext().getOrCreateSymbol(Twine("GCC_except_table") +
- Twine(MF->getFunctionNumber()));
- PersonalityADADisp = ADATable.insert(PersonalityRoutine,
- SystemZII::MO_ADA_INDIRECT_FUNC_DESC);
- GCCEHADADisp = ADATable.insert(GCCEH, SystemZII::MO_ADA_DATA_SYMBOL_ADDR);
+ if (PersonalityRoutine) {
+ GCCEH = MF->getContext().getOrCreateSymbol(
+ Twine("GCC_except_table") + Twine(MF->getFunctionNumber()));
+ PersonalityADADisp = ADATable.insert(
+ PersonalityRoutine, SystemZII::MO_ADA_INDIRECT_FUNC_DESC);
+ GCCEHADADisp = ADATable.insert(GCCEH, SystemZII::MO_ADA_DATA_SYMBOL_ADDR);
+ }
}
// Get the name of the function, with suffix _.
diff --git a/llvm/test/CodeGen/SystemZ/zos-no-personality.ll b/llvm/test/CodeGen/SystemZ/zos-no-personality.ll
new file mode 100644
index 0000000000000..d8212dc3c1e70
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/zos-no-personality.ll
@@ -0,0 +1,19 @@
+; RUN: llc -mtriple s390x-zos < %s | FileCheck %s
+
+define { ptr, i32 } @foo() personality ptr null {
+ invoke void null(ptr null, ptr null)
+ to label %1 unwind label %2
+
+1:
+ ret { ptr, i32 } zeroinitializer
+
+2:
+ %3 = landingpad { ptr, i32 }
+ catch ptr null
+ ret { ptr, i32 } %3
+}
+
+; CHECK: foo DS 0H
+; CHECK-NOT: .gcc_exception_table.foo
+; CHECK: L#PPA1_foo_0 DS 0H
+; CHECK-NOT: * Bit 3: 1 = C++ EH block
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the personality function is specified as
null, then the current code triggers an assertion. The correct behaviour, like on Linux, is to not emit the DWARF EH data and the reference to the personality function.