mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 00:29:20 +00:00
fix PR10286, a problem with the .ll printer handling block addresses that are out-of-scope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136768 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
027cbf9329
commit
fb5179a2fa
@ -1037,16 +1037,25 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
|
|||||||
|
|
||||||
char Prefix = '%';
|
char Prefix = '%';
|
||||||
int Slot;
|
int Slot;
|
||||||
|
// If we have a SlotTracker, use it.
|
||||||
if (Machine) {
|
if (Machine) {
|
||||||
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
|
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
|
||||||
Slot = Machine->getGlobalSlot(GV);
|
Slot = Machine->getGlobalSlot(GV);
|
||||||
Prefix = '@';
|
Prefix = '@';
|
||||||
} else {
|
} else {
|
||||||
Slot = Machine->getLocalSlot(V);
|
Slot = Machine->getLocalSlot(V);
|
||||||
|
|
||||||
|
// If the local value didn't succeed, then we may be referring to a value
|
||||||
|
// from a different function. Translate it, as this can happen when using
|
||||||
|
// address of blocks.
|
||||||
|
if (Slot == -1)
|
||||||
|
if ((Machine = createSlotTracker(V))) {
|
||||||
|
Slot = Machine->getLocalSlot(V);
|
||||||
|
delete Machine;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
Machine = createSlotTracker(V);
|
} else if ((Machine = createSlotTracker(V))) {
|
||||||
if (Machine) {
|
// Otherwise, create one to get the # and then destroy it.
|
||||||
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
|
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
|
||||||
Slot = Machine->getGlobalSlot(GV);
|
Slot = Machine->getGlobalSlot(GV);
|
||||||
Prefix = '@';
|
Prefix = '@';
|
||||||
@ -1054,10 +1063,10 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
|
|||||||
Slot = Machine->getLocalSlot(V);
|
Slot = Machine->getLocalSlot(V);
|
||||||
}
|
}
|
||||||
delete Machine;
|
delete Machine;
|
||||||
|
Machine = 0;
|
||||||
} else {
|
} else {
|
||||||
Slot = -1;
|
Slot = -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Slot != -1)
|
if (Slot != -1)
|
||||||
Out << Prefix << Slot;
|
Out << Prefix << Slot;
|
||||||
|
23
test/Transforms/StripSymbols/block-address.ll
Normal file
23
test/Transforms/StripSymbols/block-address.ll
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
; RUN: opt %s -strip -S | FileCheck %s
|
||||||
|
; PR10286
|
||||||
|
|
||||||
|
@main_addrs = constant [2 x i8*] [i8* blockaddress(@f, %FOO), i8* blockaddress(@f, %BAR)]
|
||||||
|
; CHECK: @main_addrs = constant [2 x i8*] [i8* blockaddress(@f, %2), i8* blockaddress(@f, %3)]
|
||||||
|
|
||||||
|
declare void @foo() nounwind
|
||||||
|
declare void @bar() nounwind
|
||||||
|
|
||||||
|
define void @f(i8* %indirect.goto.dest) nounwind uwtable ssp {
|
||||||
|
entry:
|
||||||
|
indirectbr i8* %indirect.goto.dest, [label %FOO, label %BAR]
|
||||||
|
|
||||||
|
; CHECK: indirectbr i8* %0, [label %2, label %3]
|
||||||
|
|
||||||
|
FOO:
|
||||||
|
call void @foo()
|
||||||
|
ret void
|
||||||
|
|
||||||
|
BAR:
|
||||||
|
call void @bar()
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user