[PATCH] D151644: [InstCombine] Propegating `nocapture` flag to callsites

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 06:52:11 PDT 2023


nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

propegate -> propagate everywhere

You're really playing with fire here when it comes to "it's captured, but it doesn't really matter" reasoning. Consider something like this:

  define i32 @test(ptr noalias nocapture %p) {
    %a = alloca ptr
    store i32 0, ptr %p 
    call void @store_into_alloca(ptr %a, ptr %p)
    %p2 = load ptr, ptr %a
    %v = load i32, ptr %p2
    ret i32 %v
  }
  
  declare void @store_into_alloca(ptr, ptr)

This call is clearly capturing, in a way that will affect alias analysis results (`load i32, ptr %p2` cannot ref `%p` with that `nocapture` attribute in place, which will be materialized with invalid alias scope metadata during inlining).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151644/new/

https://reviews.llvm.org/D151644



More information about the llvm-commits mailing list