Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions llvm/test/tools/llvm-dis/multiple-files-equivalent.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; RUN: llvm-as -o %t0 %s
; RUN: cp %t0 %t1
; RUN: llvm-dis %t0 %t1
; RUN: FileCheck %s < %t0.ll
; RUN: FileCheck %s < %t1.ll

; Test that if we disassemble the same bitcode twice, the type names are
; unchanged between the two. This protects against a bug whereby state was
; preserved across inputs and the types ended up with different names.

; CHECK: %Foo = type { ptr }
%Foo = type { ptr }

; CHECK: @foo = global %Foo zeroinitializer
@foo = global %Foo zeroinitializer
10 changes: 6 additions & 4 deletions llvm/tools/llvm-dis/llvm-dis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ int main(int argc, char **argv) {
if (LoadBitcodeIntoNewDbgInfoFormat == cl::boolOrDefault::BOU_UNSET)
LoadBitcodeIntoNewDbgInfoFormat = cl::boolOrDefault::BOU_TRUE;

LLVMContext Context;
Context.setDiagnosticHandler(
std::make_unique<LLVMDisDiagnosticHandler>(argv[0]));

if (InputFilenames.size() < 1) {
InputFilenames.push_back("-");
} else if (InputFilenames.size() > 1 && !OutputFilename.empty()) {
Expand All @@ -204,6 +200,12 @@ int main(int argc, char **argv) {
}

for (const auto &InputFilename : InputFilenames) {
// Use a fresh context for each input to avoid state
// cross-contamination across inputs (e.g. type name collisions).
LLVMContext Context;
Context.setDiagnosticHandler(
std::make_unique<LLVMDisDiagnosticHandler>(argv[0]));

ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFileOrSTDIN(InputFilename);
if (std::error_code EC = BufferOrErr.getError()) {
Expand Down
Loading