[all-commits] [llvm/llvm-project] df1a74: [IR] Support importing modules with invalid data l...
Jannik Silvanus via All-commits
all-commits at lists.llvm.org
Thu Jan 12 01:12:45 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: df1a74ac3c6407d0658c46c859c4a07974af3293
https://github.com/llvm/llvm-project/commit/df1a74ac3c6407d0658c46c859c4a07974af3293
Author: Jannik Silvanus <jannik.silvanus at amd.com>
Date: 2023-01-12 (Thu, 12 Jan 2023)
Changed paths:
M llvm/include/llvm/AsmParser/LLParser.h
M llvm/include/llvm/AsmParser/Parser.h
M llvm/include/llvm/Bitcode/BitcodeReader.h
M llvm/include/llvm/CodeGen/MIRParser/MIRParser.h
M llvm/include/llvm/IRReader/IRReader.h
M llvm/lib/AsmParser/LLParser.cpp
M llvm/lib/AsmParser/Parser.cpp
M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
M llvm/lib/CodeGen/MIRParser/MIRParser.cpp
A llvm/test/Assembler/invalid-datalayout-override.ll
M llvm/test/Bitcode/function-default-address-spaces.ll
M llvm/tools/llc/llc.cpp
M llvm/tools/llvm-as/llvm-as.cpp
M llvm/tools/llvm-reduce/ReducerWorkItem.cpp
M llvm/tools/opt/opt.cpp
M llvm/unittests/AsmParser/AsmParserTest.cpp
Log Message:
-----------
[IR] Support importing modules with invalid data layouts.
Use the existing mechanism to change the data layout using callbacks.
Before this patch, we had a callback type DataLayoutCallbackTy that receives
a single StringRef specifying the target triple, and optionally returns
the data layout string to be used. Module loaders (both IR and BC) then
apply the callback to potentially override the module's data layout,
after first having imported and parsed the data layout from the file.
We can't do the same to fix invalid data layouts, because the import will already
fail, before the callback has a chance to fix it.
Instead, module loaders now tentatively parse the data layout into a string,
wait until the target triple has been parsed, apply the override callback
to the imported string and only then parse the tentative string as a data layout.
Moreover, add the old data layout string S as second argument to the callback,
in addition to the already existing target triple argument.
S is either the default data layout string in case none is specified, or the data
layout string specified in the module, possibly after auto-upgrades (for the BitcodeReader).
This allows callbacks to inspect the old data layout string,
and fix it instead of setting a fixed data layout.
Also allow to pass data layout override callbacks to lazy bitcode module
loader functions.
Differential Revision: https://reviews.llvm.org/D140985
More information about the All-commits
mailing list