[llvm-commits] [llvm] r98495 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/CodeGen/MachineModuleInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/MachineModuleInfo.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/ARM/indirectbr.ll test/CodeGen/PowerPC/indirectbr.ll test/CodeGen/XCore/indirectbr.ll
Bill Wendling
wendling at apple.com
Mon Mar 15 21:39:09 PDT 2010
Yes! Thanks. :-)
-bw
On Mar 14, 2010, at 10:53 AM, Chris Lattner wrote:
> Author: lattner
> Date: Sun Mar 14 12:53:23 2010
> New Revision: 98495
>
> URL: http://llvm.org/viewvc/llvm-project?rev=98495&view=rev
> Log:
> fix AsmPrinter::GetBlockAddressSymbol to always return a unique
> label instead of trying to form one based on the BB name (which
> causes collisions if the name is empty). This fixes PR6608
>
> Modified:
> llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
> llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> llvm/trunk/test/CodeGen/ARM/indirectbr.ll
> llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll
> llvm/trunk/test/CodeGen/XCore/indirectbr.ll
>
> Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Sun Mar 14 12:53:23 2010
> @@ -337,8 +337,7 @@
> /// GetBlockAddressSymbol - Return the MCSymbol used to satisfy BlockAddress
> /// uses of the specified basic block.
> MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
> - MCSymbol *GetBlockAddressSymbol(const Function *F,
> - const BasicBlock *BB) const;
> + MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
>
> /// EmitBasicBlockStart - This method prints the label for the specified
> /// MachineBasicBlock, an alignment (if present) and a comment describing
>
> Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Sun Mar 14 12:53:23 2010
> @@ -139,6 +139,11 @@
> /// llvm.compiler.used.
> SmallPtrSet<const Function *, 32> UsedFunctions;
>
> +
> + /// AddrLabelSymbols - This map keeps track of which symbol is being used for
> + /// the specified basic block's address of label.
> + DenseMap<AssertingVH<BasicBlock>, MCSymbol*> AddrLabelSymbols;
> +
> bool CallsEHReturn;
> bool CallsUnwindInit;
>
> @@ -203,6 +208,11 @@
> /// handling comsumers.
> std::vector<MachineMove> &getFrameMoves() { return FrameMoves; }
>
> + /// getAddrLabelSymbol - Return the symbol to be used for the specified basic
> + /// block when its address is taken. This cannot be its normal LBB label
> + /// because the block may be accessed outside its containing function.
> + MCSymbol *getAddrLabelSymbol(const BasicBlock *BB);
> +
> //===- EH ---------------------------------------------------------------===//
>
> /// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sun Mar 14 12:53:23 2010
> @@ -1580,28 +1580,11 @@
> }
>
> MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BlockAddress *BA) const {
> - return GetBlockAddressSymbol(BA->getFunction(), BA->getBasicBlock());
> + return MMI->getAddrLabelSymbol(BA->getBasicBlock());
> }
>
> -MCSymbol *AsmPrinter::GetBlockAddressSymbol(const Function *F,
> - const BasicBlock *BB) const {
> - assert(BB->hasName() &&
> - "Address of anonymous basic block not supported yet!");
> -
> - // This code must use the function name itself, and not the function number,
> - // since it must be possible to generate the label name from within other
> - // functions.
> - SmallString<60> FnName;
> - Mang->getNameWithPrefix(FnName, F, false);
> -
> - // FIXME: THIS IS BROKEN IF THE LLVM BASIC BLOCK DOESN'T HAVE A NAME!
> - SmallString<60> NameResult;
> - Mang->getNameWithPrefix(NameResult,
> - StringRef("BA") + Twine((unsigned)FnName.size()) +
> - "_" + FnName.str() + "_" + BB->getName(),
> - Mangler::Private);
> -
> - return OutContext.GetOrCreateTemporarySymbol(NameResult.str());
> +MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BasicBlock *BB) const {
> + return MMI->getAddrLabelSymbol(BB);
> }
>
> /// GetCPISymbol - Return the symbol for the specified constant pool entry.
> @@ -1730,7 +1713,7 @@
> const BasicBlock *BB = MBB->getBasicBlock();
> if (VerboseAsm)
> OutStreamer.AddComment("Address Taken");
> - OutStreamer.EmitLabel(GetBlockAddressSymbol(BB->getParent(), BB));
> + OutStreamer.EmitLabel(GetBlockAddressSymbol(BB));
> }
>
> // Print the main label for the block.
>
> Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Sun Mar 14 12:53:23 2010
> @@ -104,6 +104,18 @@
> UsedFunctions.insert(F);
> }
>
> +/// getAddrLabelSymbol - Return the symbol to be used for the specified basic
> +/// block when its address is taken. This cannot be its normal LBB label
> +/// because the block may be accessed outside its containing function.
> +MCSymbol *MachineModuleInfo::getAddrLabelSymbol(const BasicBlock *BB) {
> + assert(BB->hasAddressTaken() &&
> + "Shouldn't get label for block without address taken");
> + MCSymbol *&Entry = AddrLabelSymbols[const_cast<BasicBlock*>(BB)];
> + if (Entry) return Entry;
> + return Entry = Context.CreateTempSymbol();
> +}
> +
> +
> //===-EH-------------------------------------------------------------------===//
>
> /// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Mar 14 12:53:23 2010
> @@ -2035,6 +2035,8 @@
> case ISD::EntryToken: // These nodes remain the same.
> case ISD::BasicBlock:
> case ISD::Register:
> + //case ISD::VALUETYPE:
> + //case ISD::CONDCODE:
> case ISD::HANDLENODE:
> case ISD::TargetConstant:
> case ISD::TargetConstantFP:
>
> Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (original)
> +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Sun Mar 14 12:53:23 2010
> @@ -59,6 +59,6 @@
> store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4
> ret i32 %res.3
> }
> -; ARM: .long L_BA4__foo_L5-(LPC{{.*}}+8)
> -; THUMB: .long L_BA4__foo_L5-(LPC{{.*}}+4)
> -; THUMB2: .long L_BA4__foo_L5
> +; ARM: .long Ltmp0-(LPC{{.*}}+8)
> +; THUMB: .long Ltmp0-(LPC{{.*}}+4)
> +; THUMB2: .long Ltmp0
>
> Modified: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll (original)
> +++ llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Sun Mar 14 12:53:23 2010
> @@ -43,12 +43,12 @@
>
> L1: ; preds = %L2, %bb2
> %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; <i32> [#uses=1]
> -; PIC: addis r4, r4, ha16(L_BA4__foo_L5-"L1$pb")
> -; PIC: li r6, lo16(L_BA4__foo_L5-"L1$pb")
> +; PIC: addis r4, r4, ha16(Ltmp0-"L1$pb")
> +; PIC: li r6, lo16(Ltmp0-"L1$pb")
> ; PIC: add r4, r4, r6
> ; PIC: stw r4
> -; STATIC: li r5, lo16(L_BA4__foo_L5)
> -; STATIC: addis r5, r5, ha16(L_BA4__foo_L5)
> +; STATIC: li r5, lo16(Ltmp0)
> +; STATIC: addis r5, r5, ha16(Ltmp0)
> ; STATIC: stw r5
> store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4
> ret i32 %res.3
>
> Modified: llvm/trunk/test/CodeGen/XCore/indirectbr.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/indirectbr.ll?rev=98495&r1=98494&r2=98495&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/XCore/indirectbr.ll (original)
> +++ llvm/trunk/test/CodeGen/XCore/indirectbr.ll Sun Mar 14 12:53:23 2010
> @@ -38,7 +38,7 @@
>
> L1: ; preds = %L2, %bb2
> %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; <i32> [#uses=1]
> -; CHECK: ldap r11, .LBA3_foo_L5
> +; CHECK: ldap r11, .Ltmp0
> ; CHECK: stw r11, dp[nextaddr]
> store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4
> ret i32 %res.3
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list