[PATCH] [Inlining][NFC] Introduce a InlineFunction that takes a Statepoint.
Sanjoy Das
sanjoy at playingwithpointers.com
Mon Jun 22 19:15:21 PDT 2015
Hi reames, chandlerc, nlewycky,
After this change, clients of `InlineFunction` can get it to inline
through calls / invokes wrapped in `gc_statepoint`. NFC because nothing
actually exercises this code path yet.
Depends on D10631
http://reviews.llvm.org/D10632
Files:
include/llvm/Transforms/Utils/Cloning.h
lib/Transforms/Utils/InlineFunction.cpp
Index: include/llvm/Transforms/Utils/Cloning.h
===================================================================
--- include/llvm/Transforms/Utils/Cloning.h
+++ include/llvm/Transforms/Utils/Cloning.h
@@ -20,6 +20,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/IR/Statepoint.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/IR/ValueMap.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
@@ -232,6 +233,8 @@
bool InsertLifetime = true);
bool InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
bool InsertLifetime = true);
+bool InlineFunction(Statepoint SP, InlineFunctionInfo &IFI,
+ bool InsertLifetime = true);
} // namespace llvm
Index: lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- lib/Transforms/Utils/InlineFunction.cpp
+++ lib/Transforms/Utils/InlineFunction.cpp
@@ -94,6 +94,15 @@
verify();
}
+ explicit InlineSite(Statepoint SP)
+ : CalledFunction(cast<Function>(SP.getActualCallee())),
+ CallSiteInst(SP.getCallSite().getInstruction()),
+ ArgBegin(SP.call_args_begin()), ArgEnd(SP.call_args_end()),
+ ArgSize(SP.getNumCallArgs()),
+ DoesNotThrow(cast<Function>(SP.getActualCallee())->doesNotThrow()) {
+ verify();
+ }
+
Function *getCalledFunction() const { return CalledFunction; }
Function *getCaller() const;
@@ -146,6 +155,33 @@
return true;
}
+bool llvm::InlineFunction(Statepoint SP, InlineFunctionInfo &IFI,
+ bool InsertLifetime) {
+ if (SP.gc_args_begin() != SP.gc_args_begin() ||
+ SP.vm_state_begin() != SP.vm_state_end() ||
+ SP.gc_transition_args_begin() != SP.gc_transition_args_end())
+ return false;
+
+ Value *ReturnValOut = nullptr;
+ bool InlinedMustTailCalls = false;
+ if (!InlineFunctionImpl(InlineSite(SP), IFI, InsertLifetime, ReturnValOut,
+ InlinedMustTailCalls))
+ return false;
+
+ // TODO: add handling for unreachable code that may violate
+ // defs-dominate-uses.
+ if (CallInst *Result = cast_or_null<CallInst>(SP.getGCResult())) {
+ Result->replaceAllUsesWith(ReturnValOut);
+ Result->removeFromParent();
+ }
+
+ Instruction *StatepointInst = SP.getCallSite().getInstruction();
+ assert(StatepointInst->use_empty() && "gc_result should be the only use!");
+ StatepointInst->eraseFromParent();
+
+ return true;
+}
+
namespace {
/// A class for recording information about inlining through an invoke.
class InvokeInliningInfo {
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10632.28192.patch
Type: text/x-patch
Size: 2603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150623/64f4480f/attachment.bin>
More information about the llvm-commits
mailing list