diff --git a/llvm/test/Other/bcanalyzer-dump-option.txt b/llvm/test/Other/bcanalyzer-dump-option.txt
new file mode 100644
index 000000000000..1da2a033b6a2
--- /dev/null
+++ b/llvm/test/Other/bcanalyzer-dump-option.txt
@@ -0,0 +1,11 @@
+RUN: llvm-bcanalyzer -dump %S/Inputs/has-block-info.bc | FileCheck -check-prefix=WITH-DUMP %s
+RUN: llvm-bcanalyzer %S/Inputs/has-block-info.bc | FileCheck -check-prefix=WITHOUT-DUMP %s
+
+WITH-DUMP:
+WITHOUT-DUMP-NOT:
+WITH-DUMP:
+WITHOUT-DUMP-NOT:
diff --git a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index 01cba1f6e3c9..639a6d1ec02c 100644
--- a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -102,8 +102,9 @@ int main(int argc, char **argv) {
O.Symbolic = !NonSymbolic;
O.ShowBinaryBlobs = ShowBinaryBlobs;
- ExitOnErr(
- BA.analyze(O, CheckHash.empty() ? None : Optional(CheckHash)));
+ ExitOnErr(BA.analyze(
+ Dump ? Optional(O) : Optional(None),
+ CheckHash.empty() ? None : Optional(CheckHash)));
if (Dump)
outs() << "\n\n";