[PATCH] D92913: [lld-macho] Initialize AsmParsers earlier

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 9 15:09:30 PST 2020


int3 updated this revision to Diff 310677.
int3 marked an inline comment as done.
int3 added a comment.

newline


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92913/new/

https://reviews.llvm.org/D92913

Files:
  lld/MachO/Driver.cpp
  lld/test/MachO/module-asm.ll


Index: lld/test/MachO/module-asm.ll
===================================================================
--- /dev/null
+++ lld/test/MachO/module-asm.ll
@@ -0,0 +1,24 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld %t.o -o %t
+; RUN: llvm-objdump -d %t | FileCheck %s
+
+; CHECK:      <_foo>:
+; CHECK-NEXT: retq
+
+; CHECK:      <_main>:
+; CHECK-NEXT: jmp {{.*}} <_foo>
+
+target triple = "x86_64-apple-macosx10.15.0"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+module asm ".text"
+module asm ".globl _foo"
+module asm "_foo: ret"
+
+declare void @foo()
+
+define void @main() {
+  call void @foo()
+  ret void
+}
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -749,6 +749,8 @@
     return !errorCount();
   }
 
+  initLLVM(); // must be run before any call to addFile()
+
   for (const auto &arg : args) {
     const auto &opt = arg->getOption();
     warnIfDeprecatedOption(opt);
@@ -807,7 +809,6 @@
   for (auto *arg : args.filtered(OPT_mllvm))
     parseClangOption(arg->getValue(), arg->getSpelling());
 
-  initLLVM();
   compileBitcodeFiles();
   replaceCommonSymbols();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92913.310677.patch
Type: text/x-patch
Size: 1247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201209/e28a82dc/attachment.bin>


More information about the llvm-commits mailing list