Skip to content

Instantly share code, notes, and snippets.

View nickdesaulniers's full-sized avatar

Nick Desaulniers nickdesaulniers

View GitHub Profile
@nickdesaulniers
nickdesaulniers / get_builtins.sh
Created December 5, 2024 21:22
list of symbols for compiler builtins
$ llvm-nm compiler-rt/lib/linux/libclang_rt.builtins-x86_64.a | grep T | cut -d ' ' -f 3
__absvdi2
__absvsi2
__absvti2
__adddf3
__addsf3
__addvdi3
__addvsi3
__addvti3
__ashldi3
@nickdesaulniers
nickdesaulniers / foo.gdb
Created November 19, 2024 22:34
scudo backtrace
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x0000fffff7ba0a60 in __GI_abort () at abort.c:79
#2 0x000000000040a8c8 in scudo::die ()
at /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp:48
#3 0x000000000040b248 in scudo::reportRawError (
Message=0xffffffffed78 "Scudo ERROR: internal map failure (error desc=Success)\n")
at /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/compiler-rt/lib/scudo/standalone/report.cpp:58
#4 0x000000000040b9a4 in scudo::reportMapError (SizeIfOOM=0)
at /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/compiler-rt/lib/scudo/standalone/report_linux.cpp:33
commit b0fb5270bc85dd049ddb5f4308e04136256d6783
Author: Nick Desaulniers <[email protected]>
Date: Thu Oct 3 08:18:10 2024 -0700
WIP fpbits
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 5d1f633bb56e..69307653a8e8 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index b634969cbb6f..da4c91793cdc 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -450,14 +450,18 @@ static inline pid_t clone3_vfork(void)
_metadata->exit_code = KSFT_FAIL; \
} \
} \
+ _Bool expected = false; \
+ _Bool desired = true; \
@nickdesaulniers
nickdesaulniers / all_targets.c
Last active April 10, 2024 20:02
A test file I was using while trying to fix https://github.com/llvm/llvm-project/issues/20571. It tries to forcibly cause register exhaustion by using inline asm which clobbers all GPRs. In these cases, "rm" contrained operands should fall back to "m" rather than fail to compile.
// -Wno-asm-operand-widths
// void input_pressure(int x) {
// // asm ("# %0"::"m"(x):"r0","r1","r2","r3","r12","lr","r4","r5","r6","r7","r8","r9","r10","r11");
// asm (""::"m"(x));
// }
struct foo {
long a, b, c, d, e;
};
int zzz (struct foo my_foo) {
bloaty -n 0 -s file after.a -- before.a
FILE SIZE VM SIZE
-------------- --------------
+234% +2.05Ki +212% +816 .rodata.cst16
+1.8% +1.48Ki [ = ] 0 .symtab
+0.8% +920 [ = ] 0 .strtab
+31% +864 +33% +870 .text._ZN22__llvm_libc_18_0_0_git8internal27hexadecimal_string_to_floatIeEENS_14StrToNumResultINS0_13ExpandedFloatIT_EEEEPKccNS0_14RoundDirectionE
+39% +736 +44% +760 .text._ZN22__llvm_libc_18_0_0_git8internal20decimal_exp_to_floatIeEENS0_18FloatConvertReturnIT_EENS0_13ExpandedFloatIS3_EEPKcbNS0_14RoundDirectionE
[NEW] +480 [NEW] +411 .text._ZN22__llvm_libc_18_0_0_gitL31construct_thread_name_file_pathERNS_3cpp12StringStreamEi
[NEW] +288 [NEW] +223 .text._ZN22__llvm_libc_18_0_0_git11printf_core11FloatWriter18write_middle_blockEj
struct foo {
long long x;
};
struct foo foo_factory (void);
struct foo div (struct foo, struct foo);
long long bar (void) {
return div(div(foo_factory(), foo_factory()), div(foo_factory(), foo_factory())).x;
}
@nickdesaulniers
nickdesaulniers / ast.txt
Created September 14, 2023 20:47
clang++ foo.cpp -I eigen -fsanitize=address,null -std=c++17 -O3 -march=haswell -Xclang -ast-dump -Xclang -ast-dump-filter=round
Dumping round:
FunctionDecl 0x556c3378c900 <foo.cpp:5:1, line:7:1> line:5:6 used round 'std::conditional_t<internal::is_same<float, CoeffReturnType>::value, TensorConversionOp<int, const TensorCwiseUnaryOp<bind2nd_op<scalar_sum_op<float, float>>, const TensorFixedSize<float, Sizes<2, 2>, 1, long>>>, TensorConversionOp<float, const TensorConversionOp<int, const TensorCwiseUnaryOp<bind2nd_op<scalar_sum_op<float, float>>, const TensorFixedSize<float, Sizes<2, 2>, 1, long>>>>> (Tensor)'
|-ParmVarDecl 0x556c3378c800 <col:13, col:20> col:20 used m 'Tensor':'Eigen::TensorFixedSize<float, Eigen::Sizes<2, 2>, 1>'
`-CompoundStmt 0x556c33910100 <col:23, line:7:1>
`-ReturnStmt 0x556c339100f0 <line:6:5, col:47>
`-ExprWithCleanups 0x556c339100d8 <col:12, col:47> 'std::conditional_t<internal::is_same<float, CoeffReturnType>::value, TensorConversionOp<int, const TensorCwiseUnaryOp<bind2nd_op<scalar_sum_op<float, float>>, const TensorFixedSize<float, Sizes<2, 2>, 1, long>>>, TensorConversionOp<float, const TensorConvers
struct foo {
int x;
};
// Returns a reference to the minimum foo.
foo &&min(foo &&a, foo &&b);
void consume (foo&&);
void bar () {
@nickdesaulniers
nickdesaulniers / links.txt
Last active August 24, 2023 17:57
generating pgp keys for kernel development