forked from OSchip/llvm-project
[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
This commit is contained in:
parent
000f77d728
commit
38707c45be
|
@ -595,14 +595,16 @@ int main(int argc, char **argv) {
|
||||||
SmallVector<char, 0> Buffer;
|
SmallVector<char, 0> Buffer;
|
||||||
SmallVector<char, 0> CompileTwiceBuffer;
|
SmallVector<char, 0> CompileTwiceBuffer;
|
||||||
std::unique_ptr<raw_svector_ostream> BOS;
|
std::unique_ptr<raw_svector_ostream> BOS;
|
||||||
raw_ostream *OS = &Out->os();
|
raw_ostream *OS = nullptr;
|
||||||
if (RunTwice) {
|
|
||||||
BOS = make_unique<raw_svector_ostream>(Buffer);
|
|
||||||
OS = BOS.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write bitcode or assembly to the output as the last step...
|
// Write bitcode or assembly to the output as the last step...
|
||||||
if (!NoOutput && !AnalyzeOnly) {
|
if (!NoOutput && !AnalyzeOnly) {
|
||||||
|
assert(Out);
|
||||||
|
OS = &Out->os();
|
||||||
|
if (RunTwice) {
|
||||||
|
BOS = make_unique<raw_svector_ostream>(Buffer);
|
||||||
|
OS = BOS.get();
|
||||||
|
}
|
||||||
if (OutputAssembly)
|
if (OutputAssembly)
|
||||||
Passes.add(createPrintModulePass(*OS, "", PreserveAssemblyUseListOrder));
|
Passes.add(createPrintModulePass(*OS, "", PreserveAssemblyUseListOrder));
|
||||||
else
|
else
|
||||||
|
@ -618,6 +620,7 @@ int main(int argc, char **argv) {
|
||||||
// If requested, run all passes again with the same pass manager to catch
|
// If requested, run all passes again with the same pass manager to catch
|
||||||
// bugs caused by persistent state in the passes
|
// bugs caused by persistent state in the passes
|
||||||
if (RunTwice) {
|
if (RunTwice) {
|
||||||
|
assert(Out);
|
||||||
CompileTwiceBuffer = Buffer;
|
CompileTwiceBuffer = Buffer;
|
||||||
Buffer.clear();
|
Buffer.clear();
|
||||||
std::unique_ptr<Module> M2(CloneModule(M.get()));
|
std::unique_ptr<Module> M2(CloneModule(M.get()));
|
||||||
|
|
Loading…
Reference in New Issue