Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke lowering broken with -enable-eh #1596

Closed
asl opened this issue Feb 25, 2007 · 6 comments
Closed

Invoke lowering broken with -enable-eh #1596

asl opened this issue Feb 25, 2007 · 6 comments
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag

Comments

@asl
Copy link
Collaborator

asl commented Feb 25, 2007

Bugzilla Link 1224
Resolution FIXED
Resolved on Feb 22, 2010 12:47
Version trunk
OS Linux

Extended Description

Even after #1593 was fixed, I'm getting assertions during _divsc3.o
compilation. Unfortunately, valgrind doesn't show anything wrong and the problem
isn't reproducible with llc.

Even more, if I compile _divsc3.o with llc by hands and continue llvm-gcc build,
I'll get the folowing assertion during guard.cc compilation (from libsupc++):

cc1plus:
/home/asl/proj/llvm/src/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:4100:
llvm::SDOperand
llvm::SelectionDAGLowering::CopyValueToVirtualRegister(llvm::Value*, unsigned
int): Assertion `(Op.getOpcode() != ISD::CopyFromReg ||
cast(Op.getOperand(1))->getReg() != Reg) && "Copy from a reg to
the same reg!"' failed.

And again no valgrind output...
I'm investigating

@asl
Copy link
Collaborator Author

asl commented Feb 25, 2007

Debug version is ok.... :(

@asl
Copy link
Collaborator Author

asl commented Feb 25, 2007

Nope. I was wrong. Caught assertion with another file.

@lattner
Copy link
Collaborator

lattner commented Feb 25, 2007

declare i32 @​test()
define i32 @​test2() {
%A = invoke i32 @​test() to label %invcont unwind label %blat
invcont:
ret i32 %A
blat:
ret i32 0
}

$ llvm-as < t.ll | llc --enable-eh

It looks like the valuemap isn't getting updated correctly. I will disable 'enable-eh' in llvm-gcc to make
this not a blocker.

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 25, 2007

Invoke is both a value producing instruction and a terminator. Need to split up purposes in ISel.

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 25, 2007

Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

====
RCS file: /var/cvs/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp,v
retrieving revision 1.374
diff -u -1 -0 -d -r1.374 SelectionDAGISel.cpp
--- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp 24 Feb 2007 09:45:44 -0000
1.374
+++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp 25 Feb 2007 21:15:16 -0000
@@ -493,20 +493,21 @@
void visitBr(BranchInst &I);
void visitSwitch(SwitchInst &I);
void visitUnreachable(UnreachableInst &I) { /* noop */ }
// Helper for visitSwitch
void visitSwitchCase(SelectionDAGISel::CaseBlock &CB);
void visitJumpTable(SelectionDAGISel::JumpTable &JT);

// These all get lowered before this pass.
void visitInvoke(InvokeInst &I);

  • void visitInvoke(InvokeInst &I, bool AsTerminator);
    void visitUnwind(UnwindInst &I);
    void visitScalarBinary(User &I, unsigned OpCode);
    void visitVectorBinary(User &I, unsigned OpCode);
    void visitEitherBinary(User &I, unsigned ScalarOp, unsigned VectorOp);
    void visitShift(User &I, unsigned Opcode);
    void visitAdd(User &I) {
    if (isa(I.getType()))
    visitVectorBinary(I, ISD::VADD);
    else if (I.getType()->isFloatingPoint())
    @@ -1098,58 +1099,63 @@
    // Emit the code for the jump table
    MVT::ValueType PTy = TLI.getPointerTy();
    SDOperand Index = DAG.getCopyFromReg(getRoot(), JT.Reg, PTy);
    SDOperand Table = DAG.getJumpTable(JT.JTI, PTy);
    DAG.setRoot(DAG.getNode(ISD::BR_JT, MVT::Other, Index.getValue(1),
    Table, Index));
    return;
    }
    void SelectionDAGLowering::visitInvoke(InvokeInst &I) {
  • assert(0 && "Should never be visited directly");
    +}
    +void SelectionDAGLowering::visitInvoke(InvokeInst &I, bool AsTerminator) {
    // Retrieve successors.
    MachineBasicBlock *Return = FuncInfo.MBBMap[I.getSuccessor(0)];
    MachineBasicBlock *LandingPad = FuncInfo.MBBMap[I.getSuccessor(1)];
  • // Mark landing pad so that it doesn't get deleted in branch folding.
  • LandingPad->setIsLandingPad();
  • // Insert a label before the invoke call to mark the try range.
  • // This can be used to detect deletion of the invoke via the
  • // MachineModuleInfo.
  • MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
  • unsigned BeginLabel = MMI->NextLabelID();
  • DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
  •                      DAG.getConstant(BeginLabel, MVT::i32)));
    
  • LowerCallTo(I, I.getCalledValue()->getType(),
  •             I.getCallingConv(),
    
  •             false,
    
  •             getValue(I.getOperand(0)),
    
  •             3);
    
  • if (!AsTerminator) {
  • // Mark landing pad so that it doesn't get deleted in branch folding.
  • LandingPad->setIsLandingPad();
  • // Insert a label before the invoke call to mark the try range.
  • // This can be used to detect deletion of the invoke via the
  • // MachineModuleInfo.
  • MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
  • unsigned BeginLabel = MMI->NextLabelID();
  • DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
  •                        DAG.getConstant(BeginLabel, MVT::i32)));
    
  • // Insert a label before the invoke call to mark the try range.
  • // This can be used to detect deletion of the invoke via the
  • // MachineModuleInfo.
  • unsigned EndLabel = MMI->NextLabelID();
  • DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
  •                      DAG.getConstant(EndLabel, MVT::i32)));
    
  • // Inform MachineModuleInfo of range.
  • MMI->addInvoke(LandingPad, BeginLabel, EndLabel);
  • LowerCallTo(I, I.getCalledValue()->getType(),
  •               I.getCallingConv(),
    
  •               false,
    
  •               getValue(I.getOperand(0)),
    
  •               3);
    
  • // Drop into normal successor.
  • DAG.setRoot(DAG.getNode(ISD::BR, MVT::Other, getRoot(),
  •                      DAG.getBasicBlock(Return)));
    
  • // Update successor info
  • CurMBB->addSuccessor(Return);
  • CurMBB->addSuccessor(LandingPad);
  • // Insert a label before the invoke call to mark the try range.

  • // This can be used to detect deletion of the invoke via the

  • // MachineModuleInfo.

  • unsigned EndLabel = MMI->NextLabelID();

  • DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),

  •                        DAG.getConstant(EndLabel, MVT::i32)));
    
  • // Inform MachineModuleInfo of range.

  • MMI->addInvoke(LandingPad, BeginLabel, EndLabel);

  • // Update successor info

  • CurMBB->addSuccessor(Return);

  • CurMBB->addSuccessor(LandingPad);

  • } else {

  • // Drop into normal successor.

  • DAG.setRoot(DAG.getNode(ISD::BR, MVT::Other, getRoot(),

  •                        DAG.getBasicBlock(Return)));
    
  • }
    }
    void SelectionDAGLowering::visitUnwind(UnwindInst &I) {
    }
    void SelectionDAGLowering::visitSwitch(SwitchInst &I) {
    // Figure out which block is immediately after the current one.
    MachineBasicBlock *NextBlock = 0;
    MachineFunction::iterator BBI = CurMBB;
    @@ -4212,20 +4218,24 @@
    if (LLVMBB == &LLVMBB->getParent()->front())
    LowerArguments(LLVMBB, SDL, UnorderedChains);
    BB = FuncInfo.MBBMap[LLVMBB];
    SDL.setCurrentBasicBlock(BB);
    // Lower all of the non-terminator instructions.
    for (BasicBlock::iterator I = LLVMBB->begin(), E = --LLVMBB->end();
    I != E; ++I)
    SDL.visit(*I);

  • // Lower call part of invoke.

  • InvokeInst *Invoke = dyn_cast(LLVMBB->getTerminator());

  • if (Invoke) SDL.visitInvoke(*Invoke, false);

    // Ensure that all instructions which are used outside of their defining
    // blocks are available as virtual registers.
    for (BasicBlock::iterator I = LLVMBB->begin(), E = LLVMBB->end(); I != E;++I)
    if (!I->use_empty() && !isa(I)) {
    DenseMap<const Value*, unsigned>::iterator VMI =FuncInfo.ValueMap.find(I);
    if (VMI != FuncInfo.ValueMap.end())
    UnorderedChains.push_back(
    SDL.CopyValueToVirtualRegister(I, VMI->second));
    }
    @@ -4324,21 +4334,26 @@
    }

    if (i == e)
      UnorderedChains.push_back(Root);
    

    }
    DAG.setRoot(DAG.getNode(ISD::TokenFactor, MVT::Other,
    &UnorderedChains[0], UnorderedChains.size()));
    }
    // Lower the terminator after the copies are emitted.

  • SDL.visit(*LLVMBB->getTerminator());
  • if (Invoke) {

  • // Just the branch part of invoke.

  • SDL.visitInvoke(*Invoke, true);

  • } else {

  • SDL.visit(*LLVMBB->getTerminator());

  • }
    // Copy over any CaseBlock records that may now exist due to SwitchInst
    // lowering, as well as any jump table information.
    SwitchCases.clear();
    SwitchCases = SDL.SwitchCases;
    JT = SDL.JT;

    // Make sure the root of the DAG is up-to-date.
    DAG.setRoot(SDL.getRoot());
    }

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 13, 2007

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
clementval added a commit to clementval/llvm-project that referenced this issue Apr 20, 2022
troelsbjerre pushed a commit to troelsbjerre/llvm-project that referenced this issue Jan 10, 2024
…843365aa85962a561ad4

[lldb/Test] Skip tests that try to get the remote environment
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag
Projects
None yet
Development

No branches or pull requests

3 participants