[llvm] e2e9e70 - [Coroutine] Remove the '!func_sanitize' metadata for split functions
Yuanfang Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 12:11:55 PDT 2022
Author: Yuanfang Chen
Date: 2022-06-27T12:09:13-07:00
New Revision: e2e9e708e5c2c3d5357b4bb355285ef55cd060d9
URL: https://github.com/llvm/llvm-project/commit/e2e9e708e5c2c3d5357b4bb355285ef55cd060d9
DIFF: https://github.com/llvm/llvm-project/commit/e2e9e708e5c2c3d5357b4bb355285ef55cd060d9.diff
LOG: [Coroutine] Remove the '!func_sanitize' metadata for split functions
There is no proper RTTI for these split functions. So just delete the
metadata.
Fixes https://github.com/llvm/llvm-project/issues/49689.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D116130
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-split-00.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 0516edb4aab7a..ba85691c6214d 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -926,6 +926,12 @@ void CoroCloner::create() {
NewF->setVisibility(savedVisibility);
NewF->setUnnamedAddr(savedUnnamedAddr);
NewF->setDLLStorageClass(savedDLLStorageClass);
+ // The function sanitizer metadata needs to match the signature of the
+ // function it is being attached to. However this does not hold for split
+ // functions here. Thus remove the metadata for split functions.
+ if (Shape.ABI == coro::ABI::Switch &&
+ NewF->hasMetadata(LLVMContext::MD_func_sanitize))
+ NewF->eraseMetadata(LLVMContext::MD_func_sanitize);
// Replace the attributes of the new function:
auto OrigAttrs = NewF->getAttributes();
diff --git a/llvm/test/Transforms/Coroutines/coro-split-00.ll b/llvm/test/Transforms/Coroutines/coro-split-00.ll
index 7f5259922c0f3..c34313aef59b1 100644
--- a/llvm/test/Transforms/Coroutines/coro-split-00.ll
+++ b/llvm/test/Transforms/Coroutines/coro-split-00.ll
@@ -1,7 +1,7 @@
; Tests that coro-split pass splits the coroutine into f, f.resume and f.destroy
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
-define i8* @f() presplitcoroutine {
+define i8* @f() presplitcoroutine !func_sanitize !0 {
entry:
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
%need.alloc = call i1 @llvm.coro.alloc(token %id)
@@ -32,7 +32,7 @@ suspend:
ret i8* %hdl
}
-; CHECK-LABEL: @f(
+; CHECK-LABEL: @f() !func_sanitize !0 {
; CHECK: call i8* @malloc
; CHECK: @llvm.coro.begin(token %id, i8* %phi)
; CHECK: store void (%f.Frame*)* @f.resume, void (%f.Frame*)** %resume.addr
@@ -43,7 +43,7 @@ suspend:
; CHECK-NOT: call void @free(
; CHECK: ret i8* %hdl
-; CHECK-LABEL: @f.resume(
+; CHECK-LABEL: @f.resume({{.*}}) {
; CHECK-NOT: call i8* @malloc
; CHECK-NOT: call void @print(i32 0)
; CHECK: call void @print(i32 1)
@@ -51,13 +51,13 @@ suspend:
; CHECK: call void @free(
; CHECK: ret void
-; CHECK-LABEL: @f.destroy(
+; CHECK-LABEL: @f.destroy({{.*}}) {
; CHECK-NOT: call i8* @malloc
; CHECK-NOT: call void @print(
; CHECK: call void @free(
; CHECK: ret void
-; CHECK-LABEL: @f.cleanup(
+; CHECK-LABEL: @f.cleanup({{.*}}) {
; CHECK-NOT: call i8* @malloc
; CHECK-NOT: call void @print(
; CHECK-NOT: call void @free(
@@ -77,3 +77,5 @@ declare i1 @llvm.coro.end(i8*, i1)
declare noalias i8* @malloc(i32)
declare void @print(i32)
declare void @free(i8*) willreturn
+
+!0 = !{i32 846595819, i8** null}
More information about the llvm-commits
mailing list