[PATCH] D133729: [llvm-lipo] Support object files with bitcode asm

Vincent Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 15:17:50 PDT 2022


thevinster created this revision.
Herald added a subscriber: ormris.
Herald added a project: All.
thevinster retitled this revision from "[llvm-lipo] Support object files with asm" to "[llvm-lipo] Support object files with bitcode asm".
thevinster edited the summary of this revision.
thevinster added reviewers: smeenai, alexander-shaposhnikov, keith, mtrent.
thevinster edited the summary of this revision.
thevinster published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

llvm-lipo crashes when trying to use inputs that contain bitcode asm instructions. 
This happens when trying to create universal binaries for LLVM with LTO. 
https://reviews.llvm.org/D118575 is a similar change that ran into this same issue, and I'm 
mirroring the same change by registering the targets to fix this issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133729

Files:
  llvm/test/tools/llvm-lipo/Inputs/arm64-asm.ll
  llvm/test/tools/llvm-lipo/Inputs/x86_64-asm.ll
  llvm/test/tools/llvm-lipo/create-arch-asm.test
  llvm/tools/llvm-lipo/llvm-lipo.cpp


Index: llvm/tools/llvm-lipo/llvm-lipo.cpp
===================================================================
--- llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileOutputBuffer.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/TextAPI/Architecture.h"
 
@@ -425,7 +426,7 @@
   Expected<Slice> SliceOrErr = createSliceFromIR(*IR, 0);
   if (!SliceOrErr)
     reportError(IR->getFileName(), SliceOrErr.takeError());
-  
+
   OS << SliceOrErr->getArchString() << " \n";
 }
 
@@ -720,6 +721,10 @@
 
 int main(int argc, char **argv) {
   InitLLVM X(argc, argv);
+  llvm::InitializeAllTargetInfos();
+  llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllAsmParsers();
+
   Config C = parseLipoOptions(makeArrayRef(argv + 1, argc - 1));
   LLVMContext LLVMCtx;
   SmallVector<OwningBinary<Binary>, 1> InputBinaries =
Index: llvm/test/tools/llvm-lipo/create-arch-asm.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-lipo/create-arch-asm.test
@@ -0,0 +1,8 @@
+# RUN: llvm-as %p/Inputs/arm64-asm.ll -o %t-arm64-asm.o
+# RUN: llvm-as %p/Inputs/x86_64-asm.ll -o %t-x86_64-asm.o
+
+# RUN: llvm-lipo %t-arm64-asm.o %t-x86_64-asm.o -create -output %t-universal.o
+# RUN: llvm-lipo %t-arm64-asm.o -arch x86_64 %t-x86_64-asm.o -create -output %t-universal-1.o
+# RUN: cmp %t-universal.o %t-universal-1.o
+# RUN: llvm-lipo -arch arm64 %t-arm64-asm.o -arch x86_64 %t-x86_64-asm.o -create -output %t-universal-2.o
+# RUN: cmp %t-universal.o %t-universal-2.o
Index: llvm/test/tools/llvm-lipo/Inputs/x86_64-asm.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-lipo/Inputs/x86_64-asm.ll
@@ -0,0 +1,7 @@
+target triple = "x86_64-apple-macosx11.0.0"
+
+module asm ".desc ___crashreporter_info__, 0x10"
+
+define void @somesymbol() {
+  ret void
+}
Index: llvm/test/tools/llvm-lipo/Inputs/arm64-asm.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-lipo/Inputs/arm64-asm.ll
@@ -0,0 +1,7 @@
+target triple = "arm64-apple-macosx11.0.0"
+
+module asm ".desc ___crashreporter_info__, 0x10"
+
+define void @somesymbol() {
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133729.459566.patch
Type: text/x-patch
Size: 2377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220912/c057977d/attachment.bin>


More information about the llvm-commits mailing list