[cfe-users] How to handle debug information not in source/How do I handle the error 'inlinable function call in a function with debug info must have a !dbg location'

2018-04-18 Thread Levo DeLellis via cfe-users
I'm having an issue with the error "inlinable function call in a function
with debug info must have a !dbg location"

My language will automatically call a destructor for you. LLVM is forcing
me to use give it debug information. I try to with DILocation however scope
is mandatory field. However since the destructor is generated it doesn't
exist in source. So when I try making DISubprogram for the scope I need to
give it invalid lines.

What's the best way to handle debugging information that doesn't exist in
source?
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Question about atomic variables of unsupported bitsize

2018-04-30 Thread Levo DeLellis via cfe-users
I constantly feel like I don't have much experience using LLVM but I hope
this isn't a foolish question.

I had a thought. If I have a struct with three 8bit (or 16bit) variables a,
b and c and I want to do an atomic write to one variable. What happens if
the target backend doesn't support atomic writes of that bitsize? It
wouldn't be very safe to read, modify the 8bits then write again since it's
not atomic. Logically the frontend can easily fix this problem by padding
or forcing the variables to be a supported size. My question is will I get
a compile error if I try to do an unsupported atomic write? Am I able to
query for information before I generate code? Is there a list I should
check for each backend I want to support? I'm unsure what I should do for
good frontend support.
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Is there a wiki?

2018-05-09 Thread Levo DeLellis via cfe-users
Is there a wiki or some place users can add/modify information to help
eachother?

For example, I'm looking at how I should figure out if a class inherit
another class. This page gives me hints
https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html however I'm not sure if
I need RTTI, if I will use vtables or not and if the Kind table/enum can be
per file or if that will cause problems when using indirect functions (ie I
use classof on base and it doesn't know about my class because it's in a
static library). If I should have a global list how I might deal with
static libraries.

I'm sure I'll find a simple enough solution but a wiki is more organized
than messages in a mailing list. If a wiki does exist how do I find it
because I don't really see it when typing llvm wiki cfe/frontend
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Improve build speeds?

2019-03-15 Thread Levo DeLellis via cfe-users
I have implemented a language and I'm planning to release it soon. One of
my goals is to have good build speeds so I can use it for web development.
I noticed building ll files is faster than building C. However I noticed
building a simple ll file can take 100+milliseconds on my desktop which
isn't terrible but isn't extremely fast either (-fsyntax-only is about
50ms).

What can I do to build faster? I believe I saw some kind of C++ library. Is
using that directly any faster? I'm not writing my compiler in C++ and I'm
very likely to rewrite it in my language which will provide C linking. Am I
out of luck?

The test C file I used was

int main() {
puts("Hello");
return 0;
}
I created the ll file by using `clang hello.c -S -emit-llvm` which
generated the below. Usually I program on linux but there's some debugging
I'm doing on windows atm however last time I checked I believe the speed
was comparable.

; ModuleID = 'hello.c'
source_filename = "hello.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.10.25017"

$"??_C@_05COLMCDPH@Hello?$AA@" = comdat any

@"??_C@_05COLMCDPH@Hello?$AA@" = linkonce_odr dso_local unnamed_addr
constant [6 x i8] c"Hello\00", comdat, align 1

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, i32* %1, align 4
  %2 = call i32 bitcast (i32 (...)* @puts to i32 (i8*)*)(i8* getelementptr
inbounds ([6 x i8], [6 x i8]* @"??_C@_05COLMCDPH@Hello?$AA@", i32 0, i32 0))
  ret i32 0
}

declare dso_local i32 @puts(...) #1

attributes #0 = { noinline nounwind optnone uwtable
"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-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"="+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"="+fxsr,+mmx,+sse,+sse2,+x87"
"unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}

!0 = !{i32 1, !"wchar_size", i32 2}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{!"clang version 7.0.1 (tags/RELEASE_701/final)"}
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] How to not step into function calls? (Example inside)

2019-04-07 Thread Levo DeLellis via cfe-users
In my language malloc and memset are invisible. I tried using lldb to set
breakpoints/step into/step over/step out however I get the following
message on windows

> Process 10552 stopped
> * thread #1, stop reason = step over failed (Could not create return
address breakpoint.)

Not a big deal. In vscode I am able to step in/over/out without an issue.
However since I'm pressing F11 (step in) to go line from line randomly the
debugger will enter malloc and memset which may throw the user off.

How do I prevent those functions from being entered? I'd also like to skip
"puts". I wrote some C++ code and modified the llvm file to give an
example. I was wondering how to change it to get the behavior I desire.
test.cpp

#include 
#include 
void test() {
char*p=(char*)malloc(20);
p[0] = 'H';
p[1] = 0;
puts(p);
free(p);
}
int main() {
test();
}

test.ll. NOTICE I added llvm.memset.p0i8.i64 so you can see it happen there
too which is a bit strange since it's not an explicit C call. I added the
declaration and the call right after malloc.

; ModuleID = 'test.cpp'
source_filename = "test.cpp"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.10.25017"
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1
)

; Function Attrs: noinline optnone uwtable
define dso_local void @"?test@@YAXXZ"() #0 !dbg !389 {
%1 = alloca i8*, align 8
call void @llvm.dbg.declare(metadata i8** %1, metadata !390, metadata !DIEx
pression()), !dbg !391
%2 = call noalias i8* @malloc(i64 20), !dbg !391
call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 20, i32 1, i1 false)
store i8* %2, i8** %1, align 8, !dbg !391
%3 = load i8*, i8** %1, align 8, !dbg !392
%4 = getelementptr inbounds i8, i8* %3, i64 0, !dbg !392
store i8 72, i8* %4, align 1, !dbg !392
%5 = load i8*, i8** %1, align 8, !dbg !393
%6 = getelementptr inbounds i8, i8* %5, i64 1, !dbg !393
store i8 0, i8* %6, align 1, !dbg !393
%7 = load i8*, i8** %1, align 8, !dbg !394
%8 = call i32 @puts(i8* %7), !dbg !394
%9 = load i8*, i8** %1, align 8, !dbg !395
call void @free(i8* %9), !dbg !395
ret void, !dbg !396
}

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1

declare dso_local noalias i8* @malloc(i64) #2

declare dso_local i32 @puts(i8*) #2

declare dso_local void @free(i8*) #2

; Function Attrs: noinline norecurse optnone uwtable
define dso_local i32 @main() #3 !dbg !397 {
call void @"?test@@YAXXZ"(), !dbg !398
ret i32 0, !dbg !399
}

attributes #0 = { noinline optnone 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"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"=
"false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable }
attributes #2 = { "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"=
"+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"=
"false" }
attributes #3 = { noinline norecurse optnone 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"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"=
"false" "use-soft-float"="false" }

!llvm.dbg.cu = !{!0}
!llvm.linker.options = !{!379, !380, !381, !382, !383}
!llvm.module.flags = !{!384, !385, !386, !387}
!llvm.ident = !{!388}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
producer: "clang version 8.0.0 (tags/RELEASE_800/final)", isOptimized:
false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2,
retainedTypes: !3, imports: !6, nameTableKind: None)
!1 = !DIFile(filename: "test.cpp", directory:
"D:\5Cdev\5CLang2018\5CDebuggerTestPrj", checksumkind: CSK_MD5, checksum:
"3d1a5422d6ed875b121f379a6e39b990")
!2 = !{}
!3 = !{!4}
!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
!5 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!6 = !{!7, !12, !16, !20, !27, !31, !36, !42, !50, !54, !58, !69, !76, !87,
!91, !95, !99, !103, !107, !111, !117, !121, !125, !129, !133, !138, !143,
!147, !152, !158, !162, !163, !167, !169, !173, !177, !181, !186, !190,
!194, !198, !200, !202, 

[cfe-users] Can I do a conditional jump without variables using phi?

2019-05-17 Thread Levo DeLellis via cfe-users
Lets take this C code. Obviously, it will always print out normal value

int main() {
for(int i=0; i<2; i++) {
if(i>4)
put("High value")
else
put("Normal value")
}
return 0;
}

Lets say I want the first time it runs this loop to go through the normal
control flow. I got some simple code when compiling with  -S -emit-llvm .
Lets say after it loops I'd like to go to the if statement that puts high
value instead of the start of the for loop.

I was thinking this phi statement would work. The bottom of the for loop is
label %14, 0% is the obviously the first label/control block, In the phi
statement I use %6 (start of for body) and %9 (the block with puts high)

%a = phi label [%6, %0], [%9, %14]

Then I replace the %6 with %a

br i1 %5, label %6, label %17 ;17 is after the foor loop, the return 0 line

I get the error "error: expected a basic block". I'm assuming it's because
%a isn't a fixed value.

What my real goal is in the middle of the for loop I'd like to re-use the
loop increment and conditional and continue on. Some conditions can be
quite long (a&&b && (c||d) && e>f && more) so it seems like generating the
condition at every point would cause a lot of code and be slow until I hit
it with an optimizer. What are my options? Can I do this without changing
it to a large switch statement?
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users