1 //===- LibCallSemantics.cpp - Describe library semantics ------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements interfaces that can be used to describe language
11 // specific runtime library interfaces (e.g. libc, libm, etc) to LLVM
14 //===----------------------------------------------------------------------===//
16 #include "llvm/Analysis/LibCallSemantics.h"
17 #include "llvm/ADT/StringSwitch.h"
18 #include "llvm/IR/Function.h"
21 /// See if the given exception handling personality function is one that we
22 /// understand. If so, return a description of it; otherwise return Unknown.
23 EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
24 const Function *F = dyn_cast<Function>(Pers->stripPointerCasts());
26 return EHPersonality::Unknown;
27 return StringSwitch<EHPersonality>(F->getName())
28 .Case("__gnat_eh_personality", EHPersonality::GNU_Ada)
29 .Case("__gxx_personality_v0", EHPersonality::GNU_CXX)
30 .Case("__gcc_personality_v0", EHPersonality::GNU_C)
31 .Case("__objc_personality_v0", EHPersonality::GNU_ObjC)
32 .Case("_except_handler3", EHPersonality::MSVC_X86SEH)
33 .Case("_except_handler4", EHPersonality::MSVC_X86SEH)
34 .Case("__C_specific_handler", EHPersonality::MSVC_Win64SEH)
35 .Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX)
36 .Default(EHPersonality::Unknown);
39 bool llvm::canSimplifyInvokeNoUnwind(const Function *F) {
40 EHPersonality Personality = classifyEHPersonality(F->getPersonalityFn());
41 // We can't simplify any invokes to nounwind functions if the personality
42 // function wants to catch asynch exceptions. The nounwind attribute only
43 // implies that the function does not throw synchronous exceptions.
44 return !isAsynchronousEHPersonality(Personality);