Index: lib/CodeGen/AsmPrinter/ARMException.cpp =================================================================== --- lib/CodeGen/AsmPrinter/ARMException.cpp +++ lib/CodeGen/AsmPrinter/ARMException.cpp @@ -32,6 +32,7 @@ #include "llvm/Target/TargetFrameLowering.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" + using namespace llvm; ARMException::ARMException(AsmPrinter *A) : DwarfCFIExceptionBase(A) {} @@ -44,8 +45,12 @@ } void ARMException::beginFunction(const MachineFunction *MF) { - if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM) + const Function *F = MF->getFunction(); + + if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM && + F->hasUWTable()) getTargetStreamer().emitFnStart(); + // See if we need call frame info. AsmPrinter::CFIMoveType MoveType = Asm->needsCFIMoves(); assert(MoveType != AsmPrinter::CFI_M_EH && @@ -76,10 +81,8 @@ F->needsUnwindTableEntry(); bool shouldEmitPersonality = forceEmitPersonality || !MF->getLandingPads().empty(); - if (!Asm->MF->getFunction()->needsUnwindTableEntry() && - !shouldEmitPersonality) - ATS.emitCantUnwind(); - else if (shouldEmitPersonality) { + + if (shouldEmitPersonality) { // Emit references to personality. if (Per) { MCSymbol *PerSym = Asm->getSymbol(Per); @@ -93,8 +96,11 @@ // Emit actual exception table emitExceptionTable(); } + else if (F->doesNotThrow() && F->hasUWTable()) + ATS.emitCantUnwind(); - if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM) + if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM && + F->hasUWTable()) ATS.emitFnEnd(); } Index: test/CodeGen/ARM/atomic-cmpxchg.ll =================================================================== --- test/CodeGen/ARM/atomic-cmpxchg.ll +++ test/CodeGen/ARM/atomic-cmpxchg.ll @@ -7,7 +7,7 @@ ; RUN: llc < %s -mtriple=armv7-linux-gnueabi -asm-verbose=false -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-ARMV7 ; RUN: llc < %s -mtriple=thumbv7-linux-gnueabi -asm-verbose=false -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-THUMBV7 -define zeroext i1 @test_cmpxchg_res_i8(i8* %addr, i8 %desired, i8 zeroext %new) { +define zeroext i1 @test_cmpxchg_res_i8(i8* %addr, i8 %desired, i8 zeroext %new) uwtable { entry: %0 = cmpxchg i8* %addr, i8 %desired, i8 %new monotonic monotonic %1 = extractvalue { i8, i1 } %0, 1 Index: test/CodeGen/ARM/big-endian-eh-unwind.ll =================================================================== --- test/CodeGen/ARM/big-endian-eh-unwind.ll +++ test/CodeGen/ARM/big-endian-eh-unwind.ll @@ -71,3 +71,4 @@ ; CHECK-LABEL: Contents of section .ARM.extab: ; CHECK-NEXT: 0000 00000000 00a8b0b0 +attributes #0 = { uwtable } \ No newline at end of file Index: test/CodeGen/ARM/constantpool-promote.ll =================================================================== --- test/CodeGen/ARM/constantpool-promote.ll +++ test/CodeGen/ARM/constantpool-promote.ll @@ -185,9 +185,9 @@ declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) local_unnamed_addr declare void @llvm.memmove.p0i16.p0i16.i32(i16*, i16*, i32, i32, i1) local_unnamed_addr -attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #2 = { nounwind } +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind uwtable } !llvm.module.flags = !{!0, !1} Index: test/CodeGen/ARM/ehabi-handlerdata-nounwind.ll =================================================================== --- test/CodeGen/ARM/ehabi-handlerdata-nounwind.ll +++ test/CodeGen/ARM/ehabi-handlerdata-nounwind.ll @@ -25,7 +25,7 @@ declare void @__cxa_end_catch() -define void @test1() nounwind personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { +define void @test1() nounwind uwtable personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: invoke void @throw_exception() to label %try.cont unwind label %lpad Index: test/CodeGen/ARM/ehabi-handlerdata.ll =================================================================== --- test/CodeGen/ARM/ehabi-handlerdata.ll +++ test/CodeGen/ARM/ehabi-handlerdata.ll @@ -23,7 +23,7 @@ declare void @__cxa_end_catch() -define void @test1() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { +define void @test1() uwtable personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: invoke void @throw_exception() to label %try.cont unwind label %lpad Index: test/CodeGen/ARM/ehabi-no-landingpad.ll =================================================================== --- test/CodeGen/ARM/ehabi-no-landingpad.ll +++ test/CodeGen/ARM/ehabi-no-landingpad.ll @@ -3,7 +3,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64" target triple = "armv7-unknown-linux-gnueabi" -define void @_Z4testv() { +define void @_Z4testv() uwtable { ; CHECK: _Z4testv ; CHECK: .fnstart ; CHECK: .size Index: test/CodeGen/ARM/ehabi.ll =================================================================== --- test/CodeGen/ARM/ehabi.ll +++ test/CodeGen/ARM/ehabi.ll @@ -10,7 +10,7 @@ ; (4) .vsave directive should come with vpush instruction. ; (5) .pad directive should come with stack pointer adjustment. ; (6) .cantunwind directive should be available if the function is marked with -; nounwind function attribute. +; nounwind uwtable function attributes. ; We have to check several cases: ; (1) arm with -disable-fp-elim @@ -105,7 +105,7 @@ define void @_Z4testiiiiiddddd(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, double %m, double %n, double %p, - double %q, double %r) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { + double %q, double %r) uwtable personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: invoke void @_Z5printiiiii(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) to label %try.cont unwind label %lpad @@ -295,7 +295,7 @@ declare void @throw_exception_2() -define void @test2() { +define void @test2() uwtable { entry: call void @throw_exception_2() ret void @@ -385,7 +385,7 @@ declare void @throw_exception_3(i32) define i32 @test3(i32 %a, i32 %b, i32 %c, i32 %d, - i32 %e, i32 %f, i32 %g, i32 %h) { + i32 %e, i32 %f, i32 %g, i32 %h) uwtable { entry: %add = add nsw i32 %b, %a %add1 = add nsw i32 %add, %c @@ -493,30 +493,6 @@ ret void } -; CHECK-FP-LABEL: test4: -; CHECK-FP: .fnstart -; CHECK-FP: mov pc, lr -; CHECK-FP: .cantunwind -; CHECK-FP: .fnend - -; CHECK-FP-ELIM-LABEL: test4: -; CHECK-FP-ELIM: .fnstart -; CHECK-FP-ELIM: mov pc, lr -; CHECK-FP-ELIM: .cantunwind -; CHECK-FP-ELIM: .fnend - -; CHECK-V7-FP-LABEL: test4: -; CHECK-V7-FP: .fnstart -; CHECK-V7-FP: bx lr -; CHECK-V7-FP: .cantunwind -; CHECK-V7-FP: .fnend - -; CHECK-V7-FP-ELIM-LABEL: test4: -; CHECK-V7-FP-ELIM: .fnstart -; CHECK-V7-FP-ELIM: bx lr -; CHECK-V7-FP-ELIM: .cantunwind -; CHECK-V7-FP-ELIM: .fnend - ; DWARF-FP-LABEL: test4: ; DWARF-FP-NOT: .cfi_startproc ; DWARF-FP: mov pc, lr @@ -540,3 +516,36 @@ ; DWARF-V7-FP-ELIM: bx lr ; DWARF-V7-FP-ELIM-NOT: .cfi_endproc ; DWARF-V7-FP-ELIM: .size test4, + +;------------------------------------------------------------------------------- +; Test 5 +;------------------------------------------------------------------------------- + +define void @test5() nounwind uwtable { +entry: + ret void +} + +; CHECK-FP-LABEL: test5: +; CHECK-FP: .fnstart +; CHECK-FP: mov pc, lr +; CHECK-FP: .cantunwind +; CHECK-FP: .fnend + +; CHECK-FP-ELIM-LABEL: test5: +; CHECK-FP-ELIM: .fnstart +; CHECK-FP-ELIM: mov pc, lr +; CHECK-FP-ELIM: .cantunwind +; CHECK-FP-ELIM: .fnend + +; CHECK-V7-FP-LABEL: test5: +; CHECK-V7-FP: .fnstart +; CHECK-V7-FP: bx lr +; CHECK-V7-FP: .cantunwind +; CHECK-V7-FP: .fnend + +; CHECK-V7-FP-ELIM-LABEL: test5: +; CHECK-V7-FP-ELIM: .fnstart +; CHECK-V7-FP-ELIM: bx lr +; CHECK-V7-FP-ELIM: .cantunwind +; CHECK-V7-FP-ELIM: .fnend Index: test/CodeGen/ARM/execute-only.ll =================================================================== --- test/CodeGen/ARM/execute-only.ll +++ test/CodeGen/ARM/execute-only.ll @@ -73,7 +73,7 @@ @.str = private unnamed_addr constant [4 x i8] c"FOO\00", align 1 -define hidden i8* @string_literal() { +define hidden i8* @string_literal() uwtable { entry: ; CHECK-LABEL: string_literal: ; CHECK-NOT: .asciz Index: test/CodeGen/ARM/fp16-promote.ll =================================================================== --- test/CodeGen/ARM/fp16-promote.ll +++ test/CodeGen/ARM/fp16-promote.ll @@ -893,7 +893,7 @@ ; CHECK-ALL: .fnstart ; CHECK-ALL: ldrh ; CHECK-ALL: strh -define void @test_extractvalue(%struct.dummy* %p, half* %q) { +define void @test_extractvalue(%struct.dummy* %p, half* %q) uwtable { %a = load %struct.dummy, %struct.dummy* %p %b = extractvalue %struct.dummy %a, 1 store half %b, half* %q @@ -914,7 +914,7 @@ ; CHECK-ALL-NEXT: .fnstart ; CHECK-NOVFP-NEXT: mov r0, r1 ; CHECK-ALL-NEXT: bx lr -define half @test_struct_arg(%struct.dummy %p) { +define half @test_struct_arg(%struct.dummy %p) uwtable { %a = extractvalue %struct.dummy %p, 1 ret half %a } @@ -959,4 +959,4 @@ ret half %r } -attributes #0 = { nounwind } +attributes #0 = { nounwind uwtable } Index: test/CodeGen/Thumb/copy_thumb.ll =================================================================== --- test/CodeGen/Thumb/copy_thumb.ll +++ test/CodeGen/Thumb/copy_thumb.ll @@ -24,7 +24,7 @@ declare void @bar(i32, i32) -define void @foo(i32 %a, i32 %b) { +define void @foo(i32 %a, i32 %b) uwtable { entry: call void @bar(i32 %b, i32 %a); ret void Index: test/MC/ARM/data-in-code.ll =================================================================== --- test/MC/ARM/data-in-code.ll +++ test/MC/ARM/data-in-code.ll @@ -9,7 +9,7 @@ ;; Ensure that if a jump table is generated that it has Mapping Symbols ;; marking the data-in-code region. -define void @foo(i32* %ptr, i32 %b) nounwind ssp { +define void @foo(i32* %ptr, i32 %b) nounwind uwtable ssp { %tmp = load i32, i32* %ptr, align 4 switch i32 %tmp, label %exit [ i32 0, label %bb0