[PATCH] D19171: [ELF] - Get rid of SectionOrder array.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 03:28:09 PDT 2016
grimar added inline comments.
================
Comment at: ELF/LinkerScript.cpp:93
@@ -92,1 +92,3 @@
+uint32_t LinkerScript::getSectionOrder(StringRef Name) {
+ auto Begin = Locations.begin();
----------------
ruiu wrote:
> The return value will never overflow in reality, so let's use just int instead of uint32_t. Then you can report the absent key as just -1 instead of UINT32_MAX.
Doing that will require changes that might overcomplicate the current
code of compareSections():
```
uint32_t I = getSectionOrder(A);
uint32_t J = getSectionOrder(B);
if (I == (uint32_t)-1 && J == (uint32_t)-1)
return 0;
return I < J ? -1 : 1;
```
For example if I has some order, but J does not then:
Since J is uint32_t (and == UINT32_MAX) then I < J will work as expected, placing A before B.
If we switch to int then I guess something like next should be written
(and it does not seem to worth that):
```
int I = getSectionOrder(A);
int J = getSectionOrder(B);
if (I == -1 && J == -1)
return 0;
if (I == -1)
return 1;
if (J == -1)
return -1;
return I < J ? -1 : 1;
```
So I committed without that change for now.
Repository:
rL LLVM
http://reviews.llvm.org/D19171
More information about the llvm-commits
mailing list