Skip to content

Instantly share code, notes, and snippets.

@stelleg
Last active May 30, 2018 14:43
Show Gist options
  • Save stelleg/dc4da8414f34700e557857047cc50a1d to your computer and use it in GitHub Desktop.
Save stelleg/dc4da8414f34700e557857047cc50a1d to your computer and use it in GitHub Desktop.
detach marker issue
bool detach();
void reattach(atomic_int* arg);
int f(){
atomic_int* a = alloca(sizeof(int));
a[0] = 0;
if(detach()){
a[0]++;
reattach(a);
}
else {
a[0]++;
}
return a[0];
}
define i32 @f() local_unnamed_addr #0 {
%1 = alloca i32, align 16
store atomic i32 0, i32* %1 seq_cst, align 16, !tbaa !4
%2 = tail call zeroext i1 (...) @detach() #2
%3 = atomicrmw add i32* %1, i32 1 seq_cst
br i1 %2, label %4, label %5
; <label>:4: ; preds = %0
call void @reattach(i32* nonnull %1) #2
br label %5
; <label>:5: ; preds = %0, %4
%6 = load atomic i32, i32* %1 seq_cst, align 16, !tbaa !4
ret i32 %6
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment