diff options
author | James Y Knight <jyknight@google.com> | 2019-02-01 02:28:03 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2019-02-01 02:28:03 +0000 |
commit | 13680223b9d80bb01e17372f0907cf215e424cce (patch) | |
tree | 774a79c2eef0e125cf5beb33a7515f581397c398 /llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | |
parent | b4744d306c0a21933d4339fa4fb497866a36ee49 (diff) | |
download | bcm5719-llvm-13680223b9d80bb01e17372f0907cf215e424cce.tar.gz bcm5719-llvm-13680223b9d80bb01e17372f0907cf215e424cce.zip |
[opaque pointer types] Add a FunctionCallee wrapper type, and use it.
Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc
doesn't choke on it, hopefully.
Original Message:
The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.
Then:
- update the CallInst/InvokeInst instruction creation functions to
take a Callee,
- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.
One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.
However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)
Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.
Differential Revision: https://reviews.llvm.org/D57315
llvm-svn: 352827
Diffstat (limited to 'llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index b1e76ea62f8..88d22570f82 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1480,8 +1480,9 @@ makeStatepointExplicitImpl(const CallSite CS, /* to replace */ // calls to @llvm.experimental.deoptimize with different argument types in // the same module. This is fine -- we assume the frontend knew what it // was doing when generating this kind of IR. - CallTarget = - F->getParent()->getOrInsertFunction("__llvm_deoptimize", FTy); + CallTarget = F->getParent() + ->getOrInsertFunction("__llvm_deoptimize", FTy) + .getCallee(); IsDeoptimize = true; } @@ -1900,8 +1901,8 @@ static void insertUseHolderAfter(CallSite &CS, const ArrayRef<Value *> Values, Module *M = CS.getInstruction()->getModule(); // Use a dummy vararg function to actually hold the values live - Function *Func = cast<Function>(M->getOrInsertFunction( - "__tmp_use", FunctionType::get(Type::getVoidTy(M->getContext()), true))); + FunctionCallee Func = M->getOrInsertFunction( + "__tmp_use", FunctionType::get(Type::getVoidTy(M->getContext()), true)); if (CS.isCall()) { // For call safepoints insert dummy calls right after safepoint Holders.push_back(CallInst::Create(Func, Values, "", |