JonPsson1 wrote:
For example, clang now reported:
```
ERROR: Missing extension attribute of passed value in call to function:
Callee: void @__tysan_instrument_mem_inst(ptr, ptr, i64, i1)
```
```
define dso_local signext i32 @main() #0 !dbg !5 {
entry:
%u = alloca %union.anon, align 4
store i32 42, ptr %u, align 4, !dbg !10, !tbaa !15
store i16 1, ptr %u, align 4, !dbg !17, !tbaa !15
%0 = load i32, ptr %u, align 4, !dbg !23, !tbaa !15
%call = call signext i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef
signext %0), !dbg !20
ret i32 0, !dbg !24
}
; *** IR Dump After TypeSanitizerPass on [module] ***
; Function Attrs: noinline nounwind optnone sanitize_type uwtable
define dso_local signext i32 @main() #0 !dbg !5 {
entry:
%app.mem.mask = load i64, ptr @__tysan_app_memory_mask, align 8
%shadow.base = load i64, ptr @__tysan_shadow_memory_address, align 8
%u = alloca %union.anon, align 4, !dbg !10
call void @__tysan_instrument_mem_inst(ptr %u, ptr null, i64 4, i1 false),
!dbg !10
call void @__tysan_instrument_with_shadow_update(ptr %u, ptr
@__tysan_v1_omnipotent_20char_o_0, i1 true, i64 4, i32 2), !dbg !10
store i32 42, ptr %u, align 4, !dbg !10, !tbaa !15
call void @__tysan_instrument_with_shadow_update(ptr %u, ptr
@__tysan_v1_omnipotent_20char_o_0, i1 true, i64 2, i32 2), !dbg !17
store i16 1, ptr %u, align 4, !dbg !17, !tbaa !15
call void @__tysan_instrument_with_shadow_update(ptr %u, ptr
@__tysan_v1_omnipotent_20char_o_0, i1 true, i64 4, i32 1), !dbg !23
%0 = load i32, ptr %u, align 4, !dbg !23, !tbaa !15
%call = call signext i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef
signext %0), !dbg !20
ret i32 0, !dbg !24
}
declare void @__tysan_instrument_mem_inst(ptr, ptr, i64, i1) #3
...
```
In TypeSanitizer.cpp:
```
TysanIntrumentMemInst = M.getOrInsertFunction(
"__tysan_instrument_mem_inst", Attr, IRB.getVoidTy(),
IRB.getPtrTy(), // Pointer of data to be written to
IRB.getPtrTy(), // Pointer of data to write
U64Ty, // Size of the data in bytes
BoolType // Do we need to call memmove
);
...
IRB.CreateCall(
TysanIntrumentMemInst,
{Dest, Src, Size64, NeedsMemMove ? IRB.getTrue() : IRB.getFalse()});
```
Per my understanding this is a function that the TypeSanitizer inserts into the
compiled function in order to do its checking. That function is contained in
compiler-rt/lib/tysan/tysan.cpp:
```
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__tysan_instrument_mem_inst(char *dest, char *src, uint64_t size,
bool needsMemMove) {
...
```
One solution would be to add a zext attribute to the boolean arg with
CreateCall(), and maybe that is preferred, but there are however many cases of
this, so if this could be considered an internal function (and detected in the
backend check as such), there would be no need. If tysan.cpp is guaranteed to
be compiled with clang, I think it is safe to ignore this, as long as we don't
rely on those extention attributes ourselves. I think this is the case after
the move of compiler-rt from ENABLE_PROJECTS to ENABLE_RUNTIMES, but I am not
sure that it is not possible to use another build configuration.
OTOH, it's not that difficult to add the extension attributes, and if there is
no generic "isInstrumentedRTFunction()" or similar to use, maybe this would
still be preferred.
https://github.com/llvm/llvm-project/pull/223755
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits