[llvm] r205221 - This patch fixes LTO's RecordStreamer so that it records symbols in the MCExpr

Tom Roeder tmroeder at google.com
Mon Mar 31 09:59:14 PDT 2014


Author: tmroeder
Date: Mon Mar 31 11:59:13 2014
New Revision: 205221

URL: http://llvm.org/viewvc/llvm-project?rev=205221&view=rev
Log:
This patch fixes LTO's RecordStreamer so that it records symbols in the MCExpr
part of an asm .symver directive as being used. This prevents referenced
functions from being internalized and deleted.

Without the patch to LTOModule.cpp, the test case will produce the error:

LLVM ERROR: A @@ version cannot be undefined.


Added:
    llvm/trunk/test/LTO/symver-asm.ll
Modified:
    llvm/trunk/lib/LTO/LTOModule.cpp

Modified: llvm/trunk/lib/LTO/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=205221&r1=205220&r2=205221&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOModule.cpp (original)
+++ llvm/trunk/lib/LTO/LTOModule.cpp Mon Mar 31 11:59:13 2014
@@ -660,6 +660,7 @@ namespace {
     void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override {
       // FIXME: should we handle aliases?
       markDefined(*Symbol);
+      AddValueSymbols(Value);
     }
     bool EmitSymbolAttribute(MCSymbol *Symbol,
                              MCSymbolAttr Attribute) override {

Added: llvm/trunk/test/LTO/symver-asm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/symver-asm.ll?rev=205221&view=auto
==============================================================================
--- llvm/trunk/test/LTO/symver-asm.ll (added)
+++ llvm/trunk/test/LTO/symver-asm.ll Mon Mar 31 11:59:13 2014
@@ -0,0 +1,16 @@
+; RUN: llvm-as < %s >%t1
+; RUN: llvm-lto -o %t2 %t1
+; RUN: llvm-nm %t2 | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+module asm ".symver io_cancel_0_4,io_cancel@@LIBAIO_0.4"
+
+; Even without -exported-symbol, io_cancel_0_4 should be noticed by LTOModule's
+; RecordStreamer, so it shouldn't get eliminated. However, the object file will
+; contain the aliased symver as well as the original.
+define i32 @io_cancel_0_4() {
+; CHECK: io_cancel@@LIBAIO_0.4
+; CHECK: io_cancel_0_4
+  ret i32 0
+}





More information about the llvm-commits mailing list