diff options
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp index 6b1bbd7a2b07..7abb6fa8905c 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp @@ -23,7 +23,6 @@ //===----------------------------------------------------------------------===// #include "WebAssembly.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" @@ -73,11 +72,11 @@ static void findUses(Value *V, Function &F, else if (auto *A = dyn_cast<GlobalAlias>(U.getUser())) findUses(A, F, Uses, ConstantBCs); else if (U.get()->getType() != F.getType()) { - CallSite CS(U.getUser()); - if (!CS) + CallBase *CB = dyn_cast<CallBase>(U.getUser()); + if (!CB) // Skip uses that aren't immediately called continue; - Value *Callee = CS.getCalledValue(); + Value *Callee = CB->getCalledOperand(); if (Callee != V) // Skip calls where the function isn't the callee continue; @@ -244,6 +243,10 @@ bool FixFunctionBitcasts::runOnModule(Module &M) { // Collect all the places that need wrappers. for (Function &F : M) { + // Skip to fix when the function is swiftcc because swiftcc allows + // bitcast type difference for swiftself and swifterror. + if (F.getCallingConv() == CallingConv::Swift) + continue; findUses(&F, F, Uses, ConstantBCs); // If we have a "main" function, and its type isn't @@ -304,7 +307,7 @@ bool FixFunctionBitcasts::runOnModule(Module &M) { if (CallMain) { Main->setName("__original_main"); auto *MainWrapper = - cast<Function>(CallMain->getCalledValue()->stripPointerCasts()); + cast<Function>(CallMain->getCalledOperand()->stripPointerCasts()); delete CallMain; if (Main->isDeclaration()) { // The wrapper is not needed in this case as we don't need to export |