LLVM  9.0.0svn
WebAssemblyTargetMachine.cpp
Go to the documentation of this file.
1 //===- WebAssemblyTargetMachine.cpp - Define TargetMachine for WebAssembly -==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file defines the WebAssembly-specific subclass of TargetMachine.
11 ///
12 //===----------------------------------------------------------------------===//
13 
17 #include "WebAssembly.h"
23 #include "llvm/CodeGen/Passes.h"
26 #include "llvm/IR/Function.h"
29 #include "llvm/Transforms/Scalar.h"
31 #include "llvm/Transforms/Utils.h"
32 using namespace llvm;
33 
34 #define DEBUG_TYPE "wasm"
35 
36 // Emscripten's asm.js-style exception handling
38  "enable-emscripten-cxx-exceptions",
39  cl::desc("WebAssembly Emscripten-style exception handling"),
40  cl::init(false));
41 
42 // Emscripten's asm.js-style setjmp/longjmp handling
44  "enable-emscripten-sjlj",
45  cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"),
46  cl::init(false));
47 
49  // Register the target.
54 
55  // Register backend passes
56  auto &PR = *PassRegistry::getPassRegistry();
80 }
81 
82 //===----------------------------------------------------------------------===//
83 // WebAssembly Lowering public interface.
84 //===----------------------------------------------------------------------===//
85 
87  const Triple &TT) {
88  if (!RM.hasValue()) {
89  // Default to static relocation model. This should always be more optimial
90  // than PIC since the static linker can determine all global addresses and
91  // assume direct function calls.
92  return Reloc::Static;
93  }
94 
95  if (!TT.isOSEmscripten()) {
96  // Relocation modes other than static are currently implemented in a way
97  // that only works for Emscripten, so disable them if we aren't targeting
98  // Emscripten.
99  return Reloc::Static;
100  }
101 
102  return *RM;
103 }
104 
105 /// Create an WebAssembly architecture model.
106 ///
108  const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
109  const TargetOptions &Options, Optional<Reloc::Model> RM,
111  : LLVMTargetMachine(T,
112  TT.isArch64Bit() ? "e-m:e-p:64:64-i64:64-n32:64-S128"
113  : "e-m:e-p:32:32-i64:64-n32:64-S128",
114  TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT),
115  getEffectiveCodeModel(CM, CodeModel::Large), OL),
116  TLOF(new WebAssemblyTargetObjectFile()) {
117  // WebAssembly type-checks instructions, but a noreturn function with a return
118  // type that doesn't match the context will cause a check failure. So we lower
119  // LLVM 'unreachable' to ISD::TRAP and then lower that to WebAssembly's
120  // 'unreachable' instructions which is meant for that case.
121  this->Options.TrapUnreachable = true;
122 
123  // WebAssembly treats each function as an independent unit. Force
124  // -ffunction-sections, effectively, so that we can emit them independently.
125  this->Options.FunctionSections = true;
126  this->Options.DataSections = true;
127  this->Options.UniqueSectionNames = true;
128 
129  initAsmInfo();
130 
131  // Note that we don't use setRequiresStructuredCFG(true). It disables
132  // optimizations than we're ok with, and want, such as critical edge
133  // splitting and tail merging.
134 }
135 
137 
138 const WebAssemblySubtarget *
140  std::string FS) const {
141  auto &I = SubtargetMap[CPU + FS];
142  if (!I) {
143  I = llvm::make_unique<WebAssemblySubtarget>(TargetTriple, CPU, FS, *this);
144  }
145  return I.get();
146 }
147 
148 const WebAssemblySubtarget *
150  Attribute CPUAttr = F.getFnAttribute("target-cpu");
151  Attribute FSAttr = F.getFnAttribute("target-features");
152 
153  std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
154  ? CPUAttr.getValueAsString().str()
155  : TargetCPU;
156  std::string FS = !FSAttr.hasAttribute(Attribute::None)
157  ? FSAttr.getValueAsString().str()
158  : TargetFS;
159 
160  // This needs to be done before we create a new subtarget since any
161  // creation will depend on the TM and the code generation flags on the
162  // function that reside in TargetOptions.
164 
165  return getSubtargetImpl(CPU, FS);
166 }
167 
168 namespace {
169 
170 class CoalesceFeaturesAndStripAtomics final : public ModulePass {
171  // Take the union of all features used in the module and use it for each
172  // function individually, since having multiple feature sets in one module
173  // currently does not make sense for WebAssembly. If atomics are not enabled,
174  // also strip atomic operations and thread local storage.
175  static char ID;
176  WebAssemblyTargetMachine *WasmTM;
177 
178 public:
179  CoalesceFeaturesAndStripAtomics(WebAssemblyTargetMachine *WasmTM)
180  : ModulePass(ID), WasmTM(WasmTM) {}
181 
182  bool runOnModule(Module &M) override {
183  FeatureBitset Features = coalesceFeatures(M);
184 
185  std::string FeatureStr = getFeatureString(Features);
186  for (auto &F : M)
187  replaceFeatures(F, FeatureStr);
188 
189  bool Stripped = false;
190  if (!Features[WebAssembly::FeatureAtomics]) {
191  Stripped |= stripAtomics(M);
192  Stripped |= stripThreadLocals(M);
193  }
194 
195  recordFeatures(M, Features, Stripped);
196 
197  // Conservatively assume we have made some change
198  return true;
199  }
200 
201 private:
202  FeatureBitset coalesceFeatures(const Module &M) {
203  FeatureBitset Features =
204  WasmTM
205  ->getSubtargetImpl(WasmTM->getTargetCPU(),
206  WasmTM->getTargetFeatureString())
207  ->getFeatureBits();
208  for (auto &F : M)
209  Features |= WasmTM->getSubtargetImpl(F)->getFeatureBits();
210  return Features;
211  }
212 
213  std::string getFeatureString(const FeatureBitset &Features) {
214  std::string Ret;
215  for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
216  if (Features[KV.Value])
217  Ret += (StringRef("+") + KV.Key + ",").str();
218  }
219  return Ret;
220  }
221 
222  void replaceFeatures(Function &F, const std::string &Features) {
223  F.removeFnAttr("target-features");
224  F.removeFnAttr("target-cpu");
225  F.addFnAttr("target-features", Features);
226  }
227 
228  bool stripAtomics(Module &M) {
229  // Detect whether any atomics will be lowered, since there is no way to tell
230  // whether the LowerAtomic pass lowers e.g. stores.
231  bool Stripped = false;
232  for (auto &F : M) {
233  for (auto &B : F) {
234  for (auto &I : B) {
235  if (I.isAtomic()) {
236  Stripped = true;
237  goto done;
238  }
239  }
240  }
241  }
242 
243  done:
244  if (!Stripped)
245  return false;
246 
247  LowerAtomicPass Lowerer;
249  for (auto &F : M)
250  Lowerer.run(F, FAM);
251 
252  return true;
253  }
254 
255  bool stripThreadLocals(Module &M) {
256  bool Stripped = false;
257  for (auto &GV : M.globals()) {
258  if (GV.getThreadLocalMode() !=
259  GlobalValue::ThreadLocalMode::NotThreadLocal) {
260  Stripped = true;
261  GV.setThreadLocalMode(GlobalValue::ThreadLocalMode::NotThreadLocal);
262  }
263  }
264  return Stripped;
265  }
266 
267  void recordFeatures(Module &M, const FeatureBitset &Features, bool Stripped) {
268  for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
269  std::string MDKey = (StringRef("wasm-feature-") + KV.Key).str();
270  if (KV.Value == WebAssembly::FeatureAtomics && Stripped) {
271  // "atomics" is special: code compiled without atomics may have had its
272  // atomics lowered to nonatomic operations. In that case, atomics is
273  // disallowed to prevent unsafe linking with atomics-enabled objects.
274  assert(!Features[WebAssembly::FeatureAtomics]);
277  } else if (Features[KV.Value]) {
278  // Otherwise features are marked Used or not mentioned
281  }
282  }
283  }
284 };
286 
287 /// WebAssembly Code Generator Pass Configuration Options.
288 class WebAssemblyPassConfig final : public TargetPassConfig {
289 public:
290  WebAssemblyPassConfig(WebAssemblyTargetMachine &TM, PassManagerBase &PM)
291  : TargetPassConfig(TM, PM) {}
292 
293  WebAssemblyTargetMachine &getWebAssemblyTargetMachine() const {
294  return getTM<WebAssemblyTargetMachine>();
295  }
296 
297  FunctionPass *createTargetRegisterAllocator(bool) override;
298 
299  void addIRPasses() override;
300  bool addInstSelector() override;
301  void addPostRegAlloc() override;
302  bool addGCPasses() override { return false; }
303  void addPreEmitPass() override;
304 
305  // No reg alloc
306  bool addRegAssignmentFast() override { return false; }
307 
308  // No reg alloc
309  bool addRegAssignmentOptimized() override { return false; }
310 };
311 } // end anonymous namespace
312 
315  return TargetTransformInfo(WebAssemblyTTIImpl(this, F));
316 }
317 
320  return new WebAssemblyPassConfig(*this, PM);
321 }
322 
323 FunctionPass *WebAssemblyPassConfig::createTargetRegisterAllocator(bool) {
324  return nullptr; // No reg alloc
325 }
326 
327 //===----------------------------------------------------------------------===//
328 // The following functions are called from lib/CodeGen/Passes.cpp to modify
329 // the CodeGen pass sequence.
330 //===----------------------------------------------------------------------===//
331 
332 void WebAssemblyPassConfig::addIRPasses() {
333  // Runs LowerAtomicPass if necessary
334  addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
335 
336  // This is a no-op if atomics are not used in the module
337  addPass(createAtomicExpandPass());
338 
339  // Add signatures to prototype-less function declarations
341 
342  // Lower .llvm.global_dtors into .llvm_global_ctors with __cxa_atexit calls.
344 
345  // Fix function bitcasts, as WebAssembly requires caller and callee signatures
346  // to match.
348 
349  // Optimize "returned" function attributes.
350  if (getOptLevel() != CodeGenOpt::None)
352 
353  // If exception handling is not enabled and setjmp/longjmp handling is
354  // enabled, we lower invokes into calls and delete unreachable landingpad
355  // blocks. Lowering invokes when there is no EH support is done in
356  // TargetPassConfig::addPassesToHandleExceptions, but this runs after this
357  // function and SjLj handling expects all invokes to be lowered before.
358  if (!EnableEmException &&
359  TM->Options.ExceptionModel == ExceptionHandling::None) {
360  addPass(createLowerInvokePass());
361  // The lower invoke pass may create unreachable code. Remove it in order not
362  // to process dead blocks in setjmp/longjmp handling.
364  }
365 
366  // Handle exceptions and setjmp/longjmp if enabled.
369  EnableEmSjLj));
370 
372 }
373 
374 bool WebAssemblyPassConfig::addInstSelector() {
376  addPass(
377  createWebAssemblyISelDag(getWebAssemblyTargetMachine(), getOptLevel()));
378  // Run the argument-move pass immediately after the ScheduleDAG scheduler
379  // so that we can fix up the ARGUMENT instructions before anything else
380  // sees them in the wrong place.
382  // Set the p2align operands. This information is present during ISel, however
383  // it's inconvenient to collect. Collect it now, and update the immediate
384  // operands.
386  return false;
387 }
388 
389 void WebAssemblyPassConfig::addPostRegAlloc() {
390  // TODO: The following CodeGen passes don't currently support code containing
391  // virtual registers. Consider removing their restrictions and re-enabling
392  // them.
393 
394  // These functions all require the NoVRegs property.
395  disablePass(&MachineCopyPropagationID);
396  disablePass(&PostRAMachineSinkingID);
397  disablePass(&PostRASchedulerID);
398  disablePass(&FuncletLayoutID);
399  disablePass(&StackMapLivenessID);
400  disablePass(&LiveDebugValuesID);
401  disablePass(&PatchableFunctionID);
402  disablePass(&ShrinkWrapID);
403 
404  // This pass hurts code size for wasm because it can generate irreducible
405  // control flow.
406  disablePass(&MachineBlockPlacementID);
407 
409 }
410 
411 void WebAssemblyPassConfig::addPreEmitPass() {
413 
414  // Rewrite pseudo call_indirect instructions as real instructions.
415  // This needs to run before register stackification, because we change the
416  // order of the arguments.
418 
419  // Eliminate multiple-entry loops.
421 
422  // Do various transformations for exception handling.
423  // Every CFG-changing optimizations should come before this.
425 
426  // Now that we have a prologue and epilogue and all frame indices are
427  // rewritten, eliminate SP and FP. This allows them to be stackified,
428  // colored, and numbered with the rest of the registers.
430 
431  // Preparations and optimizations related to register stackification.
432  if (getOptLevel() != CodeGenOpt::None) {
433  // LiveIntervals isn't commonly run this late. Re-establish preconditions.
435 
436  // Depend on LiveIntervals and perform some optimizations on it.
438 
439  // Prepare memory intrinsic calls for register stackifying.
441 
442  // Mark registers as representing wasm's value stack. This is a key
443  // code-compression technique in WebAssembly. We run this pass (and
444  // MemIntrinsicResults above) very late, so that it sees as much code as
445  // possible, including code emitted by PEI and expanded by late tail
446  // duplication.
447  addPass(createWebAssemblyRegStackify());
448 
449  // Run the register coloring pass to reduce the total number of registers.
450  // This runs after stackification so that it doesn't consider registers
451  // that become stackified.
452  addPass(createWebAssemblyRegColoring());
453  }
454 
455  // Sort the blocks of the CFG into topological order, a prerequisite for
456  // BLOCK and LOOP markers.
457  addPass(createWebAssemblyCFGSort());
458 
459  // Insert BLOCK and LOOP markers.
460  addPass(createWebAssemblyCFGStackify());
461 
462  // Insert explicit local.get and local.set operators.
464 
465  // Lower br_unless into br_if.
467 
468  // Perform the very last peephole optimizations on the code.
469  if (getOptLevel() != CodeGenOpt::None)
470  addPass(createWebAssemblyPeephole());
471 
472  // Create a mapping from LLVM CodeGen virtual registers to wasm registers.
474 }
475 
478  return new yaml::WebAssemblyFunctionInfo();
479 }
480 
482  const MachineFunction &MF) const {
483  const auto *MFI = MF.getInfo<WebAssemblyFunctionInfo>();
484  return new yaml::WebAssemblyFunctionInfo(*MFI);
485 }
486 
489  SMDiagnostic &Error, SMRange &SourceRange) const {
490  const auto &YamlMFI =
491  reinterpret_cast<const yaml::WebAssemblyFunctionInfo &>(MFI);
492  MachineFunction &MF = PFS.MF;
493  MF.getInfo<WebAssemblyFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
494  return false;
495 }
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
Represents a range in source code.
Definition: SMLoc.h:48
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
Definition: Triple.h:601
StringRef getTargetFeatureString() const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
FunctionPass * createWebAssemblyLowerBrUnless()
CodeModel::Model getEffectiveCodeModel(Optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value...
ModulePass * createWebAssemblyLowerEmscriptenEHSjLj(bool DoEH, bool DoSjLj)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:218
static cl::opt< bool > EnableEmSjLj("enable-emscripten-sjlj", cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"), cl::init(false))
This class represents lattice values for constants.
Definition: AllocatorList.h:23
FunctionPass * createWebAssemblyCFGSort()
void initializeWebAssemblyOptimizeLiveIntervalsPass(PassRegistry &)
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
FunctionPass * createWebAssemblyArgumentMove()
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with...
Definition: TargetMachine.h:84
This file a TargetTransformInfo::Concept conforming object specific to the WebAssembly target machine...
unsigned DataSections
Emit data into separate sections.
void initializeWebAssemblyMemIntrinsicResultsPass(PassRegistry &)
char & FuncletLayoutID
This pass lays out funclets contiguously.
FunctionPass * createWebAssemblyPeephole()
void initializeWebAssemblyRegStackifyPass(PassRegistry &)
void initializeWebAssemblyArgumentMovePass(PassRegistry &)
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
F(f)
void initializeWebAssemblyFixIrreducibleControlFlowPass(PassRegistry &)
A pass that lowers atomic intrinsic into non-atomic intrinsics.
Definition: LowerAtomic.h:22
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
virtual void addPreEmitPass()
This pass may be implemented by targets that want to run passes immediately before machine code is em...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
FunctionPass * createWebAssemblyRegStackify()
FunctionPass * createWebAssemblyOptimizeReturned()
This file declares the WebAssembly-specific subclass of TargetLoweringObjectFile. ...
This file registers the WebAssembly target.
void resetTargetOptions(const Function &F) const
Reset the target options based on the function&#39;s attributes.
FunctionPass * createWebAssemblyRegNumbering()
FunctionPass * createLowerInvokePass()
Definition: LowerInvoke.cpp:86
void initializeWebAssemblyRegNumberingPass(PassRegistry &)
No attributes have been set.
Definition: Attributes.h:71
void initializeWebAssemblyExceptionInfoPass(PassRegistry &)
void initializeOptimizeReturnedPass(PassRegistry &)
FunctionPass * createWebAssemblyRegColoring()
Target-Independent Code Generator Pass Configuration Options.
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target&#39;s MachineFunctionInfo from the YAML reprsentation.
This file declares the WebAssembly-specific subclass of TargetMachine.
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
const SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]
unsigned FunctionSections
Emit functions into separate sections.
Used to provide key value pairs for feature and CPU bit flags.
FunctionPass * createUnreachableBlockEliminationPass()
createUnreachableBlockEliminationPass - The LLVM code generator does not work well with unreachable b...
StringRef getTargetCPU() const
unsigned UniqueSectionNames
ModulePass * createWebAssemblyAddMissingPrototypes()
void initializeWebAssemblyExplicitLocalsPass(PassRegistry &)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:238
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
void initializeWebAssemblyPeepholePass(PassRegistry &)
Container class for subtarget features.
FunctionPass * createWebAssemblyISelDag(WebAssemblyTargetMachine &TM, CodeGenOpt::Level OptLevel)
This pass converts a legalized DAG into a WebAssembly-specific DAG, ready for instruction scheduling...
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
FunctionPass * createWebAssemblyCallIndirectFixup()
ModulePass * createWebAssemblyLowerGlobalDtors()
char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
This file provides WebAssembly-specific target descriptions.
void initializeWebAssemblyCallIndirectFixupPass(PassRegistry &)
virtual bool addInstSelector()
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
Definition: Module.cpp:337
char & LiveDebugValuesID
LiveDebugValues pass.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void initializeWebAssemblyReplacePhysRegsPass(PassRegistry &)
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
FunctionPass * createWebAssemblySetP2AlignOperands()
void initializeWebAssemblyLowerEmscriptenEHSjLjPass(PassRegistry &)
char & MachineCopyPropagationID
MachineCopyPropagation - This pass performs copy propagation on machine instructions.
static cl::opt< bool > EnableEmException("enable-emscripten-cxx-exceptions", cl::desc("WebAssembly Emscripten-style exception handling"), cl::init(false))
void initializeWebAssemblyLateEHPreparePass(PassRegistry &)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
char & PostRASchedulerID
createPostRAScheduler - This pass performs post register allocation scheduling.
ModulePass * createWebAssemblyFixFunctionBitcasts()
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
void initializeWebAssemblyLowerBrUnlessPass(PassRegistry &)
FunctionPass * createWebAssemblyMemIntrinsicResults()
FunctionPass * createWebAssemblyFixIrreducibleControlFlow()
Target - Wrapper for Target specific information.
virtual void addPostRegAlloc()
This method may be implemented by targets that want to run passes after register allocation pass pipe...
void initializeWebAssemblyCFGStackifyPass(PassRegistry &)
std::string TargetCPU
Definition: TargetMachine.h:85
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
bool hasValue() const
Definition: Optional.h:259
const WebAssemblySubtarget * getSubtargetImpl(std::string CPU, std::string FS) const
StringRef getValueAsString() const
Return the attribute&#39;s value as a string.
Definition: Attributes.cpp:223
FunctionPass * createWebAssemblyLateEHPrepare()
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
No exception support.
#define I(x, y, z)
Definition: MD5.cpp:58
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:224
This file declares WebAssembly-specific per-machine-function information.
char & MachineBlockPlacementID
MachineBlockPlacement - This pass places basic blocks based on branch probabilities.
WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Create an WebAssembly architecture model.
void LLVMInitializeWebAssemblyTarget()
void initializeWebAssemblyAddMissingPrototypesPass(PassRegistry &)
void initializeFixFunctionBitcastsPass(PassRegistry &)
std::string TargetFS
Definition: TargetMachine.h:86
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
Definition: Function.h:245
FunctionPass * createWebAssemblyOptimizeLiveIntervals()
FunctionPass * createWebAssemblyCFGStackify()
void initializeWebAssemblyPrepareForLiveIntervalsPass(PassRegistry &)
void initializeWebAssemblySetP2AlignOperandsPass(PassRegistry &)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void initializeLowerGlobalDtorsPass(PassRegistry &)
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
FunctionPass * createWebAssemblyPrepareForLiveIntervals()
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:333
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Definition: Function.h:229
iterator_range< global_iterator > globals()
Definition: Module.h:587
char & ShrinkWrapID
ShrinkWrap pass. Look for the best place to insert save and restore.
Definition: ShrinkWrap.cpp:249
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
A container for analyses that lazily runs them and caches their results.
unsigned TrapUnreachable
Emit target-specific trap instruction for &#39;unreachable&#39; IR instructions.
Target & getTheWebAssemblyTarget32()
FunctionPass * createWebAssemblyReplacePhysRegs()
void initializeWebAssemblyCFGSortPass(PassRegistry &)
FunctionPass * createAtomicExpandPass()
Target & getTheWebAssemblyTarget64()
FunctionPass * createWebAssemblyExplicitLocals()
void initializeWebAssemblyRegColoringPass(PassRegistry &)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:259