Index: lib/Transforms/Scalar/GVN.cpp =================================================================== --- lib/Transforms/Scalar/GVN.cpp +++ lib/Transforms/Scalar/GVN.cpp @@ -1378,7 +1378,8 @@ // We can replace assume value with true, which covers cases like this: // call void @llvm.assume(i1 %cmp) // br i1 %cmp, label %bb1, label %bb2 ; will change %cmp to true - ReplaceWithConstMap[V] = True; + if (!isa(V)) + ReplaceWithConstMap[V] = True; // If one of *cmp *eq operand is const, adding it to map will cover this: // %cmp = fcmp oeq float 3.000000e+00, %0 ; const on lhs could happen Index: test/Transforms/GVN/no-crash-on-undef-assume.ll =================================================================== --- /dev/null +++ test/Transforms/GVN/no-crash-on-undef-assume.ll @@ -0,0 +1,8 @@ +; RUN: opt < %s -gvn -S + +define i1 @foo() { + call void @llvm.assume(i1 undef) + ret i1 undef +} + +declare void @llvm.assume(i1)