[llvm-bugs] [Bug 41420] New: missed opt: nounwind on extern "C"

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 7 13:15:28 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41420

            Bug ID: 41420
           Summary: missed opt: nounwind on extern "C"
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gonzalobg88 at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Clang fails to mark `extern "C"` functions as `nounwind`
(https://gcc.godbolt.org/z/GpX96P):

extern "C" int foo(int);
int bar(int x) { return foo(x); }

when compiled with clang -O3 -g0 -S emit-llvm produces:

define dso_local i32 @_Z3bari(i32) local_unnamed_addr #0 {
  %2 = tail call i32 @foo(i32 %0)
  ret i32 %2
}

declare dso_local i32 @foo(i32) local_unnamed_addr #1

attributes #0 = { uwtable "correctly-rounded-divide-sqrt-fp-math"="false"
"disable-tail-calls"="false" "less-precise-fpmad"="false"
"min-legal-vector-width"="0" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false"
"disable-tail-calls"="false" "less-precise-fpmad"="false"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
"no-trapping-math"="false" "stack-protector-buffer-size"="8"
"target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
"unsafe-fp-math"="false" "use-soft-float"="false" }

where `foo` does not have the `nounwind` attribute. 

The dcl.link section of the standard (http://eel.is/c++draft/dcl.link) makes
it, however, clear, that `extern "C"` is for linking against the C programming
language, which is an ABI that cannot throw any exceptions.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190407/4644a2fe/attachment-0001.html>


More information about the llvm-bugs mailing list