Skip to content

LLVM ERROR: Attributes 'readnone and readonly' are incompatible! #24713

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
TyOverby opened this issue Apr 23, 2015 · 4 comments
Closed

LLVM ERROR: Attributes 'readnone and readonly' are incompatible! #24713

TyOverby opened this issue Apr 23, 2015 · 4 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

Comments

@TyOverby
Copy link
Contributor

When I use cargo to set [profile.dev] to use opt-level = 1, cargo build fails with this error. Any other opt-level and it's fine.

Attributes 'readnone and readonly' are incompatible!
void ({ i8*, void (i8*)** }*, { i8*, void (i8*)** }*)* @"_ZN25Box$LT$CloneAny$GT$.Clone5clone20hea41b2e97e38689bjhaE"
LLVM ERROR: Broken function found, compilation aborted!

The project that I'm getting this error on is private for now, but it is breaking when compiling typemap v0.2.1.

@steveklabnik steveklabnik added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-optimization labels Apr 23, 2015
@nagisa
Copy link
Member

nagisa commented Apr 23, 2015

Minimized case

#![feature(box_syntax)]
#![crate_type="lib"]

trait Clone2 {
    fn clone_convert(&self) -> Box<Clone3>;
}
trait Clone3: Clone2 {}
impl<T: Clone + 'static> Clone3 for T {}
impl<T: Clone + 'static> Clone2 for T {
    fn clone_convert(&self) -> Box<Clone3> {
        box self.clone()
    }
}
impl Clone for Box<Clone3> {
    fn clone(&self) -> Self {
        self.clone_convert()
    }
}

This is bug in our codegen, I fear (especially because we do dereference pointers we get), since we indeed emit both readonly and readnone. Interesting this is only caught by an optimisation pass, though...

@dotdash
Copy link
Contributor

dotdash commented May 25, 2015

We do not emit readnone.

This is a bug in LLVM. There are two functions that call each other and have a pointer argument that is only used in the mutual calls. In that case, the pointer argument gets the readnone attribute, but if there's already a readonly attribute present, that is not removed and the verifier complains.

This triggers the error:

define void @bar(i8* readonly) {
  call void @foo(i8* %0)
    ret void
}

define void @foo(i8* readonly) {
  call void @bar(i8* %0)
  ret void
}

Patch submitted at http://reviews.llvm.org/D9995

@sanxiyn
Copy link
Member

sanxiyn commented Sep 22, 2015

Can this be closed now?

@apasel422
Copy link
Contributor

This no longer appears to be an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
Projects
None yet
Development

No branches or pull requests

6 participants