Index: lib/CodeGen/GlobalMerge.cpp =================================================================== --- lib/CodeGen/GlobalMerge.cpp +++ lib/CodeGen/GlobalMerge.cpp @@ -280,6 +280,8 @@ // users, so look through ConstantExpr... Use *UI, *UE; if (ConstantExpr *CE = dyn_cast(U.getUser())) { + if (CE->use_empty()) + continue; UI = &*CE->use_begin(); UE = nullptr; } else if (isa(U.getUser())) {