From 117ecdd5789e6efd28505a8b84680020fd935cd1 Mon Sep 17 00:00:00 2001 From: Gulfem Savrun Yeniceri Date: Sat, 14 Jan 2023 00:48:32 +0000 Subject: [PATCH] [IRLinker] Replace CallInstr with CallBase This patch replaces CallInstr with CallBase to cover InvokeInstr besides CallInstr while removing nocallback attribute on a call site. It also extends drop-attribute.ll test to include a case for an invoke instruction. Differential Revision: https://reviews.llvm.org/D141740 --- llvm/lib/Linker/IRMover.cpp | 2 +- llvm/test/Linker/drop-attribute.ll | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 322afb9..517e2dc 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -1555,7 +1555,7 @@ void IRLinker::updateAttributes(GlobalValue &GV) { // Remove nocallback attribute when it is on a call-site. for (BasicBlock &BB : *F) for (Instruction &I : BB) - if (CallInst *CI = dyn_cast(&I)) + if (CallBase *CI = dyn_cast(&I)) CI->removeFnAttr(Attribute::NoCallback); } } diff --git a/llvm/test/Linker/drop-attribute.ll b/llvm/test/Linker/drop-attribute.ll index 8e74252..9be95a8 100644 --- a/llvm/test/Linker/drop-attribute.ll +++ b/llvm/test/Linker/drop-attribute.ll @@ -5,18 +5,26 @@ ; CHECK: define i32 @main() ; CHECK-NEXT: entry: ; CHECK-NEXT: call void @test_nocallback_definition() -; Test that checks that nocallback attribute on a call-site is dropped. +; Test that checks that nocallback attribute on a call-site in a call instruction is dropped. ; CHECK-NEXT: call void @test_nocallback_call_site(){{$}} ; CHECK-NEXT: %0 = call float @llvm.sqrt.f32(float undef) ; CHECK-NEXT: call void @test_nocallback_declaration_definition_not_linked_in() ; CHECK-NEXT: call void @test_nocallback_declaration_definition_linked_in() -define i32 @main() { +; Test that checks that nocallback attribute on a call-site in an invoke instruction is dropped. +; CHECK-NEXT: invoke void @test_nocallback_call_site(){{$}} +define i32 @main() personality i8 0 { entry: call void @test_nocallback_definition() call void @test_nocallback_call_site() nocallback call float @llvm.sqrt.f32(float undef) call void @test_nocallback_declaration_definition_not_linked_in() call void @test_nocallback_declaration_definition_linked_in() + invoke void @test_nocallback_call_site() nocallback + to label %ret unwind label %unw +unw: + %tmp = landingpad i8 cleanup + br label %ret +ret: ret i32 0 } @@ -26,7 +34,7 @@ define void @test_nocallback_definition() nocallback { ret void } -; Test that checks that nocallback attribute on a declaration when a definition is linked in is dropped. +; Test that checks that nocallback attribute on a call site is dropped. ; CHECK: declare void @test_nocallback_call_site(){{$}} declare void @test_nocallback_call_site() -- 2.7.4