efriedma added a comment.

Consider something like this:

  define i32 @div(i32 %x, i32 %y) {
  entry:
    %div = sdiv i32 %x, %y
    ret i32 %div
  }

We can mark this function readnone, but not speculatable: it doesn't read or 
write memory, but could exhibit undefined behavior.

Consider another function:

  @x = common local_unnamed_addr global i32 0, align 4
  define i32 @get_x() {
  entry:
    %0 = load i32, i32* @x, align 4, !tbaa !2
    ret i32 %0
  }

We can mark this function speculatable, but not readnone: it doesn't exhibit 
undefined behavior or have side-effects, but it does read memory.

Given that, it seems a little dubious to translate `__attribute__((const))` 
into `speculatable`.


https://reviews.llvm.org/D33774



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to