File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,12 @@ struct Walker : public VisitorType {
124124 // Copy debug info, if present.
125125 if (currFunction) {
126126 auto & debugLocations = currFunction->debugLocations ;
127- if (!debugLocations.empty ()) {
127+ // Early exit if there is no debug info at all. Also, leave if we already
128+ // have debug info on the new expression, which we don't want to trample:
129+ // if there is no debug info we do want to copy, as a replacement
130+ // operation suggests the new code plays the same role (it is an optimized
131+ // version of the old), but if the code is already annotated, trust that.
132+ if (!debugLocations.empty () && !debugLocations.count (expression)) {
128133 auto * curr = getCurrent ();
129134 auto iter = debugLocations.find (curr);
130135 if (iter != debugLocations.end ()) {
Original file line number Diff line number Diff line change 3737 )
3838 )
3939 )
40+
41+ ;; CHECK: (func $test-no-trample
42+ ;; CHECK-NEXT: (local $temp i32)
43+ ;; CHECK-NEXT: [none] ;;@ src.cpp:300:3
44+ ;; CHECK-NEXT: [none](block
45+ ;; CHECK-NEXT: [none] ;;@ src.cpp:400:4
46+ ;; CHECK-NEXT: (call $test)
47+ ;; CHECK-NEXT: [none] ;;@ src.cpp:200:2
48+ ;; CHECK-NEXT: (local.set $temp
49+ ;; CHECK-NEXT: [i32] ;;@ src.cpp:500:5
50+ ;; CHECK-NEXT: (i32.const 1)
51+ ;; CHECK-NEXT: )
52+ ;; CHECK-NEXT: ) ;; end block
53+ ;; CHECK-NEXT: ;;@ src.cpp:200:2
54+ ;; CHECK-NEXT: )
55+ (func $test-no-trample
56+ (local $temp i32 )
57+
58+ ;; As above, but now the inner block has debug info (300), which should not
59+ ;; be trampled as it is moved outside.
60+
61+ ;; @ src.cpp:200:2
62+ (local.set $temp
63+ ;; @ src.cpp:300:3
64+ (block (result i32 )
65+ ;; @ src.cpp:400:4
66+ (call $test )
67+ ;; @ src.cpp:500:5
68+ (i32.const 1 )
69+ )
70+ )
71+ )
4072)
You can’t perform that action at this time.
0 commit comments