Skip to content

Instantly share code, notes, and snippets.

View kwk's full-sized avatar

Konrad Kleine kwk

View GitHub Profile
@kwk
kwk / foo.diff
Created August 29, 2023 15:09
Test diff
--- a/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
@@ -2,6 +2,7 @@
; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj -S --mattr=+atomics,+bulk-memory | FileCheck %s -DPTR=i32
; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj --mtriple=wasm64-unknown-unknown -data-layout="e-m:e-p:64:64-i64:64-n32:64-S128" -S | FileCheck %s -DPTR=i64
+
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
@kwk
kwk / httpserver.py
Last active August 15, 2023 08:44
HTTP Server in separate thread in Python
# -*- coding: utf-8 -*-
"""
The httpserver module contains an easy and ready-to-use HTTP file server.
o ServeDirectoryWithHTTP: Spawns an HTTP file server in a separate thread.
"""
import http.server
from threading import Thread, current_thread
from sys import stderr
@kwk
kwk / Containerfile
Last active July 21, 2023 12:57
Runnning the llvm-test-suite with PGO optimized and plain LLVM in Fedora Rawhide
FROM fedora:rawhide
LABEL description="Test compilers with llvm-test-suite"
USER root
WORKDIR /root
# Install deps to run test-suite
RUN dnf install -y \
cmake \
fedora-packager \
5 ./clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-bind.cpp:boost::bind
4 ./clang/unittests/Format/UsingDeclarationsSorterTest.cpp:boost::regex;\n"
4 ./clang/unittests/Format/UsingDeclarationsSorterTest.cpp:boost::regex_constants::icase;\n"
4 ./clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-union-access.cpp:boost::)variant
3 ./libcxxabi/test/test_demangle.pass.cpp:boost::arg<2>,
3 ./libcxxabi/test/test_demangle.pass.cpp:boost::arg<1>,
3 ./clang-tools-extra/test/clang-tidy/checkers/modernize/use-nodiscard.cpp:boost::function<bool()>
3 ./clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-bind.cpp:boost::bind(add,
3 ./clang-tools-extra/test/clang-tidy/checkers/boost/use-to-string.cpp:boost::lexical_cast<T>(42);
3 ./clang/include/clang/Format/Format.h:boost::regex_constants::icase;
@kwk
kwk / .gitconfig
Last active June 4, 2023 14:31
Aliases to quickly find git commits made in quarter of a year
[alias]
# List your commits by quarters of a year in reverse order (short version)
q1 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"January $year\" --until \"March $year\" --oneline --reverse $@; }; f"
q2 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"April $year\" --until \"June $year\" --oneline --reverse $@; }; f"
q3 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"July $year\" --until \"September $year\" --oneline --reverse $@; }; f"
q4 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"October $year\" --until \"December $year\" --oneline --reverse $@; }; f"
# List your commits by quarters of a year in reverse order (long version)
quarter1 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"January $year\" --until \"March $year\" --reverse $@; }; f"
quarter2 = "!f() { year=$1; shift; git
@kwk
kwk / README.md
Created May 25, 2023 14:45
Release: -tags in LLVM spec files for Fedora Rawhide over the last 13 years

I wanted to know how many times we've changes a Release: tag in any of the package spec files under the LLVM umbrella over the course of the last 13 years.

Here's the script I ran:

projects="clang llvm lldb lld python-lit mlir libomp"

(for y in {2023..2010}; do 
     for p in $projects; do
 rows=$(git -C ~/dev/llvm-rpms/$p-fedora \
@kwk
kwk / command.sh
Created May 22, 2023 15:19
Get list of builder admins for buildbot
curl -sL https://lab.llvm.org/buildbot/api/v2/workers > workers.json
curl -sL https://lab.llvm.org/buildbot/api/v2/builders > builders.json
cat builders.json | jq '.builders[] | {(.builderid|tostring): .name}' | jq '{"builders": (reduce inputs as $in (.; . + $in))}' > builders_lut.json
jq -s '.[0] * .[1]' builders_lut.json workers.json > joined.json
cat joined.json | jq '.builders as $builders | .workers[] | {"workername": .name, "admin": (""+.workerinfo.admin|tostring), "builders": $builders[.configured_on[].builderid | tostring]}' | jq -s > temp.json
cat temp.json | jq 'group_by(.admin)[] | {"admin": ("" + .[0].admin), "builders": [.[] | .builders] | sort | unique}' | jq -s
@kwk
kwk / main.cpp
Created May 4, 2023 21:15
getNumDisplayWidth
#include <cstdio>
#include <cmath>
#include <array>
static unsigned getNumDisplayWidth(unsigned N) {
if (N < 10)
return 1;
if (N < 100)
return 2;
if (N < 1000)
@kwk
kwk / mermaid.md
Created April 28, 2023 12:14
Embed image in marmaid sequence diagram
sequenceDiagram
autonumber

actor alice as Alice

box Github.com
participant gh as Github.com Website
participant ghapi as Github.com API
end
@kwk
kwk / CMakeLists.txt
Last active April 20, 2023 19:03
Dynamic macro overriding
cmake_minimum_required(VERSION 3.13.4)
project(myapp)
add_executable(myapp myapp.cpp)
target_link_libraries(myapp)
install(TARGETS myapp RUNTIME DESTINATION bin)