Skip to content

Instantly share code, notes, and snippets.

View nickdesaulniers's full-sized avatar

Nick Desaulniers nickdesaulniers

View GitHub Profile
@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
@nickdesaulniers
nickdesaulniers / dml20_rq_dlg_get_dlg_reg.s
Created August 17, 2023 18:40
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.o dml20_rq_dlg_get_dlg_reg
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.o: file format elf32-i386
Disassembly of section .text:
<dml20_rq_dlg_get_dlg_reg>:
pushl %ebp
R_386_32 __stack_chk_guard
R_386_PC32 memset
R_386_PC32 print__data_rq_sizing_params_st
mm/vmalloc.c:1575:12: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
1575 | if (va && __this_cpu_cmpxchg(ne_fit_preload_node, NULL, va))
| ^
./include/linux/percpu-defs.h:475:2: note: expanded from macro '__this_cpu_cmpxchg'
475 | raw_cpu_cmpxchg(pcp, oval, nval); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:416:2: note: expanded from macro 'raw_cpu_cmpxchg'
416 | __pcpu_size_call_return2(raw_cpu_cmpxchg_, pcp, oval, nval)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:339:24: note: expanded from macro '__pcpu_size_call_return2'
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 05f202840186..2d0d2324cbde 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1654,11 +1654,6 @@ llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) {
QualType destType = D.getType();
- // Try to emit the initializer. Note that this can allow some things that
- // are not allowed by tryEmitPrivateForMemory alone.
wget https://lava.collabora.dev/scheduler/job/10417706/log_file/plain -O bad.txt
wget https://lava.collabora.dev/scheduler/job/10418012/log_file/plain -O good.txt
diff -u <(grep "calling " good.txt | tr -s ' ' | cut -d ' ' -f 11 | cut -d + -f 1) <(grep "calling " bad.txt | tr -s ' ' | cut -d ' ' -f 11 | cut -d + -f 1)
comm --nocheck-order --total <(grep "calling " good.txt | tr -s ' ' | cut -d ' ' -f 11 | cut -d + -f 1) <(grep "calling " bad.txt | tr -s ' ' | cut -d ' ' -f 11 | cut -d + -f 1)