<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63778>63778</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
when running opt, llvm-symbolizer's cpu is 100%, then opt crash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zzyongx
</td>
</tr>
</table>
<pre>
I modified LoopDataPrefetch.cpp as follows:
> for (auto &P : Prefetches) {
// Check if the stride of the accesses is large enough to warrant a
// prefetch.
if (!isStrideLargeEnough(P.LSCEVAddRec, TargetMinStride))
continue;
const llvm::DebugLoc &debugInfo = P.InsertPt->getDebugLoc();
LLVM_DEBUG(dbgs() << " LDP InsertPt: "
<< debugInfo->getFilename()
<< " " << debugInfo->getLine() << "\n");
then compile the follow code:
clang test.c -g -Wall -S -emit-llvm -O3
opt -debug -stats -passes='loop-data-prefetch' --prefetch-distance=64 --cache-line-size=64 --max-prefetch-iters-ahead=64 test.ll -o test.bc
```#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BN (2 * 64)
#define N (200 * 1024 * 1024 / sizeof(int))
int a[N];
int main(int argc, char *argv[])
{
memset(a, argc, sizeof(a));
long sum = 0;
int i;
long k;
for (k = 0; k < 1000; k++) {
for(i=0; i<N; i += BN) {
int j;
int m;
for(j=i; j <= i+4 && j < N; j++) {
for (m = 0; m < 5; m++) sum += a[j] * i;
}
}
}
printf("%ld\n", sum);
}
```
the opt output
LDP InsertPt: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
the llvm-symbolizer cpu usage was 100%.
the backtrace is(use gstack):
`
#0 0x00000000005e7d23 in llvm::DWARFFormValue::DWARFFormValue (this=0x7fff2280f4e0, F=llvm::dwarf::DW_FORM_ref4) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h:69
#1 0x000000000065ecc6 in llvm::DWARFAbbreviationDeclaration::getAttributeValueFromOffset (this=0x303bcde0, AttrIndex=3, Offset=236593725, U=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp:179
#2 0x000000000065ee0f in llvm::DWARFAbbreviationDeclaration::getAttributeValue (this=0x303bcde0, DIEOffset=236593717, Attr=llvm::dwarf::DW_AT_type, U=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp:198
#3 0x000000000060165d in llvm::DWARFDie::find (this=0x7fff2280f880, Attr=llvm::dwarf::DW_AT_type) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp:257
#4 0x0000000000601a81 in llvm::DWARFDie::getAttributeValueAsReferencedDie (this=0x7fff2280f880, Attr=llvm::dwarf::DW_AT_type) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp:310
#5 0x000000000060314e in llvm::DWARFDie::getTypeSize (this=0x7fff2280f880, PointerSize=8) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp:548
#6 0x00000000006217e2 in llvm::DWARFUnit::updateVariableDieMap (this=0x2113280, Die=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp:822
#7 0x0000000000621323 in llvm::DWARFUnit::updateVariableDieMap (this=0x2113280, Die=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp:759
#8 0x0000000000621323 in llvm::DWARFUnit::updateVariableDieMap (this=0x2113280, Die=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp:759
#9 0x0000000000621323 in llvm::DWARFUnit::updateVariableDieMap (this=0x2113280, Die=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp:759
#10 0x0000000000621941 in llvm::DWARFUnit::getVariableForAddress (this=0x2113280, Address=28291989) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp:836
#11 0x00000000005949eb in llvm::DWARFContext::getCompileUnitForAddress (this=0x20e65e0, Address=28291989) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1070
#12 0x0000000000595ebb in llvm::DWARFContext::getInliningInfoForAddress (this=0x20e65e0, Address=..., Spec=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1337
#13 0x0000000000574a54 in llvm::symbolize::SymbolizableObjectFile::symbolizeInlinedCode (this=0x20e67f0, ModuleOffset=..., LineInfoSpecifier=..., UseSymbolTable=true) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp:300
#14 0x000000000055e985 in llvm::symbolize::LLVMSymbolizer::symbolizeInlinedCodeCommon<std::string> (this=0x7fff22811600, ModuleSpecifier="./bin/opt", ModuleOffset=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp:118
#15 0x0000000000556686 in llvm::symbolize::LLVMSymbolizer::symbolizeInlinedCode (this=0x7fff22811600, ModuleName="./bin/opt", ModuleOffset=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp:139
#16 0x0000000000415fa1 in executeCommand<std::string> (ModuleName=..., ModuleSpec="./bin/opt", Cmd=Code, Offset=28291989, AdjustVMA=0, ShouldInline=true, Style=LLVM, Symbolizer=..., Printer=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp:224
#17 0x000000000040d9dd in symbolizeInput (Args=..., IncomingBuildID=..., AdjustVMA=0, IsAddr2Line=false, Style=LLVM, InputString=..., Symbolizer=..., Printer=...) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp:273
#18 0x000000000040ef68 in main (argc=4, argv=0x7fff22811e48) at /home/sre/data/llvm-project-llvmorg-15.0.2/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp:490
`
clang version: 15.0.2
opt version: 15.0.2
but, when replace `for (m = 0; m < 5; m++) sum += a[j] * i;` with `sum += a[j] * i;`, there is no crash.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWd1u2zoSfhrmhrAhkfq9yIVjxYsAThs0bc9lQUkjmalEGiTVJH36BSnJshUn53S3p9s9gWPzZ0jO93FmSI2Y1rwWAJcovEJhdsE6s5Pq8vv3Zynqp4tcls-XN7iVJa84lHgr5T5jht0pqMAUu2Wx32OmcSWbRj5qRFfIy5A3ftNrXEmFEUlYZyRGJLrDiK7wOBw0IilG8VUvjzHGiGwQ2eD1DoqvmFfY7ABro3gJWPY1VhSgNWjMNW6YqgGDkF29w0biR6YUEwazFxPuR42nHl5ZzRDxub53K2ztbNduMkSSu-X2fn39eVWWH6BAZI0_2m5zy0UvjUhqP4fpMC6kMFx0gOgIqJBCG9w031pLDV1lkHf1VhaWitKWb0QlMaIZvlveCA3K3JkFotc1mFHUqZhOU263n2-_ZNdXn_6FSFLmte4FMKJrRNcYEYLxNrvD43SWb0TIsZ6Hv2HMQZNh6Q1vQLAWhqXfGGlXc__nJ9pyAS_UQ-Fa2J8jUP232YHAhWz3vAG3071V4UKWMLOsomGixga0WRZ4UePFH6xp8OIeL6DlZmEJx4v3tBeWe4MXTjW80IYZjRd7Zi0I0QyRuJFyvyiZYYvRRhCJ8eJQW5RcGyYKQDSLArxYFKzYwaLhAhaafz80t-xpGsMNKL1gO2Bl3-90tTrKvpgXJ54SecOHUC6KpivBMqZNyeVy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