[PATCH] D17057: Add support for phi nodes in the LLVM C API test

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 16:27:54 PST 2016


joker.eph added inline comments.

================
Comment at: tools/llvm-c-test/echo.cpp:195
@@ -194,3 +194,3 @@
     fprintf(stderr, "Could not determine the type of %s\n", Name);
     exit(-1);
   }
----------------
Ok here is what I think the semantic is:


```
    assert((LLVMIsAArgument(Src) || LLVMIsAInstruction(Src)) && "unexpected");

    // Function argument should always be in the map already.
    auto i = VMap.find(Src);
    if (i != VMap.end())
     return i->second;

    // Instruction only are possible at this point
    assert(LLVMIsAInstruction(Src) && "unexpected");

    auto Builder = LLVMCreateBuilderInContext(Ctx);
   auto BB = DeclareBB(LLVMGetInstructionParent(Src));
   LLVMPositionBuilderAtEnd(Builder, BB);
   auto Dst = CloneInstruction(Src, Builder);
   LLVMDisposeBuilder(Builder);
   return Dst;
}
```


http://reviews.llvm.org/D17057





More information about the llvm-commits mailing list