How Pragma Unroll works in clang and llvm

I am trying to understand how Pragma Unroll is implemented in clang and llvm.

According to my understanding, this pragma is processed and new token
is generated in clang/lib/Parse/ParsePragma.cpp
PragmaUnrollHintHandler::HandlePragma function.
Then the token is processed in *handleLoopHintAttr in
clang/lib/Sema/SemaStmtAttr.cpp file.

But its not clear to me how this information is parsed to LLVM and processed.
1. Can someone explain this procedure?
2. Are their any other materials I can follow except the source code
to understand this better?


clang annotates the IR for the loop with metadata, then the loop unroll pass uses that metadata to unroll the loop as requested. See for a description of the metadata. If you want to read the related code, grep for "llvm.loop.unroll".