[PATCH] D123211: [flang][driver] Add support for generating LLVM bytecode files
Andrzej Warzynski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 6 07:56:32 PDT 2022
awarzynski added a comment.
Thanks for taking a look Diana!
> Why not use the BackendAction for this?
This action only requires the middle-end in LLVM :) The `BackendAction` will use the backend, but that's not needed here.
> There seems to be a lot of shared code, up until the point where you create and use the pass manager
This is the bit that's shared:
CompilerInstance &ci = this->instance();
// Generate an LLVM module if it's not already present (it will already be
// present if the input file is an LLVM IR/BC file).
if (!llvmModule)
GenerateLLVMIR();
// Create and configure `Target`
std::string error;
std::string theTriple = llvmModule->getTargetTriple();
const llvm::Target *theTarget =
llvm::TargetRegistry::lookupTarget(theTriple, error);
assert(theTarget && "Failed to create Target");
// Create and configure `TargetMachine`
std::unique_ptr<llvm::TargetMachine> TM;
TM.reset(theTarget->createTargetMachine(theTriple, /*CPU=*/"",
/*Features=*/"", llvm::TargetOptions(), llvm::None));
assert(TM && "Failed to create TargetMachine");
llvmModule->setDataLayout(TM->createDataLayout());
I wouldn't say it's "a lot", but probably enough for a dedicated method. I've been conservative with regard to sharing code as I anticipate things to change in the future (I expect `-O{0|1|2|3|s|z}` to complicate the logic a bit).
> (and in the future, when the backend switches to the new pass manager, there will be even more shared code).
I'm not sure about the timelines for this. And even then, the logic might be quite different (again, middle-end vs back-end).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123211/new/
https://reviews.llvm.org/D123211
More information about the cfe-commits
mailing list