llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang does not support gcc builtin llabs

Open ahatanak opened this issue 15 years ago • 1 comments

Bugzilla Link 9556
Resolution INVALID
Resolved on Mar 25, 2011 18:22
Version trunk
OS Linux
CC @efriedma-quic

Extended Description

In the following example, builtin function llabs is superseded by the function defined in the same file.

20021127-1.c

long long a = -1; long long llabs (long long); void abort (void); int main() { if (llabs (a) != 1) abort (); return 0; } long long llabs (long long b) { abort (); }

generated .ll code

clang 20021127-1.c -o 20021127-1.ll -S -emit-llvm -O3

target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" target triple = "i386-pc-linux-gnu"

@​a = global i64 -1, align 8

define i32 @​main() nounwind { entry: %call = tail call i64 @​llabs(i64 undef) unreachable }

define i64 @​llabs(i64 %b) noreturn nounwind { entry: tail call void @​abort() noreturn nounwind unreachable }

declare void @​abort() noreturn

ahatanak avatar Mar 25 '11 22:03 ahatanak

Testcase has undefined behavior per the C standard. Note that clang does folding for library functions a bit differently from gcc.

efriedma-quic avatar Mar 26 '11 01:03 efriedma-quic