Created
May 24, 2025 08:41
-
-
Save romainthomas/1f7ba555c4439d9b4b457e293834ec5a to your computer and use it in GitHub Desktop.
Creating a DWARF stack-based variable with LLVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Variable& Variable::set_stack_offset(uint64_t offset) { | |
llvm::BumpPtrAllocator& allocator = editor_->allocator(); | |
auto* loc = new (allocator) llvm::DIELoc{}; | |
loc->addValue(allocator, (llvm::dwarf::Attribute)0, llvm::dwarf::DW_FORM_data1, | |
llvm::DIEInteger(llvm::dwarf::DW_OP_fbreg)); | |
loc->addValue(allocator, (llvm::dwarf::Attribute)0, llvm::dwarf::DW_FORM_sdata, | |
llvm::DIEInteger(-offset)); | |
loc->computeSize(editor_->streamer().getAsmPrinter().getDwarfFormParams()); | |
die_->addValue(allocator, llvm::dwarf::DW_AT_location, | |
llvm::dwarf::DW_FORM_exprloc, loc); | |
return *this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment