SlideShare a Scribd company logo

Opaque Pointers Are Coming

LLVM is currently finalizing the migration from typed pointers (i32*) to opaque pointers (ptr) -- the likely largest intermediate representation change in LLVM's history. In this talk, we'll discuss the motivations for the change, how it will affect developers working on/with LLVM in practice, and why this migration took such a long time. We'll also briefly cover possible future IR changes based on opaque pointers.

1 of 69
Download to read offline
Opaque Pointers
Are Coming
Nikita Popov @ LLVM CGO 2022
About Me
● Sr. Software Engineer on Platform Tools team at Red Hat
● I maintain the LLVM Compile-Time Tracker
2
ptr
One PointerType to Rule Them All
i8*
i32*
[0 x i32]*
i8* (i8*)*
%ty*
3
ptr
… apart from address spaces
i8*
i32*
i8 addrspace(1)*
i32 addrspace(1)*
ptr addrspace(1)
4
Why?
5
Pointer element types carry no semantics
define void @test(i32* %p)
6
Ad

Recommended

A whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerA whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerNikita Popov
 
Adding a BOLT pass
Adding a BOLT passAdding a BOLT pass
Adding a BOLT passAmir42407
 
LLVM Backend の紹介
LLVM Backend の紹介LLVM Backend の紹介
LLVM Backend の紹介Akira Maruoka
 
Introduction to eBPF and XDP
Introduction to eBPF and XDPIntroduction to eBPF and XDP
Introduction to eBPF and XDPlcplcp1
 
Qemu device prototyping
Qemu device prototypingQemu device prototyping
Qemu device prototypingYan Vugenfirer
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜Retrieva inc.
 
llvm basic porting for risc v
llvm basic porting for risc vllvm basic porting for risc v
llvm basic porting for risc vTsung-Chun Lin
 
Device tree support on arm linux
Device tree support on arm linuxDevice tree support on arm linux
Device tree support on arm linuxChih-Min Chao
 

More Related Content

What's hot

「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoring「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoringJunpei Tsuji
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugginglibfetion
 
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPDockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPThomas Graf
 
CXL_説明_公開用.pdf
CXL_説明_公開用.pdfCXL_説明_公開用.pdf
CXL_説明_公開用.pdfYasunori Goto
 
1070: CUDA プログラミング入門
1070: CUDA プログラミング入門1070: CUDA プログラミング入門
1070: CUDA プログラミング入門NVIDIA Japan
 
I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24Varun Mahajan
 
LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)Wang Hsiangkai
 
Kernel Recipes 2019 - XDP closer integration with network stack
Kernel Recipes 2019 -  XDP closer integration with network stackKernel Recipes 2019 -  XDP closer integration with network stack
Kernel Recipes 2019 - XDP closer integration with network stackAnne Nicolas
 
Zynq VIPを利用したテストベンチ
Zynq VIPを利用したテストベンチZynq VIPを利用したテストベンチ
Zynq VIPを利用したテストベンチMr. Vengineer
 
How to read linux kernel
How to read linux kernelHow to read linux kernel
How to read linux kernelNaoya Ito
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)Brendan Gregg
 
Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11corehard_by
 
ラズパイでデバイスドライバを作ってみた。
ラズパイでデバイスドライバを作ってみた。ラズパイでデバイスドライバを作ってみた。
ラズパイでデバイスドライバを作ってみた。Kazuki Onishi
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic ControlSUSE Labs Taipei
 

What's hot (20)

「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoring「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoring
 
Linux Internals - Part III
Linux Internals - Part IIILinux Internals - Part III
Linux Internals - Part III
 
Linux Device Tree
Linux Device TreeLinux Device Tree
Linux Device Tree
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPDockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
 
CXL_説明_公開用.pdf
CXL_説明_公開用.pdfCXL_説明_公開用.pdf
CXL_説明_公開用.pdf
 
1070: CUDA プログラミング入門
1070: CUDA プログラミング入門1070: CUDA プログラミング入門
1070: CUDA プログラミング入門
 
I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24
 
eBPF maps 101
eBPF maps 101eBPF maps 101
eBPF maps 101
 
LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)
 
Kernel Recipes 2019 - XDP closer integration with network stack
Kernel Recipes 2019 -  XDP closer integration with network stackKernel Recipes 2019 -  XDP closer integration with network stack
Kernel Recipes 2019 - XDP closer integration with network stack
 
Ext4 filesystem(1)
Ext4 filesystem(1)Ext4 filesystem(1)
Ext4 filesystem(1)
 
Zynq VIPを利用したテストベンチ
Zynq VIPを利用したテストベンチZynq VIPを利用したテストベンチ
Zynq VIPを利用したテストベンチ
 
How to read linux kernel
How to read linux kernelHow to read linux kernel
How to read linux kernel
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)
 
Pcie basic
Pcie basicPcie basic
Pcie basic
 
Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11
 
ラズパイでデバイスドライバを作ってみた。
ラズパイでデバイスドライバを作ってみた。ラズパイでデバイスドライバを作ってみた。
ラズパイでデバイスドライバを作ってみた。
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
 

Similar to Opaque Pointers Are Coming

LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityBrendan Gregg
 
Exploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET ImplementationExploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET Implementationnkslides
 
Optimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTESOptimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTESSubhajit Sahu
 
Comparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etc
Comparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etcComparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etc
Comparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etcYukio Okuda
 
0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdf0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdfssusere19c741
 
SimpleArray between Python and C++
SimpleArray between Python and C++SimpleArray between Python and C++
SimpleArray between Python and C++Yung-Yu Chen
 
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, InternalsLAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, InternalsLinaro
 
TensorFlow Quantization Tour
TensorFlow Quantization TourTensorFlow Quantization Tour
TensorFlow Quantization TourKSuzukiii
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerMarina Kolpakova
 
MuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CMuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CSusumu Tokumoto
 
Specializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network StackSpecializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network StackKernel TLV
 
A taste of GlobalISel
A taste of GlobalISelA taste of GlobalISel
A taste of GlobalISelIgalia
 

Similar to Opaque Pointers Are Coming (20)

LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF Observability
 
Exploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET ImplementationExploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET Implementation
 
Optimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTESOptimizing Parallel Reduction in CUDA : NOTES
Optimizing Parallel Reduction in CUDA : NOTES
 
Reduction
ReductionReduction
Reduction
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
Comparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etc
Comparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etcComparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etc
Comparing On-The-Fly Accelerating Packages: Numba, TensorFlow, Dask, etc
 
Fedor Polyakov - Optimizing computer vision problems on mobile platforms
Fedor Polyakov - Optimizing computer vision problems on mobile platforms Fedor Polyakov - Optimizing computer vision problems on mobile platforms
Fedor Polyakov - Optimizing computer vision problems on mobile platforms
 
pointers CP Lecture.ppt
pointers CP Lecture.pptpointers CP Lecture.ppt
pointers CP Lecture.ppt
 
0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdf0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdf
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
SimpleArray between Python and C++
SimpleArray between Python and C++SimpleArray between Python and C++
SimpleArray between Python and C++
 
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, InternalsLAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
 
TensorFlow Quantization Tour
TensorFlow Quantization TourTensorFlow Quantization Tour
TensorFlow Quantization Tour
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
 
1. C Basics for Data Structures Bridge Course
1. C Basics for Data Structures   Bridge Course1. C Basics for Data Structures   Bridge Course
1. C Basics for Data Structures Bridge Course
 
MuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CMuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for C
 
Specializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network StackSpecializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network Stack
 
A taste of GlobalISel
A taste of GlobalISelA taste of GlobalISel
A taste of GlobalISel
 
C++_notes.pdf
C++_notes.pdfC++_notes.pdf
C++_notes.pdf
 
Joel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMDJoel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMD
 

More from Nikita Popov

What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?Nikita Popov
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Nikita Popov
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?Nikita Popov
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance TriviaNikita Popov
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Nikita Popov
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Nikita Popov
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language TriviaNikita Popov
 
PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)Nikita Popov
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)Nikita Popov
 
PHP 7 – What changed internally?
PHP 7 – What changed internally?PHP 7 – What changed internally?
PHP 7 – What changed internally?Nikita Popov
 

More from Nikita Popov (10)

What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance Trivia
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
 
PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)PHP 7 – What changed internally? (Forum PHP 2015)
PHP 7 – What changed internally? (Forum PHP 2015)
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)
 
PHP 7 – What changed internally?
PHP 7 – What changed internally?PHP 7 – What changed internally?
PHP 7 – What changed internally?
 

Recently uploaded

maximum subarray ppt for killing camp students
maximum subarray ppt for killing camp studentsmaximum subarray ppt for killing camp students
maximum subarray ppt for killing camp studentsssuser82c38d
 
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이ssuser82c38d
 
Getting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptxGetting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptxmavinoikein
 
killing camp week 6 problem - maximal matrix.pdf
killing camp week 6 problem - maximal matrix.pdfkilling camp week 6 problem - maximal matrix.pdf
killing camp week 6 problem - maximal matrix.pdfssuser82c38d
 
sql ppt for students who preparing for sql
sql ppt for students who preparing for sqlsql ppt for students who preparing for sql
sql ppt for students who preparing for sqlbharatjanadharwarud
 
The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!ISPMAIndia
 
Automation for Bonterra Impact Management (fka Apricot)
Automation for Bonterra Impact Management (fka Apricot)Automation for Bonterra Impact Management (fka Apricot)
Automation for Bonterra Impact Management (fka Apricot)Jeffrey Haguewood
 
Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024Asher Sterkin
 
AUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdf
AUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdfAUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdf
AUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdfAutokey
 
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...ISPMAIndia
 
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ..."Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...ISPMAIndia
 
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A..."Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...ISPMAIndia
 
P1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 SmartsheetP1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 SmartsheetMatthewTHawley
 
SPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product ManagementSPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product ManagementISPMAIndia
 
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)GDSCNiT
 
OpenChain AI Study Group - North America and Europe - 2024-02-20
OpenChain AI Study Group - North America and Europe - 2024-02-20OpenChain AI Study Group - North America and Europe - 2024-02-20
OpenChain AI Study Group - North America and Europe - 2024-02-20Shane Coughlan
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!Anthony Dahanne
 
AI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit BendigiriAI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit BendigiriISPMAIndia
 
The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...
The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...
The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...emili denli
 

Recently uploaded (20)

maximum subarray ppt for killing camp students
maximum subarray ppt for killing camp studentsmaximum subarray ppt for killing camp students
maximum subarray ppt for killing camp students
 
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
killingcamp 광고삽입문제 풀이, killingcamp 광고삽입문제 풀이
 
Getting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptxGetting Started with Trello for Beginners.pptx
Getting Started with Trello for Beginners.pptx
 
killing camp week 6 problem - maximal matrix.pdf
killing camp week 6 problem - maximal matrix.pdfkilling camp week 6 problem - maximal matrix.pdf
killing camp week 6 problem - maximal matrix.pdf
 
sql ppt for students who preparing for sql
sql ppt for students who preparing for sqlsql ppt for students who preparing for sql
sql ppt for students who preparing for sql
 
The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!The Age of AI: Elevating Experiences & Delivering Customer Value!
The Age of AI: Elevating Experiences & Delivering Customer Value!
 
Automation for Bonterra Impact Management (fka Apricot)
Automation for Bonterra Impact Management (fka Apricot)Automation for Bonterra Impact Management (fka Apricot)
Automation for Bonterra Impact Management (fka Apricot)
 
Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024Essence of Requirements Engineering: Pragmatic Insights for 2024
Essence of Requirements Engineering: Pragmatic Insights for 2024
 
AUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdf
AUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdfAUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdf
AUTOKEYUNLOCKER-BRANDS-SUPPORT-STANDARD-VERSION.pdf
 
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
Product Manager vs Product Owner – Why Do Companies Still Struggle 23 Years A...
 
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ..."Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
"Taking an idea to a Product in Health diagnostics" by Dr. Geetha Manjunath, ...
 
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A..."Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
"Discovery and Delivery through Product IntelliGenAI framework" by Ramkumar A...
 
P1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 SmartsheetP1 Inspection Types in Municity 5 Smartsheet
P1 Inspection Types in Municity 5 Smartsheet
 
SPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product ManagementSPM 2024 – Overview of and benefits of AI in Product Management
SPM 2024 – Overview of and benefits of AI in Product Management
 
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
Open Sprintera (Where Open Source Sparks a Sprint of Possibilities)
 
eLearning Content Development Company Code and Pixels.pdf
eLearning Content Development Company Code and Pixels.pdfeLearning Content Development Company Code and Pixels.pdf
eLearning Content Development Company Code and Pixels.pdf
 
OpenChain AI Study Group - North America and Europe - 2024-02-20
OpenChain AI Study Group - North America and Europe - 2024-02-20OpenChain AI Study Group - North America and Europe - 2024-02-20
OpenChain AI Study Group - North America and Europe - 2024-02-20
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!
 
AI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit BendigiriAI Product Management by Abhijit Bendigiri
AI Product Management by Abhijit Bendigiri
 
The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...
The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...
The Game-Changer_ How Software Development Outsource Can Catapult Your Growth...
 

Opaque Pointers Are Coming

  • 1. Opaque Pointers Are Coming Nikita Popov @ LLVM CGO 2022
  • 2. About Me ● Sr. Software Engineer on Platform Tools team at Red Hat ● I maintain the LLVM Compile-Time Tracker 2
  • 3. ptr One PointerType to Rule Them All i8* i32* [0 x i32]* i8* (i8*)* %ty* 3
  • 4. ptr … apart from address spaces i8* i32* i8 addrspace(1)* i32 addrspace(1)* ptr addrspace(1) 4
  • 6. Pointer element types carry no semantics define void @test(i32* %p) 6
  • 7. Pointer element types carry no semantics define void @test(i32* %p) ⇒ Does not imply that %p is 4-byte aligned define void @test(i32* aligned 4 %p) 7
  • 8. Pointer element types carry no semantics define void @test(i32* %p) ⇒ Does not imply that %p is 4-byte aligned define void @test(i32* aligned 4 %p) ⇒ Does not imply that %p is 4-byte dereferenceable define void @test(i32* dereferenceable(4) %p) 8
  • 9. Pointer element types carry no semantics define void @test(i32* %p) ⇒ Does not imply that %p is 4-byte aligned define void @test(i32* aligned 4 %p) ⇒ Does not imply that %p is 4-byte dereferenceable define void @test(i32* dereferenceable(4) %p) ⇒ Does not imply any aliasing semantics (TBAA metadata does) 9
  • 10. Pointer element types carry no semantics define void @test(i32* %p) ⇒ Does not imply that %p is 4-byte aligned define void @test(i32* aligned 4 %p) ⇒ Does not imply that %p is 4-byte dereferenceable define void @test(i32* dereferenceable(4) %p) ⇒ Does not imply any aliasing semantics (TBAA metadata does) ⇒ Does not imply it will be accessed as i32! 10
  • 11. Pointers can be arbitrarily bitcasted define i64 @test(double* byval(double) %p) { %p.p0i8 = bitcast double* %p to i8** store i8* null, i8** %p.p0i8 %p.i64 = bitcast double* %p to i64* %x = load i64, i64** %p.i64 ret i64 %x } 11
  • 12. Only types at certain uses matter define i64 @test(double* byval(double) %p) { %p.p0i8 = bitcast double* %p to i8** store i8* null, i8** %p.p0i8 %p.i64 = bitcast double* %p to i64* %x = load i64, i64** %p.i64 ret i64 %x } 12
  • 13. Only types at certain uses matter define i64 @test(ptr byval(double) %p) { store ptr 0.0, ptr %p %x = load i64, ptr %p ret i64 %x } 13
  • 14. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations 14
  • 15. Compile-Time Improvements (CTMark) Link to data Disclaimer: There may be differences in optimization behavior. 15
  • 16. Compile-Time Improvements (rustc) Link to data Disclaimer: There may be differences in optimization behavior. 16
  • 17. Max-RSS Improvements (rustc) Link to data Disclaimer: There may be differences in optimization behavior. 17
  • 18. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: ○ Optimizations should ignore pointer bitcasts 18
  • 19. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: ○ Optimizations should ignore pointer bitcasts ○ …and many do (e.g. cost models says they’re free) 19
  • 20. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: ○ Optimizations should ignore pointer bitcasts ○ …and many do (e.g. cost models says they’re free) ○ …but many don’t (e.g. limited instruction/use walks) 20
  • 21. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: ○ Bitcasts can’t affect optimization if they don’t exist 21
  • 22. Equivalence modulo pointer type define i32* @test(i8** %p) { store i8* null, i8** %p %p.i32 = bitcast i8** %p to i32** %v = load i32*, i32** %p.i32 ret i32* %v } EarlyCSE can’t optimize this! (But full GVN can.) 22
  • 23. Equivalence modulo pointer type define ptr @test(ptr %p) { store ptr null, ptr %p %v = load ptr, ptr %p ret ptr %v } EarlyCSE can optimize this! 23
  • 24. Equivalence modulo pointer type define ptr @test(ptr %p) { store ptr null, ptr %p %v = load ptr, ptr %p ret ptr %v } ; RUN: opt -S -early-cse < %s define ptr @test(ptr %p) { store ptr null, ptr %p ret ptr null } 24
  • 25. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: ○ Bitcasts can’t affect optimization if they don’t exist ○ Pointer element type difference cannot prevent CSE / forwarding / etc. 25
  • 26. Offset-based reasoning define internal i32 @add({ i32, i32 }* %p) { %p0 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 0 %v0 = load i32, i32* %p0 %p1 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 1 %v1 = load i32, i32* %p1 %add = add i32 %v0, %v1 ret i32 %add } define i32 @caller({ i32, i32 }* %p) { %res = call i32 @add({ i32, i32 }* %p) ret i32 %res } 26
  • 27. Offset-based reasoning ; RUN: opt -S -argpromotion < %s define internal i32 @add(i32 %p.0.val, i32 %p.4.val) { %add = add i32 %p.0.val, %p.4.val ret i32 %add } define i32 @caller({ i32, i32 }* %p) { %1 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 0 %p.val = load i32, i32* %1, align 4 %2 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 1 %p.val1 = load i32, i32* %2, align 4 %res = call i32 @add(i32 %p.val, i32 %p.val1) ret i32 %res } 27
  • 28. Offset-based reasoning ; RUN: opt -S -argpromotion < %s define internal i32 @add(i32 %p.0.val, i32 %p.4.val) { %add = add i32 %p.0.val, %p.4.val ret i32 %add } define i32 @caller({ i32, i32 }* %p) { %1 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 0 %p.val = load i32, i32* %1, align 4 %2 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 1 %p.val1 = load i32, i32* %2, align 4 %res = call i32 @add(i32 %p.val, i32 %p.val1) ret i32 %res } Used to be based on GEP indices 28
  • 29. Getelementptr index ambiguity ; Equivalent despite different indices: getelementptr { [1 x i32], i32 }, ptr %p, i64 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 0 29
  • 30. Getelementptr index ambiguity ; Equivalent despite different indices: getelementptr { [1 x i32], i32 }, ptr %p, i64 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 0 ; Equivalent despite different indices: getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 1, i32 0, i64 -1 30
  • 31. Getelementptr index ambiguity ; Equivalent despite different indices: getelementptr { [1 x i32], i32 }, ptr %p, i64 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 0 ; Equivalent despite different indices: getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 1, i32 0, i64 -1 ⇒ Requires careful restriction to ensure uniqueness ⇒ Can’t support bitcasts 31
  • 32. Getelementptr index ambiguity ; Equivalent despite different indices: getelementptr { [1 x i32], i32 }, ptr %p, i64 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 0 ; Equivalent despite different indices: getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 1, i32 0, i64 -1 ⇒ Requires careful restriction to ensure uniqueness ⇒ Can’t support bitcasts ⇒ Very hard to ensure correctness with opaque pointers 32
  • 33. Offset-based reasoning define internal i32 @add({ i32, i32 }* %p) { %p0 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 0 %v0 = load i32, i32* %p0 ← Load of i32 at offset 0 %p1 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 1 %v1 = load i32, i32* %p1 ← Load of i32 at offset 4 %add = add i32 %v0, %v1 ret i32 %add } define i32 @caller({ i32, i32 }* %p) { %res = call i32 @add({ i32, i32 }* %p) ret i32 %res } 33
  • 34. Offset-based reasoning define internal i32 @add({ i32, i32 }* %p) { %p0 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 0 %v0 = load i32, i32* %p0 ← Load of i32 at offset 0 %p1 = getelementptr { i32, i32 }, { i32, i32 }* %p, i64 0, i32 1 %v1 = load i32, i32* %p1 ← Load of i32 at offset 4 %add = add i32 %v0, %v1 ret i32 %add } define i32 @caller({ i32, i32 }* %p) { %res = call i32 @add({ i32, i32 }* %p) ret i32 %res } Derive “struct type” from access pattern, rather than IR type information 34
  • 35. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: ○ Bitcasts can’t affect optimization if they don’t exist ○ Pointer element type difference cannot prevent CSE / forwarding / etc. ○ Opaque pointers require/encourage generic offset-based reasoning 35
  • 36. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: … ● Implementation simplification: ○ Don’t need to insert bitcasts all over the place 36
  • 37. Type-System recursion %ty = type { %ty* } ⇒ This requires struct types to be mutable 37
  • 38. Type-System recursion %ty = type { %ty* } ⇒ This requires struct types to be mutable %ty = type { ptr } ⇒ All types can be immutable 38
  • 39. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: … ● Implementation simplification: ○ Don’t need to insert bitcasts all over the place ○ Removes recursion from the type system 39
  • 40. Why? ● Memory usage: Don’t need to store bitcasts ● Compile-time: Don’t need to skip bitcasts in optimizations ● Performance: … ● Implementation simplification: ○ Don’t need to insert bitcasts all over the place ○ Removes recursion from the type system ○ Enables follow-up IR changes to remove more types 40
  • 42. IR changes Add explicit type where semantically relevant. load i32* %p load i32, i32* %p getelementptr i32* %p, i64 1 getelementptr i32, i32* %p, i64 1 define void @test(i32* byval %p) define void @test(i32* byval(i32) %p) 42
  • 45. Code changes Use value types: Load->getPointerOperandType()->getPointerElementType() ⇒ Load->getType() Store->getPointerOperandType()->getPointerElementType() ⇒ Store->getValueOperand()->getType() Global->getType()->getPointerElementType() ⇒ Global->getValueType() Call->getType()->getPointerElementType() ⇒ Call->getFunctionType() 45
  • 47. Code changes PointerType::get(ElemTy, AS) still works in opaque pointer mode! The element type is simply ignored. 47
  • 48. Code changes PointerType::get(ElemTy, AS) still works in opaque pointer mode! The element type is simply ignored. ⇒ As long as getPointerElementType() is not called, code usually “just works” in opaque pointer mode. 48
  • 49. Pointer equality does not imply access type equality define ptr @test(ptr %p) { store i32 0, ptr %p %v = load i64, ptr %p ret ptr %v } 49
  • 50. Pointer equality does not imply access type equality define ptr @test(ptr %p) { store i32 0, ptr %p %v = load i64, ptr %p ret ptr %v } Need to explicitly check that load type == store type. Not implied by same pointer operand anymore! 50
  • 51. Frontends Need to track pointer element types in their own structures now – can’t rely on LLVM PointerType! 51
  • 52. Frontends Need to track pointer element types in their own structures now – can’t rely on LLVM PointerType! Clang: Address, LValue, RValue store pointer element type now. 52
  • 53. Opaque pointer mode Automatically enabled if you use ptr in IR or bitcode. 53
  • 54. Opaque pointer mode Automatically enabled if you use ptr in IR or bitcode. Manually enabled with -opaque-pointers. define i32* @test(i32* %p) ret i32* %p } 54
  • 55. Opaque pointer mode Automatically enabled if you use ptr in IR or bitcode. Manually enabled with -opaque-pointers. define i32* @test(i32* %p) ret i32* %p } ; RUN: opt -S -opaque-pointers < %s define ptr @test(ptr %p) ret ptr %p } 55
  • 56. Opaque pointer mode Automatically enabled if you use ptr in IR or bitcode. Manually enabled with -opaque-pointers. Upgrading (very old) bitcode to opaque pointers is supported! 56
  • 57. Migration ● Proposed by David Blaikie in 2015 57
  • 58. Migration ● Proposed by David Blaikie in 2015 ● Massive migration scope, with many hundreds of direct and indirect pointer element type uses across the code base. ○ Some trivial to remove. ○ Some require IR changes or full transform rewrites. 58
  • 59. Migration ● Proposed by David Blaikie in 2015 ● Massive migration scope, with many hundreds of direct and indirect pointer element type uses across the code base. ○ Some trivial to remove. ○ Some require IR changes or full transform rewrites. ● Opaque pointer type ptr only introduced in 2021 by Arthur Eubanks 59
  • 60. Migration ● Proposed by David Blaikie in 2015 ● Massive migration scope, with many hundreds of direct and indirect pointer element type uses across the code base. ○ Some trivial to remove. ○ Some require IR changes or full transform rewrites. ● Opaque pointer type ptr only introduced in 2021 by Arthur Eubanks ● Now (end of March 2022): All pointer element type accesses in LLVM and Clang eradicated. 60
  • 61. Migration ● Proposed by David Blaikie in 2015 ● Massive migration scope, with many hundreds of direct and indirect pointer element type uses across the code base. ○ Some trivial to remove. ○ Some require IR changes or full transform rewrites. ● Opaque pointer type ptr only introduced in 2021 by Arthur Eubanks ● Now (end of March 2022): All pointer element type accesses in LLVM and Clang eradicated. ● Next step: Enable opaque pointers by default. ○ Caveat: Requires updating ~7k tests. 61
  • 62. Migration ● Proposed by David Blaikie in 2015 ● Massive migration scope, with many hundreds of direct and indirect pointer element type uses across the code base. ○ Some trivial to remove. ○ Some require IR changes or full transform rewrites. ● Opaque pointer type ptr only introduced in 2021 by Arthur Eubanks ● Now (end of March 2022): All pointer element type accesses in LLVM and Clang eradicated. ● Next step: Enable opaque pointers by default. ○ Caveat: Requires updating ~7k tests. ● Typed pointers expected to be removed after LLVM 15 branch. 62
  • 63. Future: Type-less GEP All of these are equivalent: getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 1, i32 0, i64 -1 63
  • 64. Future: Type-less GEP All of these are equivalent: getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 1, i32 0, i64 -1 getelementptr i32, ptr %p, i64 1 getelementptr i8, ptr %p, i64 4 64
  • 65. Future: Type-less GEP All of these are equivalent: getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 0, i32 0, i64 1 getelementptr { [1 x i32], i32 }, ptr %p, i64 1, i32 0, i64 -1 getelementptr i32, ptr %p, i64 1 getelementptr i8, ptr %p, i64 4 Offset-based algorithms will realize these are equivalent, but… 65
  • 66. Future: Type-less GEP Nothing in the -O3 pipeline realizes that %p1 and %p2 can be CSEd: define void @test(ptr %p) { %p1 = getelementptr i8, ptr %p, i64 4 %p2 = getelementptr i32, ptr %p, i64 1 call void @use(ptr %p1, ptr %p2) ret void } 66
  • 67. Future: Type-less GEP Offset-based GEP makes these trivially equivalent: define void @test(ptr %p) { %p1 = getelementptr ptr %p, i64 4 %p2 = getelementptr ptr %p, i64 4 call void @use(ptr %p1, ptr %p2) ret void } 67
  • 68. Future: Type-less GEP How far should we go? %p.idx = getelementptr ptr %p, 4 * i64 %idx ; or %off = shl i64 %idx, 2 %p.idx = getelementptr ptr %p, i64 %off 68
  • 69. The End ● Docs: https://llvm.org/docs/OpaquePointers.html ● Reach me at: ○ npopov@redhat.com ○ https://twitter.com/nikita_ppv 69