Index: lib/CodeGen/AsmPrinter/ARMException.cpp =================================================================== --- lib/CodeGen/AsmPrinter/ARMException.cpp +++ lib/CodeGen/AsmPrinter/ARMException.cpp @@ -32,6 +32,8 @@ #include "llvm/Target/TargetFrameLowering.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" +#include + using namespace llvm; ARMException::ARMException(AsmPrinter *A) : DwarfCFIExceptionBase(A) {} @@ -44,8 +46,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 +82,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 +97,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 @@ -1,15 +1,10 @@ -; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM -; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM -; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM -; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM -; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB -; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB -; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB -; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB -; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M -; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M -; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M -; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M +; RUN: llc -relocation-model=static < %s | FileCheck %s +; RUN: llc -relocation-model=pic < %s | FileCheck %s +; RUN: llc -relocation-model=ropi < %s | FileCheck %s +; RUN: llc -relocation-model=rwpi < %s | FileCheck %s + +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" +target triple = "armv7--linux-gnueabihf" @.str = private unnamed_addr constant [2 x i8] c"s\00", align 1 @.str1 = private unnamed_addr constant [69 x i8] c"this string is far too long to fit in a literal pool by far and away\00", align 1 @@ -21,7 +16,6 @@ @.arr3 = private unnamed_addr constant [2 x i16*] [i16* null, i16* null], align 4 @.ptr = private unnamed_addr constant [2 x i16*] [i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr2, i32 0, i32 0), i16* null], align 2 @.arr4 = private unnamed_addr constant [2 x i16] [i16 3, i16 4], align 16 -@.zerosize = private unnamed_addr constant [0 x i16] zeroinitializer, align 4 ; CHECK-LABEL: @test1 ; CHECK: adr r0, [[x:.*]] @@ -140,56 +134,18 @@ ret void } -; Ensure that zero sized values are supported / not promoted. -; CHECK-LABEL: @pr32130 -; CHECK-NOT: adr -define void @pr32130() #0 { - tail call void @c(i16* getelementptr inbounds ([0 x i16], [0 x i16]* @.zerosize, i32 0, i32 0)) #2 - ret void -} - -; CHECK-LABEL: @test10 -; CHECK-V6M: adr r{{[0-9]*}}, [[x:.*]] -; CHECK-V6M: [[x]]: -; CHECK-V6M: .asciz "s\000\000" -; CHECK-V7: ldrb{{(.w)?}} r{{[0-9]*}}, [[x:.*]] -; CHECK-V7: [[x]]: -; CHECK-V7: .asciz "s\000\000" -define void @test10(i8* %a) local_unnamed_addr #0 { - call void @llvm.memmove.p0i8.p0i8.i32(i8* %a, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i32 1, i32 1, i1 false) - ret void -} - -; CHECK-LABEL: @test11 -; CHECK-V6M: adr r{{[0-9]*}}, [[x:.*]] -; CHECK-V6M: [[x]]: -; CHECK-V6M: .short 3 -; CHECK-V6M: .short 4 -; CHECK-V7THUMB: ldrh{{(.w)?}} r{{[0-9]*}}, [[x:.*]] -; CHECK-V7THUMB: [[x]]: -; CHECK-V7THUMB: .short 3 -; CHECK-V7THUMB: .short 4 -; CHECK-V7ARM: adr r{{[0-9]*}}, [[x:.*]] -; CHECK-V7ARM: [[x]]: -; CHECK-V7ARM: .short 3 -; CHECK-V7ARM: .short 4 -define void @test11(i16* %a) local_unnamed_addr #0 { - call void @llvm.memmove.p0i16.p0i16.i32(i16* %a, i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr1, i32 0, i32 0), i32 2, i32 2, i1 false) - ret void -} - declare void @b(i8*) #1 declare void @c(i16*) #1 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i32, i1) -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 #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 = { "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 } !llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{!"Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)"} 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 @@ -1,5 +1,5 @@ ; RUN: llc -asm-verbose=false < %s -mattr=+vfp3,+fp16 | FileCheck %s -check-prefix=CHECK-FP16 --check-prefix=CHECK-VFP -check-prefix=CHECK-ALL -; RUN: llc -asm-verbose=false < %s | FileCheck %s -check-prefix=CHECK-LIBCALL --check-prefix=CHECK-VFP -check-prefix=CHECK-ALL --check-prefix=CHECK-LIBCALL-VFP +; RUN: llc -asm-verbose=false < %s | FileCheck %s -check-prefix=CHECK-LIBCALL --check-prefix=CHECK-VFP -check-prefix=CHECK-ALL --check-prefix=CHECK-LIBCALL-VF ; RUN: llc -asm-verbose=false < %s -mattr=-vfp2 | FileCheck %s --check-prefix=CHECK-LIBCALL -check-prefix=CHECK-NOVFP -check-prefix=CHECK-ALL 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:128:128-a0:0:64-n32" @@ -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