[llvm-dev] Problem with intrinsic::trap insertion instead of null pointer dereference
HEITZMANN Frédéric 218168 via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 21 05:46:16 PDT 2015
Hi everyone,
Llvm detects zero pointer dereference in CFG simplify and insert intrinsic::trap (at least with -O1 or -O2).
Problem 1 : I find it unfortunate not to be able to disable it, and allow a specific target to handle it its own way (with MMU fault or dedicated HW stuff).
>> Is there a trick to avoid this ?
Problem 2 : Unless special care is taken in LLVM backend, DAG select will fail on trap, without a clear indication of the guilty C fragment
>> Should the frontend emit at least a warning ?
Thanks for your help.
--
Fred
Example :
C code (many lines remove for the sake of clarity) :
struct s;
struct s{
struct s *next;
};
struct s* foo (struct s *a){
struct s *b = 0;
b->next = a;
return b;
}
LLVM (clang -O2 -emit-llvm) :
%struct.s = type { %struct.s* }
; Function Attrs: noreturn nounwind
define noalias %struct.s* @foo(%struct.s* nocapture readnone %a) #0 {
entry:
tail call void @llvm.trap()
unreachable
}
; Function Attrs: noreturn nounwind
declare void @llvm.trap() #1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151021/9e79f071/attachment-0001.html>
-------------- next part --------------
An embedded message was scrubbed...
From: unknown sender
Subject:
Date: Wed, 21 Oct 2015 12:42:53 +0000
Size: 1332
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151021/9e79f071/attachment-0004.mht>
-------------- next part --------------
An embedded message was scrubbed...
From: unknown sender
Subject:
Date: Wed, 21 Oct 2015 12:38:15 +0000
Size: 592
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151021/9e79f071/attachment-0005.mht>
-------------- next part --------------
An embedded message was scrubbed...
From: unknown sender
Subject: How to disable intrinsic::trap automatic insertion
Date: no date
Size: 45143
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151021/9e79f071/attachment-0006.mht>
-------------- next part --------------
An embedded message was scrubbed...
From: unknown sender
Subject:
Date: no date
Size: 41329
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151021/9e79f071/attachment-0007.mht>
More information about the llvm-dev
mailing list