Skip to content

Instantly share code, notes, and snippets.

View rui314's full-sized avatar

Rui Ueyama rui314

  • Blue Whale Systems
  • Tokyo
View GitHub Profile
Before
415.548666 task-clock (msec) # 1.000 CPUs utilized ( +- 0.42% )
25 context-switches # 0.061 K/sec ( +- 4.42% )
1 cpu-migrations # 0.002 K/sec ( +- 28.86% )
60,001 page-faults # 0.144 M/sec
1,159,320,437 cycles # 2.790 GHz ( +- 0.42% )
713,987,937 stalled-cycles-frontend # 61.59% frontend cycles idle ( +- 0.68% )
<not supported> stalled-cycles-backend
1,151,611,502 instructions # 0.99 insns per cycle
# 0.62 stalled cycles per insn ( +- 0.02% )
diff --git a/ELF/OutputSections.cpp b/ELF/OutputSections.cpp
index c941993..cefdb46 100644
--- a/ELF/OutputSections.cpp
+++ b/ELF/OutputSections.cpp
@@ -844,8 +844,8 @@ static bool compCtors(const InputSection<ELFT> *A,
assert(Y.startswith(".ctors") || Y.startswith(".dtors"));
X = X.substr(6);
Y = Y.substr(6);
- if (X.empty() || Y.empty())
- return X.empty();
diff --git a/ELF/OutputSections.cpp b/ELF/OutputSections.cpp
index b885601..1a6fbc1 100644
--- a/ELF/OutputSections.cpp
+++ b/ELF/OutputSections.cpp
@@ -1385,18 +1385,22 @@ StringTableSection<ELFT>::StringTableSection(StringRef Name, bool Dynamic)
// we obtained in the former function can be written in the latter.
// This design eliminated that need.
template <class ELFT> void StringTableSection<ELFT>::reserve(StringRef S) {
- Reserved += S.size() + 1; // +1 for NUL
+ if (Seen.insert(S).second)
@rui314
rui314 / gist:6959261
Created October 13, 2013 07:42
A nqueen solver that works on my lisp implemenation (https://github.com/rui314/minilisp)
(defun list (expr . rest)
(cons expr rest))
(defun zero? (expr)
(= expr 0))
(defun nil? (expr)
(eq expr ()))
(defmacro let1 (var val . body)
@rui314
rui314 / gist:2014832
Created March 11, 2012 03:16
N queen
int print_board(int *board) {
for (int i = 0; i < 8; i = i + 1) {
for (int j = 0; j < 8; j =j +1) {
int *v = board + i * 8 + j;
if (*v) {
printf("Q ");
} else {
printf(". ");
}
}
diff --git a/src/util.cc b/src/util.cc
index 746d7ed..3a3c7df 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -190,6 +190,9 @@ bool CanonicalizePath(char* path, size_t* len, unsigned int* slash_bits,
bits_offset--;
bits = ShiftOverBit(bits_offset, bits);
#endif
+ } else if (*start == '/') {
+ src += 3;