MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / buildPHI

Method buildPHI

lib/llvm/compiler.cpp:5726–5757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5724 }
5725
5726 void
5727 buildPHI(Span<const ValType> RetType,
5728 Span<const std::tuple<std::vector<LLVM::Value>, LLVM::BasicBlock>>
5729 Incomings) noexcept {
5730 if (isVoidReturn(RetType)) {
5731 return;
5732 }
5733 std::vector<LLVM::Value> Nodes;
5734 if (Incomings.size() == 0) {
5735 const auto &Types = toLLVMTypeVector(LLContext, RetType);
5736 Nodes.reserve(Types.size());
5737 for (LLVM::Type Type : Types) {
5738 Nodes.push_back(LLVM::Value::getUndef(Type));
5739 }
5740 } else if (Incomings.size() == 1) {
5741 Nodes = std::move(std::get<0>(Incomings.front()));
5742 } else {
5743 const auto &Types = toLLVMTypeVector(LLContext, RetType);
5744 Nodes.reserve(Types.size());
5745 for (size_t I = 0; I < Types.size(); ++I) {
5746 auto PHIRet = Builder.createPHI(Types[I]);
5747 for (auto &[Value, BB] : Incomings) {
5748 assuming(Value.size() == Types.size());
5749 PHIRet.addIncoming(Value[I], BB);
5750 }
5751 Nodes.push_back(PHIRet);
5752 }
5753 }
5754 for (auto &Val : Nodes) {
5755 stackPush(Val);
5756 }
5757 }
5758
5759 void setLableJumpPHI(unsigned int Index) noexcept {
5760 assuming(Index < ControlStack.size());

Callers

nothing calls this directly

Calls 6

isVoidReturnFunction · 0.85
toLLVMTypeVectorFunction · 0.85
frontMethod · 0.80
createPHIMethod · 0.80
addIncomingMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected