summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt
diff options
context:
space:
mode:
authorKeno Fischer <kfischer@college.harvard.edu>2015-12-05 00:06:37 +0000
committerKeno Fischer <kfischer@college.harvard.edu>2015-12-05 00:06:37 +0000
commit38707c45be6ea1c6f3d382efbee960151d7301c8 (patch)
tree44a93218b3a3167cdceb8de63b6a6d6715ab2dcf /llvm/tools/opt
parent000f77d72815e45c40c5382717f8a7ab8bbf2d94 (diff)
downloadbcm5719-llvm-38707c45be6ea1c6f3d382efbee960151d7301c8.tar.gz
bcm5719-llvm-38707c45be6ea1c6f3d382efbee960151d7301c8.zip
[opt] Fix sanitizer complaints about r254774
`Out` can be null if no output is requested, so move any access to it inside the conditional. Thanks to Justin Bogner for finding this. llvm-svn: 254804
Diffstat (limited to 'llvm/tools/opt')
-rw-r--r--llvm/tools/opt/opt.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index c1510a7fb25..fc31beb4815 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -595,14 +595,16 @@ int main(int argc, char **argv) {
SmallVector<char, 0> Buffer;
SmallVector<char, 0> CompileTwiceBuffer;
std::unique_ptr<raw_svector_ostream> BOS;
- raw_ostream *OS = &Out->os();
- if (RunTwice) {
- BOS = make_unique<raw_svector_ostream>(Buffer);
- OS = BOS.get();
- }
+ raw_ostream *OS = nullptr;
// Write bitcode or assembly to the output as the last step...
if (!NoOutput && !AnalyzeOnly) {
+ assert(Out);
+ OS = &Out->os();
+ if (RunTwice) {
+ BOS = make_unique<raw_svector_ostream>(Buffer);
+ OS = BOS.get();
+ }
if (OutputAssembly)
Passes.add(createPrintModulePass(*OS, "", PreserveAssemblyUseListOrder));
else
@@ -618,6 +620,7 @@ int main(int argc, char **argv) {
// If requested, run all passes again with the same pass manager to catch
// bugs caused by persistent state in the passes
if (RunTwice) {
+ assert(Out);
CompileTwiceBuffer = Buffer;
Buffer.clear();
std::unique_ptr<Module> M2(CloneModule(M.get()));
OpenPOWER on IntegriCloud