kparzysz-quic commented on PR #15761:
URL: https://github.com/apache/tvm/pull/15761#issuecomment-1727872007

   The idea behind `LLVMInstance` is that all interactions with the LLVM 
libraries only happen when an object of that class has been created.  You can 
think of it as if "LLVM instance" was turning on LLVM, and turning it back off 
when the object is destroyed.  There was a discussion about this a while back, 
motivated mostly by keeping track of the global state of LLVM.  Long story 
short, LLVM code has a global state, and modifying the global state in one part 
of TVM may affect how LLVM works in other parts (e.g. setting up codegen for 
CPU may affect codegen for GPU).  LLVM instance was created to encapsulate any 
potential global state changes into the lifetime period of the LLVM instance 
object.
   
   The functions you wrote can be moved to llvm_instance.cc.  They can create a 
temporary LLVMInstance object, get LLVMTargetInfo, get the `llvm::Target` 
object (or `llvm::TargetMachine`) from it, and do their work.
   
   Btw, the functionality you're adding is great, what I'm asking for is to 
integrate it with the existing code.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to