[llvm] Disable santizers on constructors. (PR #111960)
Daniel Kiss via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 11 06:29:38 PDT 2024
https://github.com/DanielKristofKiss updated https://github.com/llvm/llvm-project/pull/111960
>From a2244f55982968c24009014a038daa4afadfa375 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Fri, 11 Oct 2024 00:23:27 +0200
Subject: [PATCH 1/2] Disable santizers on contstructors.
---
llvm/lib/Transforms/Utils/ModuleUtils.cpp | 4 ++++
llvm/test/tools/llvm-reduce/ifunc-alias.ll | 3 ++-
llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll | 3 ++-
llvm/test/tools/llvm-reduce/remove-ifunc.ll | 3 ++-
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 7249571f344938..5358fc2c77f28c 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -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 initilised when the contructor
+ // runs.
+ NewCtor->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
+
BasicBlock *BB = BasicBlock::Create(Ctx, "", NewCtor);
IRBuilder<> InitBuilder(BB);
diff --git a/llvm/test/tools/llvm-reduce/ifunc-alias.ll b/llvm/test/tools/llvm-reduce/ifunc-alias.ll
index 258eb00383f7e6..01337a7abc0f1b 100644
--- a/llvm/test/tools/llvm-reduce/ifunc-alias.ll
+++ b/llvm/test/tools/llvm-reduce/ifunc-alias.ll
@@ -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 {{.*}}
diff --git a/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll b/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll
index e275d61764b216..c76fa10f393297 100644
--- a/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll
+++ b/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll
@@ -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()
@@ -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 {{.*}}
\ No newline at end of file
diff --git a/llvm/test/tools/llvm-reduce/remove-ifunc.ll b/llvm/test/tools/llvm-reduce/remove-ifunc.ll
index a7853d937d9a65..62e2e2b5af771a 100644
--- a/llvm/test/tools/llvm-reduce/remove-ifunc.ll
+++ b/llvm/test/tools/llvm-reduce/remove-ifunc.ll
@@ -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()
@@ -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 {{.*}}
\ No newline at end of file
>From 19230ac8c0152bc4c3272d382bf2a1cfd0cbc76d Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Fri, 11 Oct 2024 15:28:58 +0200
Subject: [PATCH 2/2] Address review comments
---
llvm/lib/Transforms/Utils/ModuleUtils.cpp | 2 +-
llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll | 2 +-
llvm/test/tools/llvm-reduce/remove-ifunc.ll | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 5358fc2c77f28c..208d49da04a377 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -433,7 +433,7 @@ bool llvm::lowerGlobalIFuncUsersAsGlobalCtor(
FunctionType::get(Type::getVoidTy(Ctx), false), Function::InternalLinkage,
DL.getProgramAddressSpace(), "", &M);
- // Disable Sanitizers as they might not yet initilised when the contructor
+ // Disable Sanitizers as they might not yet initialized when the contructor
// runs.
NewCtor->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
diff --git a/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll b/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll
index c76fa10f393297..450448d11c6a6f 100644
--- a/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll
+++ b/llvm/test/tools/llvm-reduce/remove-ifunc-program-addrspace.ll
@@ -105,4 +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 {{.*}}
\ No newline at end of file
+; CHECK-FINAL-DAG: attributes #[[#CONSTRUCTOR_ATTR]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
diff --git a/llvm/test/tools/llvm-reduce/remove-ifunc.ll b/llvm/test/tools/llvm-reduce/remove-ifunc.ll
index 62e2e2b5af771a..33cadd134245aa 100644
--- a/llvm/test/tools/llvm-reduce/remove-ifunc.ll
+++ b/llvm/test/tools/llvm-reduce/remove-ifunc.ll
@@ -196,4 +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 {{.*}}
\ No newline at end of file
+; CHECK-FINAL-DAG: attributes #[[#CONSTRUCTOR_ATTR]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
More information about the llvm-commits
mailing list