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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to