2008-05-07 18:21:13 +00:00
|
|
|
//===- LibCallSemantics.cpp - Describe library semantics ------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements interfaces that can be used to describe language
|
|
|
|
// specific runtime library interfaces (e.g. libc, libm, etc) to LLVM
|
|
|
|
// optimizers.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Analysis/LibCallSemantics.h"
|
2015-01-28 01:17:38 +00:00
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/Function.h"
|
2008-05-07 18:21:13 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2015-01-28 01:17:38 +00:00
|
|
|
/// See if the given exception handling personality function is one that we
|
|
|
|
/// understand. If so, return a description of it; otherwise return Unknown.
|
2015-02-14 00:21:02 +00:00
|
|
|
EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
|
2015-08-31 20:02:16 +00:00
|
|
|
const Function *F =
|
|
|
|
Pers ? dyn_cast<Function>(Pers->stripPointerCasts()) : nullptr;
|
2015-01-28 01:17:38 +00:00
|
|
|
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("__gcc_personality_v0", EHPersonality::GNU_C)
|
|
|
|
.Case("__objc_personality_v0", EHPersonality::GNU_ObjC)
|
2015-04-29 22:49:54 +00:00
|
|
|
.Case("_except_handler3", EHPersonality::MSVC_X86SEH)
|
|
|
|
.Case("_except_handler4", EHPersonality::MSVC_X86SEH)
|
2015-01-28 01:17:38 +00:00
|
|
|
.Case("__C_specific_handler", EHPersonality::MSVC_Win64SEH)
|
|
|
|
.Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX)
|
2015-10-06 20:28:16 +00:00
|
|
|
.Case("ProcessCLRException", EHPersonality::CoreCLR)
|
2015-01-28 01:17:38 +00:00
|
|
|
.Default(EHPersonality::Unknown);
|
|
|
|
}
|
2015-02-11 01:23:16 +00:00
|
|
|
|
2015-06-17 20:52:32 +00:00
|
|
|
bool llvm::canSimplifyInvokeNoUnwind(const Function *F) {
|
|
|
|
EHPersonality Personality = classifyEHPersonality(F->getPersonalityFn());
|
2015-02-11 01:23:16 +00:00
|
|
|
// We can't simplify any invokes to nounwind functions if the personality
|
|
|
|
// function wants to catch asynch exceptions. The nounwind attribute only
|
|
|
|
// implies that the function does not throw synchronous exceptions.
|
|
|
|
return !isAsynchronousEHPersonality(Personality);
|
|
|
|
}
|