Skip to content

Commit 1297bf2

Browse files
[llvm-profdata] Reintroduce use of InitLLVM (#164736)
Before llvm-profdata participated in llvm-driver it directly called InitLLVM, which takes care of wildcard argument expansion for tools on Windows. When llvm-driver support was added to llvm-profdata this InitLLVM call was effectively moved into the common llvm-driver wrapper mechanism. More recently, in #162191, llvm-driver support was temporarily backed out of llvm-profdata due to an issue with `cl::opt` handling. This change reintroduces the direct call to InitLLVM in order to restore wildcard expansion and also adds a test for the wildcard expansion on Windows.
1 parent 8c4d661 commit 1297bf2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This test verifies that llvm-profdata will do wildcard expansion on its
2+
# arguments. The expansion is done by Windows-specific support in InitLLVM, so
3+
# we only expect this to work on Windows hosts.
4+
# REQUIRES: system-windows
5+
6+
# Create two files to glob.
7+
RUN: echo '# empty profile 1' > %t.prof1.proftxt
8+
RUN: echo '# empty profile 2' >> %t.prof2.proftxt
9+
10+
# Prevent LIT itself from globbing by quoting the wildcard argument.
11+
RUN: llvm-profdata merge "%t.*.proftxt" -dump-input-file-list -o /dev/null | FileCheck %s
12+
13+
# Verify that llvm-profdata expanded the wildcard argument.
14+
CHECK: 1,{{.*}}.prof1.proftxt
15+
CHECK-NEXT: 1,{{.*}}.prof2.proftxt

llvm/tools/llvm-profdata/llvm-profdata.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "llvm/Support/FileSystem.h"
3535
#include "llvm/Support/Format.h"
3636
#include "llvm/Support/FormattedStream.h"
37-
#include "llvm/Support/LLVMDriver.h"
37+
#include "llvm/Support/InitLLVM.h"
3838
#include "llvm/Support/MD5.h"
3939
#include "llvm/Support/MemoryBuffer.h"
4040
#include "llvm/Support/Path.h"
@@ -3465,6 +3465,7 @@ static int order_main() {
34653465
}
34663466

34673467
int main(int argc, const char *argv[]) {
3468+
InitLLVM X(argc, argv);
34683469
StringRef ProgName(sys::path::filename(argv[0]));
34693470

34703471
if (argc < 2) {

0 commit comments

Comments
 (0)