Author: Jez Ng Date: 2020-12-10T15:57:52-08:00 New Revision: 74d799926e557928352dcd980788cae6487e421c
URL: https://github.com/llvm/llvm-project/commit/74d799926e557928352dcd980788cae6487e421c DIFF: https://github.com/llvm/llvm-project/commit/74d799926e557928352dcd980788cae6487e421c.diff LOG: [lld-macho] Initialize AsmParsers earlier We need to initialize AsmParsers before any calls to `addFile`, as bitcode files may require them. Otherwise we trigger `Assertion T && T->hasMCAsmParser()' failed`. Reviewed By: #lld-macho, compnerd Differential Revision: https://reviews.llvm.org/D92913 Added: lld/test/MachO/module-asm.ll Modified: lld/MachO/Driver.cpp Removed: ################################################################################ diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index 432bb81925da..b8a926279891 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -749,6 +749,8 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly, 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 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly, for (auto *arg : args.filtered(OPT_mllvm)) parseClangOption(arg->getValue(), arg->getSpelling()); - initLLVM(); compileBitcodeFiles(); replaceCommonSymbols(); diff --git a/lld/test/MachO/module-asm.ll b/lld/test/MachO/module-asm.ll new file mode 100644 index 000000000000..01adcc438d2a --- /dev/null +++ b/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 +} _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits