Skip to content

Problem with CodeExtractor.cpp #1376

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

Closed
llvmbot opened this issue Nov 15, 2006 · 5 comments
Closed

Problem with CodeExtractor.cpp #1376

llvmbot opened this issue Nov 15, 2006 · 5 comments
Labels
bugzilla Issues migrated from bugzilla invalid Resolved as invalid, i.e. not a bug

Comments

@llvmbot
Copy link
Member

llvmbot commented Nov 15, 2006

Bugzilla Link 1004
Resolution INVALID
Resolved on Feb 22, 2010 12:45
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

I have this code:

loopexit.6:
... // something
no_exit.7:
... // something
loopexit.7: ; preds = %no_exit.7, %loopexit.6
%n.3.1 = phi int [ 0, %loopexit.6 ], [ %n.2, %no_exit.7 ]
...

I want extract code region, which contains loopexit.6 and no_exit.7.
CodeExtractor creates new function and puts those basic blocks to this function.
CodeExtractor creates codeReplacer block containing call-instr to new function.
So CodeExtractor modifies phi-node instruction in loopexit.7 :
%n.3.1 = phi int [ 0, %codeRepl1 ], [ %n.2.reload, %codeRepl1 ]
And verifier say 'Error' :

PHINode should have one entry for each predecessor of its parent basic block!
%n.3.1 = phi int [ 0, %codeRepl1 ], [ %n.2.reload, %codeRepl1 ]
; [#uses=1]
Broken module found, compilation aborted!

@lattner
Copy link
Collaborator

lattner commented Nov 20, 2006

Can you provide some information on how to reproduce this? The code extractor requires critical edges to
be broken, are they?

If so, this case shouldn't occur.

-Chris

@llvmbot
Copy link
Member Author

llvmbot commented Nov 21, 2006

bug reproduced information
bug reproduced information

@llvmbot
Copy link
Member Author

llvmbot commented Nov 21, 2006

bug reproduced information
There is in the attachment.
*example1.bc (example program)
*one.cpp/h (bug demonstrated code (using only on example1.bc))
*bad_modification.txt (resulted bc in text format)

Compile one.cpp and run on example1.bc. You will see error message:
<--
PHINode should have one entry for each predecessor of its parent basic block!
%res.0.1 = phi int [ 0, %codeRepl ], [ %tmp.30.reload, %codeRepl ]
; [#uses=2]
Broken module found, compilation aborted! -->

I think that CodeExtractor doesn't correctly modify phi instruction.

@nlewycky
Copy link
Contributor

nlewycky commented Dec 1, 2006

Right, so you're taking code which hasn't been run through break-crit-edges,
then directly calling ExtractCodeRegion like so:

Function* func = ExtractCodeRegion((DominatorSet)0, region, false);

The trouble is that there's no PassManager to recognize the need to run BCE
first and make the code valid. The bad phi node is caused by a critical edge
between label %loopexit.0 and label %loopexit.1.

Because your code is special-case anyways, I don't think you should bother with
a PassManager. Instead just use BCE directly -- something like this:

FunctionPass *BCE = createBreakCriticalEdgesPass();
BCE->runOnFunction(*mainfunc);

before you run the code extractor ought to fix it up for you.

@lattner
Copy link
Collaborator

lattner commented Dec 19, 2006

The problem is that the code extractor expects critical edges to be broken and they are not.

-Chris

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
clementval pushed a commit to clementval/llvm-project that referenced this issue Jan 17, 2022
Fixes stack allocation growth issue. When in a loop, allocating on the
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 invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

3 participants