Author: regehr

  • Testing LLVM

    [This piece is loosely a followup to this one.] Background Once a piece of software reaches a certain size, it is guaranteed to be loosely specified and not completely understood by any individual. It gets committed to many times per day by people who are only loosely aware of each others’ work. It has many…

  • A Tourist’s Guide to the LLVM Source Code

    In my Advanced Compilers course last fall we spent some time poking around in the LLVM source tree. A million lines of C++ is pretty daunting but I found this to be an interesting exercise and at least some of the students agreed, so I thought I’d try to write up something similar. We’ll be…

  • Undefined Behavior: Not Just for Programming Languages

    This is an oldie but goodie. Start with this premise: a = b Multiply both sides by a: a2 = ab Subtract b2 from both sides: a2 – b2 = ab – b2 Factor the left side: (a + b)(a – b) = ab – b2 Factor the right side: (a + b)(a – b)…

  • Principles for Undefined Behavior in Programming Language Design

    I’ve had a post with this title on the back burner for years but I was never quite convinced that it would say anything I haven’t said before. Last night I watched Chandler Carruth’s talk about undefined behavior at CppCon 2016 and it is good material and he says it better than I think I…

  • Vigorous Public Debates in Academic Computer Science

    The other day a non-CS friend remarked to me that since computer science is a quantitative, technical discipline, most issues probably have an obvious objective truth. Of course this is not at all the case, and it is not uncommon to find major disagreements even when all parties are apparently reasonable and acting in good…

  • Advanced Compilers Weeks 3-5

    This continues a previous post. We went through the lattice theory and introduction to dataflow analysis parts of SPA. I consider this extremely good and important material, but I’m afraid that the students looked pretty bored. It may be the case that this material is best approached by first looking at practical aspects and only…

  • Advanced Compilers Weeks 1 and 2

    This post will be of somewhat narrow interest; it’s a quick attempt to take my lecture notes for the first weeks of an advanced compilers course and turn them into something a bit more readable. I’m not using slides for this class. Motivation The great thing about an advanced course (on any topic) is that…

  • Solutions to Integer Overflow

    Humans are typically not very good at reasoning about integers with limited range, whereas computers fundamentally work with limited-range numbers. This impedance mismatch has been the source of a lot of bugs over the last 50 years. The solution comes in multiple parts. In most programming languages, the default integer type should be a bignum:…

  • Compilation and Hyperthreading

    Hyperthreading (HT) may or may not be a performance win, depending on the workload. I had poor luck with HT in the Pentium 4 era and ever since then have just disabled it in the BIOS on the idea that the kind of software that I typically wait around for—compilers and SMT solvers—is going to…

  • Isolating a Free-Range Miscompilation

    If we say that a compiler is buggy, we need to be able to back up that claim with reproducible, compelling, and understandable evidence. Usually, this evidence centers on a test case that triggers the buggy behavior; we’ll say something like “given this test case, compiler A produces an executable that prints 0 whereas compiler…