Otherwise looks fine. ================ Comment at: lib/Analysis/ConstantFolding.cpp:1000 @@ -991,1 +999,3 @@ + } + } ---------------- Isn't this missing some sort of address-space check? You're building a bitcast between two pointer types. http://llvm-reviews.chandlerc.com/D1199