whentojump wrote:

Hi, thanks for the fix.

I can confirm it addressed your test case (https://godbolt.org/z/sMscqWeq7). 
But unfortunately it doesn't fix the one in my original post of #87000 
([compiler explorer 
link](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGIM6SuADJ4DJgAcj4ARpjEEgDM8aQADqgKhE4MHt6%2B/ilpGQIhYZEsMXFcibaY9o4CQgRMxATZPn4BdpgOmQ1NBMUR0bEJSQqNza25HeP9oYNlw5XxAJS2qF7EyOwcAPQ7ANQAgvuYqqzJ9PvpLBd4NJjo%2B1TEqCz7CAQEyQogezV4qjwxAAdFFUKgCLRQsC0CwdlCGF5VDsAG4ANmBAA5gVwdgp1ptMDt0MQ8CjYgodk4WCwvFTBDUdslYlQWAIYSYNIc9vsAEqYZIvdBeZB4KKXADuhAQ%2B2QBiM%2B3JxHSAn2XGxXGB8X20EIAAFgNKvFEYa8QLRaCi4RarQBaQWobRdAjAw0ETncg5mSQATkxmHiTA0AHYqPF0FQzGZg2YqF1MZiAKxURPxKgaH1MTCVMxSUTxTHLfaGR5yKJeQReWXy4CKimZNUarUenkQazWMwab0aeJRkPxLip6yYKho9BcLoh5Bon22rgAP1OyQXne7vdzPsSGg0WLRy2BLZ2h/24QhmH2BAQTAIxYUSmamQU%2BwAVCw8MAPs/3kxyRfUPsYhOZhxQeUgLwQWIRxIc9BUwcs6BvZImGQABrJhgEwBRj2eV5i2SF0bRYYESFrTACGQF83w/AgvwYCEAMwK9f0vc8FFYTBgX2bBXU4pgn1QKh9gAWSafYzExUhj0I200BROdMSeF43iYfDgUI4jiFIhh0CfLxkn2KVL32cwzCETBgDYQRrwbKgmC8Wh3SjMDpNkucfWPdBUEwhgwA4G9bLoYsb3oPibyXKFRUhABPTiAHkGHA88IQg4hv20sC7gM894NoR4giCAA1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QGQQQRQFQdQSk3QLgfQX6FAdsSwfQMUH4SAVYVAfCR8TgWGK2RGc2VGdGPGCuHGLWPGSmQmZIYmBUF0pUfGFgamZAXgV04gUkLAU0iAVYToboZwPNbSSYPwXU4IOYUocoPQVIdIRqeMtMgoRqAYFMxYaoWoHoGYLM3UqMxqXoZoPMoYCoWwEszwNoPQQgqs5MmsiQSM2A9s7YjgYY0gUY8YyYjgfYVnNEW0NESQH6BUI1T4h8AQJ8cZBgFCBlXAQgKuF5XFJYlY0lUgdYzY7s3Y0gIUvc/soMw42wEAE4rci464iAJAIgTwR4o1TSIk3gJocU9/fOIQI2OUtEu4l48IdiTgEcscic4AZACiLgMwYEMwXgB4Vc0MvQBU4QUQcQVUpCjUtQfYnUw8gQZCVAFcogYgMaPiCwTARgQ4BaVAGUxgB4FkhmPCgikgain8nC5gNABofAFisYTis87i0ID8moL8vWFi%2B82gOFdAc0S0FgGSLWBcgE8pFSYU7s3sk8g4jgTWbWCAN4owWWBgP5IsYC8cyc2sachqR8C8P4xc5c/AQihY3U/YDwG4F4uy5YTcs47ciCbVYYCM/c3gI8rY1Swco4i80gU4rQbc3crY9k%2BIPYykoK0KrcgYzgGCvs/Y%2BKsK1Y21esZwSQIAA%3D%3D%3D)).

In fact, I utilized [creduce](https://github.com/csmith-project/creduce) to 
automatically reduce that one and ended up with this (with a bit manual 
modification):

```c
#define pre_a 0
#define PRE(x) pre_##x

void f(void) {
    PRE(a) && 0;
}

int main(void) { return 0; }
```

This time an expansion region is missing ([compiler explorer 
link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:29,endLineNumber:8,positionColumn:29,positionLineNumber:8,selectionStartColumn:29,selectionStartLineNumber:8,startColumn:29,startLineNumber:8),source:'%23define+pre_a+0%0A%23define+PRE(x)+pre_%23%23x%0A%0Avoid+f(void)+%7B%0A++++PRE(a)+%26%26+0%3B%0A%7D%0A%0Aint+main(void)+%7B+return+0%3B+%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:51.69491525423727,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:cclang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,libs:!(),options:'-fprofile-instr-generate+-fcoverage-mapping+-fcoverage-mcdc+-Xclang+-dump-coverage-mapping+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0')),k:34.5741843594503,l:'4',m:28.903654485049834,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:2,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%232)',t:'0')),header:(),l:'4',m:71.09634551495017,n:'0',o:'',s:0,t:'0')),k:48.30508474576271,l:'3',n:'0',o:'',t:'0')),l:'2',m:100,n:'0',o:'',t:'0')),version:4))

```text
f:
  File 0, 4:14 -> 6:2 = #0
  Decision,File 0, 5:5 -> 5:16 = M:0, C:2
  Expansion,File 0, 5:5 -> 5:8 = #0 (Expanded file = 1)
  File 0, 5:15 -> 5:16 = #1
  Branch,File 0, 5:15 -> 5:16 = 0, 0 [2,0,0] 
  File 1, 2:16 -> 2:23 = #0
  File 2, 1:15 -> 1:16 = #0
  File 2, 1:15 -> 1:16 = #0
  Branch,File 2, 1:15 -> 1:16 = 0, 0 [1,2,0] 
main:
  File 0, 8:16 -> 8:29 = #0
```

As a result, `addBranch()` here 
https://github.com/llvm/llvm-project/blob/28d85e2d9e9f3b62554ad8446095aac275022c3c/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L693-L704

fails to associate the branch with the decision.

I will keep investigating it and posting my findings here.




https://github.com/llvm/llvm-project/pull/89573
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to