[all-commits] [llvm/llvm-project] 14ce56: [DFSan] Add `zeroext` attribute for callbacks with...

Lu Weining via All-commits all-commits at lists.llvm.org
Wed Dec 28 19:52:09 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 14ce567fa267cce9466354bed1549a83286866b1
  Author: Weining Lu <luweining at loongson.cn>
  Date:   2022-12-29 (Thu, 29 Dec 2022)

  Changed paths:
    M llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
    M llvm/test/Instrumentation/DataFlowSanitizer/array.ll
    M llvm/test/Instrumentation/DataFlowSanitizer/basic.ll
    M llvm/test/Instrumentation/DataFlowSanitizer/callback.ll
    M llvm/test/Instrumentation/DataFlowSanitizer/reaches_function.ll
    M llvm/test/Instrumentation/DataFlowSanitizer/struct.ll

  Log Message:
  [DFSan] Add `zeroext` attribute for callbacks with 8bit shadow variable arguments

Add `zeroext` attribute for below callbacks' first parameter
(8bit shadow variable arguments) to conform to many platforms'
ABI calling convention and some compiler behavior.
- __dfsan_load_callback
- __dfsan_store_callback
- __dfsan_cmp_callback
- __dfsan_conditional_callback
- __dfsan_conditional_callback_origin
- __dfsan_reaches_function_callback
- __dfsan_reaches_function_callback_origin

The type of these callbacks' first parameter is u8 (see the
definition of `dfsan_label`). First, many platforms' ABI
requires unsigned integer data types (except unsigned int)
are zero-extended when stored in general-purpose register.
Second, the problem is that compiler optimization may assume
the arguments are zero-extended and, if not, misbehave, e.g.
it uses an `i8` argument to index into a jump table. If the
argument has non-zero high bits, the output executable may
crash at run-time. So we need to add the `zeroext` attribute
when declaring and calling them.

Reviewed By: browneee, MaskRay

Differential Revision: https://reviews.llvm.org/D140689

More information about the All-commits mailing list