Skip to content

Commit 8db49b8

Browse files
committed
[Comgr] Fix disassem-instruction memory corruption
Previously for multi-feature ISAs, we were corrupting the first feature when processing the second feature: Expected: +sramecc,-xnack Actual: -xnackc,-xnack In this patch, we've fixed this via llvm::StringSaver
1 parent e1f2791 commit 8db49b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

amd/comgr/src/comgr-disassembly.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "llvm/ADT/StringExtras.h"
3838
#include "llvm/MC/TargetRegistry.h"
3939

40+
4041
using namespace llvm;
4142
using namespace COMGR;
4243

@@ -46,6 +47,10 @@ DisassemblyInfo::create(const TargetIdentifier &Ident,
4647
PrintInstructionCallback PrintInstruction,
4748
PrintAddressAnnotationCallback PrintAddressAnnotation,
4849
amd_comgr_disassembly_info_t *DisassemblyInfoT) {
50+
51+
llvm::BumpPtrAllocator Allocator;
52+
llvm::StringSaver Saver = Allocator;
53+
4954
std::string TT = (Twine(Ident.Arch) + "-" + Ident.Vendor + "-" + Ident.OS +
5055
"-" + Ident.Environ)
5156
.str();
@@ -54,7 +59,7 @@ DisassemblyInfo::create(const TargetIdentifier &Ident,
5459

5560
for (auto &Feature : Ident.Features) {
5661
FeaturesVec.push_back(
57-
Twine(Feature.take_back() + Feature.drop_back()).str());
62+
Saver.save(Twine(Feature.take_back() + Feature.drop_back()).str()));
5863
}
5964

6065
std::string Features = join(FeaturesVec, ",");

0 commit comments

Comments
 (0)