aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-as/llvm-as.cpp
diff options
context:
space:
mode:
authorJannik Silvanus <jannik.silvanus@amd.com>2023-01-04 11:52:00 +0100
committerJannik Silvanus <jannik.silvanus@amd.com>2023-01-12 10:10:45 +0100
commitdf1a74ac3c6407d0658c46c859c4a07974af3293 (patch)
tree3dc13e8546e02e0d3e290c685f5fe9d4cae3d965 /llvm/tools/llvm-as/llvm-as.cpp
parent02856565ac12e21f14f2af64ce1135ecc3c2021f (diff)
downloadllvm-df1a74ac3c6407d0658c46c859c4a07974af3293.zip
llvm-df1a74ac3c6407d0658c46c859c4a07974af3293.tar.gz
llvm-df1a74ac3c6407d0658c46c859c4a07974af3293.tar.bz2
[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
Diffstat (limited to 'llvm/tools/llvm-as/llvm-as.cpp')
-rw-r--r--llvm/tools/llvm-as/llvm-as.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index e6d4780..ef1c50fc 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -121,7 +121,7 @@ int main(int argc, char **argv) {
// Parse the file now...
SMDiagnostic Err;
- auto SetDataLayout = [](StringRef) -> std::optional<std::string> {
+ auto SetDataLayout = [](StringRef, StringRef) -> std::optional<std::string> {
if (ClDataLayout.empty())
return std::nullopt;
return ClDataLayout;