[llvm] r255434 - [PGO] Stop using invalid char in instr variable names.
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 12 13:06:01 PST 2015
The tests were updated right after the LLVM change. Let me know if you
still had the problem.
thanks,
David
On Sat, Dec 12, 2015 at 12:14 PM, JF Bastien via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Hi David,
>
> It looks like this patch causes the following failures:
> Clang :: CoverageMapping/unused_names.c
> Clang :: Profile/c-captured.c
> Clang :: Profile/c-general.c
> Clang :: Profile/c-linkage.c
> Clang :: Profile/cxx-lambda.cpp
> Clang :: Profile/objc-general.m
>
> Log:
> https://build.chromium.org/p/client.wasm.llvm/builders/linux/builds/856/steps/steps/logs/stdio
>
> Could you look into it or revert?
>
> Thanks,
>
> JF
>
> On Sat, Dec 12, 2015 at 6:28 PM, Xinliang David Li via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: davidxl
>> Date: Sat Dec 12 11:28:03 2015
>> New Revision: 255434
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=255434&view=rev
>> Log:
>> [PGO] Stop using invalid char in instr variable names.
>>
>> Before the patch, -fprofile-instr-generate compile will fail
>> if no integrated-as is specified when the file contains
>> any static functions (the -S output is also invalid).
>>
>> This is the second try. The fix in this patch is very localized.
>> Only profile symbol names of profile symbols with internal
>> linkage are fixed up while initializer of name syms are not
>> changes. This means there is no format change nor version bump.
>>
>>
>>
>> Modified:
>> llvm/trunk/lib/ProfileData/InstrProf.cpp
>> llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
>> llvm/trunk/test/Instrumentation/InstrProfiling/profiling.ll
>> llvm/trunk/test/Transforms/PGOProfile/criticaledge.ll
>>
>> Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=255434&r1=255433&r2=255434&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
>> +++ llvm/trunk/lib/ProfileData/InstrProf.cpp Sat Dec 12 11:28:03 2015
>> @@ -102,6 +102,26 @@ std::string getPGOFuncName(const Functio
>> Version);
>> }
>>
>> +// \p FuncName is the string used as profile lookup key for the
>> function. A
>> +// symbol is created to hold the name. Return the legalized symbol name.
>> +static std::string getPGOFuncNameVarName(StringRef FuncName,
>> + GlobalValue::LinkageTypes
>> Linkage) {
>> + std::string VarName = getInstrProfNameVarPrefix();
>> + VarName += FuncName;
>> +
>> + if (!GlobalValue::isLocalLinkage(Linkage))
>> + return VarName;
>> +
>> + // Now fix up illegal chars in local VarName that may upset the
>> assembler.
>> + const char *InvalidChars = "-:<>\"'";
>> + size_t found = VarName.find_first_of(InvalidChars);
>> + while (found != std::string::npos) {
>> + VarName[found] = '_';
>> + found = VarName.find_first_of(InvalidChars, found + 1);
>> + }
>> + return VarName;
>> +}
>> +
>> GlobalVariable *createPGOFuncNameVar(Module &M,
>> GlobalValue::LinkageTypes Linkage,
>> StringRef FuncName) {
>> @@ -120,7 +140,7 @@ GlobalVariable *createPGOFuncNameVar(Mod
>> auto *Value = ConstantDataArray::getString(M.getContext(), FuncName,
>> false);
>> auto FuncNameVar =
>> new GlobalVariable(M, Value->getType(), true, Linkage, Value,
>> - Twine(getInstrProfNameVarPrefix()) + FuncName);
>> + getPGOFuncNameVarName(FuncName, Linkage));
>>
>> // Hide the symbol so that we correctly get a copy for each executable.
>> if (!GlobalValue::isLocalLinkage(FuncNameVar->getLinkage()))
>>
>> Modified: llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp?rev=255434&r1=255433&r2=255434&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
>> (original)
>> +++ llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp Sat Dec
>> 12 11:28:03 2015
>> @@ -265,8 +265,8 @@ void InstrProfiling::lowerCoverageData(G
>>
>> /// Get the name of a profiling variable for a particular function.
>> static std::string getVarName(InstrProfIncrementInst *Inc, StringRef
>> Prefix) {
>> - auto *Arr = cast<ConstantDataArray>(Inc->getName()->getInitializer());
>> - StringRef Name = Arr->isCString() ? Arr->getAsCString() :
>> Arr->getAsString();
>> + StringRef NamePrefix = getInstrProfNameVarPrefix();
>> + StringRef Name = Inc->getName()->getName().substr(NamePrefix.size());
>> return (Prefix + Name).str();
>> }
>>
>>
>> Modified: llvm/trunk/test/Instrumentation/InstrProfiling/profiling.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/InstrProfiling/profiling.ll?rev=255434&r1=255433&r2=255434&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/Instrumentation/InstrProfiling/profiling.ll (original)
>> +++ llvm/trunk/test/Instrumentation/InstrProfiling/profiling.ll Sat Dec
>> 12 11:28:03 2015
>> @@ -6,8 +6,8 @@ target triple = "x86_64-apple-macosx10.1
>> ; CHECK: @__llvm_profile_name_foo = hidden constant [3 x i8] c"foo",
>> section "__DATA,__llvm_prf_names", align 1
>> @__llvm_profile_name_bar = hidden constant [4 x i8] c"bar\00"
>> ; CHECK: @__llvm_profile_name_bar = hidden constant [4 x i8] c"bar\00",
>> section "__DATA,__llvm_prf_names", align 1
>> - at baz_prof_name = hidden constant [3 x i8] c"baz"
>> -; CHECK: @baz_prof_name = hidden constant [3 x i8] c"baz", section
>> "__DATA,__llvm_prf_names", align 1
>> + at __llvm_profile_name_baz = hidden constant [3 x i8] c"baz"
>> +; CHECK: @__llvm_profile_name_baz = hidden constant [3 x i8] c"baz",
>> section "__DATA,__llvm_prf_names", align 1
>>
>> ; CHECK: @__llvm_profile_counters_foo = hidden global [1 x i64]
>> zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
>> ; CHECK: @__llvm_profile_data_foo = hidden {{.*}}, section
>> "__DATA,__llvm_prf_data", align 8
>> @@ -26,9 +26,9 @@ define void @bar() {
>> ; CHECK: @__llvm_profile_counters_baz = hidden global [3 x i64]
>> zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
>> ; CHECK: @__llvm_profile_data_baz = hidden {{.*}}, section
>> "__DATA,__llvm_prf_data", align 8
>> define void @baz() {
>> - call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x
>> i8], [3 x i8]* @baz_prof_name, i32 0, i32 0), i64 0, i32 3, i32 0)
>> - call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x
>> i8], [3 x i8]* @baz_prof_name, i32 0, i32 0), i64 0, i32 3, i32 1)
>> - call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x
>> i8], [3 x i8]* @baz_prof_name, i32 0, i32 0), i64 0, i32 3, i32 2)
>> + call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x
>> i8], [3 x i8]* @__llvm_profile_name_baz, i32 0, i32 0), i64 0, i32 3, i32 0)
>> + call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x
>> i8], [3 x i8]* @__llvm_profile_name_baz, i32 0, i32 0), i64 0, i32 3, i32 1)
>> + call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x
>> i8], [3 x i8]* @__llvm_profile_name_baz, i32 0, i32 0), i64 0, i32 3, i32 2)
>> ret void
>> }
>>
>>
>> Modified: llvm/trunk/test/Transforms/PGOProfile/criticaledge.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/criticaledge.ll?rev=255434&r1=255433&r2=255434&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/Transforms/PGOProfile/criticaledge.ll (original)
>> +++ llvm/trunk/test/Transforms/PGOProfile/criticaledge.ll Sat Dec 12
>> 11:28:03 2015
>> @@ -5,7 +5,7 @@ target datalayout = "e-m:e-i64:64-f80:12
>> target triple = "x86_64-unknown-linux-gnu"
>>
>> ; GEN: @__llvm_profile_name_test_criticalEdge = private constant [17 x
>> i8] c"test_criticalEdge"
>> -; GEN: @"__llvm_profile_name_<stdin>:bar" = private constant [11 x i8]
>> c"<stdin>:bar"
>> +; GEN: @__llvm_profile_name__stdin__bar = private constant [11 x i8]
>> c"<stdin>:bar"
>>
>> define i32 @test_criticalEdge(i32 %i, i32 %j) {
>> entry:
>> @@ -99,7 +99,7 @@ return:
>>
>> define internal i32 @bar(i32 %i) {
>> entry:
>> -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds
>> ([11 x i8], [11 x i8]* @"__llvm_profile_name_<stdin>:bar", i32 0, i32 0),
>> i64 12884901887, i32 1, i32 0)
>> +; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds
>> ([11 x i8], [11 x i8]* @__llvm_profile_name__stdin__bar, i32 0, i32 0), i64
>> 12884901887, i32 1, i32 0)
>> ret i32 %i
>> }
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151212/79417239/attachment.html>
More information about the llvm-commits
mailing list