From: Chris Lattner Date: Mon, 22 Mar 2010 23:15:57 +0000 (+0000) Subject: Fix PR6673: updating the callback should not clear the map. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ea16ea59011ce6d5d9baaab16c33b1457ceab0da;p=oota-llvm.git Fix PR6673: updating the callback should not clear the map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99227 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp index af48e9ebb5b..ad4f01b7a9a 100644 --- a/lib/CodeGen/MachineModuleInfo.cpp +++ b/lib/CodeGen/MachineModuleInfo.cpp @@ -44,6 +44,10 @@ public: MMIAddrLabelMapCallbackPtr() : Map(0) {} MMIAddrLabelMapCallbackPtr(Value *V) : CallbackVH(V), Map(0) {} + void setPtr(BasicBlock *BB) { + ValueHandleBase::operator=(BB); + } + void setMap(MMIAddrLabelMap *map) { Map = map; } virtual void deleted(); @@ -209,7 +213,7 @@ void MMIAddrLabelMap::UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New) { // If New is not address taken, just move our symbol over to it. if (NewEntry.Symbols.isNull()) { - BBCallbacks[OldEntry.Index] = New; // Update the callback. + BBCallbacks[OldEntry.Index].setPtr(New); // Update the callback. NewEntry = OldEntry; // Set New's entry. return; } diff --git a/test/CodeGen/Generic/addr-label.ll b/test/CodeGen/Generic/addr-label.ll index 51741110e07..0dbe5021bbf 100644 --- a/test/CodeGen/Generic/addr-label.ll +++ b/test/CodeGen/Generic/addr-label.ll @@ -56,3 +56,26 @@ ret: ret i32 -1 } + +; PR6673 + +define i64 @test4a() { + %target = bitcast i8* blockaddress(@test4b, %usermain) to i8* + %ret = call i64 @test4b(i8* %target) + + ret i64 %ret +} + +define i64 @test4b(i8* %Code) { +entry: + indirectbr i8* %Code, [label %usermain] +usermain: + br label %label_line_0 + +label_line_0: + br label %label_line_1 + +label_line_1: + %target = ptrtoint i8* blockaddress(@test4b, %label_line_0) to i64 + ret i64 %target +}