diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-08-03 06:15:41 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-08-03 06:15:41 +0000 |
| commit | 5b82a0ac0caebbf373d67f4f947af61546aa82fe (patch) | |
| tree | 89f833e2cd576f7753ad10b6e2afc50e261e8699 /llvm/lib/VMCore/AsmWriter.cpp | |
| parent | e826a2a56ba334eba9d15e79c418fe412750e22f (diff) | |
| download | bcm5719-llvm-5b82a0ac0caebbf373d67f4f947af61546aa82fe.tar.gz bcm5719-llvm-5b82a0ac0caebbf373d67f4f947af61546aa82fe.zip | |
fix PR10286, a problem with the .ll printer handling block addresses that are out-of-scope.
llvm-svn: 136768
Diffstat (limited to 'llvm/lib/VMCore/AsmWriter.cpp')
| -rw-r--r-- | llvm/lib/VMCore/AsmWriter.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 7deba0d0382..442e8b8f7f9 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -1037,26 +1037,35 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V, char Prefix = '%'; int Slot; + // If we have a SlotTracker, use it. if (Machine) { if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) { Slot = Machine->getGlobalSlot(GV); Prefix = '@'; } else { 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); - if (Machine) { - if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) { - Slot = Machine->getGlobalSlot(GV); - Prefix = '@'; - } else { - Slot = Machine->getLocalSlot(V); - } - delete Machine; + } else if ((Machine = createSlotTracker(V))) { + // Otherwise, create one to get the # and then destroy it. + if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) { + Slot = Machine->getGlobalSlot(GV); + Prefix = '@'; } else { - Slot = -1; + Slot = Machine->getLocalSlot(V); } + delete Machine; + Machine = 0; + } else { + Slot = -1; } if (Slot != -1) |

