[mlir][LLVMIR] Do not cache Instruction generated on-the-fly
authorMin-Yih Hsu <minyihh@uci.edu>
Wed, 20 Apr 2022 17:30:43 +0000 (10:30 -0700)
committerMin-Yih Hsu <minyihh@uci.edu>
Wed, 27 Apr 2022 16:42:59 +0000 (09:42 -0700)
commitea9bcb8b274ae6ef2fd5cbf8c8c9f42a8aa3c096
tree99de7331e1e4843adfee1e5806e3eea29235bbc0
parent00fcf9e95a4ab4ee5846b55bd09bb8a4257dfb67
[mlir][LLVMIR] Do not cache Instruction generated on-the-fly

More specifically, the llvm::Instruction generated by
llvm::ConstantExpr::getAsInstruction. Such Instruction will be deleted
right away, but it's possible that when getAsInstruction is called
again, it will create a new Instruction that has the same address with
the one we just deleted. Thus, we shouldn't keep it in the `instMap` to
avoid a conflicting index that triggers an assertion in
processInstruction.

Differential Revision: https://reviews.llvm.org/D124402
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/test/Target/LLVMIR/Import/incorrect-constexpr-inst-caching.ll [new file with mode: 0644]