[llvm] r352112 - allow COFF .def directive in module assembly when using ThinLTO
Bob Haarman via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 24 13:41:04 PST 2019
Author: inglorion
Date: Thu Jan 24 13:41:03 2019
New Revision: 352112
URL: http://llvm.org/viewvc/llvm-project?rev=352112&view=rev
Log:
allow COFF .def directive in module assembly when using ThinLTO
Summary:
Using COFF's .def directive in module assembly used to crash ThinLTO
with "this directive only supported on COFF targets" when getting
symbol information in ModuleSymbolTable. This change allows
ModuleSymbolTable to process such code and adds a test to verify that
the .def directive has the desired effect on the native object file,
with and without ThinLTO.
Fixes https://bugs.llvm.org/show_bug.cgi?id=36789
Reviewers: rnk, pcc, vlad.tsyrklevich
Subscribers: mehdi_amini, eraman, hiraditya, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D57073
Added:
llvm/trunk/test/MC/COFF/module-asm-coff.ll
Modified:
llvm/trunk/lib/Object/RecordStreamer.h
Modified: llvm/trunk/lib/Object/RecordStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/RecordStreamer.h?rev=352112&r1=352111&r2=352112&view=diff
==============================================================================
--- llvm/trunk/lib/Object/RecordStreamer.h (original)
+++ llvm/trunk/lib/Object/RecordStreamer.h Thu Jan 24 13:41:03 2019
@@ -55,6 +55,15 @@ public:
unsigned ByteAlignment, SMLoc Loc = SMLoc()) override;
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) override;
+
+ // Ignore COFF-specific directives; we do not need any information from them,
+ // but the default implementation of these methods crashes, so we override
+ // them with versions that do nothing.
+ void BeginCOFFSymbolDef(const MCSymbol *Symbol) override {}
+ void EmitCOFFSymbolStorageClass(int StorageClass) override {}
+ void EmitCOFFSymbolType(int Type) override {}
+ void EndCOFFSymbolDef() override {}
+
/// Record .symver aliases for later processing.
void emitELFSymverDirective(StringRef AliasName,
const MCSymbol *Aliasee) override;
Added: llvm/trunk/test/MC/COFF/module-asm-coff.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/module-asm-coff.ll?rev=352112&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/module-asm-coff.ll (added)
+++ llvm/trunk/test/MC/COFF/module-asm-coff.ll Thu Jan 24 13:41:03 2019
@@ -0,0 +1,21 @@
+; Tests COFF-specific directives in module level assembly.
+
+; RUN: llc -filetype=obj %s -o %t.obj
+; RUN: llvm-readobj -t %t.obj | FileCheck %s
+; RUN: opt -thinlto-bc %s -o %t.thinlto.bc
+; RUN: llvm-lto2 run %t.thinlto.bc -o %t.thinlto.obj -r=%t.thinlto.bc,foo,plx
+; RUN: llvm-readobj -t %t.thinlto.obj.1 | FileCheck %s
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.24210"
+
+module asm ".text"
+module asm ".def foo; .scl 3; .type 32; .endef"
+module asm ".global foo"
+module asm "foo:"
+module asm " ret"
+
+; CHECK: Symbol {
+; CHECK: Name: foo
+; CHECK: StorageClass:
+; CHECK-SAME: Static (0x3)
More information about the llvm-commits
mailing list