================ @@ -760,8 +787,10 @@ std::unique_ptr<llvm::Module> Interpreter::GenModule() { return nullptr; } -CodeGenerator *Interpreter::getCodeGen() const { - FrontendAction *WrappedAct = Act->getWrapped(); +CodeGenerator *Interpreter::getCodeGen(IncrementalAction *Action) const { + if (!Action) + Action = Act.get(); + FrontendAction *WrappedAct = Action->getWrapped(); ---------------- anutosh491 wrote:
Talking about changes with respect to codegen. So errors like these ``` ./bin/clang-repl --cuda module flag identifiers must be unique (or of 'require' type) !"wchar_size" module flag identifiers must be unique (or of 'require' type) !"nvvm-reflect-ftz" module flag identifiers must be unique (or of 'require' type) !"frame-pointer" fatal error: error in backend: Broken module found, compilation aborted! ``` or even something like this ``` error: Added modules have incompatible data layouts: e-p6:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64 (module) vs e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128 (jit) ``` Occur because we use the `Act` (the host IncrementalAction) to come up with the Module every time as of now. But think about it when we are registering a PTU through registerPTU ``` if (!M) M = GenModule(); ``` And we have this block. We shouldn't be generating the same Module for both the hostPTU (parsed through the incremental parser) and the devicePTU (parsed through the incrementalCudaParser) . For the first case the Module should revolve around the triple `x86_64-unknown-linux-gnu` and for the device case the module should be framed around the target triple `nvptx64-nvidia-cuda`. This is taken care of based on which `IncrementalAction` we use. We should use Act for hostPTU and DeviceACT for PTU. Hence the changes here (as one trickles into the other) ``` CodeGenerator *getCodeGen(IncrementalAction *Action = nullptr) const; std::unique_ptr<llvm::Module> GenModule(IncrementalAction *Action = nullptr); PartialTranslationUnit &RegisterPTU(TranslationUnitDecl *TU, std::unique_ptr<llvm::Module> M = {}, IncrementalAction *Action = nullptr); ``` So by default we use Act but we can take of it when required. 1) So while regiserting a devicePTU we use this https://github.com/llvm/llvm-project/pull/136404/files#diff-b8484f1fc5b057f146ed5d9b6e2cd47c3f6f5ae879c7a0eee44f0a272581a88cR580 2) While registering a hostptu we use this https://github.com/llvm/llvm-project/pull/136404/files#diff-b8484f1fc5b057f146ed5d9b6e2cd47c3f6f5ae879c7a0eee44f0a272581a88cR600 https://github.com/llvm/llvm-project/pull/136404 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits