Help: annotate unsafe code in LLVM IR

Hello,

I am building a static analysis tool which gets LLVM IR as input. I want to know which Basic blocks map to an unsafe scope in the source program.

AFAICT this information is not present in LLVM IR and doesn't seem to be present in MIR also. I am looking for

  1. Is there a known method to retain this information in LLVM IR?
  2. If nothing exists, how might I might go about mapping an unsafe code block/function to it equivalent LLVM IR?

thanks
Siddharth

You might get more help asking on the internals forum. IIRC the unsafe keyword doesn't actually do anything beyond being a surface level lint. So there's no reason to keep the information around once a file has been parsed.

2 Likes

Thank you. I've posted a question here: Annotate unsafe code in LLVM IR - compiler - Rust Internals

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.