Skip to content

Commit

Permalink
PruneEH pass incorrectly reports that a change was made
Browse files Browse the repository at this point in the history
Reviewed By: reames

Differential Revision: http://reviews.llvm.org/D14097


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255343 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
arpilipe committed Dec 11, 2015
1 parent 9c695e4 commit 89fa0a8
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions lib/Transforms/IPO/PruneEH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,16 @@ bool PruneEH::runOnSCC(CallGraphSCC &SCC) {
// If the SCC doesn't unwind or doesn't throw, note this fact.
if (!SCCMightUnwind || !SCCMightReturn)
for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
AttrBuilder NewAttributes;

if (!SCCMightUnwind)
NewAttributes.addAttribute(Attribute::NoUnwind);
if (!SCCMightReturn)
NewAttributes.addAttribute(Attribute::NoReturn);

Function *F = (*I)->getFunction();
const AttributeSet &PAL = F->getAttributes().getFnAttributes();
const AttributeSet &NPAL = AttributeSet::get(
F->getContext(), AttributeSet::FunctionIndex, NewAttributes);

if (PAL != NPAL) {
if (!SCCMightUnwind && !F->hasFnAttribute(Attribute::NoUnwind)) {
F->addFnAttr(Attribute::NoUnwind);
MadeChange = true;
}

if (!SCCMightReturn && !F->hasFnAttribute(Attribute::NoReturn)) {
F->addFnAttr(Attribute::NoReturn);
MadeChange = true;
F->addAttributes(AttributeSet::FunctionIndex, NPAL);
}
}

Expand Down

0 comments on commit 89fa0a8

Please sign in to comment.