How ubsan inserts checking code to detect undefined behaviors?

Dear list,

I know that unsan can detect certain number of undefined behaviors at runtime.

When compiling the program with option -fsanitize=undefined, some checking code
will be inserted into the necessary position. I looked at the source code of ubsan,
but failed to find the code that performs the instrumentation.

I’m trying to understand how ubsan works by looking at its source code.

Does anybody know where is the corresponding source code located?

Thanks in advance.

Dear list,
I know that unsan can detect certain number of undefined behaviors at
runtime.
When compiling the program with option -fsanitize=undefined, some checking
code
will be inserted into the necessary position. I looked at the source code
of ubsan,

I assume you mean the ubsan runtime in compiler_rt?

but failed to find the code that performs the instrumentation.
I'm trying to understand how ubsan works by looking at its source code.
Does anybody know where is the corresponding source code located?

The code that inserts the instrumentation is spread throughout Clang's
lib/CodeGen. Search for calls to EmitCheck.