[PATCH] lld] handle the case of errors from createLinkerInput

Rui Ueyama ruiu at google.com
Mon Sep 2 20:09:12 PDT 2013



================
Comment at: lib/Driver/GnuLdDriver.cpp:96
@@ +95,3 @@
+      return (Twine("Unable to find library -l") + _path).str();
+    return (Twine("Unable to find file ") + _path).str();
+  }
----------------
Shankar Kalpathi Easwaran wrote:
> Rui Ueyama wrote:
> > Use-after-return?
> I was avoiding calling the allocation routine here since the string is going to get immediately printed out, the string should still be available in the stack. It might be unsafe to make an assumption like that, will use allocateString
Yes please. You might want to return std::string (in combination with std::move) to return as value.

================
Comment at: include/lld/Driver/GnuLDInputGraph.h:77
@@ -72,2 +76,3 @@
   bool _asNeeded : 1;
+  bool _isDashlPrefix : 1;
   std::vector<StringRef> _libraryPaths;
----------------
Shankar Kalpathi Easwaran wrote:
> Rui Ueyama wrote:
> > Why did you make them bitfields? I think we don't usually make boolean fields bitfields only because they need only 1 bit.
> bool is an alias for a char, which takes a byte instead of a bit.
> 
> Below is an example :-
> 
> #include <stdio.h>
> 
> struct x {
> bool a:1;
> bool b:1;
> bool c:1;
> };
> 
> struct y {
>   bool a;
>   bool b;
>   bool c;
> };
> 
> int main() {
>   printf("%ld\n",sizeof(struct x));
>   printf("%ld\n",sizeof(struct y));
> }
> 
> Prints :
> 1
> 3
> 
As far as I know in LLVM and in general we don't use bitfield unless

 - it's mapped to some concrete data structure that already exists in memory or file, nor
 - the number of instance is really large and need to save memory.

Otherwise bitfield is not necessary. It will actually slows down the execution of code because the compiler need to emit load, mask, and shift operations to get a boolean bitfield value, instead of one load instruction.


http://llvm-reviews.chandlerc.com/D1571



More information about the llvm-commits mailing list