[PATCH] D21550: [lld] support --trace-symbol (alias -y) option

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 03:04:13 PDT 2016


ruiu added a subscriber: ruiu.

================
Comment at: ELF/Config.h:67
@@ -66,2 +66,3 @@
   std::vector<llvm::StringRef> VersionScriptGlobals;
+  std::vector<llvm::StringRef> TraceSymbolList;
   std::vector<uint8_t> BuildIdVector;
----------------
Use StringSet<> instead. I'd name this TraceSymbol since all members in Config class are named after their corresponding command line options.

================
Comment at: ELF/Driver.cpp:420
@@ -419,1 +419,3 @@
   }
+  for (auto *Arg : Args.filtered(OPT_y)) {
+    Config->TraceSymbolList.push_back(Arg->getValue());
----------------
Remove {}

================
Comment at: ELF/Driver.cpp:423
@@ +422,3 @@
+  }
+  for (auto *Arg : Args.filtered(OPT_trace_symbol)) {
+    Config->TraceSymbolList.push_back(Arg->getValue());
----------------
Define `-y` as an alias to `--trace-symbol` in Options.td instead of handling the two as different options.

================
Comment at: ELF/Error.cpp:53
@@ -52,1 +52,3 @@
 
+void info(const Twine &Msg) {
+  llvm::outs() << Msg << "\n"; 
----------------
No need to define this function -- just print out to out().

================
Comment at: ELF/InputFiles.cpp:318
@@ +317,3 @@
+// notified symbols provided through -y or trace-symbol option
+void InputFile::notify(StringRef &Name, bool isDefined) {
+  if (!Config->TraceSymbolList.empty()) {
----------------
This generic name is overkill. I'd define two functions

  void ObjectFile<ELFT>::traceDefined(StringRef Name);
  void ObjectFile<ELFT>::traceUndefined(StringRef Name);

where traceDefined prints out "definition of" message and traceUndefined prints out "reference to" message, and call them from ObjectFile<ELFT>::createSymbolBody.

================
Comment at: ELF/Options.td:129
@@ +128,3 @@
+def trace_symbol : Joined<["--", "-"], "trace-symbol=">,
+  HelpText<"Trace module names which define or reference symbols ">;
+
----------------
"Trace references to symbol"

================
Comment at: ELF/SymbolTable.cpp:348-349
@@ -347,2 +347,4 @@
   int Cmp = compareDefinedNonCommon(S, WasInserted, Sym.getBinding());
+  if (Cmp >= 0)
+    cast<InputFile>(Section->getFile())->notify(Name, true);
   if (Cmp > 0)
----------------
Remove.

================
Comment at: test/ELF/trace-symbols.s:1
@@ +1,2 @@
+# Test -y symbol and -trace-symbol=symbol
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
----------------
Insert blank lines to separate this file in meaningful blocks. Wrap in 80 columns.


http://reviews.llvm.org/D21550





More information about the llvm-commits mailing list