From 34706936412b9e9ff73511fed58e97bf6e100e69 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Sun, 18 Dec 2011 20:35:43 +0000 Subject: Allow inlining of functions with returns_twice calls, if they have the attribute themselve. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146851 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CodeMetrics.h | 7 ++++--- include/llvm/CodeGen/MachineFunction.h | 26 +++++++++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/CodeMetrics.h b/include/llvm/Analysis/CodeMetrics.h index 5f78021f3d..c01507f0a9 100644 --- a/include/llvm/Analysis/CodeMetrics.h +++ b/include/llvm/Analysis/CodeMetrics.h @@ -31,8 +31,9 @@ namespace llvm { /// caller. // bool NeverInline; - // True if this function contains a call to setjmp or _setjmp - bool callsSetJmp; + // True if this function contains a call to setjmp or other functions + // with attribute "returns twice" without having the attribute by itself. + bool exposesReturnsTwice; // True if this function calls itself bool isRecursive; @@ -66,7 +67,7 @@ namespace llvm { /// NumRets - Keep track of how many Ret instructions the block contains. unsigned NumRets; - CodeMetrics() : callsSetJmp(false), isRecursive(false), + CodeMetrics() : exposesReturnsTwice(false), isRecursive(false), containsIndirectBr(false), usesDynamicAlloca(false), NumInsts(0), NumBlocks(0), NumCalls(0), NumInlineCandidates(0), NumVectorInsts(0), diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 3a4568a59d..fd4cac8c12 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -120,10 +120,12 @@ class MachineFunction { /// Alignment - The alignment of the function. unsigned Alignment; - /// CallsSetJmp - True if the function calls setjmp or sigsetjmp. This is used - /// to limit optimizations which cannot reason about the control flow of - /// setjmp. - bool CallsSetJmp; + /// ExposesReturnsTwice - True if the function calls setjmp or related + /// functions with attribute "returns twice", but doesn't have + /// the attribute itself. + /// This is used to limit optimizations which cannot reason + /// about the control flow of such functions. + bool ExposesReturnsTwice; MachineFunction(const MachineFunction &); // DO NOT IMPLEMENT void operator=(const MachineFunction&); // DO NOT IMPLEMENT @@ -192,15 +194,17 @@ public: if (Alignment < A) Alignment = A; } - /// callsSetJmp - Returns true if the function calls setjmp or sigsetjmp. - bool callsSetJmp() const { - return CallsSetJmp; + /// exposesReturnsTwice - Returns true if the function calls setjmp or + /// any other similar functions with attribute "returns twice" without + /// having the attribute itself. + bool exposesReturnsTwice() const { + return ExposesReturnsTwice; } - /// setCallsSetJmp - Set a flag that indicates if there's a call to setjmp or - /// sigsetjmp. - void setCallsSetJmp(bool B) { - CallsSetJmp = B; + /// setCallsSetJmp - Set a flag that indicates if there's a call to + /// a "returns twice" function. + void setExposesReturnsTwice(bool B) { + ExposesReturnsTwice = B; } /// getInfo - Keep track of various per-function pieces of information for -- cgit v1.2.3