Revert r251050 to fix miscompile when running Clang -O1
[oota-llvm.git] / include / llvm / Analysis / LibCallSemantics.h
1 //===- LibCallSemantics.h - Describe library semantics --------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines interfaces that can be used to describe language specific
11 // runtime library interfaces (e.g. libc, libm, etc) to LLVM optimizers.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_ANALYSIS_LIBCALLSEMANTICS_H
16 #define LLVM_ANALYSIS_LIBCALLSEMANTICS_H
17
18 #include "llvm/Analysis/AliasAnalysis.h"
19
20 namespace llvm {
21 class InvokeInst;
22
23   enum class EHPersonality {
24     Unknown,
25     GNU_Ada,
26     GNU_C,
27     GNU_CXX,
28     GNU_ObjC,
29     MSVC_X86SEH,
30     MSVC_Win64SEH,
31     MSVC_CXX,
32     CoreCLR
33   };
34
35   /// \brief See if the given exception handling personality function is one
36   /// that we understand.  If so, return a description of it; otherwise return
37   /// Unknown.
38   EHPersonality classifyEHPersonality(const Value *Pers);
39
40   /// \brief Returns true if this personality function catches asynchronous
41   /// exceptions.
42   inline bool isAsynchronousEHPersonality(EHPersonality Pers) {
43     // The two SEH personality functions can catch asynch exceptions. We assume
44     // unknown personalities don't catch asynch exceptions.
45     switch (Pers) {
46     case EHPersonality::MSVC_X86SEH:
47     case EHPersonality::MSVC_Win64SEH:
48       return true;
49     default: return false;
50     }
51     llvm_unreachable("invalid enum");
52   }
53
54   /// \brief Returns true if this is a personality function that invokes
55   /// handler funclets (which must return to it).
56   inline bool isFuncletEHPersonality(EHPersonality Pers) {
57     switch (Pers) {
58     case EHPersonality::MSVC_CXX:
59     case EHPersonality::MSVC_X86SEH:
60     case EHPersonality::MSVC_Win64SEH:
61     case EHPersonality::CoreCLR:
62       return true;
63     default: return false;
64     }
65     llvm_unreachable("invalid enum");
66   }
67
68   /// \brief Return true if this personality may be safely removed if there
69   /// are no invoke instructions remaining in the current function.
70   inline bool isNoOpWithoutInvoke(EHPersonality Pers) {
71     switch (Pers) {
72     case EHPersonality::Unknown:
73       return false;
74     // All known personalities currently have this behavior
75     default: return true;
76     }
77     llvm_unreachable("invalid enum");
78   }
79
80   bool canSimplifyInvokeNoUnwind(const Function *F);
81
82 } // end namespace llvm
83
84 #endif