[PATCH] Bug 20788 - bugpoint does not respect the "Alias must point to a definition"

Daniel Berlin dberlin at dberlin.org
Thu May 14 08:07:28 PDT 2015


I still get the same crash on bugpoint with this patch, though
slightly further along

Checking for crash with only these blocks:   ._crit_edge
_ZN12_GLOBAL__N_111StmtPrinter9PrintExprEPN5clang4ExprE.exit ... <25
total>: Alias must point to a definition
void (%"class.clang::DiagnosticNoteRenderer"*)*
@_ZN5clang22DiagnosticNoteRendererD1Ev
Alias must point to a definition
void (%"class.clang::DiagnosticNoteRenderer"*)*
@_ZN5clang22DiagnosticNoteRendererD2Ev
Alias must point to a definition
void (%"class.llvm::ReturnInst"*)* @_ZN4llvm10ReturnInstD1Ev
Alias must point to a definition
void (%"class.llvm::ReturnInst"*)* @_ZN4llvm10ReturnInstD2Ev
Alias must point to a definition
void (%"class.llvm::AllocaInst"*)* @_ZN4llvm10AllocaInstD1Ev
Alias must point to a definition
void (%"class.llvm::AllocaInst"*)* @_ZN4llvm10AllocaInstD2Ev
Alias must point to a definition
void (%"class.llvm::ModulePass"*)* @_ZN4llvm10ModulePassD1Ev
Alias must point to a definition
void (%"class.llvm::ModulePass"*)* @_ZN4llvm10ModulePassD2Ev
Alias must point to a definition
void (%"class.llvm::ImmutablePass"*)* @_ZN4llvm13ImmutablePassD1Ev
Alias must point to a definition
void (%"class.llvm::ImmutablePass"*)* @_ZN4llvm13ImmutablePassD2Ev
Alias must point to a definition
void (%"class.llvm::raw_null_ostream"*)* @_ZN4llvm16raw_null_ostreamD1Ev
Alias must point to a definition
void (%"class.llvm::raw_null_ostream"*)* @_ZN4llvm16raw_null_ostreamD2Ev
./opt: bugpoint-input-b1bae24.bc: error: input module is broken!
simplifycfg failed!



On Thu, May 14, 2015 at 7:18 AM, Nick Johnson
<Nicholas.Paul.Johnson at deshawresearch.com> wrote:
> @dberlin: your testcase demonstrates that a GlobalAlias may refer to any kind of ConstantExpr, whereas my previous patch incorrectly assumed that the aliasee must be an llvm::Function.
>
> Consequently, the test on line 194 needs a ->stripPointerCasts().  My latest patch handles that testcase correctly.
>
> @dberlin: you mentioned you have many test cases.  Would you be so kind as to run this latest patch on them?  Thanks,
>
>
> http://reviews.llvm.org/D9529
>
> Files:
>   tools/bugpoint/ExtractFunction.cpp
>
> Index: tools/bugpoint/ExtractFunction.cpp
> ===================================================================
> --- tools/bugpoint/ExtractFunction.cpp
> +++ tools/bugpoint/ExtractFunction.cpp
> @@ -184,6 +184,26 @@
>  // blocks, making it external.
>  //
>  void llvm::DeleteFunctionBody(Function *F) {
> +  // First, check whether a GlobalAlias references this definition.
> +  // GlobalAlias MAY NOT reference declarations.
> +  for (;;) {
> +    // 1. Find aliases
> +    SmallVector<GlobalAlias*,1> aliases;
> +    Module *M = F->getParent();
> +    for (Module::alias_iterator I=M->alias_begin(), E=M->alias_end(); I!=E; ++I)
> +      if (I->getAliasee()->stripPointerCasts() == F)
> +        aliases.push_back(&*I);
> +    if (aliases.empty())
> +      break;
> +    // 2. Resolve aliases
> +    for (unsigned i=0, e=aliases.size(); i<e; ++i) {
> +      aliases[i]->replaceAllUsesWith(aliases[i]->getAliasee());
> +      aliases[i]->eraseFromParent();
> +    }
> +    // 3. Repeat until no more aliases found; there might
> +    // be an alias to an alias...
> +  }
> +
>    // delete the body of the function...
>    F->deleteBody();
>    assert(F->isDeclaration() && "This didn't make the function external!");
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/



More information about the llvm-commits mailing list