[llvm] r332667 - [WebAssembly] Add Wasm personality and isScopedEHPersonality()
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Thu May 17 13:52:04 PDT 2018
Author: aheejin
Date: Thu May 17 13:52:03 2018
New Revision: 332667
URL: http://llvm.org/viewvc/llvm-project?rev=332667&view=rev
Log:
[WebAssembly] Add Wasm personality and isScopedEHPersonality()
Summary:
- Add wasm personality function
- Re-categorize the existing `isFuncletEHPersonality()` function into
two different functions: `isFuncletEHPersonality()` and
`isScopedEHPersonality(). This becomes necessary as wasm EH uses scoped
EH instructions (catchswitch, catchpad/ret, and cleanuppad/ret) but not
outlined funclets.
- Changed some callsites of `isFuncletEHPersonality()` to
`isScopedEHPersonality()` if they are related to scoped EH IR-level
stuff.
Reviewers: majnemer, dschuff, rnk
Subscribers: jfb, sbc100, jgravelle-google, eraman, JDevlieghere, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D45559
Modified:
llvm/trunk/include/llvm/Analysis/EHPersonalities.h
llvm/trunk/lib/Analysis/EHPersonalities.cpp
llvm/trunk/lib/Analysis/MustExecute.cpp
llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp
llvm/trunk/lib/CodeGen/MachineVerifier.cpp
llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/trunk/lib/Transforms/ObjCARC/ObjCARCContract.cpp
llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/trunk/lib/Transforms/Utils/EscapeEnumerator.cpp
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
Modified: llvm/trunk/include/llvm/Analysis/EHPersonalities.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/EHPersonalities.h?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/EHPersonalities.h (original)
+++ llvm/trunk/include/llvm/Analysis/EHPersonalities.h Thu May 17 13:52:03 2018
@@ -32,7 +32,8 @@ enum class EHPersonality {
MSVC_Win64SEH,
MSVC_CXX,
CoreCLR,
- Rust
+ Rust,
+ Wasm_CXX
};
/// See if the given exception handling personality function is one
@@ -70,6 +71,22 @@ inline bool isFuncletEHPersonality(EHPer
return true;
default:
return false;
+ }
+ llvm_unreachable("invalid enum");
+}
+
+/// Returns true if this personality uses scope-style EH IR instructions:
+/// catchswitch, catchpad/ret, and cleanuppad/ret.
+inline bool isScopedEHPersonality(EHPersonality Pers) {
+ switch (Pers) {
+ case EHPersonality::MSVC_CXX:
+ case EHPersonality::MSVC_X86SEH:
+ case EHPersonality::MSVC_Win64SEH:
+ case EHPersonality::CoreCLR:
+ case EHPersonality::Wasm_CXX:
+ return true;
+ default:
+ return false;
}
llvm_unreachable("invalid enum");
}
Modified: llvm/trunk/lib/Analysis/EHPersonalities.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/EHPersonalities.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/EHPersonalities.cpp (original)
+++ llvm/trunk/lib/Analysis/EHPersonalities.cpp Thu May 17 13:52:03 2018
@@ -25,20 +25,21 @@ EHPersonality llvm::classifyEHPersonalit
if (!F)
return EHPersonality::Unknown;
return StringSwitch<EHPersonality>(F->getName())
- .Case("__gnat_eh_personality", EHPersonality::GNU_Ada)
- .Case("__gxx_personality_v0", EHPersonality::GNU_CXX)
- .Case("__gxx_personality_seh0",EHPersonality::GNU_CXX)
- .Case("__gxx_personality_sj0", EHPersonality::GNU_CXX_SjLj)
- .Case("__gcc_personality_v0", EHPersonality::GNU_C)
- .Case("__gcc_personality_seh0",EHPersonality::GNU_C)
- .Case("__gcc_personality_sj0", EHPersonality::GNU_C_SjLj)
- .Case("__objc_personality_v0", EHPersonality::GNU_ObjC)
- .Case("_except_handler3", EHPersonality::MSVC_X86SEH)
- .Case("_except_handler4", EHPersonality::MSVC_X86SEH)
- .Case("__C_specific_handler", EHPersonality::MSVC_Win64SEH)
- .Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX)
- .Case("ProcessCLRException", EHPersonality::CoreCLR)
- .Case("rust_eh_personality", EHPersonality::Rust)
+ .Case("__gnat_eh_personality", EHPersonality::GNU_Ada)
+ .Case("__gxx_personality_v0", EHPersonality::GNU_CXX)
+ .Case("__gxx_personality_seh0", EHPersonality::GNU_CXX)
+ .Case("__gxx_personality_sj0", EHPersonality::GNU_CXX_SjLj)
+ .Case("__gcc_personality_v0", EHPersonality::GNU_C)
+ .Case("__gcc_personality_seh0", EHPersonality::GNU_C)
+ .Case("__gcc_personality_sj0", EHPersonality::GNU_C_SjLj)
+ .Case("__objc_personality_v0", EHPersonality::GNU_ObjC)
+ .Case("_except_handler3", EHPersonality::MSVC_X86SEH)
+ .Case("_except_handler4", EHPersonality::MSVC_X86SEH)
+ .Case("__C_specific_handler", EHPersonality::MSVC_Win64SEH)
+ .Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX)
+ .Case("ProcessCLRException", EHPersonality::CoreCLR)
+ .Case("rust_eh_personality", EHPersonality::Rust)
+ .Case("__gxx_wasm_personality_v0", EHPersonality::Wasm_CXX)
.Default(EHPersonality::Unknown);
}
@@ -55,6 +56,7 @@ StringRef llvm::getEHPersonalityName(EHP
case EHPersonality::MSVC_CXX: return "__CxxFrameHandler3";
case EHPersonality::CoreCLR: return "ProcessCLRException";
case EHPersonality::Rust: return "rust_eh_personality";
+ case EHPersonality::Wasm_CXX: return "__gxx_wasm_personality_v0";
case EHPersonality::Unknown: llvm_unreachable("Unknown EHPersonality!");
}
Modified: llvm/trunk/lib/Analysis/MustExecute.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MustExecute.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MustExecute.cpp (original)
+++ llvm/trunk/lib/Analysis/MustExecute.cpp Thu May 17 13:52:03 2018
@@ -52,7 +52,7 @@ void llvm::computeLoopSafetyInfo(LoopSaf
Function *Fn = CurLoop->getHeader()->getParent();
if (Fn->hasPersonalityFn())
if (Constant *PersonalityFn = Fn->getPersonalityFn())
- if (isFuncletEHPersonality(classifyEHPersonality(PersonalityFn)))
+ if (isScopedEHPersonality(classifyEHPersonality(PersonalityFn)))
SafetyInfo->BlockColors = colorEHFunclets(*Fn);
}
Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Thu May 17 13:52:03 2018
@@ -195,9 +195,9 @@ bool DwarfEHPrepare::InsertUnwindResumeC
if (Resumes.empty())
return false;
- // Check the personality, don't do anything if it's funclet-based.
+ // Check the personality, don't do anything if it's scope-based.
EHPersonality Pers = classifyEHPersonality(Fn.getPersonalityFn());
- if (isFuncletEHPersonality(Pers))
+ if (isScopedEHPersonality(Pers))
return false;
LLVMContext &Ctx = Fn.getContext();
Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Thu May 17 13:52:03 2018
@@ -646,7 +646,7 @@ MachineVerifier::visitMachineBasicBlockB
!(AsmInfo &&
AsmInfo->getExceptionHandlingType() == ExceptionHandling::SjLj &&
BB && isa<SwitchInst>(BB->getTerminator())) &&
- !isFuncletEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
+ !isScopedEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
report("MBB has more than one landing pad successor", MBB);
// Call AnalyzeBranch. If it succeeds, there several more conditions to check.
Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Thu May 17 13:52:03 2018
@@ -41,7 +41,7 @@ using namespace llvm;
static cl::opt<bool> DisableDemotion(
"disable-demotion", cl::Hidden,
cl::desc(
- "Clone multicolor basic blocks but do not demote cross funclet values"),
+ "Clone multicolor basic blocks but do not demote cross scopes"),
cl::init(false));
static cl::opt<bool> DisableCleanups(
@@ -106,8 +106,8 @@ bool WinEHPrepare::runOnFunction(Functio
// Classify the personality to see what kind of preparation we need.
Personality = classifyEHPersonality(Fn.getPersonalityFn());
- // Do nothing if this is not a funclet-based personality.
- if (!isFuncletEHPersonality(Personality))
+ // Do nothing if this is not a scope-based personality.
+ if (!isScopedEHPersonality(Personality))
return false;
DL = &Fn.getParent()->getDataLayout();
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Thu May 17 13:52:03 2018
@@ -2567,6 +2567,7 @@ static bool isCatchAll(EHPersonality Per
case EHPersonality::MSVC_Win64SEH:
case EHPersonality::MSVC_CXX:
case EHPersonality::CoreCLR:
+ case EHPersonality::Wasm_CXX:
return TypeInfo->isNullValue();
}
llvm_unreachable("invalid enum");
Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Thu May 17 13:52:03 2018
@@ -504,11 +504,11 @@ static bool functionHasLines(Function &F
return false;
}
-static bool isUsingFuncletBasedEH(Function &F) {
+static bool isUsingScopeBasedEH(Function &F) {
if (!F.hasPersonalityFn()) return false;
EHPersonality Personality = classifyEHPersonality(F.getPersonalityFn());
- return isFuncletEHPersonality(Personality);
+ return isScopedEHPersonality(Personality);
}
static bool shouldKeepInEntry(BasicBlock::iterator It) {
@@ -551,8 +551,8 @@ void GCOVProfiler::emitProfileNotes() {
DISubprogram *SP = F.getSubprogram();
if (!SP) continue;
if (!functionHasLines(F)) continue;
- // TODO: Functions using funclet-based EH are currently not supported.
- if (isUsingFuncletBasedEH(F)) continue;
+ // TODO: Functions using scope-based EH are currently not supported.
+ if (isUsingScopeBasedEH(F)) continue;
// gcov expects every function to start with an entry block that has a
// single successor, so split the entry block to make sure of that.
@@ -630,8 +630,8 @@ bool GCOVProfiler::emitProfileArcs() {
DISubprogram *SP = F.getSubprogram();
if (!SP) continue;
if (!functionHasLines(F)) continue;
- // TODO: Functions using funclet-based EH are currently not supported.
- if (isUsingFuncletBasedEH(F)) continue;
+ // TODO: Functions using scope-based EH are currently not supported.
+ if (isUsingScopeBasedEH(F)) continue;
if (!Result) Result = true;
unsigned Edges = 0;
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCContract.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCContract.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCContract.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCContract.cpp Thu May 17 13:52:03 2018
@@ -550,7 +550,7 @@ bool ObjCARCContract::runOnFunction(Func
DenseMap<BasicBlock *, ColorVector> BlockColors;
if (F.hasPersonalityFn() &&
- isFuncletEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
+ isScopedEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
BlockColors = colorEHFunclets(F);
LLVM_DEBUG(llvm::dbgs() << "**** ObjCARC Contract ****\n");
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp Thu May 17 13:52:03 2018
@@ -722,7 +722,7 @@ void ObjCARCOpt::OptimizeIndividualCalls
DenseMap<BasicBlock *, ColorVector> BlockColors;
if (F.hasPersonalityFn() &&
- isFuncletEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
+ isScopedEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
BlockColors = colorEHFunclets(F);
// Visit all objc_* calls in F.
Modified: llvm/trunk/lib/Transforms/Utils/EscapeEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/EscapeEnumerator.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/EscapeEnumerator.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/EscapeEnumerator.cpp Thu May 17 13:52:03 2018
@@ -73,8 +73,8 @@ IRBuilder<> *EscapeEnumerator::Next() {
F.setPersonalityFn(PersFn);
}
- if (isFuncletEHPersonality(classifyEHPersonality(F.getPersonalityFn()))) {
- report_fatal_error("Funclet EH not supported");
+ if (isScopedEHPersonality(classifyEHPersonality(F.getPersonalityFn()))) {
+ report_fatal_error("Scoped EH not supported");
}
LandingPadInst *LPad =
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=332667&r1=332666&r2=332667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Thu May 17 13:52:03 2018
@@ -1569,7 +1569,7 @@ bool llvm::InlineFunction(CallSite CS, I
Instruction *CallSiteEHPad = nullptr;
if (CallerPersonality) {
EHPersonality Personality = classifyEHPersonality(CallerPersonality);
- if (isFuncletEHPersonality(Personality)) {
+ if (isScopedEHPersonality(Personality)) {
Optional<OperandBundleUse> ParentFunclet =
CS.getOperandBundle(LLVMContext::OB_funclet);
if (ParentFunclet)
More information about the llvm-commits
mailing list