[PATCH] D41832: LLParser: do not verify LLVM module

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 13:56:30 PST 2018


aprantl added a comment.

In https://reviews.llvm.org/D41832#989463, @yaxunl wrote:

> In https://reviews.llvm.org/D41832#989406, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D41832#989354, @aprantl wrote:
> >
> > > > If the user does not specify target on llc command line, llc is supposed to get the target from LLVM assembly, then use it to get the datalayout string through TargetMachine. However, that means it has to parse the LLVM assembly first, but it cannot. Because to parse the LLVM assembly it needs to know the datalayout string first.
> > >
> > > I'm probably missing something obvious here. The case where llc gets invoked without a target on the command line must be working today, doesn't it? Why can't we fall back to that code path?
> >
> >
> > This patch is trying to let llc load an llvm module which does not contain datalayout. In most cases, the parser is able to do that even though there is no datalayout in the module.
> >
> > However, in some rare cases, the parser needs to know the datalayout to be able to parse the module. Therefore we discussed and concluded that we need to inject datalayout when parsing the module.
> >
> > Let's consider the situation where llc command line does not contain target.
> >
> > The old code path just parses the LLVM assembly and gets the target from the assembly. It can do that because it does not need to inject the datalayout.
> >
> > However, now we need to inject datalayout when parsing, then we cannot since we don't know datalayout unless we parse the module to know the target first.
>
>
> My suggestion is
>
> 1. Introduce a function parseIRFileWithoutValidation, which does not drop invalid debug info and does not verify module.




> 2. Add an optional DataLayoutString argument to parseIRFile
> 
>   parseIRFile will call parseIRFileWithoutValidation, then inject datalayout, then drop invalid debug info and verify the module.



> only llc calls parseIRFileWithoutValidation, it will inject datalayout, drop invalid debuginfo and verify module by itself.



> All other tools call parseIRFile. They either inject datalayout by command line option, or does not inject datalayout.

That sounds good to me, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D41832





More information about the llvm-commits mailing list