[llvm] 1ae36b1 - Remove special cases for invoke of non-throwing inline-asm.
James Y Knight via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 10:53:32 PST 2023
Author: James Y Knight
Date: 2023-01-06T13:53:10-05:00
New Revision: 1ae36b1387e4d023cc00aaa6139bcd90b2e48ff4
URL: https://github.com/llvm/llvm-project/commit/1ae36b1387e4d023cc00aaa6139bcd90b2e48ff4
DIFF: https://github.com/llvm/llvm-project/commit/1ae36b1387e4d023cc00aaa6139bcd90b2e48ff4.diff
LOG: Remove special cases for invoke of non-throwing inline-asm.
Non-throwing inline asm infers the nounwind attribute in
instcombine. Thus, it can be handled in the same manner as
non-throwing target functions are generally. Further special casing is
unnecessary complexity.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-unwind-inline-asm.ll
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-unwind-inline-asm.ll
llvm/test/Transforms/Inline/inline-invoke-with-asm-call.ll
llvm/test/Transforms/Inline/no-unwind-inline-asm.ll
Removed:
llvm/test/CodeGen/X86/no-seh-unwind-inline-asm-codegen.ll
llvm/test/CodeGen/X86/no-unwind-inline-asm-codegen.ll
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 9494a3e94a7d0..31b5c7cfd2f70 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -2591,9 +2591,6 @@ bool IRTranslator::translateInvoke(const User &U,
bool LowerInlineAsm = I.isInlineAsm();
bool NeedEHLabel = true;
- // If it can't throw then use a fast-path without emitting EH labels.
- if (LowerInlineAsm)
- NeedEHLabel = (cast<InlineAsm>(I.getCalledOperand()))->canThrow();
// Emit the actual call, bracketed by EH_LABELs so that the MF knows about
// the region covered by the try.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 1b514231fa844..954628d779f30 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -8896,7 +8896,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
// memory and is nonvolatile.
SDValue Flag, Chain = (HasSideEffect) ? getRoot() : DAG.getRoot();
- bool EmitEHLabels = isa<InvokeInst>(Call) && IA->canThrow();
+ bool EmitEHLabels = isa<InvokeInst>(Call);
if (EmitEHLabels) {
assert(EHPadBB && "InvokeInst must have an EHPadBB");
}
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index a429b0d56ed57..6aaaa33cebdec 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -550,13 +550,6 @@ static BasicBlock *HandleCallsInBlockInlinedThroughInvoke(
if (!CI || CI->doesNotThrow())
continue;
- if (CI->isInlineAsm()) {
- InlineAsm *IA = cast<InlineAsm>(CI->getCalledOperand());
- if (!IA->canThrow()) {
- continue;
- }
- }
-
// We do not need to (and in fact, cannot) convert possibly throwing calls
// to @llvm.experimental_deoptimize (resp. @llvm.experimental.guard) into
// invokes. The caller's "segment" of the deoptimization continuation
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-unwind-inline-asm.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-unwind-inline-asm.ll
index 7f008bccd6ab5..33e842ac535e2 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-unwind-inline-asm.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-no-unwind-inline-asm.ll
@@ -16,9 +16,9 @@ entry:
; CHECK-LABEL: name: test
; CHECK: body:
; CHECK-NEXT: bb.1.entry
-; CHECK-NOT: EH_LABEL
+; CHECK: EH_LABEL
; CHECK: INLINEASM
-; CHECK-NOT: EH_LABEL
+; CHECK: EH_LABEL
invoke void asm sideeffect "bl trap", ""()
to label %invoke.cont unwind label %lpad
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-unwind-inline-asm.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-unwind-inline-asm.ll
index 7f6139feca782..bb7c9e274814e 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-unwind-inline-asm.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-unwind-inline-asm.ll
@@ -68,8 +68,11 @@ define void @test2() #0 personality ptr @__gcc_personality_v0 {
; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p0) = G_IMPLICIT_DEF
+ ; CHECK-NEXT: G_INVOKE_REGION_START
+ ; CHECK-NEXT: EH_LABEL <mcsymbol >
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64common = COPY [[DEF]](p0)
; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */, 2555913 /* reguse:GPR64common */, [[COPY]]
+ ; CHECK-NEXT: EH_LABEL <mcsymbol >
; CHECK-NEXT: G_BR %bb.2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.2.a:
diff --git a/llvm/test/CodeGen/X86/no-seh-unwind-inline-asm-codegen.ll b/llvm/test/CodeGen/X86/no-seh-unwind-inline-asm-codegen.ll
deleted file mode 100644
index 1f93220fb1eb6..0000000000000
--- a/llvm/test/CodeGen/X86/no-seh-unwind-inline-asm-codegen.ll
+++ /dev/null
@@ -1,58 +0,0 @@
-; RUN: llc < %s | FileCheck %s
-
-target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc19.28.29914"
-
- at str = private unnamed_addr constant [6 x i8] c"Boom!\00", align 1
-
-define dso_local void @trap() {
-entry:
- unreachable
-}
-
-define dso_local void @test() personality ptr @__CxxFrameHandler3 {
-entry:
-
-; CHECK-NOT: .Ltmp0:
-; CHECK: callq trap
-; CHECK-NOT: .Ltmp1:
-
- invoke void asm sideeffect "call trap", "~{dirflag},~{fpsr},~{flags}"()
- to label %exit unwind label %except
-
-exit:
- ret void
-
-except:
-
-; CHECK-LABEL: "?dtor$2@?0?test at 4HA":
-; CHECK: callq printf
-
- %0 = cleanuppad within none []
- call void (ptr, ...) @printf(ptr @str) [ "funclet"(token %0) ]
- cleanupret from %0 unwind to caller
-}
-
-declare dso_local i32 @__CxxFrameHandler3(...)
-
-declare dso_local void @printf(ptr, ...)
-
-; SEH Table
-
-; CHECK-LABEL: $cppxdata$test:
-; CHECK-NEXT: .long 429065506 # MagicNumber
-; CHECK-NEXT: .long 1 # MaxState
-; CHECK-NEXT: .long ($stateUnwindMap$test)@IMGREL # UnwindMap
-; CHECK-NEXT: .long 0 # NumTryBlocks
-; CHECK-NEXT: .long 0 # TryBlockMap
-; CHECK-NEXT: .long 1 # IPMapEntries
-; CHECK-NEXT: .long ($ip2state$test)@IMGREL # IPToStateXData
-; CHECK-NEXT: .long 40 # UnwindHelp
-; CHECK-NEXT: .long 0 # ESTypeList
-; CHECK-NEXT: .long 1 # EHFlags
-; CHECK-NEXT:$stateUnwindMap$test:
-; CHECK-NEXT: .long -1 # ToState
-; CHECK-NEXT: .long "?dtor$2@?0?test at 4HA"@IMGREL # Action
-; CHECK-NEXT:$ip2state$test:
-; CHECK-NEXT: .long .Lfunc_begin0 at IMGREL # IP
-; CHECK-NEXT: .long -1 # ToState
diff --git a/llvm/test/CodeGen/X86/no-unwind-inline-asm-codegen.ll b/llvm/test/CodeGen/X86/no-unwind-inline-asm-codegen.ll
deleted file mode 100644
index 3a093d94a65a1..0000000000000
--- a/llvm/test/CodeGen/X86/no-unwind-inline-asm-codegen.ll
+++ /dev/null
@@ -1,51 +0,0 @@
-; RUN: llc < %s | FileCheck %s
-
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
- at .str.2 = private unnamed_addr constant [7 x i8] c"Boom!\0A\00", align 1
-
-define dso_local void @trap() {
-entry:
- unreachable
-}
-
-define dso_local void @test() personality ptr @__gxx_personality_v0 {
-entry:
-
-; CHECK-NOT: .Ltmp0:
-; CHECK: callq trap
-; CHECK-NOT: .Ltmp1:
-
- invoke void asm sideeffect "call trap", "~{dirflag},~{fpsr},~{flags}"()
- to label %invoke.cont unwind label %lpad
-
-invoke.cont:
- ret void
-
-lpad:
- %0 = landingpad { ptr, i32 }
- cleanup
- call void (ptr, ...) @printf(ptr @.str.2)
- resume { ptr, i32 } %0
-
-}
-
-declare dso_local i32 @__gxx_personality_v0(...)
-
-declare dso_local void @printf(ptr, ...)
-
-; Exception table generation around the inline assembly shouldn't exist
-
-; CHECK-LABEL: GCC_except_table1:
-; CHECK-NEXT: .Lexception0:
-; CHECK-NEXT: .byte 255 # @LPStart Encoding = omit
-; CHECK-NEXT: .byte 255 # @TType Encoding = omit
-; CHECK-NEXT: .byte 1 # Call site Encoding = uleb128
-; CHECK-NEXT: .uleb128 .Lcst_end0-.Lcst_begin0
-; CHECK-NEXT: .Lcst_begin0:
-; CHECK-NEXT: .uleb128 .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 <<
-; CHECK-NEXT: .uleb128 .Lfunc_end1-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Lfunc_end1
-; CHECK-NEXT: .byte 0 # has no landing pad
-; CHECK-NEXT: .byte 0 # On action: cleanup
-; CHECK-NEXT: .Lcst_end0:
diff --git a/llvm/test/Transforms/Inline/inline-invoke-with-asm-call.ll b/llvm/test/Transforms/Inline/inline-invoke-with-asm-call.ll
index 51abbc74a5314..c2bfa79fa2ec6 100644
--- a/llvm/test/Transforms/Inline/inline-invoke-with-asm-call.ll
+++ b/llvm/test/Transforms/Inline/inline-invoke-with-asm-call.ll
@@ -26,7 +26,7 @@ define void @caller() personality ptr @__objc_personality_v0 {
}
define void @callee_with_asm() {
- call void asm sideeffect "mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue", ""()
+ call void asm sideeffect "mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue", ""() nounwind
ret void
}
diff --git a/llvm/test/Transforms/Inline/no-unwind-inline-asm.ll b/llvm/test/Transforms/Inline/no-unwind-inline-asm.ll
index bfe51e81575f2..ca8dbc019835c 100644
--- a/llvm/test/Transforms/Inline/no-unwind-inline-asm.ll
+++ b/llvm/test/Transforms/Inline/no-unwind-inline-asm.ll
@@ -12,8 +12,8 @@ entry:
define dso_local void @proxy() personality ptr @__gxx_personality_v0 {
entry:
- call void asm sideeffect "call trap", "~{dirflag},~{fpsr},~{flags}"()
- call void asm sideeffect "call trap", "~{dirflag},~{fpsr},~{flags}"()
+ call void asm sideeffect "call trap", "~{dirflag},~{fpsr},~{flags}"() nounwind
+ call void asm sideeffect "call trap", "~{dirflag},~{fpsr},~{flags}"() nounwind
ret void
}
More information about the llvm-commits
mailing list