| Issue |
244323
|
| Summary |
LLVM may ignore no-builtin attributes
|
| Labels |
bug,
llvm
|
| Assignees |
momchil-velikov
|
| Reporter |
momchil-velikov
|
For the following example, compiled as `clang -S -O1 x.c` (https://clang.godbolt.org/z/YqKj3Wj3s):
```
#include <cmath>
__attribute__((no_builtin)) double foo(double x) { return pow(x, 1.2); }
struct S {
S(double f) { x = foo(f); }
double x;
};
S s(2.0);
```
LLVM will evaluate the call to `pow` at compile time despite the `no_builtins` attribute.
The analogous LLVM IR testcase, compiled as `opt -S -p globalopt x.ll` is (https://clang.godbolt.org/z/dMGdh58r1):
```
%struct.S = type { double }
@s = global %struct.S zeroinitializer, align 8
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_x.cc, ptr null }]
declare double @pow(double, double)
define double @foo(double %x) "no-builtins" {
entry:
%call = call double @pow(double %x, double f0x3FF3333340000000)
ret double %call
}
define internal void @__cxx_global_var_init() {
entry:
call void @ctor(ptr @s, double 2.000000e+00)
ret void
}
define void @ctor(ptr %this, double %f) {
entry:
%call = call double @foo(double %f)
store double %call, ptr %this, align 8
ret void
}
define internal void @_GLOBAL__sub_I_x.cc() {
entry:
call void @__cxx_global_var_init()
ret void
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs