<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70290>70290</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Code dump when --save-temps in O3 and use DiagnosticInfo to output diag msg
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hstk30-hw
</td>
</tr>
</table>
<pre>
I use `DiagnosticInfoMisExpect` to output some info, but in `-O3 --save-temps` it code dump.
```
Stack dump: 0. Program arguments: ./clang-15 -cc1 -triple aarch64-target-linux-gnu -emit-llvm -save-temps=cw
d -disable-free -clear-ast-before-backend -main-file-name test.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +neon -target-feature +v8a -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-
fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=./testcases/malloc_dirty -resource-dir ./lib64/clang/15.0.4 -O3 -fdebug-compilation-dir=./testcases/malloc_dirty -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -target-feature +outline-atomics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o test.ll -x ir test.tmp.bc
1. Optimizer
#0 0x0000560f1f61137a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/llvm/lib/Support/Unix/Signals.inc:569:0
#1 0x0000560f1f611431 PrintStackTraceSignalHandler(void*)
/llvm/lib/Support/Unix/Signals.inc:636:0
#2 0x0000560f1f60f0c4 llvm::sys::RunSignalHandlers()
/llvm/lib/Support/Signals.cpp:103:0
#3 0x0000560f1f610ce7 SignalHandler(int)
/llvm/lib/Support/Unix/Signals.inc:407:0
#4 0x00007f3cf3f59980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#5 0x0000560f1fc50ee0 clang::ASTContext::getSourceManager()
/clang/include/clang/AST/ASTContext.h:725:0
#6 0x0000560f2103b718 clang::BackendConsumer::getBestLocationFromDebugLoc(llvm::DiagnosticInfoWithLocationBase const&, bool&, llvm::StringRef&, unsigned int&, unsigned int&) const
/clang/lib/CodeGen/CodeGenAction.cpp:638:0
#7 0x0000560f2103c6f6 clang::BackendConsumer::MisExpectDiagHandler(llvm::DiagnosticInfoMisExpect const&)
/clang/lib/CodeGen/CodeGenAction.cpp:845:0
#8 0x0000560f2103cd6a clang::BackendConsumer::DiagnosticHandlerImpl(llvm::DiagnosticInfo const&)
/clang/lib/CodeGen/CodeGenAction.cpp:953:0
#9 0x0000560f2103ac6b clang::ClangDiagnosticHandler::handleDiagnostics(llvm::DiagnosticInfo const&)
/clang/lib/CodeGen/CodeGenAction.cpp:465:0
#10 0x0000560f1ebe4589 llvm::LLVMContext::diagnose(llvm::DiagnosticInfo const&)
/llvm/lib/IR/LLVMContext.cpp:265:0
#11 0x0000560f1f2c9198 checkLoadMallocDirty(llvm::Instruction*)
/llvm/lib/Transforms/Scalar/GVN.cpp:2686:0
#12 0x0000560f1f2c9486 llvm::GVNPass::processBlock(llvm::BasicBlock*)
/llvm/lib/Transforms/Scalar/GVN.cpp:2733:0
#13 0x0000560f1f2ca9be llvm::GVNPass::iterateOnFunction(llvm::Function&)
/llvm/lib/Transforms/Scalar/GVN.cpp:3058:0
#14 0x0000560f1f2c8e30 llvm::GVNPass::runImpl(llvm::Function&, llvm::AssumptionCache&, llvm::DominatorTree&, llvm::TargetLibraryInfo const&, llvm::AAResults&, llvm::MemoryDependenceRe
sults*, llvm::LoopInfo*, llvm::OptimizationRemarkEmitter*, llvm::MemorySSA*)
/llvm/lib/Transforms/Scalar/GVN.cpp:262
1:0
#15 0x0000560f1f2c07c7 llvm::GVNPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
/llvm/lib/Transfo
rms/Scalar/GVN.cpp:737:0
#16 0x0000560f211afbc7 llvm::detail::PassModel<llvm::Function, llvm::GVNPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManag
er<llvm::Function>&)
/llvm/include/llvm/IR/PassManagerInternal.h:89:0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0mN9v46gWx_8a-oKIMP4R-yEPaTKZrdTujNre2ccI42OHWwwW4P7Yv_4K223itDM7O6NbVZENGD7new6cY3PnZKMBVii9ROn2gvf-YOzq4PxDTMnh6aI01cvqCvcOMEYZ3UreaOO8FFe6NjfSfXruQHiUUewNNr3veo-daQFLXRvENrjsPZY6PEu-xJgQxx-BeGg7Fx6SHgtTAa76tlsgukV0Pf1mdPofbu88Fw_DKBSvMV3g4e-rNY3lLea26VvQ3oXOBWI7obhuSJRiIkSEibeyU4A5t-KQJcRz24AnSur-mTS6xwRa6YlSjy0-5Yu34mlcvsKkko6XCkhtATARCrgl3HlSQm0skJKLB9AVJi2XmtRSAdG8BezB-YXApLWgjOBeGk1aU4HCnRSYdFIQBY-gMBtvpCOdBEza2vIWSGek9mBRvNVGEwW8xqRuuT8QsFYbTOq6I8Job7nwKN4ajUmtDbGm15XUDQljMWmF0c7bXnhjCVeSO3CY1L1-kroiPhgWzGX4VRvR9bgBDTZATm01cN9bwIhdaggLvW9_zPlbMy8l5rwTYSGulHkiB65q8uYrwnVFLPjeaodJO6rvLXBPnOBqEHtUv5bPUAWDA7wjT9xqqRtMKij7pgFLfB8aULxtqhKTWphHsLwBIkzbSTWKXsmgYgiO4BIRFEBs1wYysa-k9S-YWHCmtwLC4CGOlCyz5DWeENtF6YIuEjxEcj0s_6_XqEc7lGylx1ExumvYhBURB24xqRvdC_II1kmjUbxNFmwRDWYpY0n1tgMdJo8QPCr_BqKM6WYNTnUfecj0XkkNhHvTytE3VWWdbDDZ7vefN5v9H-tvn_bbv9a3O7bf7K7267sbFG8jTMwYz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