Skip to content
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

Opague Pointers #127

Open
ahueck opened this issue May 5, 2022 · 0 comments
Open

Opague Pointers #127

ahueck opened this issue May 5, 2022 · 0 comments

Comments

@ahueck
Copy link
Contributor

ahueck commented May 5, 2022

With future LLVM versions "opaque pointers" replace the currently typed pointers in LLVM, also eliminating the need for bitcasts.
As TypeART relies on these for determining the type of a heap allocation, adaptions are required to handle opaque pointers, e.g., relying on the DINodes.

Example: Affected test

malloc_free_double

define dso_local void @test() #0 {
  %1 = alloca double*, align 8
  %2 = bitcast double** %1 to i8*
  call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #3
  %3 = call noalias i8* @malloc(i64 noundef 336) #3
  %4 = bitcast i8* %3 to double*
  store double* %4, double** %1, align 8, !tbaa !3
  %5 = load double*, double** %1, align 8, !tbaa !3
  %6 = bitcast double* %5 to i8*
  call void @free(i8* noundef %6) #3
  %7 = bitcast double** %1 to i8*
  call void @llvm.lifetime.end.p0i8(i64 8, i8* %7) #3
  ret void
}

vs.

define dso_local void @test() #0 {
entry:
  %p = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %p) #4
  %call = call noalias ptr @malloc(i64 noundef 336) #5
  store ptr %call, ptr %p, align 8, !tbaa !5
  %0 = load ptr, ptr %p, align 8, !tbaa !5
  call void @free(ptr noundef %0) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %p) #4
  ret void
}

Affected LLVM version

Opague pointers may be default with LLVM 15.

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant