Skip to content

Instantly share code, notes, and snippets.

View bryant's full-sized avatar

bryant bryant

  • New York; Berlin
View GitHub Profile
@bryant
bryant / fast.cmake
Created January 18, 2018 18:35
Faster LLVM debug builds. Used primarily during dev.
cmake_minimum_required(VERSION 3.4)
execute_process(
COMMAND "grep" "^processor" "/proc/cpuinfo"
COMMAND "wc" "-l"
COMMAND "tr" "-d" "'\n'"
OUTPUT_VARIABLE ncpu
)
set(GIT_ORIGIN "file://$ENV{HOME}/usr/git" CACHE STRING "")
@bryant
bryant / quizzer.py
Created November 14, 2017 00:44
I needed to learn the phoenetic alphabet.
from random import choice
from string import lowercase
from datetime import datetime
answers = [
"alpha",
"bravo",
"charlie",
"delta",
"echo",
@bryant
bryant / -
Last active November 19, 2017 06:22 — forked from anonymous/-
GCC's linear-time DF calculation, pasted by Dan Berlin.
static void
compute_dominance_frontiers_1 (bitmap_head *frontiers)
{
edge p;
edge_iterator ei;
basic_block b;
FOR_EACH_BB_FN (b, cfun)
{
if (EDGE_COUNT (b->preds) >= 2)
@bryant
bryant / dse-catalog.md
Created March 31, 2017 03:02
Notes from writing the basic MemorySSA-backed global DSE https://reviews.llvm.org/D29624
  • stores with no dependency (post-order traversal reaches end of mssa):
    • store to alloca
      • dead on unwind, so elim even if
  • store post-dommed regular store
    • should must-alias or partial-alias the first store
  • store post-dommed by a free, lifetime_end
    • should must-alias or partial-alias the store
  • store immediately dominated by a free, lifetime_end
    • kill if must-alias
@bryant
bryant / memcpyopt-catalog
Created March 31, 2017 03:01
Notes for porting MemCpyOpt to MemorySSA
load-to-store of agg => memcpy/memmove (processStore)
call-load-to-store of non-agg => call-direct (processStore,
performCallSlotOptzn)
byte-wise store sequence => memset (processStore, tryMergingIntoMemset)
store to agg => memset (processStore)
memset => widen memset with neighboring stores/memset (processMemSet)
erase identity memcpy (processMemCpy)
memcpy from global constant => memset (processMemCpy)
memset-memcpy => memcpy-memset with disjoint dest ranges (processMemCpy,
processMemSetMemCpyDependence)
@bryant
bryant / cmakenotes.md
Last active March 31, 2017 03:06
Porting LLVMBuild to CMake.

current

  • all-targets: used by libs to depend on all possible targets. used in llvm-config to get a list of all target descs, infos, codegens, etc. during enumeration. the equivalent in cmakelists is:

    AllTargetsAsmPrinters
    AllTargetsAsmParsers
    

AllTargetsDescs

main spre entry point is Perform_SPRE_optimization. calls:

  • Propagate_downsafe
  • SPRE_compute_backward_attributes
    • which just forwards to Compute_forward_attributes.
  • SPRE_compute_insert_delete
  • SPRE_perform_insert_delete

[]( vim: set syntax=markdown textwidth=80 tabstop=2 shiftwidth=2: )

@bryant
bryant / github_identicon.py
Created October 26, 2016 00:21
generates a ppm of github identicon.
# what? i was bored.
class Identicon(object):
def __init__(self, bg, fg, border=35, block=71, count=5):
self.bg = bg
self.fg = fg
self.border = border
self.block = block
self.count = count
%struct.S = type { [65536 x i8] }
; Function Attrs: nounwind uwtable
define void @f(%struct.S* noalias nocapture sret, %struct.S* nocapture readonly, %struct.S* nocapture readonly) local_unnamed_addr #0 {
%4 = alloca %struct.S, align 1
%5 = getelementptr inbounds %struct.S, %struct.S* %4, i64 0, i32 0, i64 0
call void @llvm.lifetime.start(i64 65536, i8* %5) #2
%6 = getelementptr inbounds %struct.S, %struct.S* %1, i64 0, i32 0, i64 0
%7 = load i8, i8* %6, align 1
%8 = getelementptr inbounds %struct.S, %struct.S* %2, i64 0, i32 0, i64 0

Understanding LLVM's undef

- value domain is:
    n => {n} where n is a numeric value
    undef => {B} where B is all possible bit sequences
    use dom(x) to denote domain of x

- a `op` b = {m `op` n` | m <- dom(a), n <- dom(b)}