<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/83174>83174</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `CGDebugInfo` appends working directory to absolute path converted to relative with `DebugPrefixMap`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          noxwell
      </td>
    </tr>
</table>

<pre>
    ### Description

DWARF file entry consists of filename and directory. When `filename` is relative, it is relative to the`directory`, but when `filename` is absolute, `directory` should be empty. However, after being transformed through `CGDebugInfo::remapDIPath`, absolute `filename` may become relative, which leads to a bug, that it becomes relative to the current working directory, and the resulting DWARF file location points to a file that doesn't exist.

### Steps to reproduce

```bash
WORKDIR=$PWD
CC=clang
mkdir -p src
echo "int main() { return 0; }" > src/main.c
mkdir -p out
cd out
$CC -g -ffile-prefix-map="$WORKDIR/=./" -S -emit-llvm -o main.ll "$WORKDIR/src/main.c"
$CC -g -ffile-prefix-map="$WORKDIR/=./" -o main.o -c "$WORKDIR/src/main.c"
cat main.ll | grep 'DIFile' | head -n 1
llvm-dwarfdump main.o | grep 'DW_AT_decl_file'
```

### Expected output

```
!1 = !DIFile(filename: "./src/main.c", directory: "", checksumkind: CSK_MD5, checksum: "5c11ff1def313f2a87eabf3a30f130ad")
DW_AT_decl_file ("./src/main.c")
```

### Actual output

```
!1 = !DIFile(filename: "./src/main.c", directory: "./out", checksumkind: CSK_MD5, checksum: "5c11ff1def313f2a87eabf3a30f130ad")
DW_AT_decl_file ("./out/./src/main.c")
```

### How to fix

This case is already handled in `CGDebugInfo::createFile`. But `CGDebugInfo::CreateCompileUnit` uses `DBuilder.createFile` directly instead of calling `CGDebugInfo::createFile` wrapper, which leads to incorrect file entry.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVl-P2jgQ_zTmZZQ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