Skip to content

Disable santizers on constructors. #111960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/Utils/ModuleUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ bool llvm::lowerGlobalIFuncUsersAsGlobalCtor(
FunctionType::get(Type::getVoidTy(Ctx), false), Function::InternalLinkage,
DL.getProgramAddressSpace(), "", &M);

// Disable Sanitizers as they might not yet initialized when the contructor
// runs.
NewCtor->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);

BasicBlock *BB = BasicBlock::Create(Ctx, "", NewCtor);
IRBuilder<> InitBuilder(BB);

Expand Down
3 changes: 2 additions & 1 deletion llvm/test/tools/llvm-reduce/ifunc-alias.ll
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ define float @call_alias_of_ifunc(i64 %arg) {
ret float %call
}

; CHECK-FINAL-BOTH: define internal void [[CONSTRUCTOR]]() {
; CHECK-FINAL-BOTH: define internal void [[CONSTRUCTOR]]() #[[#CONSTRUCTOR_ATTR:]] {
; CHECK-FINAL-BOTH-NEXT: %1 = call ptr @resolver()
; CHECK-FINAL-BOTH-NEXT: store ptr %1, ptr [[TABLE]], align 8
; CHECK-FINAL-BOTH-NEXT: %2 = call ptr @resolver()
; CHECK-FINAL-BOTH-NEXT: store ptr %2, ptr getelementptr inbounds ([2 x ptr], ptr [[TABLE]], i32 0, i32 1), align 8
; CHECK-FINAL-BOTH-NEXT: ret void
; CHECK-FINAL-DAG: attributes #[[#CONSTRUCTOR_ATTR]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ define void @load_removed() addrspace(0) {
ret void
}

; CHECK-FINAL: define internal void [[TABLE_CTOR]]() addrspace(1) {
; CHECK-FINAL: define internal void [[TABLE_CTOR]]() addrspace(1) #[[#CONSTRUCTOR_ATTR:]] {
; CHECK-FINAL-NEXT: %1 = call addrspace(1) ptr addrspace(1) @resolver1_in_1()
; CHECK-FINAL-NEXT: store ptr addrspace(1) %1, ptr addrspace(2) [[TABLE]], align 8
; CHECK-FINAL-NEXT: %2 = call addrspace(0) ptr addrspace(1) @resolver1_in_0()
Expand All @@ -105,3 +105,4 @@ define void @load_removed() addrspace(0) {
; CHECK-FINAL-NEXT: %7 = call addrspace(0) ptr addrspace(1) @resolver1_in_0()
; CHECK-FINAL-NEXT: store ptr addrspace(1) %7, ptr addrspace(2) getelementptr inbounds ([6 x ptr addrspace(1)], ptr addrspace(2) [[TABLE]], i32 0, i32 5), align 8
; CHECK-FINAL-NEXT: ret void
; CHECK-FINAL-DAG: attributes #[[#CONSTRUCTOR_ATTR]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
3 changes: 2 additions & 1 deletion llvm/test/tools/llvm-reduce/remove-ifunc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ define i32 @call_used_in_initializer(double %arg) {
ret i32 %ret
}

; CHECK-FINAL-LABEL: define internal void @1() {
; CHECK-FINAL-LABEL: define internal void @1() #[[#CONSTRUCTOR_ATTR:]] {
; CHECK-FINAL-NEXT: %1 = call ptr @resolver1()
; CHECK-FINAL-NEXT: store ptr %1, ptr @0, align 8
; CHECK-FINAL-NEXT: %2 = call ptr @resolver2()
Expand All @@ -196,3 +196,4 @@ define i32 @call_used_in_initializer(double %arg) {
; CHECK-FINAL-NEXT: store ptr %8, ptr getelementptr inbounds ([8 x ptr], ptr @0, i32 0, i32 7), align 8
; CHECK-FINAL-NEXT: ret void
; CHECK-FINAL-NEXT: }
; CHECK-FINAL-DAG: attributes #[[#CONSTRUCTOR_ATTR]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
Loading