//===-- WebAssemblyAddMissingPrototypes.cpp - Fix prototypeless functions -===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// Add prototypes to prototypes-less functions. /// /// WebAssembly has strict function prototype checking so we need functions /// declarations to match the call sites. Clang treats prototype-less functions /// as varargs (foo(...)) which happens to work on existing platforms but /// doesn't under WebAssembly. This pass will find all the call sites of each /// prototype-less function, ensure they agree, and then set the signature /// on the function declaration accordingly. /// //===----------------------------------------------------------------------===// #include "WebAssembly.h" #include "llvm/IR/Constants.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Module.h" #include "llvm/IR/Operator.h" #include "llvm/Pass.h" #include "llvm/Support/Debug.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/ModuleUtils.h" usingnamespacellvm; #define DEBUG_TYPE … namespace { class WebAssemblyAddMissingPrototypes final : public ModulePass { … }; } // End anonymous namespace char WebAssemblyAddMissingPrototypes::ID = …; INITIALIZE_PASS(…) ModulePass *llvm::createWebAssemblyAddMissingPrototypes() { … } bool WebAssemblyAddMissingPrototypes::runOnModule(Module &M) { … }