[PATCH] D128128: [GlobalOpt] Perform store->dominated load forwarding for stored once globals
    Johannes Doerfert via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Jun 21 06:28:35 PDT 2022
    
    
  
jdoerfert added a comment.
This breaks in the presence of synchronization.
  static int X = 42;
  
  int foo(int Arg) {
    sync();
    X = Arg;
    sync();
    return X;
  }
Two threads call `foo` with two values of `Arg` and the `sync` will ensure they proceed "one after another":
      X = 42;
  sync
  T1: X = Arg1;
  sync
  T2: X = Arg2;
  sync
  T1, T2: return Arg2
Whereas replacing the load will result
  T1, T2, return Arg{1,2}
Right?
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128128/new/
https://reviews.llvm.org/D128128
    
    
More information about the llvm-commits
mailing list